Quantcast
Channel: SCN : Unanswered Discussions - ABAP Development
Viewing all articles
Browse latest Browse all 8768

assigning sequential number from number range

$
0
0

Hi All,

 

My Zreport is updating Ztable with sequential number field assigned for each document numbers for each period. Below are the numbers assigned for period 5 in Ztable.

00001000000000000000

00001000000000000001

00001000000000000002

00001100000000000000

00001200000000000000

00001200000000000001

00001200000000000002

00001200000000000003

 

When I ran for period 6 the sequence number is coming as below.

00001000000000000003

00001000000000000004

00001100000000000001

00001200000000000004

00001200000000000005

00001200000000000006


It should give me the below.

00001000000000000003

00001000000000000004

00001100000000000000

00001200000000000004

00001200000000000005

00001200000000000006

 

I am fetching the data from Ztable and sorting in descending order. Below is the data in my internal table in debugging.

bukrs belnr           blart   monat   numkr      zsequence

2700 |1700002431 |KA   |05         |03         |00001200000000000003

2700 |5100000804 |RE   |05         |02         |00001100000000000000

2700 |2200000004 |P2   |05          |01         |00001000000000000002

 

 

Below is my code.

      loop at t_ztable.

        clear w_zsequence.

        unpack t_table-zsequence to t_ztable-zsequence.

        if (t_ztable-zsequence = '00001200000000000000' or

             t_ztable-zsequence = '00001100000000000000' or

             t_ztable-zsequence = '00001000000000000000' ).

        w_zsequence = t_ztable-zsequence

        else.

          w_zsequence = t_ztable-zsequence + 1.

          unpack w_zsequence to w_zsequence.

        endif.                                              "BK003

*   shift w_zbelnr left deleting leading space.

        loop at t_bkpf

              where bukrs = t_ztable-bukrs

                and groupnumber = t_ztable-numkr.

          move-corresponding t_bkpf to t_ztable_load.

          t_ztable_load-zsequence = w_zsequence.

          t_ztable_load-numkr = t_ztable-numkr.

          append t_ztable_load.

          w_zsequence = w_zsequence + 1.

*         shift w_zsequence left deleting leading space.

          unpack w_zsequence to w_zsequence.

        endloop.

      endloop.

 

How to acheive this. Please help me.

 

Thanks,

VBK


Viewing all articles
Browse latest Browse all 8768

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>