Application Development and Automation 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: 
Read only

Question with adding

Former Member
0 Likes
312

Hi,

I have an internal table with the fields sales order and item number. I also want to add another field to this internal table which can show 'Serial No'.

For ex:

The present internal table:

Order Item

35 10

35 30

37 20

The requirement:

S.No Order Item

1 35 10

2 35 30

3 37 20

Can you tell me the best logic to get this extra field? Is there any standard SAP field that can calculate these serial numbers?

Thanks and best regards,

Krishen

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
289

Hi,

How are you populating the internal table..One by one or bulk..

DATA: BEGIN OF ITAB OCCURS 0,

<b> SERIAL TYPE SYTABIX,</b>

ORDER TYPE VBELN,

ITEM TYPE POSNR,

END OF ITAB.

<b>If one by one..</b>

DATA: V_TABIX TYPE SYTABIX.

LOOP AT ITAB_OLD.

V_TABIX = V_TABIX + 1.

ITAB-SERAIL = V_TABIX.

ITAB-VBELN = ..

APPEND ITAB.

ENDLOOP.

<b>If bulk insert..Then loop at the internal table and then add the serial number..</b>

LOOP AT ITAB.

ITAB-SERIAL = SY-TABIX.

MODIFY ITAB TRANSPORTING SERIAL.

ENDLOOP.

Thanks,

Naren

1 REPLY 1
Read only

Former Member
0 Likes
290

Hi,

How are you populating the internal table..One by one or bulk..

DATA: BEGIN OF ITAB OCCURS 0,

<b> SERIAL TYPE SYTABIX,</b>

ORDER TYPE VBELN,

ITEM TYPE POSNR,

END OF ITAB.

<b>If one by one..</b>

DATA: V_TABIX TYPE SYTABIX.

LOOP AT ITAB_OLD.

V_TABIX = V_TABIX + 1.

ITAB-SERAIL = V_TABIX.

ITAB-VBELN = ..

APPEND ITAB.

ENDLOOP.

<b>If bulk insert..Then loop at the internal table and then add the serial number..</b>

LOOP AT ITAB.

ITAB-SERIAL = SY-TABIX.

MODIFY ITAB TRANSPORTING SERIAL.

ENDLOOP.

Thanks,

Naren