9
11/ 09/1 3 Creatin g RFC and Remot e-en ab led F M an d ca ll fro m ano th er S AP sy stem usin g ABAP Pro gram - Code G allery - Con flu ence w ik i.scn.sa p. com /w iki/d ispla y /Snip pe ts/ Creatin g+RFC+ and+Remot e-e na ble d+FM+an d+call+from+an ot he r+SAP+sy ste m+usin g+ABAP +Program 1/9 Getti ng St arted Newsl et ters St ore Search the Community  Welcome, Guest Login Register Products Serv i ces & Support About SCN Downl oads Industries Training & Education Partnership Developer Center  Li nes of Business Univ ersity All iances Ev ents & Webinars Innovati on  Added by Guest, last edited by M anis h Kumar on Aug 18, 2013 Code Gallery Creating RFC and Remote-enabled FM and call from another SAP system using ABAP Program Remote Function Module calling From SAP 4.7E to SAP ECC 5.0 Contents: 1.Goal 2.Step-By-Step for RF C 3.Step-By-Step for Function Module 4. Source Code of  ABAP Program  Goal  This assignment goal is to call a Function module from SAP 4.7E to SAP ECC5.0 through ABAP program. Function Module Goal : The Function Module Goal is to convert the data of table into XML format and save it in the system as xml format Requirements: RFC Connection, Function Module Remote Enabled, Database Table for data, LAN Connection betw een Both SAP systems. Used sources: RFC Destination = EC C5.0 f rom SAP 4.7E, Func tion Module = Y_FM_IDOC_CATSDB (Remote Enabled Module), Database Table = CATSDB, Fields Used From CATSDB  Fiel ds Type Length COUNTER CATSCOUNTE 12 P E RNR P E RNR D 8 WORKDATE CATSDATE 8 ---- STEP-BY-STEP FOR RFC DESTINATION CREATION:(SAP 4.7E) STEP 1: IN SAP 4.7E call Transaction code "SM59".

Creating RFC

Embed Size (px)

Citation preview

7/29/2019 Creating RFC

http://slidepdf.com/reader/full/creating-rfc 1/9

11/09/13 Creating RFC and Remote-enabled FM and call from another SAP system using ABAP Program - Code Gallery - Confluence

wiki.scn.sap.com/wiki/display/Snippets/Creating+RFC+and+Remote-enabled+FM+and+call+from+another+SAP+system+using+ABAP+Program 1/9

Getting Started Newsletters Store

Search the Community  Welcome, Guest Login  Register 

Products Services & Support About SCN Downloads

Industries Training & Education Partnership Developer Center  

Lines of Business University Alliances Events & Webinars Innovation

 Added by Guest, last edited by Manis h Kumar on Aug 18, 2013

Code Gallery

Creating RFC and Remote-enabled FM and call from another SAP system using ABAP

Program

Remote Function Module calling From SAP 4.7E to SAP ECC 5.0

Contents:

1.Goal

2.Step-By-Step for RFC

3.Step-By-Step for Function Module

4. Source Code of  ABAP Program

 

Goal

 

This assignment goal is to call a Function module from SAP 4.7E to SAP ECC5.0 through ABAP

program.

Function Module Goal: The Function Module Goal is to convert the data of  table into XML

format and save it in the system as xml format

Requirements: RFC Connection, Function Module Remote Enabled, Database Table for data,

LAN Connection betw een Both SAP systems.

Used sources:

RFC Destination = ECC5.0 f rom SAP 4.7E,

Function Module = Y_FM_IDOC_CATSDB (Remote Enabled

Module),

Database Table = CATSDB,

Fields Used From CATSDB

 

Fields Type Length

COUNTER CATSCOUNTE 12

PERNR PERNR_D 8

WORKDATE CATSDATE 8

----

STEP-BY-STEP FOR RFC DESTINATION

CREATION:(SAP 4.7E)

STEP 1:

IN SAP 4.7E call Transaction code "SM59".

7/29/2019 Creating RFC

http://slidepdf.com/reader/full/creating-rfc 2/9

 Ads not by this site

7/29/2019 Creating RFC

http://slidepdf.com/reader/full/creating-rfc 3/9

11/09/13 Creating RFC and Remote-enabled FM and call from another SAP system using ABAP Program - Code Gallery - Confluence

wiki.scn.sap.com/wiki/display/Snippets/Creating+RFC+and+Remote-enabled+FM+and+call+from+another+SAP+system+using+ABAP+Program 3/9

 

STEP 3:

1. Type RFC Destination as "ECC5.0",

2. Select connection type as "3" for 3tire architecture,

3. Type Description for your Reference,

4. And "SAVE" it.

7/29/2019 Creating RFC

http://slidepdf.com/reader/full/creating-rfc 4/9

11/09/13 Creating RFC and Remote-enabled FM and call from another SAP system using ABAP Program - Code Gallery - Confluence

wiki.scn.sap.com/wiki/display/Snippets/Creating+RFC+and+Remote-enabled+FM+and+call+from+another+SAP+system+using+ABAP+Program 4/9

 

STEP 4:

1. Type Target host as your host name of the destination SAP (i.e.) ECC5.0,

2. Give the System Number of Destination system Number,

3. Select LOGON/SECURITY in tab str ip,

4. Give client no, Login id, Passw ord of SAP ECC5.0 if you know,

5. Save it.

Fig1.3

STEP 5:

To check connection click on 'TEST CONNECTION'

STEP 6:

To Remote Login click on 'Remote Logon'

Caution: It will logon only if connection is perfect (i.e.) Destination Host name and system

number is correct

and LAN is enabled.

 

7/29/2019 Creating RFC

http://slidepdf.com/reader/full/creating-rfc 5/9

11/09/13 Creating RFC and Remote-enabled FM and call from another SAP system using ABAP Program - Code Gallery - Confluence

wiki.scn.sap.com/wiki/display/Snippets/Creating+RFC+and+Remote-enabled+FM+and+call+from+another+SAP+system+using+ABAP+Program 5/9

Step-by-step to create Remote Enabled Function Module In SAP 4.7E

STEP 1:

1. IN SAP 4.7E call Transaction code "SE37", Fig 2.0

2. Select Goto --> Function Groups --> Create Group

3. Create Function Group by Giving FG name in Entry and Proceed

4. Type Function Module name in Function Module path after creation of f unction group,

5. Click on Create.

Fig 2.0

Step 2:

1. Select "Remote-Enabled Module" in Radio Button, Fig 2.1

2. Write descriptions for your referenc e,

3. Click on "Import" tab,

4. Fill the parameters name, type, Associated type as Field type from database table Fig 2.2

5. Tick on the "Pass value" check boxes for all entered fields,

6. Click on "Export" tab,

7. Fill the Parameters name, type, Assoc iated types ,

8. Tick on the "Pass value" check box for all entered fields,

9. Click on "Source code" tab,

10. Write the source code depend on your logics,

11. Save it, Compile it, activate it.

-

7/29/2019 Creating RFC

http://slidepdf.com/reader/full/creating-rfc 6/9

11/09/13 Creating RFC and Remote-enabled FM and call from another SAP system using ABAP Program - Code Gallery - Confluence

wiki.scn.sap.com/wiki/display/Snippets/Creating+RFC+and+Remote-enabled+FM+and+call+from+another+SAP+system+using+ABAP+Program 6/9

 

Fig 2.1

Fig 2.2

7/29/2019 Creating RFC

http://slidepdf.com/reader/full/creating-rfc 7/9

11/09/13 Creating RFC and Remote-enabled FM and call from another SAP system using ABAP Program - Code Gallery - Confluence

wiki.scn.sap.com/wiki/display/Snippets/Creating+RFC+and+Remote-enabled+FM+and+call+from+another+SAP+system+using+ABAP+Program 7/9

Fig 2.3

Fiig 2.4

Source code of an ABAP program created in SAP ECC5.0 for calling SAP 4.7E Function

Module Remotely.

Note: If Function Module is not Remote-enabled Module then you cannot A ccess that Function Module of SAP 4.7E in SAP ECC5.0.

LAN is Important.

FUNCTION MODULE SOURCE FOR CONVERTING DATA INTO XML AND SAVE IT IN ANY

 Ads not by this site

REPORT  yfm_remote_destination.

TABLES: catsdb.

* Creating Variable for Return value

DATA: fs_messafe TYPE bapiret2.

* Parameters for entering value for fields in table

PARAMETERS: counter1 TYPE catsdb-counter,

  workdt1 TYPE catsdb-workdate.

* calling the Function Module of SAP4.7E in this program manually.

* the parameters value will be passed here to the export parameters

CALL FUNCTION 'Y_FM_IDOC_CATSDB' DESTINATION 'SAP4.7E'

  EXPORTING

  counter = counter1

  pernr = catsdb-pernr

  workdate = workdt1.

* IMPORTING

* ctr = catsdb-counter

* pnr = catsdb-pernr

* wrkdate = catsdb-workdate

* reuturn = fs_messafe.

*

IF sy-subrc EQ 0.

* Display if Function Module called Successfully

  WRITE: 'DATA DOWNLOADED SUCCESSFULLY TO C:\JAGRUT\XML\ '.

ENDIF.

7/29/2019 Creating RFC

http://slidepdf.com/reader/full/creating-rfc 8/9

11/09/13 Creating RFC and Remote-enabled FM and call from another SAP system using ABAP Program - Code Gallery - Confluence

wiki.scn.sap.com/wiki/display/Snippets/Creating+RFC+and+Remote-enabled+FM+and+call+from+another+SAP+system+using+ABAP+Program 8/9

FOLDER OF SYSTEM

FUNCTION y_fm_idoc_catsdb.

*"----------------------------------------------------------------------

*"*"Local interface:

*"  IMPORTING

*"  VALUE(COUNTER) TYPE  CATSCOUNTE

*"  VALUE(PERNR) TYPE  PERNR

*"  VALUE(WORKDATE) TYPE  CATSDATE

*"  EXPORTING

*"  VALUE(CTR) TYPE  CATSCOUNTE

*"  VALUE(PNR) TYPE  PERNR

*"  VALUE(WRKDATE) TYPE  CATSDATE

*"  VALUE(RETURN1) TYPE  BAPIRET2

*"----------------------------------------------------------------------

  TABLES: catsdb.

  TYPE-POOLS: ixml.

  TYPES: BEGIN OF my_xml,

  data1(256) TYPE x,

  END OF my_xml.

  DATA: itab LIKE catsdb OCCURS 0 WITH HEADER LINE.

  DATA: ld_filename TYPE string,

  ld_path TYPE string,

  ld_fullpath TYPE string,

  ld_result TYPE i.

  DATA: xml_table TYPE TABLE OF my_xml,

  l_xml_size TYPE i,

  l_xml_rc TYPE i.

  SELECT counter pernr workdate FROM catsdb INTO CORRESPONDING FIELDS OF TABLE itab.

  CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'

* EXPORTING

* I_FIELD_SEPERATOR =

* I_LINE_HEADER =

* I_FILENAME =

* I_APPL_KEEP = ' '

* I_XML_DOC_NAME =

  IMPORTING

  pe_bin_filesize = l_xml_size  TABLES

  i_tab_sap_data = itab

  CHANGING

  i_tab_converted_data = xml_table

  EXCEPTIONS

  conversion_failed = 1

  OTHERS  = 24

  .

 

CALL METHOD cl_gui_frontend_services=>file_save_dialog

  EXPORTING

* window_title = ' '

  default_extension = 'xml'

  default_file_name = 'accountsdata'

  initial_directory = 'd:\jagrut\xml'

  CHANGING

  filename = ld_filename

  path = ld_path

  fullpath = ld_fullpath

  user_action = ld_result.

  CALL FUNCTION 'GUI_DOWNLOAD'

  EXPORTING

  bin_filesize = l_xml_size

  filename = ld_fullpath

  filetype = 'BIN'

* APPEND  = ' '

* WRITE_FIELD_SEPARATOR = ' '

* HEADER  = '00'

* TRUNC_TRAILING_BLANKS = ' '

* WRITE_LF = 'X'

* COL_SELECT = ' '

* COL_SELECT_MASK = ' '

* DAT_MODE = ' '

7/29/2019 Creating RFC

http://slidepdf.com/reader/full/creating-rfc 9/9