TABLES:BSIK,BSAK,FAGLFLEXA,EKKO,LFA1,CEPCT,SKAT,BSAS.
TYPES:BEGIN OF TYP_01,
BZDWX TYPE CEPCT-KTEXT,
ZDATE TYPE D,
NAME1 TYPE LFA1-NAME1,
NUM TYPE I,
TXT50 TYPE SKAT-TXT50,
DMBTR TYPE BSIK-DMBTR,
LIFNR TYPE LFA1-LIFNR,
END OF TYP_01.
DATA GS_01 TYPE TYP_01.
DATA GT_01 TYPE STANDARD TABLE OF TYP_01.
TYPES:BEGIN OF TYP_02,
LIFNR TYPE LFA1-LIFNR,
SHKZG TYPE BSIK-SHKZG,
DMBTR TYPE BSIK-DMBTR,
END OF TYP_02.
DATA GT_02 TYPE STANDARD TABLE OF TYP_02.
DATA GS_02 TYPE TYP_02.
**********************************************************************
PARAMETERS P_BUKRS TYPE BUKRS OBLIGATORY DEFAULT '2000'.
SELECT-OPTIONS S_PRCTR FOR CEPCT-PRCTR.
PARAMETERS P_GJAHR TYPE RYEAR OBLIGATORY DEFAULT SY-DATUM.
SELECT-OPTIONS S_MONAT FOR BSIK-MONAT OBLIGATORY .
**********************************************************************
INITIALIZATION.
S_MONAT-LOW = '9'.
S_MONAT-HIGH = '9'.
S_MONAT-SIGN = 'I'.
S_MONAT-OPTION = 'BT'.
APPEND S_MONAT.
CLEAR S_MONAT.
START-OF-SELECTION.
PERFORM FRM_GETDATA.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form FRM_GETDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GETDATA .
SELECT BUKRS,
GJAHR,
BELNR,
EBELN,
HKONT,
PRCTR,
SHKZG,
DMBTR,
BUZEI,
LIFNR
FROM BSIK
INTO TABLE @DATA(GT_BSIK)
WHERE BUKRS = @P_BUKRS
AND PRCTR IN @S_PRCTR
AND GJAHR EQ @P_GJAHR
AND MONAT IN @S_MONAT
AND HKONT LIKE '2202%%'.
SELECT BUKRS,
GJAHR,
BELNR,
EBELN,
HKONT,
PRCTR,
SHKZG,
DMBTR,
BUZEI,
LIFNR
FROM BSAK
INTO TABLE @DATA(GT_BSAK)
WHERE BUKRS = @P_BUKRS
AND PRCTR IN @S_PRCTR
AND GJAHR EQ @P_GJAHR
AND MONAT IN @S_MONAT
AND HKONT LIKE '2202%%'.
LOOP AT GT_BSAK INTO DATA(GS_BS) .
APPEND GS_BS TO GT_BSIK.
ENDLOOP.
**********************************************************************
*期末余额
* SELECT EKKO~LIFNR,
* EKKO~EBELN
* FROM EKKO
* INTO TABLE @DATA(GT_EKKO)
* FOR ALL ENTRIES IN @GT_BSIK
* WHERE EBELN = @GT_BSIK-EBELN.
CLEAR GS_BS.
LOOP AT GT_BSIK INTO GS_BS .
"READ TABLE GT_EKKO INTO DATA(GS_EKKO) WITH KEY EBELN = GS_BS-EBELN.
"IF SY-SUBRC = 0.
GS_02-LIFNR = GS_BS-LIFNR.
GS_02-DMBTR = GS_BS-DMBTR.
GS_02-SHKZG = GS_BS-SHKZG.
* IF GS_02-LIFNR = '00000249'.
COLLECT GS_02 INTO GT_02.
" ENDIF.
* ENDIF.
ENDLOOP.
LOOP AT GT_BSIK INTO GS_BS.
*********************************************************************
*编制单位
* CONCATENATE '___' GS_BS-BUZEI INTO DATA(LV_CON).
IF GS_BS-prctr IS INITIAL