03-31-2011 9:24 AM
Hi,
I m new for abap. There is a report for challan gate pass, in which i hv to enter serial no for every material. i use following coding for this....
data:ld_tab type zseqno.
clear ld_tab.
loop at it_dtl2.
select single seqno into it_dtl2-seqno from zseqno
where mblnr = it_dtl2-mblnr
and mjahr = it_dtl2-mjahr
and werks = it_dtl2-werks.
if sy-subrc ne 0.
select count(*) into it_dtl2-seqno from zseqno
where mjahr = it_dtl2-mjahr
and werks = it_dtl2-werks.
it_dtl2-seqno = it_dtl2-seqno + 1.
clear ld_tab.
ld_tab-mblnr = it_dtl2-mblnr.
ld_tab-mjahr = it_dtl2-mjahr.
ld_tab-werks = it_dtl2-werks.
ld_tab-seqno = it_dtl2-seqno.
modify zseqno from ld_tab.
endif.
clear ld_tab.
modify it_dtl2.
clear it_dtl2.
endloop.
In this coding , there is a table ZSEQNO which has MBLNR, MJAHR, WERKS, SEQNO fields.
How to reset serial no according to financial year? It means how to reset serial no in april of every year?
Thanks
Moderator message: code tages added, subject corrected, please choose a meaningful one next time.
Edited by: Thomas Zloch on Mar 31, 2011 10:31 AM
03-31-2011 9:44 AM
Hi sanchita,
Your code is little bit confusing., in your table ZSEQNO there should be a field for month.,
Now.,
data index type i.
loop itab into wa.
index = index + 1.
wa2-sno = index.
wa2-f1 = wa-f1.
wa2-f2 = wa-f2.
append wa2 to itabb2.
clear wa2.
if wa-month = 'April'. " ---> when month = april or 4 what ever it is.. reset index value
index = 0.
endif.
endloop.
hope this will help u.,
Revert if u need some more clarifications.,
Thanks & Regards
Kiran
03-31-2011 10:27 AM
03-31-2011 10:40 AM
Hi Sanchita,
First u have to fetch the records to internal table. then sort the internal table by fiscal year month.
Now take a temporary index variable and loop the internal table., and increment the index and assign it to serial num and append it to your final output table., when the month = April reset index.. so it ll reset the sno. Up to what i understood ur requirement i provided the logic.
Reply if u need some more clarifications.,
Thanks & Regards
Kiran
03-31-2011 10:33 AM