Skip to end of metadata
Go to start of metadata

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 between Both SAP systems.

Used sources:

RFC Destination = ECC5.0 from 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".

  

  

 

 

 

 

 

 

 

 

---


STEP 2:

 

Select the R/3 Connections Node in Tree and Click "CREATE"  

 

 

 

 

 

 

 

 

 

 

 

 


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.

 

 

 

 

 

 

 

 

 

 


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 strip,

4.      Give client no, Login id, Password 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.



 

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 function 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 reference,

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, Associated 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.

 - 

 

  

Fig 2.1

 Fig 2.2

 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 Access that Function Module of SAP 4.7E in SAP ECC5.0.

LAN is Important.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
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.

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

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
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                      = ' '
   IMPORTING
     filelength                    = l_xml_size
    TABLES
      data_tab                      = xml_table
* EXCEPTIONS
*   FILE_WRITE_ERROR              = 1
*   NO_BATCH                      = 2
*   GUI_REFUSE_FILETRANSFER       = 3
*   INVALID_TYPE                  = 4
*   NO_AUTHORITY                  = 5
*   UNKNOWN_ERROR                 = 6
*   HEADER_NOT_ALLOWED            = 7
*   SEPARATOR_NOT_ALLOWED         = 8
*   FILESIZE_NOT_ALLOWED          = 9
*   HEADER_TOO_LONG               = 10
*   DP_ERROR_CREATE               = 11
*   DP_ERROR_SEND                 = 12
*   DP_ERROR_WRITE                = 13
*   UNKNOWN_DP_ERROR              = 14
*   ACCESS_DENIED                 = 15
*   DP_OUT_OF_MEMORY              = 16
*   DISK_FULL                     = 17
*   DP_TIMEOUT                    = 18
*   FILE_NOT_FOUND                = 19
*   DATAPROVIDER_EXCEPTION        = 20
*   CONTROL_FLUSH_ERROR           = 21
*   OTHERS                        = 22
            .

ENDFUNCTION.