Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to reset serial no according to financial year

Former Member
0 Kudos

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

4 REPLIES 4

former_member184578
Active Contributor
0 Kudos

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

0 Kudos

Hi Kiran,

Can u plz explain ur coding.

Thanks

Sanchita

0 Kudos

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

Former Member
0 Kudos

Can anyone explain it.