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

Modifying internal table.

Former Member
0 Likes
874

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
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
838

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
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
839

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

Read only

0 Likes
838

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

Read only

0 Likes
838

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.

Read only

0 Likes
838

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

Read only

0 Likes
838

Thanks Rich,

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

Shejal.

Read only

Manohar2u
Active Contributor
0 Likes
838

What is short dump?

Use

<b>MODIFY TABLE i_input.</b>

Regds

Manohar