Go on link..

link us with ...

Friday, December 31, 2010

Logic is changed from baseline date to posting date

*&---------------------------------------------------------------------*
*& Report ZVVF_FIRO_VDOCAGEING *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

***-------------

REPORT ZVVF_FIRO_VDOCAGEING
no standard page heading
line-size 175.

tables: bseg, bsik, bkpf.

select-options: s_lifnr for bseg-lifnr," Vendor
s_gsber for bseg-gsber," Business Area
s_bukrs for bseg-bukrs
obligatory no-extension no intervals,
" Company Code
s_umskz for bsik-umskz. " Special G/L Acct Ind

parameters: p_zfbdt like bsik-zfbdt obligatory,
block1 type i obligatory,
block2 type i,
block3 type i,
block4 type i,
block5 type i.

data: begin of itab occurs 0,
lifnr like bsik-lifnr,
belnr like bsik-belnr,
zfbdt like bsik-zfbdt,
dmbtr like bsik-dmbtr,
shkzg like bsik-shkzg,
name1 like kna1-name1,
end of itab.

data: begin of i_age occurs 0,
val type i,
end of i_age.

data: begin of i_temp occurs 0,
belnr like bsik-belnr,
zfbdt like bsik-zfbdt,
dmbtr like bsik-dmbtr,
shkzg like bsik-shkzg,
lifnr like bsik-lifnr,
end of i_temp.

data: begin of i_bsak occurs 0,
belnr like bsik-belnr,
zfbdt like bsik-zfbdt,
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_lifnr occurs 0,
lifnr like bsik-lifnr,
end of i_lifnr.


data: v_belnr like bsik-belnr,
v_dmbtr like bsik-dmbtr,
date1 like bsik-zfbdt,
date2 like bsik-zfbdt,
coln type i,
cur_lifnr like bsik-lifnr,
cur_lifname like lfa1-name1.

data: coln_head type i,
lastval type i,
v_tabix like sy-tabix.

data: begin of i_total occurs 0,
dmbtr like bsid-dmbtr,
block type i,
end of i_total.

data: sum_tot_dmbtr like bsid-dmbtr.

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 zfbdt dmbtr shkzg lifnr
select belnr budat 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 belnr zfbdt dmbtr shkzg lifnr budat augdt
select belnr budat 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 ' '.

sort i_temp by lifnr zfbdt.

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.


***--- Open Item
loop at i_temp. " where lifnr = i_lifnr-lifnr.
if i_temp-shkzg = 'H'.
itab-dmbtr = -1 * i_temp-dmbtr.
else.
itab-dmbtr = i_temp-dmbtr.
endif.
itab-belnr = i_temp-belnr.
itab-zfbdt = i_temp-zfbdt.
itab-lifnr = i_temp-lifnr.

*-- Change table from kna1 to lfa1
*--- By Samir on 28 feb 2002

select name1 into itab-name1
from lfa1
where lifnr = i_temp-lifnr.
endselect.

append itab.
clear itab.
endloop.

***--- Clear Item
loop at i_bsak. " where lifnr = i_lifnr-lifnr.
if i_bsak-shkzg = 'H'.
itab-dmbtr = -1 * i_bsak-dmbtr.
else.
itab-dmbtr = i_bsak-dmbtr.
endif.
itab-belnr = i_bsak-belnr.
itab-zfbdt = i_bsak-zfbdt.
itab-lifnr = i_bsak-lifnr.

select name1 into itab-name1
from lfa1
where lifnr = i_bsak-lifnr.
endselect.

append itab.
clear itab.
endloop.

sort itab by lifnr.

perform age_split.

top-of-page.

perform header_data.

end-of-page.

******** Age Split

form age_split.

data: preval type i,
v_dmbtr like bsik-dmbtr,
v_toggle type i,
v_tabixw type i.

preval = 0.
coln = 50.

loop at i_age.
v_tabix = v_tabix + 1.
endloop.

*write:/ 'tabix: ', v_tabix.

loop at itab.
format reset.
if v_toggle = 0.
format color col_normal.
v_toggle = 1.
else.
format color col_normal intensified.
v_toggle = 0.
endif.

on change of itab-lifnr.
if sy-tabix > 1.
perform age_total.
endif.
endon.

write:/ sy-vline.
write:2 itab-lifnr.
write:10 sy-vline.
write:11 itab-name1+0(16).
write:27 sy-vline.
write:28 itab-belnr.
write:39 sy-vline.
write:40 itab-zfbdt.
write:51 sy-vline.
write:52 itab-dmbtr .
write:68 sy-vline.

coln = 69.

clear preval.

data: contr1 type i value 0,
v_flag type i,
loopcntr type i,
loopcoln type i.

loopcntr = 1.
loopcoln = 0.

contr1 = -1.

v_flag = 0.

loop at i_age.

contr1 = contr1 + 1.
coln = 69 + ( contr1 * 17 ).

date1 = p_zfbdt - preval.
date2 = p_zfbdt - i_age-val.

if itab-zfbdt > date2 and itab-zfbdt <= date1.
v_flag = 1.

write at coln itab-dmbtr .
endif.

preval = i_age-val.
endloop.

if v_flag = 0.

coln = 69 + ( v_tabix * 17 ).

write at coln itab-dmbtr .

* coln = coln + 13.
* write at coln sy-vline.

endif.

loopcntr = 1.
v_tabixw = 0.

v_tabixw = v_tabix + 1.

while loopcntr <= v_tabixw.
loopcoln = 68 + ( loopcntr * 17 ).
write at loopcoln sy-vline.
loopcntr = loopcntr + 1.
endwhile.

cur_lifnr = itab-lifnr.
cur_lifname = itab-name1.

*write:/ cur_lifnr.


endloop.

perform age_total.

perform display_block_total.

format reset.

write:/ sy-uline.
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 Vendor Code :'.
write :66 s_lifnr-high.

write :/4 'Business Area :'.
write :25 s_gsber .

write :/4 'Posting Date :'.
write :25 p_zfbdt.

write :/4 'Company Code :'.
write :25 s_bukrs-low.

write :/4 'Sp. G/L Acct Ind :'.
write :25 s_umskz-low.

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:30 'Doc No'.
write:39 sy-vline.
write:40 'Post Date'.
write:51 sy-vline.
write:57 'Total'.
write:68 sy-vline.
write:72 'From 0'.
write:85 sy-vline.

coln_head = 85.

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:39 sy-vline.
write:51 sy-vline.
write:68 sy-vline.


coln_head = 74.

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.


**********************
** Total **
**********************

form age_total.
data: preval type i,
v_dmbtr like bsik-dmbtr,
date1 like bsik-zfbdt,
date2 like bsik-zfbdt,
coln type i,
tot_dmbtr like bsik-dmbtr.


data: begin of i_temp_tot occurs 0,
dmbtr like bsik-dmbtr,
shkzg like bsik-shkzg,
lifnr like bsik-lifnr,
end of i_temp_tot.

data: begin of i_btemp_tot occurs 0,
dmbtr like bsik-dmbtr,
shkzg like bsik-shkzg,
lifnr like bsik-lifnr,
end of i_btemp_tot.

data: loop_cntr type i value 0.


format color col_total.

select dmbtr shkzg lifnr
into table i_temp_tot
from bsik
* where zfbdt <= p_zfbdt
where budat <= p_zfbdt
and lifnr = cur_lifnr
and gsber in s_gsber
and bukrs in s_bukrs
and umskz in s_umskz
and zumsk eq ' '.

select dmbtr shkzg lifnr
into table i_btemp_tot
from bsak
where
( budat <= p_zfbdt
and augdt > p_zfbdt )
and lifnr = cur_lifnr
and gsber in s_gsber
and bukrs in s_bukrs
and umskz in s_umskz
and zumsk eq ' '.

loop at i_temp_tot.
if i_temp_tot-shkzg = 'H'.
tot_dmbtr = tot_dmbtr + ( -1 * i_temp_tot-dmbtr ).
else.
tot_dmbtr = tot_dmbtr + i_temp_tot-dmbtr.
endif.
endloop.

loop at i_btemp_tot.
if i_btemp_tot-shkzg = 'H'.
tot_dmbtr = tot_dmbtr + ( -1 * i_btemp_tot-dmbtr ).
else.
tot_dmbtr = tot_dmbtr + i_btemp_tot-dmbtr.
endif.
endloop.

sum_tot_dmbtr = sum_tot_dmbtr + tot_dmbtr.

write:/ sy-uline.
write:/ sy-vline.
write:2 cur_lifnr.
write:10 sy-vline.
write:11 cur_lifname+0(16).
write:27 sy-vline.
write:51 sy-vline.
write:52 tot_dmbtr .
write:68 sy-vline.

coln = 69.

clear preval.

loop at i_age.
loop_cntr = loop_cntr + 1.

clear v_dmbtr.
clear: i_temp_tot,i_btemp_tot.
refresh: i_temp_tot,i_btemp_tot.

date1 = p_zfbdt - preval.
date2 = p_zfbdt - i_age-val.

select lifnr dmbtr shkzg from bsik
into corresponding fields of table i_temp_tot
where lifnr = cur_lifnr
* and zfbdt > date2
* and zfbdt <= date1
and budat <= p_zfbdt
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_tot. " WHERE lifnr = itab-lifnr.
if i_temp_tot-shkzg = 'H'.
v_dmbtr = v_dmbtr - i_temp_tot-dmbtr.
else.
v_dmbtr = v_dmbtr + i_temp_tot-dmbtr.
endif.
endloop.

select lifnr dmbtr shkzg budat augdt from bsak
into corresponding fields of table i_btemp_tot
where lifnr = cur_lifnr
* and zfbdt > date2
* and zfbdt <= date1
and ( budat <= p_zfbdt
and augdt > p_zfbdt )
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_btemp_tot. " WHERE lifnr = itab-lifnr.
if i_btemp_tot-shkzg = 'H'.
v_dmbtr = v_dmbtr - i_btemp_tot-dmbtr.
else.
v_dmbtr = v_dmbtr + i_btemp_tot-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_tot,i_btemp_tot.
refresh: i_temp_tot,i_btemp_tot.

clear v_dmbtr.

select dmbtr shkzg from bsik
into corresponding fields of table i_temp_tot
where lifnr = cur_lifnr
* and zfbdt <= date2
and budat <= p_zfbdt
and budat <= date2
and gsber in s_gsber
and bukrs in s_bukrs
and umskz in s_umskz
and zumsk eq ' '.

loop at i_temp_tot.
if i_temp_tot-shkzg = 'H'.
v_dmbtr = v_dmbtr - i_temp_tot-dmbtr.
else.
v_dmbtr = v_dmbtr + i_temp_tot-dmbtr.
endif.
endloop.

select lifnr dmbtr shkzg from bsak
into corresponding fields of table i_btemp_tot
where lifnr = cur_lifnr
* and zfbdt <= date2
and ( budat <= p_zfbdt
and augdt > p_zfbdt )
and budat <= date2
and gsber in s_gsber
and bukrs in s_bukrs
and umskz in s_umskz
and zumsk eq ' '.

loop at i_btemp_tot.
if i_btemp_tot-shkzg = 'H'.
v_dmbtr = v_dmbtr - i_btemp_tot-dmbtr.
else.
v_dmbtr = v_dmbtr + i_btemp_tot-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.

format reset.

write:/ sy-uline.


endform.

*---------------------------------------------------------------------*
* FORM display_block_total *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form display_block_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: 51 sy-vline.
write: 52 sum_tot_dmbtr .
write: 68 sy-vline.

tabix_cntr = v_tabix + 1.

col_total = 69.

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.

No comments:

link us...

For Visitors

if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours

email-id :- avinashkr_raj@yahoo.com(any email)

email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)