*&---------------------------------------------------------------------*
*& Report ZVVF_FIRO_VDAGEING *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
***----------------------------
***---- Report for Vendor Debit Ageing Analysis.
***----
***----------------------------
***----------------------------------
***--- Change History
***--- Changed on 8 April 03 by Samira , asked by Maheshdk
***--- Changes to consider Cleared items of Vendor from BSAK
***----------------------------------
*----------------------------------------------------------------------*
*--- Change History ---*
*--- Change asked by Mahesh Kasbekar , done by Samira
*--- Logic is changed from baseline date to posting date
*--- That is it is from from zfbdt to budat
*----------------------------------------------------------------------*
REPORT ZVVF_FIRO_VDAGEING
no standard page heading
line-size 152.
***--- Tables used
tables: bseg, bsik, bkpf.
***--- User selections
select-options: s_lifnr for bseg-lifnr,
s_gsber for bseg-gsber,
s_bukrs for bseg-bukrs
obligatory no-extension no intervals,
s_umskz for bsik-umskz.
parameters: p_zfbdt like bsik-zfbdt obligatory,
block1 type i obligatory,
block2 type i,
block3 type i,
block4 type i,
block5 type i.
***--- Internal data
data: begin of itab occurs 0,
lifnr like bsik-lifnr,
dmbtr like bsik-dmbtr,
name1 like kna1-name1,
end of itab.
data: begin of i_age occurs 0,
val type i,
end of i_age.
data: v_belnr like bsik-belnr,
v_dmbtr like bsik-dmbtr,
date1 like bsik-zfbdt,
date2 like bsik-zfbdt,
coln type i.
data: coln_head type i,
lastval type i.
data: begin of i_total occurs 0,
dmbtr like bsid-dmbtr,
block type i,
end of i_total.
data: v_tabix type i.
data: sum_tot_dmbtr like bsid-dmbtr.
data: begin of i_temp occurs 0,
dmbtr like bsik-dmbtr,
shkzg like bsik-shkzg,
lifnr like bsik-lifnr,
end of i_temp.
data: begin of i_bsak occurs 0,
dmbtr like bsik-dmbtr,
shkzg like bsik-shkzg,
lifnr like bsik-lifnr,
budat like bsak-budat,
augdt like bsak-augdt,
end of i_bsak.
data: begin of i_btemp occurs 0,
dmbtr like bsik-dmbtr,
shkzg like bsik-shkzg,
lifnr like bsik-lifnr,
budat like bsak-budat,
augdt like bsak-augdt,
end of i_btemp.
data: begin of i_lifnr occurs 0,
lifnr like bsik-lifnr,
end of i_lifnr.
start-of-selection.
if not ( block1 is initial ).
i_age-val = block1.
append i_age.
if not ( block2 is initial ).
i_age-val = block2.
append i_age.
if not ( block3 is initial ).
i_age-val = block3.
append i_age.
if not ( block4 is initial ).
i_age-val = block4.
append i_age.
if not ( block5 is initial ).
i_age-val = block5.
append i_age.
endif.
endif.
endif.
endif.
else.
message e000(zfi) with 'Enter at least one ageing block'.
endif.
* select belnr dmbtr
* into (v_belnr, v_dmbtr)
* from bsik
** where zfbdt = p_zfbdt
* where budat = p_zfbdt
* and lifnr in s_lifnr
* and gsber in s_gsber
* and bukrs in s_bukrs
* and umskz in s_umskz.
* endselect.
***--- Open items
select dmbtr shkzg lifnr
into table i_temp
from bsik
* where zfbdt <= p_zfbdt where budat <= p_zfbdt and lifnr in s_lifnr and gsber in s_gsber and bukrs in s_bukrs and umskz in s_umskz and zumsk eq ' '. ***--- Clear items select dmbtr shkzg lifnr budat augdt into table i_bsak from bsak where ( budat <= p_zfbdt and augdt > p_zfbdt )
and lifnr in s_lifnr
and gsber in s_gsber
and bukrs in s_bukrs
and umskz in s_umskz
and zumsk eq ' '.
***--- Finding out Uniq Vendor
loop at i_temp.
i_lifnr-lifnr = i_temp-lifnr.
append i_lifnr.
endloop.
loop at i_bsak.
i_lifnr-lifnr = i_bsak-lifnr.
append i_lifnr.
endloop.
sort i_lifnr by lifnr.
delete adjacent duplicates from i_lifnr comparing lifnr.
loop at i_lifnr.
***--- For Open Item of Vendor
loop at i_temp where lifnr = i_lifnr-lifnr.
if i_temp-shkzg = 'H'.
itab-dmbtr = itab-dmbtr + ( -1 * i_temp-dmbtr ).
else.
itab-dmbtr = itab-dmbtr + i_temp-dmbtr.
endif.
endloop.
***--- For Clear Item of Vendor
loop at i_bsak where lifnr = i_lifnr-lifnr.
if i_bsak-shkzg = 'H'.
itab-dmbtr = itab-dmbtr + ( -1 * i_bsak-dmbtr ).
else.
itab-dmbtr = itab-dmbtr + i_bsak-dmbtr.
endif.
endloop.
itab-lifnr = i_lifnr-lifnr.
***--- Change table from kna1 to lfa1
select name1 into itab-name1
from lfa1 where lifnr = i_lifnr-lifnr.
endselect.
append itab.
clear itab.
endloop.
perform age_split.
top-of-page.
perform header_data.
end-of-page.
*---------------------------------------------------------------------*
* FORM age_split *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form age_split.
data: preval type i,
v_dmbtr like bsik-dmbtr,
v_toggle type i.
data: loop_cntr type i value 0.
loop at i_age.
v_tabix = v_tabix + 1.
endloop.
preval = 0.
coln = 52.
loop at itab.
if v_toggle = 0.
format color col_normal.
v_toggle = 1.
else.
format color col_normal intensified.
v_toggle = 0.
endif.
write:/ sy-vline.
write:2 itab-lifnr.
write:10 sy-vline.
write:11 itab-name1+0(16).
write:27 sy-vline.
write:28 itab-dmbtr.
write:44 sy-vline.
sum_tot_dmbtr = sum_tot_dmbtr + itab-dmbtr.
coln = 45.
clear loop_cntr.
clear preval.
loop at i_age.
loop_cntr = loop_cntr + 1.
clear: i_temp,i_btemp.
refresh: i_temp,i_btemp.
clear v_dmbtr.
date1 = p_zfbdt - preval.
date2 = p_zfbdt - i_age-val.
***--- Open Item
select lifnr dmbtr shkzg from bsik
into corresponding fields of table i_temp
where lifnr = itab-lifnr
* and zfbdt > date2
* and zfbdt <= date1 and budat > date2
and budat <= date1 and gsber in s_gsber and bukrs in s_bukrs and umskz in s_umskz and zumsk eq ' '. loop at i_temp where lifnr = itab-lifnr. if i_temp-shkzg = 'H'. v_dmbtr = v_dmbtr - i_temp-dmbtr. else. v_dmbtr = v_dmbtr + i_temp-dmbtr. endif. endloop. ***--- Clear Item select lifnr dmbtr shkzg budat augdt from bsak into corresponding fields of table i_btemp where lifnr = itab-lifnr * and zfbdt > date2
* and zfbdt <= date1 and budat > date2
and budat <= date1 and ( budat <= p_zfbdt and augdt > p_zfbdt )
and gsber in s_gsber
and bukrs in s_bukrs
and umskz in s_umskz
and zumsk eq ' '.
loop at i_btemp where lifnr = itab-lifnr.
if i_btemp-shkzg = 'H'.
v_dmbtr = v_dmbtr - i_btemp-dmbtr.
else.
v_dmbtr = v_dmbtr + i_btemp-dmbtr.
endif.
endloop.
i_total-dmbtr = v_dmbtr.
i_total-block = loop_cntr.
append i_total.
clear i_total.
write at coln v_dmbtr.
coln = coln + 16.
write at coln sy-vline.
coln = coln + 1.
preval = i_age-val.
endloop.
clear: i_temp,i_btemp.
refresh: i_temp,i_btemp.
clear v_dmbtr.
select dmbtr shkzg from bsik
into corresponding fields of table i_temp
where lifnr = itab-lifnr
* and zfbdt <= date2 and budat <= date2 and gsber in s_gsber and bukrs in s_bukrs and umskz in s_umskz and zumsk eq ' '. select lifnr dmbtr shkzg from bsak into corresponding fields of table i_btemp where lifnr = itab-lifnr * and zfbdt <= date2 and budat <= date2 and ( budat <= p_zfbdt and augdt > p_zfbdt )
and gsber in s_gsber
and bukrs in s_bukrs
and umskz in s_umskz
and zumsk eq ' '.
loop at i_btemp.
if i_btemp-shkzg = 'H'.
v_dmbtr = v_dmbtr - i_btemp-dmbtr.
else.
v_dmbtr = v_dmbtr + i_btemp-dmbtr.
endif.
endloop.
loop at i_temp.
if i_temp-shkzg = 'H'.
v_dmbtr = v_dmbtr - i_temp-dmbtr.
else.
v_dmbtr = v_dmbtr + i_temp-dmbtr.
endif.
endloop.
loop_cntr = loop_cntr + 1.
i_total-dmbtr = v_dmbtr.
i_total-block = loop_cntr.
append i_total.
clear i_total.
write at coln v_dmbtr.
coln = coln + 16.
write at coln sy-vline.
endloop.
format reset.
write:/ sy-uline.
perform display_total.
endform.
****** Header
form header_data.
format reset.
write:/4 'User Id :'.
write:25 sy-uname.
write: 45 'Date :'.
write: 66 sy-datum .
write:/4 'From Vendor Code:'.
write:25 s_lifnr-low.
write :45 'To Custmer Code :'.
write :66 s_lifnr-high.
write :/4 'Business Area :'.
write :25 s_gsber-low, 'To', s_gsber-high.
write :/4 'Sp. G/L Acct No :'.
write :25 s_umskz-low.
write :/4 'Posting Date :'.
write :25 p_zfbdt.
format color col_heading.
write:/.
write:/ sy-uline.
write:/ sy-vline.
write:2 'Vendor'.
write:10 sy-vline.
write:13 'Description'.
write:27 sy-vline.
write:33 'Total'.
write:44 sy-vline.
write:48 'From 0'.
write:61 sy-vline.
coln_head = 61.
loop at i_age.
coln_head = coln_head + 4.
write at coln_head 'From'.
coln_head = coln_head + 5.
write at coln_head i_age-val left-justified.
coln_head = coln_head + 8.
write at coln_head sy-vline.
endloop.
*write at coln_head 'From'.
*coln_head = coln_head + 5.
*write at coln_head lastval left-justified.
*coln_head = coln_head + 11.
*write at coln_head sy-vline.
write:/ sy-vline.
write:10 sy-vline.
write:27 sy-vline.
write:44 sy-vline.
coln_head = 50.
loop at i_age.
write at coln_head 'To'.
coln_head = coln_head + 3.
write at coln_head i_age-val left-justified.
coln_head = coln_head + 8.
write at coln_head sy-vline.
coln_head = coln_head + 6.
endloop.
coln_head = coln_head + 11.
write at coln_head sy-vline.
write:/ sy-uline.
format reset.
endform.
*---------------------------------------------------------------------*
* FORM display_total *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form display_total.
data: col_total type i,
loop_cntr type i value 0,
v_block_total like bsid-dmbtr,
tabix_cntr type i.
skip 1.
format color col_total intensified.
write:/ sy-uline.
write:/1 sy-vline.
write: 2 'Total:'.
write: 27 sy-vline.
write: 28 sum_tot_dmbtr .
write: 44 sy-vline.
tabix_cntr = v_tabix + 1.
col_total = 45.
loop_cntr = 1.
while ( loop_cntr <= tabix_cntr ). clear v_block_total. loop at i_total where block = loop_cntr. v_block_total = v_block_total + i_total-dmbtr. endloop. write at col_total v_block_total . col_total = col_total + 16. write at col_total sy-vline. col_total = col_total + 1. loop_cntr = loop_cntr + 1. endwhile. write:/ sy-uline. format reset. endform. " DISPLAY_TOTAL
No comments:
Post a Comment