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: 

How to reflect the changes made in the internal table?

Former Member
0 Kudos

Hi,

I changed one field of the internal table.

i used

modify workarea. in the loop.

when i am debugging that row is getting modified but after execution when i am displaying that changes are not reflected. why?

14 REPLIES 14

former_member181962
Active Contributor
0 Kudos

Hi Shefali,

If you are doing what you are saying, then it must work.

Can you show your code?

loop at itab.

itab-field = 'new'.

modify itab index sy-tabix.

endloop.

Regards,

Ravi

Former Member
0 Kudos

use

modify itab from workarea

Former Member
0 Kudos

Hii

When you are doing a 'modify' or 'delete', you need to let the system know which record(its index in the table) you want to 'modify' or 'delete'. In a loop at the internal table, system knows this, but if it is not in a loop, you have to specify the index of the record.

chk this code

Report z_itabtest .

data: v_index like sy-tabix.

clear v_index.

loop at itab.

v_index = sy-tabix.

if<your condition>.

itab-flag = 'X'.

<b>modify itab index v_index.</b>

endif.

endloop.

Regards

Naresh

rahulkavuri
Active Contributor
0 Kudos

hi it should work, just check whether u have worked correctly with SY-TABIX..

  LOOP AT T_VBRK_VBRP.
    V_SYTAB = SY-TABIX.
    AT NEW VBELN.
      READ TABLE T_VBRK_VBRP INDEX V_SYTAB.
      READ TABLE IT_VBRK WITH KEY VBELN = T_VBRK_VBRP-VBELN.
      IF SY-SUBRC = 0.
        T_VBRK_VBRP-FKDAT = IT_VBRK-FKDAT.
        MODIFY T_VBRK_VBRP  TRANSPORTING FKDAT
                  WHERE VBELN = IT_VBRK-VBELN.
      ENDIF.
    ENDAT.
  ENDLOOP.

<b>Check this code too where we assign Sy-Tabix to another variable</b>

  LOOP AT IT_VBRK.

    CTAB = SY-TABIX.

    LOOP AT IT_T001 WHERE BUKRS = IT_VBRK-BUKRS.

      IF SY-SUBRC  = 0.
        IT_VBRK-BUTXT = IT_T001-BUTXT.
        MODIFY IT_VBRK INDEX CTAB.
        CLEAR CTAB.
      ENDIF.

    ENDLOOP.

  ENDLOOP.

<b>Award points if found helpful</b>

Former Member
0 Kudos

HI

Modify <target> FROM <wa> .

The contents of the work area <wa> are written to the database table <dbtab>. The work area <wa> must be a data object with at least the same length and alignment as the line structure of the database table. The data is placed in the database table according to the line structure of the table, and regardless of the structure of the work area. It is a good idea to define the work area with reference to the structure of the database table.

If the database table does not already contain a line with the same primary key as specified in the work area, a new line is inserted. If the database table does already contain a line with the same primary key as specified in the work area, the existing line is overwritten. SY-SUBRC is always set to 0.

To change a line using its index, use the following statement:

MODIFY <itab> FROM <wa> [INDEX <idx>] [TRANSPORTING <f1> <f 2> ... ].

Regards

0 Kudos

Hi,

My code is

loop at xvbkd.

xvbkd-sdabw = l_sdabw.

MODIFY XVBKD.

endloop.

as this code is within lop so i think no need of specifing index. am I right?

0 Kudos

HI Shefali,

Looks like you are coding in an USER EXIT.

So, you may be using an exit which doesn't allow you to modify values or you are using an exit that is not the correct place to do the changes.

Regards,

Ravi

0 Kudos

Yes you are right. what is there in l_sdabw.

is it not having the oldvalue.

Regards

vijay

0 Kudos

Hi,

try to code it in <b>USEREXIT_SAVE_DOCUMENT_PREPARE.</b>

Reagrds

vijay

0 Kudos

Hi,

yes i am working on user exit. and i coded in the userexit_save_document_prepare.

l_sdabw is not a internal table field. it is a local variable.

i simply had some value in it. i have to copy the same value at each item level.

but its not working.

Former Member
0 Kudos

use modify itab from workarea transporting (the field that you are modifying)

0 Kudos

sorry laxmi , i must have submitted at the same time

former_member188685
Active Contributor
0 Kudos

Hi,

i doubt you are looping and also inside the loop you are reading the another itab.

in that case.

data: l_index type sy-tabix.
loop at itab.
l_index = sy-tabix.
read table itab1 with key field = itab-field.
if sy-subrc = 0.
itab-field2 = itab1-field2.
modify itab index l_index.
endif.
clear l_index.
endloop.

regards

vijay

Former Member
0 Kudos

Hello Shefali,

I tried your code in the user exit USEREXIT_SAVE_DOCUMENT_PREPARE

loop at xvbkd.

xvbkd-sdabw = l_sdabw.

MODIFY XVBKD.

endloop.

and it works and updated the table. There is only one change that I made and that is with the field lsdabw. I am not sure if this field is defined locally by u as I am not able to trace this field in the program. secodly the value which u are trying to force in the field is available in table TVSAK as it is a chek table for the field sdabw.