‎2007 Apr 13 3:55 AM
hi,
if want to convert posnr from 500001 to 000010, 500002 to 000020 and so on what can i do?
i need to loop through an internal table for this and how do i know when it meets 500001 until maybe 500100 as i need to convert it to 000010 to 001000.
thanks
‎2007 Apr 13 4:06 AM
‎2007 Apr 13 4:03 AM
Hi,
Check this.
DATA: i_posnr LIKE vbap-posnr VALUE '500001',
o_posnr LIKE vbap-posnr.
o_posnr = ( i_posnr - 500000 ) * 10.You can write the below given statement inside you loop.
o_posnr = ( i_posnr - 500000 ) * 10.Regards,
RS
‎2007 Apr 13 4:06 AM
‎2007 Apr 13 4:13 AM
hi,
let say i already have the number until 000040. i need to continue and start from 000050 for 500001.
i need to loop to check until which number it stops and continue with this 500001 as 000050.
how should i do so?
thanks
points already awarded
‎2007 Apr 13 4:24 AM
Hi,
In that case your code would be like this.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
DATA: i_posnr LIKE vbap-posnr VALUE '500001',
o_posnr LIKE vbap-posnr.
DATA: l_posnr LIKE vbap-posnr VALUE '000040'.
o_posnr = ( i_posnr - 500000 ) * 10.
o_posnr = o_posnr + l_posnr.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*So, if you are looping the internal table, then write these statments in loop. Here l_posnr holds the starting line item number, let's say 000040
o_posnr = ( i_posnr - 500000 ) * 10.
o_posnr = o_posnr + l_posnr.Let me know if you have any question.
Regards,
RS
‎2007 Apr 13 4:32 AM
hi,
how do i know it stops at 000040 before i convert the 5series to continue as 000050.
thanks
‎2007 Apr 13 4:41 AM
Hi,
you do not need to know anything.
See,
o_posnr = ( i_posnr - 500000 ) * 10.always gives '000010' saying your internal table always start from 500001. That means o_posnr always has value '000010' to begin with.
Now, let say you have already reached to '000040' before converting 5 series nos. Let's say whatever current line item number you have is store in variable l_posnr.
So, now o_posnr = '000010' and l_posnr = '000040'.
When you do <b>o_posnr = o_posnr + l_posnr.</b>, it will give you '000050'. Which you want/
Now, say you already have l_posnr = '000100'. In that case you should start with '000110'. Now based on my formula above, o_posnr begin with '000010'
So, o_posnr = o_posnr + l_posnr means ( 000010 + 000100 ) = 000110.
Let me know if you still have any question.
Regards,
RS
‎2007 Apr 13 4:51 AM
hi,
points given again. i will test it out.
i will close the thread when ok.
thanks
‎2007 Apr 13 4:30 AM
Hi,
This works for u. Check out this sample code :
DATA : i TYPE i,
j TYPE i.
DATA : BEGIN OF itab OCCURS 0,
text TYPE string,
END OF itab.
i = 1.
DO 100 TIMES.
itab-text = 500000 + i.
APPEND itab.
i = i + 1.
ENDDO.
CLEAR i.
LOOP AT itab.
i = 0.
i = i + 1.
WHILE itab-text+i(1) EQ '0'.
i = i + 1.
ENDWHILE.
j = itab-text+i.
j = j * 10.
WRITE 😕 j, itab-text+i.
ENDLOOP.
-Please reward if it's helpful.