Code: Alles auswählen.
REPORT ZTESTF6.
SUBMIT ZTESTF5
WITH DATUM EQ '20140220'
WITH LAUFID EQ 'GEH02P' AND RETURN.
Code: Alles auswählen.
REPORT ZTESTF5.
*INCLUDE BDCRECX1.
DATA: SESSION(1).
DATA: CTU(1). "call transaction
DATA: GROUP(12). "group name of session
DATA: CTUMODE LIKE CTU_PARAMS-DISMODE VALUE 'N'.
DATA: USER(12). "user for session in batch
DATA: CUPDATE LIKE CTU_PARAMS-UPDMODE VALUE 'L'.
DATA: KEEP(1). "' ' = delete session if finished
DATA: E_GROUP(12). "group name of error-session
DATA: HOLDDATE LIKE SY-DATUM.
DATA: E_USER(12). "user for error-session
DATA: E_KEEP(1). "' ' = delete session if finished
DATA: E_HDATE LIKE SY-DATUM.
DATA: SMALLLOG(1). "' ' = log all transactions
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA: E_GROUP_OPENED.
TABLES: T100.
PARAMETER: DATUM LIKE SY-DATUM.
PARAMETER: LAUFID tYPE LAUFI.
DATA: DATUM10(10).
DATA: TEXT(65) VALUE 'HINWEIS'.
DATA: BEGIN OF ABTAB OCCURS 20,
TDFORMAT(2) VALUE 'AS',
LINE(132),
END OF ABTAB.
INITIALIZATION.
CTU = 'X'.
CTUMODE = 'E'.
SMALLLOG = ' '.
E_GROUP = SY-UNAME.
E_USER = SY-UNAME.
START-OF-SELECTION.
WRITE DATUM TO DATUM10 DD/MM/YYYY.
PERFORM OPEN_GROUP.
PERFORM BDC_DYNPRO USING 'SAPMFDTA' '0100'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'TAB_LAUFI-HIGH'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=EXEC'.
PERFORM BDC_FIELD USING 'TAB_LAUFD-LOW'
DATUM10.
PERFORM BDC_FIELD USING 'TAB_LAUFI-LOW'
LAUFID.
PERFORM BDC_FIELD USING 'FDTA-XECHT'
'X'.
PERFORM BDC_FIELD USING 'FDTA-DOWNL_OHNE'
'X'.
PERFORM BDC_FIELD USING 'FDTA-KOAUS_OHNE'
'X'.
PERFORM BDC_TRANSACTION USING 'FDTA'.
PERFORM CLOSE_GROUP.
*&---------------------------------------------------------------------*
*& Form OPEN_GROUP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM OPEN_GROUP.
IF SESSION = 'X'.
* open batchinput group
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = GROUP
USER = USER
KEEP = KEEP
HOLDDATE = HOLDDATE.
ENDIF.
ENDFORM. "OPEN_GROUP
*----------------------------------------------------------------------*
* end batchinput session *
* (call transaction using...: error session) *
*----------------------------------------------------------------------*
FORM CLOSE_GROUP.
IF SESSION = 'X'.
* close batchinput group
CALL FUNCTION 'BDC_CLOSE_GROUP'.
WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),
(12) 'returncode:'(I05),
SY-SUBRC.
ELSE.
IF E_GROUP_OPENED = 'X'.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
E_GROUP_OPENED = ' '.
ENDIF.
ENDIF.
ENDFORM. "CLOSE_GROUP
*----------------------------------------------------------------------*
* Start new transaction according to parameters *
*----------------------------------------------------------------------*
FORM BDC_TRANSACTION USING TCODE.
DATA: L_MSTRING(480).
DATA: L_SUBRC LIKE SY-SUBRC.
* batch input session
IF SESSION = 'X'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = TCODE
TABLES
DYNPROTAB = BDCDATA.
IF SMALLLOG <> 'X'.
ENDIF.
* call transaction using
ELSE.
REFRESH MESSTAB.
CALL TRANSACTION TCODE USING BDCDATA
MODE CTUMODE
UPDATE CUPDATE
MESSAGES INTO MESSTAB.
L_SUBRC = SY-SUBRC.
IF SMALLLOG <> 'X'.
LOOP AT MESSTAB.
SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA
AND ARBGB = MESSTAB-MSGID
AND MSGNR = MESSTAB-MSGNR.
IF SY-SUBRC = 0.
L_MSTRING = T100-TEXT.
IF L_MSTRING CS '&1'.
REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ELSE.
REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ENDIF.
CONDENSE L_MSTRING.
ELSE.
ENDIF.
ENDLOOP.
ENDIF.
** Erzeugen fehlermappe ************************************************
IF L_SUBRC <> 0 AND E_GROUP <> SPACE. "wenn Egroup = Space, dann keine Fehlermappe
IF E_GROUP_OPENED = ' '.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = E_GROUP
USER = E_USER
KEEP = E_KEEP
HOLDDATE = E_HDATE.
E_GROUP_OPENED = 'X'.
ENDIF.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = TCODE
TABLES
DYNPROTAB = BDCDATA.
ENDIF.
ENDIF.
REFRESH BDCDATA.
ENDFORM. "BDC_TRANSACTION
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDFORM. "BDC_FIELD