案例:
REPORT ZFIR_ARAGE_SAVE.
*----------------------------------------------------------------------*
* TABLE DECLARATION
*----------------------------------------------------------------------*
TYPE-POOLS: SLIS.
TABLES:T001.
*&---------------------------------------------------------------------*
* INTERNAL TABLE DECLARATION
*&---------------------------------------------------------------------*
DATA: GT_ITAB TYPE STANDARD TABLE OF ZFT_AR_AGE,
GW_ITAB TYPE ZFT_AR_AGE.
FIELD-SYMBOLS <ITAB> TYPE ZFT_AR_AGE.
*&---------------------------------------------------------------------*
* SELECTION SCREEN DECLARATION
*&---------------------------------------------------------------------*
SELECTION-SCREEN:BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
S_BUKRS FOR T001-BUKRS.
SELECTION-SCREEN END OF BLOCK B1.
*&---------------------------------------------------------------------*
* START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
REFRESH GT_ITAB.
DATA : LT_T001 LIKE TABLE OF T001 WITH HEADER LINE.
SELECT * FROM T001 INTO TABLE LT_T001
WHERE KTOPL = 'DJJT' AND BUKRS IN S_BUKRS.
LOOP AT LT_T001.
PERFORM FRM_GET_DATA USING LT_T001-BUKRS.
ENDLOOP.
PERFORM FRM_SAVE_DATA.
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_DATA USING P_BUKRS TYPE T001-BUKRS.
DATA : LT_ARAGE TYPE STANDARD TABLE OF ZFT_AR_AGE,
LW_ARAGE TYPE ZFT_AR_AGE.
RANGES : R_BUKRS FOR T001-BUKRS,
R_KUNNR FOR VBAK-KUNNR,
R_BUDAT FOR BKPF-BUDAT.
REFRESH LT_ARAGE.
SET PARAMETER ID 'ZEXPORT_ZFI054' FIELD 'X'.
CLEAR : R_BUKRS.
R_BUKRS-SIGN = 'I'.
R_BUKRS-OPTION = 'EQ'.
R_BUKRS-LOW = P_BUKRS.
APPEND R_BUKRS.
SUBMIT ZFIR_AR_AGE
AND RETURN
WITH S_BUKRS IN R_BUKRS
WITH S_KUNNR IN R_KUNNR
WITH S_BUDAT IN R_BUDAT
WITH P_JZR = SY-DATUM
WITH P_ZERO = 'X'
WITH P_RFBSK = 'X'
WITH P_NBGS = ''
WITH P_FS = ''
WITH P_QTYS = ''.
IMPORT LT_ARAGE FROM MEMORY ID 'ZFI054'.
SET PARAMETER ID 'ZEXPORT_ZFI054' FIELD SPACE.
LOOP AT LT_ARAGE INTO LW_ARAGE.
MOVE-CORRESPONDING LW_ARAGE TO GW_ITAB.
IF GW_ITAB-VKORG IS NOT INITIAL AND GW_ITAB-BUKRS IS NOT INITIAL.
GW_ITAB-GJAHR = SY-DATUM+0(4).
GW_ITAB-MONAT = SY-DATUM+4(2).
APPEND GW_ITAB TO GT_ITAB.
ENDIF.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_SAVE_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_SAVE_DATA .
IF GT_ITAB IS NOT INITIAL.
MODIFY ZFT_AR_AGE FROM TABLE GT_ITAB.
IF SY-SUBRC = 0 .
COMMIT WORK.
MESSAGE 'Save successful!' TYPE 'S'.
ELSE.
ROLLBACK WORK.
MESSAGE 'Save failed!' TYPE 'E'.
ENDIF.
ELSE.
MESSAGE 'No data!' TYPE 'E'.
ENDIF.
ENDFORM.