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

help with modify

Former Member
0 Likes
865

hallow

i do loop and when subrc = 0. i fill x_wa and i working the problem here that the modify dont do any thihng what can be the problem?


  DATA: l_sdprojectinvoice TYPE TABLE OF zsdprojectinvoices,
        wa_sd LIKE LINE OF l_sdprojectinvoice,
        x_wa LIKE LINE OF sdprojectinvoice.

 LOOP AT l_sdprojectinvoice INTO wa_sd.

    READ  TABLE sdprojectinvoice into x_wa WITH KEY vbeln = wa_sd-vbeln.

    IF sy-subrc = 0.

      MOVE:wa_sd-vbtyp TO x_wa-vbtyp,
           wa_sd-fkdat TO x_wa-fkdat,
           wa_sd-netwr TO x_wa-netwr,
           wa_sd-waerk TO x_wa-waerk.

      MODIFY TABLE sdprojectinvoice from x_wa  TRANSPORTING vbtyp fkdat netwr waerk.

      CLEAR:wa_sd,x_wa.

    ENDIF.

  ENDLOOP.

reagards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
849

DATA: l_sdprojectinvoice TYPE TABLE OF zsdprojectinvoices,

wa_sd LIKE LINE OF l_sdprojectinvoice,

x_wa LIKE LINE OF sdprojectinvoice.

LOOP AT l_sdprojectinvoice INTO wa_sd.

READ TABLE sdprojectinvoice into x_wa WITH KEY vbeln = wa_sd-vbeln.

IF sy-subrc = 0.

MOVE:wa_sd-vbtyp TO x_wa-vbtyp,

wa_sd-fkdat TO x_wa-fkdat,

wa_sd-netwr TO x_wa-netwr,

wa_sd-waerk TO x_wa-waerk.

MODIFY sdprojectinvoice from x_wa INDEX sy-tabix.

CLEAR:wa_sd,x_wa.

ENDIF.

ENDLOOP.

It should work now....

Message was edited by:

Perez C

7 REPLIES 7
Read only

Former Member
0 Likes
850

DATA: l_sdprojectinvoice TYPE TABLE OF zsdprojectinvoices,

wa_sd LIKE LINE OF l_sdprojectinvoice,

x_wa LIKE LINE OF sdprojectinvoice.

LOOP AT l_sdprojectinvoice INTO wa_sd.

READ TABLE sdprojectinvoice into x_wa WITH KEY vbeln = wa_sd-vbeln.

IF sy-subrc = 0.

MOVE:wa_sd-vbtyp TO x_wa-vbtyp,

wa_sd-fkdat TO x_wa-fkdat,

wa_sd-netwr TO x_wa-netwr,

wa_sd-waerk TO x_wa-waerk.

MODIFY sdprojectinvoice from x_wa INDEX sy-tabix.

CLEAR:wa_sd,x_wa.

ENDIF.

ENDLOOP.

It should work now....

Message was edited by:

Perez C

Read only

0 Likes
849

HI PEREZ

thanks it solved with sy-index, but way? all the time that i use modify i dont use sy-index and its work o.k. way now it dont work ?

Regards

Read only

0 Likes
849

because...



LOOP AT l_sdprojectinvoice INTO wa_sd.
"here sy-tabix will set to index of l_sdprojectinvoice. 
READ TABLE sdprojectinvoice into x_wa WITH KEY vbeln = wa_sd-vbeln.
"If read stmt is successful then sy-tabix will set to table sdprojectinvoice.
"So you can  MODIFY sdprojectinvoice using particular table  index

Read only

Former Member
0 Likes
849

Hi,

vbtyp fkdat netwr waerk

Are they in the same order as you declared in internal table

Reward if it helps,

Satish

Read only

Former Member
0 Likes
849

Hi,

Just remove key word 'table' from modify statement.

Please reward points if useful.

Thanks,

Sudha

Read only

Former Member
0 Likes
849

Try

MODIFY sdprojectinvoice index sy-tabix from x_wa TRANSPORTING vbtyp fkdat netwr waerk.

Regards,

Michael

Read only

Former Member
0 Likes
849

Hello Ricardo,

The modify table sdprojectinvoice statement doesn't work, you have to use modify sdprojectinvoice. But in your case you can't use that either because you don't have a valid cursor for sdprojectinvoice. The loop you are doing is at l_sdprojectinvoice, you access table sdprojectinvoice through a read instead of a loop that's why you can't use modify sdprojectinvoice without index.

If your internal table is larger than a few entries a more performant way to do that would be:

READ TABLE sdprojectinvoice ASSIGNING <fs_wa> WITH KEY vbeln = wa_sd-vbeln.

IF sy-subrc = 0.

MOVE: wa_sd-vbtyp TO <fs_wa>-vbtyp,

wa_sd-fkdat TO <fs_wa>-fkdat,

wa_sd-netwr TO <fs_wa>-netwr,

wa_sd-waerk TO <fs_wa>-waerk.

Since the field-symbol is pointing to the table you don't even need to do a modify.

Regards,

Michael