Wednesday, March 29, 2023

How to read table from remote SAP system - reading HU from SAP EWM from SAP ECC


How to read table from remote SAP system - reading HU from SAP EWM from SAP ECC

Sample code to read HU number VLENR from table /SCWM/ORDIM_C in SAP EWM from another SAP.


DATA
T_OPTION TYPE RFC_DB_OPT.
DATAT_OPTIONS TYPE TABLE OF RFC_DB_OPT WITH HEADER LINE.
DATAT_FIELDS  TYPE TABLE OF RFC_DB_FLD WITH HEADER LINE.
DATAT_DATA    TYPE TABLE OF TAB512     WITH HEADER LINE.

P_DEST =  'RFC name of the EWM system'.

* Field we are going to read
T_FIELD-fieldname 'VLENR'.
append T_FIELD TO T_FIELDS.

* Filter over warehouse task field
CONCATENATE 'TANUM = 100012344'.
append T_OPTIONS TO T_OPTIONS.

* Connection to EWM in order to read table /SCWM/ORDIM_C

CALL FUNCTION 'RFC_READ_TABLE'
DESTINATION P_DEST
  EXPORTING
    QUERY_TABLE                '/SCWM/ORDIM_C'
*   DELIMITER                  = ' '
*   NO_DATA                    = ' '
*   ROWSKIPS                   = 0
    ROWCOUNT                   999
  TABLES
  OPTIONS                    T_OPTIONS
    FIELDS                   T_FIELDS
    DATA                     T_DATA.
* EXCEPTIONS
*   TABLE_NOT_AVAILABLE        = 1
*   TABLE_WITHOUT_DATA         = 2
*   OPTION_NOT_VALID           = 3
*   FIELD_NOT_VALID            = 4
*   NOT_AUTHORIZED             = 5
*   DATA_BUFFER_EXCEEDED       = 6
*   OTHERS                     = 7
          .
IF SY-SUBRC 0.
 * result to be retrieved from T_DATA
ENDIF.

No comments:

Post a Comment

Problem with database open ORA-19804, ORA-19809, ORA-03113

1. Try to login to database with SYS AS SYSDBA user. If the instance is idle, run the startup command. 2. If ORA-03113 occured, check the la...