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

Regarding logic in manipulation of internal table

Former Member
0 Likes
626

Hi All,

I have one internal table as below:

<b>I_TAB</b>.

<b>VBELN LIKE VBAP-VBELN,

POSNR LIKE VBAP-POSNR,

QTY LIKE VBAP-KWMENG,

SUM LIKE VBAP-KWMENG,

</b>

Now i have filled in this internal table from select statement

Data is:

100, 10, 100

100, 10, 200

100, 10, 300

100, 20, 50

100, 30, 100

100, 30, 200

etc.

Now what i want is i want t calculate SUM field in above internal table based on VBELN & POSNR

Finally data should come as

100, 10, QTY, 600

100, 20, QTY, 50

100, 30, QTY, 300

(or)

we can update QTY with SUM of all VBELN/POSNR.

Can anybody tell me what is the logiic!

Thanks,

Deep.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
591

Hi,

Declare on more table as ITAB, say JTAB.

Loop at ITAB.

JTAB-VBELN = ITAB-VBELN.

JTAB-POSNR = ITAB-POSNR.

JTAB-SUM = ITAB-QTY.

COLLECT JTAB

endloop.

JTAB will have ur required output, But u cant put QTY in between since, the Qunattity is Integer field u cant place 'QTY', since it is a char.

Sreedhar

Message was edited by:

Sreedhar Kanchanapalli

Hi All,

I have one internal table as below:

<b>I_TAB</b>.

<b>VBELN LIKE VBAP-VBELN,

POSNR LIKE VBAP-POSNR,

QTY LIKE VBAP-KWMENG,

SUM LIKE VBAP-KWMENG,

</b>

Now i have filled in this internal table from select statement

Data is:

100, 10, 100

100, 10, 200

100, 10, 300

100, 20, 50

100, 30, 100

100, 30, 200

etc.

Now what i want is i want t calculate SUM field in above internal table based on VBELN & POSNR

Finally data should come as

100, 10, QTY, 600

100, 20, QTY, 50

100, 30, QTY, 300

(or)

we can update QTY with SUM of all VBELN/POSNR.

Can anybody tell me what is the logiic!

Thanks,

Deep.

4 REPLIES 4
Read only

Former Member
0 Likes
592

Hi,

Declare on more table as ITAB, say JTAB.

Loop at ITAB.

JTAB-VBELN = ITAB-VBELN.

JTAB-POSNR = ITAB-POSNR.

JTAB-SUM = ITAB-QTY.

COLLECT JTAB

endloop.

JTAB will have ur required output, But u cant put QTY in between since, the Qunattity is Integer field u cant place 'QTY', since it is a char.

Sreedhar

Message was edited by:

Sreedhar Kanchanapalli

Read only

Former Member
0 Likes
591

hi

loop at itab.

at end of posnr.

sum.

write: / itab-vbeln, itab-posnr, itab-qty.

endat.

endloop.

i dint understand why u would want to print QTY agn as the sum is what you need.

santhosh

mark if helps

Message was edited by:

Kaluvala Santhosh

Read only

Former Member
0 Likes
591
loop at i_tab.

  at end of posnr.
    sum.
   i_tab-sum = i_tab-qty.
   modify i_tab index sy-tabix.
  endat.

endloop.
Read only

Former Member
0 Likes
591

Hi,

loop at i_tab

at end of posnr.

sum.

i_final-vbeln = i_tab-vbeln.

i_final-posnr = i_tab-posnr.

i_final-qty = 'QTY'

i_final- sum = i_tab-qty.

append i_final.

clear i_final.

endat.

Regards,

Satya

endloop.