*&---------------------------------------------------------------------*
*& Report ZVVF_FIRO_BANK_CASH *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZVVF_FR009_BANK_OUTFLOW LINE-SIZE 140.
TABLES : bkpf , bseg, t035t, lfb1.
SELECT-OPTIONS : gl_accs FOR bseg-hkont OBLIGATORY, " From & To GL A/c
s_date FOR sy-datum OBLIGATORY, "One set of dates is compulsory
s_date1 FOR sy-datum,
s_date2 FOR sy-datum,
s_date3 FOR sy-datum,
s_date4 FOR sy-datum,
s_date5 FOR sy-datum,
s_date6 FOR sy-datum.
PARAMETERS : p_curr1 RADIOBUTTON GROUP rslc,
p_curr2 RADIOBUTTON GROUP rslc.
DATA : BEGIN OF itab_bkpf OCCURS 0,
bukrs LIKE bkpf-bukrs,
gjahr LIKE bkpf-gjahr,
belnr LIKE bkpf-belnr,
budat LIKE bkpf-budat,
END OF itab_bkpf.
DATA: BEGIN OF itab_bseg1 OCCURS 0,
belnr LIKE bseg-belnr,
budat LIKE bkpf-budat,
hkont LIKE bseg-hkont,
shkzg LIKE bseg-shkzg,
dmbtr LIKE bseg-dmbtr,
lifnr LIKE bseg-lifnr,
kunnr LIKE bseg-kunnr,
END OF itab_bseg1.
DATA: BEGIN OF itab_bseg2 OCCURS 0,
belnr LIKE bseg-belnr,
budat LIKE bkpf-budat,
hkont LIKE bseg-hkont,
shkzg LIKE bseg-shkzg,
dmbtr LIKE bseg-dmbtr,
lifnr LIKE bseg-lifnr,
kunnr LIKE bseg-kunnr,
END OF itab_bseg2.
DATA: BEGIN OF itab_bseg3 OCCURS 0,
belnr LIKE bseg-belnr,
budat LIKE bkpf-budat,
hkont LIKE bseg-hkont,
shkzg LIKE bseg-shkzg,
dmbtr LIKE bseg-dmbtr,
lifnr LIKE bseg-lifnr,
kunnr LIKE bseg-kunnr,
END OF itab_bseg3.
DATA : BEGIN OF cust_group OCCURS 0,
lifnr LIKE lfb1-lifnr,
fdgrv LIKE lfb1-fdgrv,
textl LIKE t035t-textl,
END OF cust_group.
DATA : BEGIN OF vend_group OCCURS 0,
kunnr LIKE knb1-kunnr,
fdgrv LIKE knb1-fdgrv,
textl LIKE t036t-ltext,
END OF vend_group.
DATA : BEGIN OF itab_dates OCCURS 14,
cur_date LIKE sy-datum,
END OF itab_dates.
DATA : group_code(10),
group_desc(25).
DATA : BEGIN OF group_data OCCURS 0,
group_code LIKE lfb1-fdgrv,
group_desc LIKE group_desc,
amt0 LIKE bseg-dmbtr,
amt1 LIKE bseg-dmbtr,
amt2 LIKE bseg-dmbtr,
amt3 LIKE bseg-dmbtr,
amt4 LIKE bseg-dmbtr,
amt5 LIKE bseg-dmbtr,
amt6 LIKE bseg-dmbtr,
END OF group_data.
DATA : min_date LIKE sy-datum,
max_date LIKE sy-datum,
color_toggle TYPE i,
xamount(14),
xtot0 like bseg-dmbtr, xtot1 like bseg-dmbtr,
xtot2 like bseg-dmbtr, xtot3 like bseg-dmbtr,
xtot4 like bseg-dmbtr, xtot5 like bseg-dmbtr,
xtot6 like bseg-dmbtr.
START-OF-SELECTION.
PERFORM get_min_max.
PERFORM create_bkpf.
IF sy-subrc EQ 0.
PERFORM create_bseg1.
PERFORM create_bseg2.
PERFORM create_bseg3.
PERFORM create_cust_group.
PERFORM create_vend_group.
PERFORM update_date.
PERFORM create_final_table.
PERFORM write_report.
PERFORM print_total.
ENDIF.
END-OF-SELECTION.
*---------------------------------------------------------------------*
* FORM get_min_max *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM get_min_max.
CLEAR : min_date, max_date.
min_date = s_date-low.
max_date = s_date-high.
MOVE s_date-low TO itab_dates.
APPEND itab_dates.
IF NOT s_date1 IS INITIAL.
MOVE s_date1-low TO itab_dates.
APPEND itab_dates.
ENDIF.
IF NOT s_date2 IS INITIAL.
MOVE s_date2-low TO itab_dates.
APPEND itab_dates.
ENDIF.
IF NOT s_date3 IS INITIAL.
MOVE s_date3-low TO itab_dates.
APPEND itab_dates.
ENDIF.
IF NOT s_date4 IS INITIAL.
MOVE s_date4-low TO itab_dates.
APPEND itab_dates.
ENDIF.
IF NOT s_date5 IS INITIAL.
MOVE s_date5-low TO itab_dates.
APPEND itab_dates.
ENDIF.
IF NOT s_date6 IS INITIAL.
MOVE s_date6-low TO itab_dates.
APPEND itab_dates.
ENDIF.
LOOP AT itab_dates.
IF itab_dates-cur_date < min_date
AND NOT itab_dates-cur_date IS INITIAL.
min_date = itab_dates-cur_date.
ENDIF.
ENDLOOP.
REFRESH itab_dates.
MOVE s_date-high TO itab_dates.
APPEND itab_dates.
IF NOT s_date1 IS INITIAL.
MOVE s_date1-high TO itab_dates.
APPEND itab_dates.
ENDIF.
IF NOT s_date2 IS INITIAL.
MOVE s_date2-high TO itab_dates.
APPEND itab_dates.
ENDIF.
IF NOT s_date3 IS INITIAL.
MOVE s_date3-high TO itab_dates.
APPEND itab_dates.
ENDIF.
IF NOT s_date4 IS INITIAL.
MOVE s_date4-high TO itab_dates.
APPEND itab_dates.
ENDIF.
IF NOT s_date5 IS INITIAL.
MOVE s_date5-high TO itab_dates.
APPEND itab_dates.
ENDIF.
IF NOT s_date6 IS INITIAL.
MOVE s_date6-high TO itab_dates.
APPEND itab_dates.
ENDIF.
LOOP AT itab_dates.
IF itab_dates-cur_date > max_date
AND NOT itab_dates-cur_date IS INITIAL.
max_date = itab_dates-cur_date.
ENDIF.
ENDLOOP.
ENDFORM.
*---------------------------------------------------------------------*
* FORM create_bkpf *
*---------------------------------------------------------------------*
* Creates an internal table of BKPF, so that all the entries ie. BELNR*
* the Document Number for the dates selected is available. *
*---------------------------------------------------------------------*
FORM create_bkpf.
SELECT gjahr
belnr
bukrs
budat
INTO CORRESPONDING FIELDS OF TABLE itab_bkpf
FROM bkpf
WHERE budat BETWEEN min_date and max_date
AND blart ne 'F1'.
ENDFORM.
*---------------------------------------------------------------------*
* FORM create_bseg1 *
*---------------------------------------------------------------------*
*Creates an internal table BSEG1 which will have all the document nos.*
*from BSEG for all the entries that are available in internal BKPF. *
*---------------------------------------------------------------------*
FORM create_bseg1.
SELECT belnr
hkont
shkzg
dmbtr
lifnr
kunnr
INTO CORRESPONDING FIELDS OF TABLE itab_bseg1
FROM bseg
FOR ALL ENTRIES IN itab_bkpf
WHERE belnr = itab_bkpf-belnr
AND gjahr = itab_bkpf-gjahr
AND bukrs = itab_bkpf-bukrs.
ENDFORM.
*---------------------------------------------------------------------*
* FORM create_bseg2 *
*---------------------------------------------------------------------*
* For all entries in BSEG1, if the Account Code exists in the range *
* specified by the User, this entry is inserted into BSEG2. *
*---------------------------------------------------------------------*
FORM create_bseg2.
LOOP AT itab_bseg1.
IF itab_bseg1-hkont IN gl_accs.
MOVE-CORRESPONDING itab_bseg1 TO itab_bseg2.
APPEND itab_bseg2.
ENDIF.
ENDLOOP.
ENDFORM.
*---------------------------------------------------------------------*
* FORM create_bseg3 *
*---------------------------------------------------------------------*
* Now compare BSEG2 with entries in BSEG1, *
*---------------------------------------------------------------------*
FORM create_bseg3.
LOOP AT itab_bseg1.
LOOP AT itab_bseg2 WHERE belnr = itab_bseg1-belnr
AND hkont NE itab_bseg1-hkont.
MOVE-CORRESPONDING itab_bseg1 TO itab_bseg3.
APPEND itab_bseg3.
ENDLOOP.
ENDLOOP.
ENDFORM.
*---------------------------------------------------------------------*
* FORM write_report *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM write_report.
sort group_data by group_code group_desc ascending.
FORMAT COLOR COL_NORMAL.
color_toggle = 0.
LOOP AT group_data.
IF color_toggle = 1.
FORMAT INTENSIFIED ON.
color_toggle = 0.
ELSE.
FORMAT INTENSIFIED OFF.
color_toggle = 1.
ENDIF.
WRITE : /1 sy-vline.
format color col_normal.
WRITE : 2 group_data-group_code.
WRITE : 9 sy-vline.
if not group_data-group_desc is initial.
WRITE : 10 group_data-group_desc.
else.
WRITE : 10 'GROUP NOT DEFINED '.
endif.
format color col_group.
WRITE : 34 sy-vline.
if not group_data-amt0 is initial.
MOVE group_data-amt0 TO xamount.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = xamount.
WRITE : 35 xamount RIGHT-JUSTIFIED.
endif.
WRITE : 49 sy-vline.
format color col_normal.
if not group_data-amt1 is initial.
MOVE group_data-amt1 TO xamount.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = xamount.
WRITE : 50 xamount RIGHT-JUSTIFIED.
endif.
WRITE : 64 sy-vline.
format color col_group.
if not group_data-amt2 is initial.
MOVE group_data-amt2 TO xamount.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = xamount.
WRITE : 65 xamount RIGHT-JUSTIFIED.
endif.
WRITE : 79 sy-vline.
format color col_normal.
if not group_data-amt3 is initial.
MOVE group_data-amt3 TO xamount.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = xamount.
WRITE : 80 xamount RIGHT-JUSTIFIED.
endif.
WRITE : 94 sy-vline.
format color col_group.
if not group_data-amt4 is initial.
MOVE group_data-amt4 TO xamount.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = xamount.
WRITE : 95 xamount RIGHT-JUSTIFIED.
endif.
WRITE : 109 sy-vline.
format color col_normal.
if not group_data-amt5 is initial.
MOVE group_data-amt5 TO xamount.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = xamount.
WRITE : 110 xamount RIGHT-JUSTIFIED.
endif.
WRITE : 124 sy-vline.
format color col_group.
if not group_data-amt6 is initial.
MOVE group_data-amt6 TO xamount.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = xamount.
WRITE : 125 xamount RIGHT-JUSTIFIED.
endif.
WRITE : 140 sy-vline.
ENDLOOP.
ULINE.
ENDFORM.
*---------------------------------------------------------------------*
* FORM create_cust_group *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM create_cust_group.
SELECT a~lifnr
a~fdgrv
INTO CORRESPONDING FIELDS OF TABLE cust_group
FROM lfb1 AS a
FOR ALL ENTRIES IN itab_bseg3
WHERE lifnr = itab_bseg3-lifnr.
LOOP AT cust_group.
CLEAR : group_desc.
SELECT SINGLE textl
INTO (group_desc)
FROM t035t WHERE grupp = cust_group-fdgrv
AND spras = 'EN'.
cust_group-textl = group_desc.
MODIFY cust_group.
ENDLOOP.
ENDFORM.
*---------------------------------------------------------------------*
* FORM create_vend_group *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM create_vend_group.
SELECT a~kunnr
a~fdgrv
APPENDING TABLE vend_group
FROM knb1 AS a
FOR ALL ENTRIES IN itab_bseg3
WHERE kunnr = itab_bseg3-kunnr.
LOOP AT vend_group WHERE textl IS initial.
CLEAR : group_desc.
SELECT SINGLE ltext
INTO (group_desc)
FROM t036t WHERE ebene = vend_group-fdgrv
AND spras = 'EN'.
vend_group-textl = group_desc.
MODIFY vend_group.
ENDLOOP.
ENDFORM.
*---------------------------------------------------------------------*
* FORM update_date *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM update_date.
LOOP AT itab_bseg3.
LOOP AT itab_bkpf WHERE belnr = itab_bseg3-belnr.
itab_bseg3-budat = itab_bkpf-budat.
if p_curr2 = 'X'.
itab_bseg3-dmbtr = itab_bseg3-dmbtr / 100000.
endif.
MODIFY itab_bseg3.
ENDLOOP.
ENDLOOP.
ENDFORM.
*---------------------------------------------------------------------*
* FORM CREATE_FINAL_table *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM create_final_table.
CLEAR : xtot0, xtot1, xtot2, xtot3, xtot4, xtot5, xtot6.
LOOP AT itab_bseg3.
CLEAR : group_code, group_desc.
IF NOT itab_bseg3-lifnr IS INITIAL.
LOOP AT cust_group WHERE lifnr = itab_bseg3-lifnr.
LOOP AT group_data WHERE group_code = cust_group-fdgrv
AND group_desc = cust_group-textl.
EXIT.
ENDLOOP.
IF sy-subrc NE 0.
clear : group_data.
group_data-group_code = cust_group-fdgrv.
group_data-group_desc = cust_group-textl.
APPEND group_data.
ENDIF.
CLEAR : group_code, group_desc.
group_code = cust_group-fdgrv.
group_desc = cust_group-textl.
ENDLOOP.
ENDIF.
IF NOT itab_bseg3-kunnr IS INITIAL.
LOOP AT vend_group WHERE kunnr = itab_bseg3-kunnr.
LOOP AT group_data WHERE group_code = vend_group-fdgrv
AND group_desc = vend_group-textl.
EXIT.
ENDLOOP.
IF sy-subrc NE 0.
clear : group_data.
group_data-group_code = vend_group-fdgrv.
group_data-group_desc = vend_group-textl.
APPEND group_data.
ENDIF.
CLEAR : group_code, group_desc.
group_code = vend_group-fdgrv.
group_desc = vend_group-textl.
ENDLOOP.
ENDIF.
LOOP AT group_data WHERE group_code = group_data-group_code
AND group_desc = group_data-group_desc.
IF itab_bseg3-budat IN s_date AND NOT s_date IS INITIAL.
IF itab_bseg3-shkzg = 'H'.
group_data-amt0 = group_data-amt0 + itab_bseg3-dmbtr.
MODIFY group_data.
xtot0 = xtot0 + itab_bseg3-dmbtr.
ELSE.
group_data-amt0 = group_data-amt0 - itab_bseg3-dmbtr.
xtot0 = xtot0 - itab_bseg3-dmbtr.
ENDIF.
MODIFY group_data.
ENDIF.
IF itab_bseg3-budat IN s_date1 AND NOT s_date1 IS INITIAL.
IF itab_bseg3-shkzg = 'H'.
group_data-amt1 = group_data-amt1 + itab_bseg3-dmbtr.
xtot1 = xtot1 + itab_bseg3-dmbtr.
ELSE.
group_data-amt1 = group_data-amt1 - itab_bseg3-dmbtr.
xtot1 = xtot1 - itab_bseg3-dmbtr.
ENDIF.
MODIFY group_data.
ENDIF.
IF itab_bseg3-budat IN s_date2 AND NOT s_date2 IS INITIAL.
IF itab_bseg3-shkzg = 'H'.
group_data-amt2 = group_data-amt2 + itab_bseg3-dmbtr.
xtot2 = xtot2 + itab_bseg3-dmbtr.
ELSE.
group_data-amt2 = group_data-amt2 - itab_bseg3-dmbtr.
xtot2 = xtot2 - itab_bseg3-dmbtr.
ENDIF.
MODIFY group_data.
ENDIF.
IF itab_bseg3-budat IN s_date3 AND NOT s_date3 IS INITIAL.
IF itab_bseg3-shkzg = 'H'.
group_data-amt3 = group_data-amt3 + itab_bseg3-dmbtr.
xtot3 = xtot3 + itab_bseg3-dmbtr.
ELSE.
group_data-amt3 = group_data-amt3 - itab_bseg3-dmbtr.
xtot3 = xtot3 - itab_bseg3-dmbtr.
ENDIF.
MODIFY group_data.
ENDIF.
IF itab_bseg3-budat IN s_date4 AND NOT s_date4 IS INITIAL.
IF itab_bseg3-shkzg = 'H'.
group_data-amt4 = group_data-amt4 + itab_bseg3-dmbtr.
xtot4 = xtot4 + itab_bseg3-dmbtr.
ELSE.
group_data-amt4 = group_data-amt4 - itab_bseg3-dmbtr.
xtot4 = xtot4 - itab_bseg3-dmbtr.
ENDIF.
MODIFY group_data.
ENDIF.
IF itab_bseg3-budat IN s_date5 AND NOT s_date5 IS INITIAL.
IF itab_bseg3-shkzg = 'H'.
group_data-amt5 = group_data-amt5 + itab_bseg3-dmbtr.
xtot5 = xtot5 + itab_bseg3-dmbtr.
ELSE.
group_data-amt5 = group_data-amt5 - itab_bseg3-dmbtr.
xtot5 = xtot5 - itab_bseg3-dmbtr.
ENDIF.
MODIFY group_data.
ENDIF.
IF itab_bseg3-budat IN s_date6 AND NOT s_date6 IS INITIAL.
IF itab_bseg3-shkzg = 'H'.
group_data-amt6 = group_data-amt6 + itab_bseg3-dmbtr.
xtot6 = xtot6 + itab_bseg3-dmbtr.
ELSE.
group_data-amt6 = group_data-amt6 - itab_bseg3-dmbtr.
xtot6 = xtot6 - itab_bseg3-dmbtr.
ENDIF.
MODIFY group_data.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDFORM.
TOP-OF-PAGE.
WRITE :/(140) sy-uline.
WRITE: /1 sy-vline.
WRITE: 4 'User Name : ' .
WRITE : 20(10) sy-uname.
WRITE: 120 'Module : FI'.
WRITE: 140 sy-vline.
WRITE: /1 sy-vline.
WRITE: 4 'Time : '.
WRITE: 20(10) sy-uzeit.
WRITE: 120 'Date :'.
WRITE: 127(12) sy-datum DD/MM/YYYY.
WRITE: 140 sy-vline.
FORMAT COLOR COL_HEADING.
write : sy-uline(140).
WRITE: /1 sy-vline.
WRITE : 2 'Code'.
WRITE : 9 sy-vline.
WRITE : 10 'Description'.
WRITE : 34 sy-vline.
WRITE : 35 s_date-low.
WRITE : 49 sy-vline.
WRITE : 50 s_date1-low.
WRITE : 64 sy-vline.
WRITE : 65 s_date2-low.
WRITE : 79 sy-vline.
WRITE : 80 s_date3-low.
WRITE : 94 sy-vline.
WRITE : 95 s_date4-low.
WRITE : 109 sy-vline.
WRITE : 110 s_date5-low.
WRITE : 124 sy-vline.
WRITE : 125 s_date6-low.
WRITE : 140 sy-vline.
WRITE: /1 sy-vline.
WRITE : 9 sy-vline.
WRITE : 34 sy-vline.
WRITE : 35 s_date-high.
WRITE : 49 sy-vline.
WRITE : 50 s_date1-high.
WRITE : 64 sy-vline.
WRITE : 65 s_date2-high.
WRITE : 79 sy-vline.
WRITE : 80 s_date3-high.
WRITE : 94 sy-vline.
WRITE : 95 s_date4-high.
WRITE : 109 sy-vline.
WRITE : 110 s_date5-high.
WRITE : 124 sy-vline.
WRITE : 125 s_date6-high.
WRITE : 140 sy-vline.
ULINE.
END-OF-PAGE.
WRITE : /1 sy-vline.
WRITE : 2 sy-uline(139).
WRITE : 140 sy-uline.
*---------------------------------------------------------------------*
* FORM print_total *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM print_total.
FORMAT COLOR COL_TOTAL.
WRITE : /1 sy-vline.
WRITE : 15 'Totals : '.
* WRITE : 34 sy-vline.
move xtot0 to xamount.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = xamount.
WRITE : 34 sy-vline.
WRITE : 35 xamount RIGHT-JUSTIFIED.
WRITE : 49 sy-vline.
move xtot1 to xamount.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = xamount.
WRITE : 50 xamount RIGHT-JUSTIFIED.
move xtot2 to xamount.
WRITE : 64 sy-vline.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = xamount.
WRITE : 65 xamount RIGHT-JUSTIFIED.
move xtot3 to xamount.
WRITE : 79 sy-vline.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = xamount.
WRITE : 80 xamount RIGHT-JUSTIFIED.
move xtot4 to xamount.
WRITE : 94 sy-vline.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = xamount.
WRITE : 95 xamount RIGHT-JUSTIFIED.
move xtot5 to xamount.
WRITE : 109 sy-vline.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = xamount.
WRITE : 110 xamount RIGHT-JUSTIFIED.
move xtot6 to xamount.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = xamount.
WRITE : 124 sy-vline.
WRITE : 125 xamount RIGHT-JUSTIFIED.
WRITE : 140 sy-vline.
ULINE.
ENDFORM.
No comments:
Post a Comment