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

Modify statment is not working.

Former Member
0 Likes
944

Hi Experts,

I have a small query, modify statment is not working properly, Maybe my syntax wrong. Kindly suggest me.


      DESCRIBE TABLE it_marc1 LINES count.
      IF count = 1.
        LOOP AT it_marc INTO wa_marc where sernp ne space.
          READ TABLE it_stpo INTO wa_stpo WITH KEY idnrk = wa_marc-matnr.
          IF sy-subrc = 0.
            wa_stpo-potx2 = c_primary.
            MODIFY table it_stpo FROM wa_stpo TRANSPORTING potx2.
          ENDIF.
        ENDLOOP.
      ENDIF.

Mohana

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
915

Hi Mohana,

Try this.

Specify a "WHERE" clause in the MODIFY statement and it will work.

The MODIFY statement without "WHERE" clause will work only within a LOOP statement. For "READ" statements it works correctly with the "WHERE" clause.

Hope this may be helpful.

Regards,

Sharin.

Hi Mohana,

Try this.

Specify a "WHERE" clause in the MODIFY statement and it will work.

The MODIFY statement without "WHERE" clause will work only within a LOOP statement. For "READ" statements it works correctly with the "WHERE" clause.

Hope this may be helpful.

Regards,

Sharin.

6 REPLIES 6
Read only

Former Member
0 Likes
915

Hello,

Add the index addition and check


DESCRIBE TABLE it_marc1 LINES count.
      IF count = 1.
        LOOP AT it_marc INTO wa_marc where sernp ne space.
          READ TABLE it_stpo INTO wa_stpo WITH KEY idnrk = wa_marc-matnr.
          IF sy-subrc = 0.
            wa_stpo-potx2 = c_primary.
            MODIFY table it_stpo FROM wa_stpo TRANSPORTING potx2 INDEX sy-index.  " here 
          ENDIF.
        ENDLOOP.
      ENDIF.

Vikranth

Read only

Former Member
0 Likes
916

Hi Mohana,

Try this.

Specify a "WHERE" clause in the MODIFY statement and it will work.

The MODIFY statement without "WHERE" clause will work only within a LOOP statement. For "READ" statements it works correctly with the "WHERE" clause.

Hope this may be helpful.

Regards,

Sharin.

Read only

Former Member
0 Likes
915

Hi,

You need to mention which row of the table to modify as shown below using the key word index. i is the row number.


READ TABLE it_stpo INTO wa_stpo WITH KEY idnrk = wa_marc-matnr.
          IF sy-subrc = 0.
i = sy-tabix.
MODIFY table it_stpo Index i FROM wa_stpo TRANSPORTING potx2.

Thanks

Mani

Read only

Former Member
0 Likes
915

Do like following it will work

DATA : l_index TYPE SY-TABIX.

DESCRIBE TABLE it_marc1 LINES count.

IF count = 1.

CLEAR l_index .

LOOP AT it_marc INTO wa_marc where sernp ne space.

l_index = l_index + 1.

CLEAR wa_stpo.

READ TABLE it_stpo INTO wa_stpo WITH KEY idnrk = wa_marc-matnr.

IF sy-subrc = 0.

wa_stpo-potx2 = c_primary.

MODIFYit_stpo INDEX l_index FROM wa_stpo TRANSPORTING potx2.

ENDIF.

ENDLOOP.

ENDIF.

Read only

0 Likes
915

Problem solved,


            MODIFY it_stpo FROM wa_stpo TRANSPORTING potx2 where idnrk = wa_marc-matnr.

Thanks for you all inputs.

Read only

Former Member
0 Likes
915

Hi mohana......

you just change your modify


MODIFY table it_stpo FROM wa_stpo TRANSPORTING potx2.

with this


MODIFY it_stpo FROM wa_stpo TRANSPORTING potx2.

delete table....only MODIFY

Regards

Marco