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

Urgent Internal table

former_member184495
Active Contributor
0 Likes
1,051

hi,

my requirement is :

i have 2 internal tables ioutput and iouput1.

iouput has matnr, minbe, labst.

there are 4 records for the same matnr with different labst.

using 'collect' i add those records to ioutput1.

so now ioutput1 has all minbe,labst added.

but i require to add just the labst's and not minbe.

-ioutput-

matnr minbe labst

1 1 1

1 1 2

1 1 3

1 1 4

-ioutput-

matnr minbe labst

1 4 10

now how do i get

-ioutput-

matnr minbe labst

1 1 10

cheers,

Aditya

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,032

Make a READ TABLE output index 1. iF sy-subrc = 0 Set MINBE to 1.

I hope this could bea the easiest way.

8 REPLIES 8
Read only

former_member184495
Active Contributor
0 Likes
1,032

hi,

my requirement is :

i have 2 internal tables ioutput and iouput1.

iouput has matnr, minbe, labst.

there are 4 records for the same matnr with different labst.

using 'collect' i add those records to ioutput1.

so now ioutput1 has all minbe,labst added.

but i require to add just the labst's and not minbe.

-ioutput-

matnr minbe labst

1 1 1

1 1 2

1 1 3

1 1 4

-ioutput1-

matnr minbe labst

1 4 10

now how do i get

-ioutput1-

matnr minbe labst

1 1 10

cheers,

Aditya

Read only

0 Likes
1,032

You could try using "insert" instead of collect.

Example:

insert the first record of ioutput into ioutput1.

Then do a loop through the remainder of ioutput where matnr = ioutput1-matnr and minbe = ioutput1-minbe.

Inside the loop use the statement "ioutput1-labst = ioutput1-labst + ioutput-labst". Hope this helps.

- April King

Read only

0 Likes
1,032

Just Change the format of the field MINBE for the ioutput1 table to Character Format the field will not be taken into consideration while the collect statement is working for you.

Thanks

Anirban M.

Read only

Former Member
0 Likes
1,033

Make a READ TABLE output index 1. iF sy-subrc = 0 Set MINBE to 1.

I hope this could bea the easiest way.

Read only

Former Member
0 Likes
1,032

try this code....

loop at ioutput.

read table ioutput1

with key matnr = ioutput-matnr .

if sy-subrc = 0.

ioutput1-labst = ioutput-labst + ioutput1-labst .

modify ioutput1 index sy-tabix.

else.

append ioutput1.

endif.

endloop.

Read only

Former Member
0 Likes
1,032

HI Aditya

Please see if you can acheive the same while extraction.

Eg:

   select matnr minbe sum( labst )
          into table it_output
          from <table>
          where <cond>.

OR

another manipulating your internal table would be:

data: l_tabix like sy-tabix.

  loop at i_output.
       l_tabix = sy-tabix.
       i_output1-labst = i_output1-labst + i_output-labst.
       at end of matnr.
          read table i_output index l_tabix.
          move: i_output-matnr to i_output1-matnr,
                i_output-minbe to i_output1-minbe.
          append i_output1.
          clear: i_output1.
       endat.
  endloop.

Kind Regards

Eswar

Read only

Former Member
0 Likes
1,032

Hi,

tyr this.

define 2 internal tables itab and itab2 with matnr,minbe and labst fields.

data:sum(10) type c.

*****************************

itab-matnr = 1.

itab-minbe = 1.

itab-labst = 1. SUPPOSE THIS IS YOUR INPUT DATA

append itab.

itab-matnr = 1.

itab-minbe = 1.

itab-labst = 2.

append itab.

itab-matnr = 1.

itab-minbe = 1.

itab-labst = 3.

append itab.

itab-matnr = 1.

itab-minbe = 1.

itab-labst = 4.

append itab.

****************************

sort itab by matnr.

loop at itab.

at new matnr.

sum = 0.

endat.

sum = sum + itab-labst.

itab2-matnr = itab-matnr.

itab2-minbe = itab-minbe.

itab2-labst = itab-labst.

append itab2.

at end of matnr.

write:/ itab2-matnr,itab2-minbe,sum.

endat.

endloop.

do reward points if it helps you,

Regards,

Sowjanya.

Read only

former_member184495
Active Contributor
0 Likes
1,032

answered