REPORT zfi_rept_cust_balanceamt NO STANDARD PAGE HEADING
MESSAGE-ID zivs.
TABLES : t001, tvkbt, bsid, bsad, knb1,bkpf,knc1,sscrfields,T009.
selection-screen begin of block b1 with frame title text-000.
PARAMETERS : ccode LIKE bsid-bukrs,
date LIKE bsid-budat,
cust LIKE knb1-kunnr.
selection-screen end of block b1.
DATA : BEGIN OF i_customers OCCURS 0,
kunnr LIKE knb1-kunnr, "customer no
END OF i_customers.
DATA : BEGIN OF i_custopnbal OCCURS 0,
budat LIKE bsid-budat, "posting date
kunnr LIKE bsid-kunnr, "customer no
wrbtr LIKE bsid-wrbtr, "amount in document
shkzg LIKE bsid-shkzg, "debit/credit indicator
END OF i_custopnbal.
DATA: fdate LIKE bsid-budat,
ldate LIKE bsid-budat,
month LIKE T009-ANZBP,
monat like bkpf-monat,
year LIKE bkpf-gjahr,
tramount LIKE knc1-um01s,
opamt LIKE bsid-wrbtr ,
opind ,
clamt LIKE bsid-wrbtr,
clind ,
optot LIKE bsid-wrbtr ,
optoti,
trtot LIKE bsid-wrbtr ,
trtoti,
cltot LIKE bsid-wrbtr ,
cltoti,
opgtot LIKE bsid-wrbtr,
opgtoti,
trgtot LIKE bsid-wrbtr,
trgtoti,
clgtot LIKE bsid-wrbtr,
clgtoti,
no type i value 1.
selection-screen: function key 1.
initialization.
move 'Data1' to sscrfields-functxt_01.
at selection-screen.
if sscrfields-ucomm = 'FC01'.
ccode = 'DATT'.
date = '20040910'.
cust = '0000500001'.
endif.
SELECT SINGLE * FROM t001 WHERE bukrs = ccode.
IF sy-subrc <> 0.
MESSAGE e000.
ENDIF.
IF date > sy-datum.
MESSAGE e002.
ENDIF.
START-OF-SELECTION.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
day_in = date
IMPORTING
last_day_of_month = ldate.
fdate = date.
fdate+6(2) = '01'.
SELECT kunnr FROM knb1 INTO TABLE i_customers
WHERE bukrs = ccode.
LOOP AT i_customers.
SELECT budat kunnr wrbtr shkzg FROM bsid
APPENDING
CORRESPONDING FIELDS OF TABLE i_custopnbal
WHERE bukrs = ccode AND
kunnr = cust AND
budat BETWEEN fdate AND ldate.
ENDLOOP.
* IF SY-SUBRC <> 0.
* WRITE:/15(30) 'NO DATA IS HERE WITH UR INPUT',/35 'ENTER ANOTHER ONE'
.
* ENDIF.
SORT i_custopnbal BY budat.
CALL FUNCTION 'FTI_FISCAL_YEAR_MONTH_GET'
EXPORTING
i_bukrs = ccode
i_budat = date
IMPORTING
e_gjahr = year
e_monat = monat.
month = monat.
CALL FUNCTION 'CUSTOMER_BALANCE'
EXPORTING
anzbp = '012'
bukrs = ccode
gjahr = year
kunnr = cust
monat = month
periv = 'V3'
xh12mon = ' '
xh6mon = ' '
IMPORTING
uml01 = tramount.
opamt = tramount.
LOOP AT i_custopnbal.
AT NEW budat.
FORMAT COLOR COL_GROUP INVERSE..
WRITE :/, / 'DATE:' , i_custopnbal-budat,
' CUSTMOER NO: ', i_customers-kunnr ,
'COMPANY CODE:', ccode.
FORMAT RESET.
FORMAT COLOR 3.
WRITE : /5 'S.NO' , 10 ' OPENING BAL', 30 'D/C',
35 ' TRANS AMT ', 60 'D/C',
65 ' CLOSING AMT ', 85 'D/C'.
FORMAT RESET.
ENDAT.
PERFORM sub1 USING opamt opind.
IF i_custopnbal-shkzg = 'S'.
clamt = opamt + i_custopnbal-wrbtr.
ELSE .
clamt = opamt - i_custopnbal-wrbtr.
ENDIF.
PERFORM sub1 USING clamt clind .
FORMAT COLOR 2.
WRITE :/5 no,10 opamt NO-SIGN,30 opind,
35 i_custopnbal-wrbtr,60 i_custopnbal-shkzg,
65 clamt NO-SIGN,85 clind.
FORMAT RESET.
PERFORM sub2 USING optot opamt .
PERFORM sub1 USING optot optoti.
PERFORM sub2 USING trtot i_custopnbal-wrbtr .
PERFORM sub1 USING trtot trtoti.
PERFORM sub2 USING cltot clamt .
PERFORM sub1 USING cltot cltoti.
PERFORM sub2 USING opgtot opamt .
PERFORM sub1 USING opgtot opgtoti.
PERFORM sub2 USING trgtot i_custopnbal-wrbtr .
PERFORM sub1 USING trgtot trgtoti.
PERFORM sub2 USING clgtot clamt .
PERFORM sub1 USING clgtot clgtoti.
opamt = clamt.
AT END OF budat.
FORMAT COLOR 4.
WRITE:/'SUBTOTAL:',10 optot NO-SIGN, 30 optoti,
34 trtot NO-SIGN, 60 trtoti,
65 cltot NO-SIGN, 85 cltoti .
CLEAR :optot,trtot,cltot.
FORMAT RESET.
ENDAT.
AT LAST.
FORMAT COLOR 5.
WRITE:/'GRANDTOT:',10 opgtot NO-SIGN, 30 opgtoti,
34 trgtot NO-SIGN, 60 trgtoti,
65 clgtot NO-SIGN, 85 clgtoti .
FORMAT RESET.
ENDAT.
ENDLOOP.
*&---------------------------------------------------------------------*
*& Form SUB1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_CLAMT text
* -->P_CLIND text
*----------------------------------------------------------------------*
FORM sub1 USING p_clamt
p_clind.
IF p_clamt > 0.
p_clind = 'S'.
ELSEIF p_clamt < 0.
p_clind = 'H'.
ELSE.
p_clind = '-' .
ENDIF.
ENDFORM. " SUB1
*&---------------------------------------------------------------------*
*& Form SUB2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_OPTOT text
* -->P_OPAMT text
* -->P_OPIND text
*----------------------------------------------------------------------*
FORM sub2 USING p_optot
p_opamt.
p_optot = p_optot + p_opamt .
ENDFORM. " SUB2