Application Development 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: 

Modifying internal table.

Former Member
0 Kudos

HI Friends,

I have an internal table with some line and each line has a material number, quantity etc.....

I need to add quantites based on a condition and add the result to the first line which does not satisfy the condition and delete all the lines which satisfy the condition from the internal table.

My code is as follows however its giving me a short dump.

DATA : wa1_input line lone of i_input.

loop at i_input.

if xvbap-pstyv = 'TAL'

wa1_input-qty = wa1_input-qty + i_input-qty.

endif.

endloop.

read table i_input where xvbap-pstyv <> 'TAL'.

i_input-qty = i_input-qty + wa1_input-qty.

modify i_input.

Any help on this will be helpful.

Shejal.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Interesting requirement. Maybe this will work. I assume that PSTYV is in the internal tabe I_INPUT?




DATA : wa1_input like line of i_input. 

clear wa1_input.
loop at i_input where pstyv = 'TAL'.
  wa1_input-qty = wa1_input-qty + i_input-qty.
  delete i_input.
endloop.

read table i_input with key pstyv <> 'TAL'.
if sy-subrc = 0.
  i_input-qty = i_input-qty + wa1_input-qty.
  modify i_input index sy-tabix.
endif.



Regards,

Rich Heilman

6 REPLIES 6

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Interesting requirement. Maybe this will work. I assume that PSTYV is in the internal tabe I_INPUT?




DATA : wa1_input like line of i_input. 

clear wa1_input.
loop at i_input where pstyv = 'TAL'.
  wa1_input-qty = wa1_input-qty + i_input-qty.
  delete i_input.
endloop.

read table i_input with key pstyv <> 'TAL'.
if sy-subrc = 0.
  i_input-qty = i_input-qty + wa1_input-qty.
  modify i_input index sy-tabix.
endif.



Regards,

Rich Heilman

0 Kudos

This won't work.

read table i_input with key pstyv <> 'TAL'.
if sy-subrc = 0.
  i_input-qty = i_input-qty + wa1_input-qty.
  modify i_input index sy-tabix.
endif.

Try this instead.



loop at i_input where pstyv <> 'TAL'.
  i_input-qty = i_input-qty + wa1_input-qty.
  modify i_input.
  exit.   " We only want to do this read once
Endloop.


Regards,

Rich Heilman

0 Kudos

Thanks Rich,

No pstyv is not in the internal table of i_input.

Its in the XVBAP table od user exit MV45AFZZ for SO.

I have looped xvbap and have appended to i_input but the i_input table does not have PSTYV field.

once i get all the rows in my internal table from XVBAP i need to do this calculation ie, regarding quantities.

Shejal.

0 Kudos

Then you code does not make much sense. Why are you checking it while looping at I_INPUT?



loop at i_input.
if <b>xvbap-pstyv</b> = 'TAL'
wa1_input-qty = wa1_input-qty + i_input-qty.
endif.
endloop.


Regards,

Rich Heilman

0 Kudos

Thanks Rich,

I will try to change the code and will let you know if i need any help.

Shejal.

Manohar2u
Active Contributor
0 Kudos

What is short dump?

Use

<b>MODIFY TABLE i_input.</b>

Regds

Manohar