*&---------------------------------------------------------------------*ir
*& Report ZFARR004
*& Hershey's
*&
*&---------------------------------------------------------------------*
REPORT zfarr004_tmp.
TABLES: bkpf,bseg,kna1,skat.
DATA subtotal_debit TYPE p DECIMALS 3.
DATA subtotal_credit TYPE p DECIMALS 3.
DATA total_debit TYPE p DECIMALS 3.
DATA total_credit TYPE p DECIMALS 3.
DATA:BEGIN OF itab_bkpf OCCURS 0,
bukrs LIKE bkpf-bukrs, "Company Code
gjahr LIKE bkpf-gjahr, "Fiscal Year
belnr LIKE bkpf-belnr, "Accounting Document Number
bktxt LIKE bkpf-bktxt, "Document Header Text
budat LIKE bkpf-budat, "Posting Date in the Document
xblnr LIKE bkpf-xblnr, "Reference Document Number
END OF itab_bkpf.
DATA:BEGIN OF itab_bseg OCCURS 0,
bukrs LIKE bseg-bukrs, "Company Code
belnr LIKE bseg-belnr, "Accounting Document Number
gjahr LIKE bseg-gjahr, "Fiscal Year
kunnr LIKE bseg-kunnr, "Customer Number 1
hkont LIKE bseg-hkont, "General Ledger Account
dmbtr LIKE bseg-dmbtr, "Amount in Local Currency
saknr LIKE bseg-saknr, "G/L Account Number
shkzg LIKE bseg-shkzg, "Debit/Credit Indicator
END OF itab_bseg.
DATA:BEGIN OF itab_kna1 OCCURS 0,
kunnr LIKE kna1-kunnr, "Customer Number 1
name1 LIKE kna1-name1, "Name 1
END OF itab_kna1.
DATA: BEGIN OF itab_skat OCCURS 0 ,
saknr LIKE skat-saknr, "G/L Account Number
txt20 LIKE skat-txt20, "G/L account short text
END OF itab_skat.
DATA: tmp TYPE i VALUE 0.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS s_kunnr FOR bseg-kunnr. "Customer Number 1
PARAMETERS p_bukrs LIKE bkpf-bukrs. "Company Code
SELECT-OPTIONS s_hkont FOR bseg-hkont MODIF ID gl."G/L Account
SELECT-OPTIONS s_belnr FOR bkpf-belnr. "Accounting Document Number
SELECT-OPTIONS s_budat FOR bkpf-budat OBLIGATORY. "Posting Date in the Document
PARAMETERS: r1 RADIOBUTTON GROUP rad1
DEFAULT 'X'
USER-COMMAND scr,
r2 RADIOBUTTON GROUP rad1,
r3 RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECT-OPTIONS r_hkont FOR bseg-hkont MODIF ID acc NO INTERVALS.
SELECTION-SCREEN END OF BLOCK b2.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 EQ 'ACC'.
IF r1 NE 'X'.
screen-active = '1'.
MODIFY SCREEN.
ELSE.
screen-active = '0'.
MODIFY SCREEN.
ENDIF.
ELSEIF screen-group1 EQ 'GL'.
IF r1 NE 'X'.
IF screen-name CS 'S_HKONT'.
screen-input = '0'.
MODIFY SCREEN.
REFRESH s_hkont.
ENDIF.
ELSE.
IF screen-name CS 'S_HKONT'.
screen-input = '1'.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
START-OF-SELECTION.
IF r1 EQ 'X'.
PERFORM get_header_data.
PERFORM output.
ENDIF.
END-OF-SELECTION.
**********************************************************************
* FORM : get_header_data
* Created : 13.08.2007 16:48:28
**********************************************************************
FORM get_header_data .
SELECT *
INTO CORRESPONDING FIELDS OF TABLE itab_bkpf
FROM bkpf
WHERE
bukrs = p_bukrs "Company Code
AND belnr IN s_belnr "Accounting Document Number
AND budat IN s_budat "Posting Date in the Document
AND blart = 'DZ' "Document type is 'DZ'
.
IF NOT itab_bkpf[] IS INITIAL.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE itab_bseg
FROM bseg
FOR ALL ENTRIES IN itab_bkpf
WHERE
bukrs = itab_bkpf-bukrs "Company Code
AND belnr = itab_bkpf-belnr "Accounting Document Number
AND gjahr = itab_bkpf-gjahr "Finance Year
AND hkont IN s_hkont "G/L Account
AND kunnr IN s_kunnr "Customer Number 1
.
SORT itab_bseg BY bukrs belnr gjahr.
ENDIF.
IF NOT itab_bseg[] IS INITIAL.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE itab_kna1
FROM kna1
FOR ALL ENTRIES IN itab_bseg
WHERE
kunnr = itab_bseg-kunnr "Customer Number 1
.
SORT itab_kna1 BY kunnr.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE itab_skat
FROM skat
FOR ALL ENTRIES IN itab_bseg
WHERE
saknr = itab_bseg-hkont "G/L Account Number
"AND spras = sy-langu. " Client language.
.
SORT itab_skat BY saknr.
ENDIF.
ENDFORM. "get_data
**********************************************************************
* FORM : output
* Created : 13.08.2007 16:48:41
**********************************************************************
FORM output.
NEW-PAGE.
WRITE:/ 'Hershey Philippines, Inc.' .
WRITE:/ 'CASH RECEIPTS REGISTER'.
IF s_budat-low = 0.
WRITE:/ 'Inclusive Dates:',AT 40 s_budat-high.
ELSEIF s_budat-high = 0.
WRITE:/ 'Inclusive Dates:',AT 40 s_budat-low.
ELSE.
WRITE:/ 'Inclusive Dates:',AT 40 s_budat-low,' to ',s_budat-high.
ENDIF.
NEW-LINE.
WRITE: AT 10 'Date',AT 18 'Account No.', AT 32 'Account Description ', AT 72 'Debit' , AT 103 'Credit'.
NEW-LINE.
ULINE (120).
NEW-LINE.
IF NOT itab_bkpf[] IS INITIAL.
LOOP AT itab_bkpf INTO line_bkpf.
READ TABLE itab_bseg INTO line_bseg
WITH KEY
bukrs = line_bkpf-bukrs
belnr = line_bkpf-belnr
gjahr = line_bkpf-gjahr ." to check that wethere there is a bseg item for the bkpf.
IF NOT line_bseg IS INITIAL.
CLEAR line_bseg.
" out put the detailed infomation.
LOOP AT itab_bseg INTO line_bseg
WHERE
bukrs = line_bkpf-bukrs
AND belnr = line_bkpf-belnr
AND gjahr = line_bkpf-gjahr .
READ TABLE itab_kna1 INTO line_kna1
WITH KEY kunnr = line_bseg-kunnr BINARY SEARCH.
READ TABLE itab_skat INTO line_skat
WITH KEY saknr = line_bseg-hkont BINARY SEARCH.
IF tmp = 0 .
"out put the document header infomation.
WRITE:/'OR No.: ',line_bkpf-xblnr,AT 32 'Document No.:',line_bkpf-belnr.
NEW-LINE.
WRITE :/'Received from: ', line_bseg-kunnr, AT 30 line_kna1-name1.
NEW-LINE.
WRITE :/ 'Particulars: ',line_bkpf-bktxt.
NEW-LINE.
tmp = tmp + 1.
ENDIF.
WRITE: AT 10 line_bkpf-budat , line_bseg-hkont , line_skat-txt20.
CASE line_bseg-shkzg .
WHEN 'S'.
subtotal_debit = subtotal_debit + line_bseg-dmbtr.
total_debit = total_debit + line_bseg-dmbtr.
WRITE: AT 100 line_bseg-dmbtr.
WHEN 'H'.
subtotal_credit = subtotal_credit + line_bseg-dmbtr.
total_credit = total_credit + line_bseg-dmbtr.
WRITE: AT 70 line_bseg-dmbtr.
WHEN OTHERS.
ENDCASE.
NEW-LINE.
CLEAR line_bseg.
ENDLOOP.
ENDIF.
CLEAR line_bkpf.
"NEW-LINE.
ULINE AT /72(45).
NEW-LINE.
WRITE: AT 70 subtotal_credit , AT 100 subtotal_debit.
NEW-LINE.
WRITE /.
CLEAR subtotal_credit.
CLEAR subtotal_debit.
CLEAR line_skat.
CLEAR line_kna1.
tmp = 0 .
ENDLOOP.
NEW-LINE.
WRITE /.
WRITE: AT 70 total_credit , AT 100 total_debit.
ULINE AT /72(45).
ULINE AT /72(45).
ENDIF.
ENDFORM. "output
生第一个ABAP程序 6个人天就是3000USD啊...感动ing...