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 internal table

Former Member
0 Likes
7,877

i used this code in my program.

MODIFY TABLE int_fdata FROM int_fdata

TRANSPORTING shkzg.

but it is not updating. This row already exists. i want to update the value of SHKZG.

1 ACCEPTED SOLUTION
Read only

mvoros
Active Contributor
0 Likes
6,601

Hi,

You should not use tables with header lines. It is obsolete. Can you paste the definition of the table? The key value in working area have to match with at least one record in table. Are you sure that it is true? Here is the example from ABAP documentation:


PARAMETERS p_carrid TYPE scarr-carrid. 

DATA scarr_tab TYPE SORTED TABLE OF scarr 
               WITH UNIQUE KEY carrid. 

DATA: idx      TYPE sy-tabix, 
      scarr_wa TYPE scarr. 

SELECT * 
       FROM scarr 
       INTO TABLE scarr_tab. 

READ TABLE scarr_tab 
     WITH TABLE KEY carrid   = p_carrid 
     TRANSPORTING NO FIELDS. 

idx = sy-tabix. 

scarr_wa-currcode = 'EUR'. 

MODIFY scarr_tab INDEX idx FROM scarr_wa 
       TRANSPORTING currcode. 

7 REPLIES 7
Read only

Former Member
0 Likes
6,601

hi Christy,

In that case pass all the primary key fields in the internal table for the record which you want to update ...You can avoid using transporting statement ...

Regards,

Santosh

Read only

Former Member
0 Likes
6,601

check the following :

1) is this modify within the loop?

2) if the internal table is with header line, do you still explicitely require modify table itab FROM itab clause or simple

Modify table itab transporting... will do?

Do let me know if this helped.

Thanks,

Pranjal.

Read only

Former Member
0 Likes
6,601

Hi,

Try using :


MODIFY int_fdata.
clear int_fdata.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
6,601

Hi

You have two options

1) Add a where condition

MODIFY TABLE int_fdata FROM int_fdata

TRANSPORTING shkzg Where XYZ = 'ABC'.

Where XYZ is a key in the internal table and 'ABC is the value where you want to change SHKZG

2) Add Index

MODIFY TABLE int_fdata FROM int_fdata

TRANSPORTING shkzg Index Sy-Tabix/Sy-Index/Index.

Hope this helps.

santhosh

Read only

0 Likes
6,601

thanks to all......

i did in this way.

MODIFY int_fdata index idx FROM int_fdata

TRANSPORTING shkzg.

Read only

Former Member
0 Likes
6,601

Hi!

I personally like to use the modify using indexes, it makes the update always correct.

DATA: lv_tabix LIKE sy-tabix.

LOOP AT itab INTO wa.

MOVE sy-tabix TO lv_tabix.

...

MOVE 'S' TO wa-shkzg.

MODIFY itab FROM wa INDEX lv_tabix.

ENDLOOP.

Regards

Tamá

Read only

mvoros
Active Contributor
0 Likes
6,602

Hi,

You should not use tables with header lines. It is obsolete. Can you paste the definition of the table? The key value in working area have to match with at least one record in table. Are you sure that it is true? Here is the example from ABAP documentation:


PARAMETERS p_carrid TYPE scarr-carrid. 

DATA scarr_tab TYPE SORTED TABLE OF scarr 
               WITH UNIQUE KEY carrid. 

DATA: idx      TYPE sy-tabix, 
      scarr_wa TYPE scarr. 

SELECT * 
       FROM scarr 
       INTO TABLE scarr_tab. 

READ TABLE scarr_tab 
     WITH TABLE KEY carrid   = p_carrid 
     TRANSPORTING NO FIELDS. 

idx = sy-tabix. 

scarr_wa-currcode = 'EUR'. 

MODIFY scarr_tab INDEX idx FROM scarr_wa 
       TRANSPORTING currcode.