[ABAP] RFC-Aufruf einer Transaktion

DATA: it_error TYPE STANDARD TABLE OF bdcmsgcoll.

DATA: lv_rc TYPE sy-subrc.

* Batch
DATA(it_batch) = VALUE bdcdata_tab( ( dynbegin = 'T' fnam = 'FD03' )
                                    ( program = 'SAPMF02D' dynpro = '0106' dynbegin = 'X' )
                                    ( fnam = 'RF02D-KUNNR' fval = '40000' )
                                    ( fnam = 'RF02D-BUKRS' fval = '' )
                                    ( fnam = 'RF02D-D0110' fval = abap_true )
                                    ( fnam = 'RF02D-D0120' fval = abap_true )
                                    ( fnam = 'BDC_OKCODE'  fval = '/00' ) ).

* RFC-Aufruf
CALL FUNCTION 'RFC_CALL_TRANSACTION_USING'
  DESTINATION 'XYZ'
  EXPORTING
    tcode                   = 'FD03'
    mode                    = 'E'
  IMPORTING
    subrc                   = lv_rc
  TABLES
    bt_data                 = it_batch
    l_errors                = it_error
  EXCEPTIONS
    authority_not_available = 1
    OTHERS                  = 2.

* Datenausgabe
WRITE: / sy-subrc.
WRITE: / lv_rc.

LOOP AT it_batch ASSIGNING FIELD-SYMBOL(<b>).
  WRITE: / <b>-program, <b>-dynpro, <b>-dynbegin, <b>-fnam, <b>-fval.
ENDLOOP.

LOOP AT it_error ASSIGNING FIELD-SYMBOL(<e>).
  WRITE: / <e>-tcode, <e>-dyname, <e>-dynumb, <e>-msgtyp, <e>-msgspra, <e>-msgid, <e>-msgnr, <e>-msgv1, <e>-msgv2, <e>-msgv3, <e>-msgv4, <e>-env, <e>-fldname.
ENDLOOP.

[ABAP] Transaktion mit Parametern vorbelegen und aufrufen

Variante 1 (Batch-Input-Daten)

DATA: it_batchdata TYPE STANDARD TABLE OF bdcdata.
DATA: it_msg TYPE STANDARD TABLE OF bdcmsgcoll.
  
* Batch-Input-Daten, mit Transaktion SHDB aufgezeichnet
it_batchdata = VALUE #( ( program = 'SAPLSD_ENTRY' dynpro = '1000' dynbegin = 'X' fnam = '' fval = '' )
                        ( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_CURSOR' fval = 'RSRD1-VIMA_VAL' )
                        ( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_OKCODE' fval = '=WB_DISPLAY' )
                        ( program = '' dynpro = '' dynbegin = '' fnam = 'RSRD1-VIMA' fval = 'X' )
                        ( program = '' dynpro = '' dynbegin = '' fnam = 'RSRD1-VIMA_VAL' fval = 'MARA' ) ). 

* SE11 aufrufen, kein AUTHORITY-CHECK
CALL TRANSACTION 'SE11' WITHOUT AUTHORITY-CHECK
  USING it_batchdata
  MODE 'E'
  UPDATE 'A'
  MESSAGES INTO it_msg.

IF sy-subrc NE 0.
  MESSAGE 'Fehler beim Aufruf des SE11' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.

Variante 2 (SET PARAMETER – SE11)

* Parameter "Datenbakname" mit Wert 'MARA' vorbelegen
SET PARAMETER ID 'DTB' FIELD 'MARA'.
* SE11 ohne Prüfung aufrufen
CALL TRANSACTION 'SE11' WITHOUT AUTHORITY-CHECK.

IF sy-subrc NE 0.
  MESSAGE 'Fehler beim Aufruf des SE11' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.

Variante 3 (SET PARAMETER – MM03)

PARAMETERS: p_matnr TYPE matnr.

* MATNR setzen
SET PARAMETER ID 'MAT' FIELD p_matnr.
* Grunddaten anzeigen
SET PARAMETER ID 'MXX' FIELD 'K'.
* Transaktion MM03 aufrufen (Material anzeigen)
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

Links