Former Member

# modify statement problem

hi all,

my modify statement is not working proerply. can any one help me in this regard...

IF NOT i_vetvg IS INITIAL.

SELECT mblnr mjahr bwart FROM mseg

INTO TABLE i_gr

FOR ALL ENTRIES IN i_vetvg

WHERE ebeln EQ i_vetvg-vbeln.

LOOP AT i_gr INTO wa_gr.

CASE wa_gr-bwart.

WHEN '643'.

wa_final-gr = wa_gr-mblnr.

MODIFY i_final FROM wa_final index sy-tabix TRANSPORTING gr.

WHEN '101'.

wa_final-in_gr = wa_gr-mblnr.

MODIFY i_final FROM wa_final index sy-tabix TRANSPORTING in_gr.

ENDCASE.

ENDLOOP.

ENDIF.

i_gr exapmle data

1 2009 643

2 2009 101

5 2009 643

6 2009 101

here my second modify statement is not working. first statemet is working perfectly.

##### Add a comment
10|10000 characters needed characters exceeded

### Related questions

Former Member
Posted on Nov 13, 2009 at 07:16 PM

Hi Senthil,

Try this your problem will be solved:

Assign sy-tabix to a local variable and the use it .

Also check the number of records in i_final, is that index persent?

Edited by: Harsh Bhalla on Nov 14, 2009 12:49 AM

##### Add a comment
10|10000 characters needed characters exceeded
• Former Member
Posted on Nov 13, 2009 at 06:19 PM

i cant say for sure, becuase i am not sure what is is you are trying to do, but what is in i_final at the beginning of all of this? you are looping over i_gr and modifying i_final using the tabix from i_gr.. this assumes that i_gr and i_final are identical GOING IN to your loop, or it wont work.

##### Add a comment
10|10000 characters needed characters exceeded
• Posted on Nov 13, 2009 at 06:23 PM

Hello,

What is the structure of i_final? Even i think the problem is because of using the modify statement using sy-tabix which may not yield desireable results. If you have any common field between i_final and i_gr, the results would be more accurate

Vikranth

##### Add a comment
10|10000 characters needed characters exceeded
• Former Member

correct. you need to READ an entry with a key or some other method from i_final before you change the data and MODIFY it.

• Posted on Nov 14, 2009 at 08:20 PM

Hi Senthil Kumar,

please post code as

`code`

where and how do you populate itab i_final? How do you know that sy-tabix of table i_gr always matches i_final.

This does not look like good programming.

Regards,

Clemens

##### Add a comment
10|10000 characters needed characters exceeded