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: 

Modify ztable from internal table

Former Member
0 Kudos

Hi,

I have a Ztable in which i have 4 diff fields....1 2 3 4

and an internal table in whch i have same number of fields...

Internal table :

1 2 3 4

a w x 9

a w x 10

a w x 11

a w x 13

a w x 12

When I am using Modify it only appends last record into ztable as below:

Ztable : 1 2 3 4

a w x 12

Internal table has 6 records and z table should be appended with 6 records too...

if varid-report = 'ZFINRR1001' and

  • varid-VARIANT = 'CITI - ZBA' or

varid-VARIANT = 'WACHOVIA - ZBA'.

Modify ZV12_SWEEP from t_data_new.

endif.

Any suggestions will be aprreciated!

Regards,

Kittu

1 ACCEPTED SOLUTION

former_member226203
Active Contributor
0 Kudos

jus check if ur passing the values to the same set of primary keys.

if a w x are primary keys and it has a value already, then it would not append any value instead it will modify or overwrite the existing record with the value from the internal table. jus check this.if not, make the 4th field as primary key and the records will get appended.

11 REPLIES 11

Former Member
0 Kudos

Hi,

u need to use code for modify as below

Modify ZV12_SWEEP from table t_data_new.

Former Member
0 Kudos

Hi..

Check if 1, 2 3 and 4 are all primary keys for the Z table..

former_member226203
Active Contributor
0 Kudos

jus check if ur passing the values to the same set of primary keys.

if a w x are primary keys and it has a value already, then it would not append any value instead it will modify or overwrite the existing record with the value from the internal table. jus check this.if not, make the 4th field as primary key and the records will get appended.

0 Kudos

Hi,

Thank you for your quick response!

Thats correct ....1 2 3 are primary key fields...

I cannot change the 4 th fields a primary key field...as it is a table maintenance table and 4 th field will be currency field...

Any other way I can append the records into ztable ...?

Any suggestions will be apprecaiated!

Regards,

Kittu

Edited by: Kittu on May 11, 2009 1:42 PM

0 Kudos

try to make this 4th field as a primary key or another way is to add an additional filed and make it as primary key such that the values will be appended to the table instead of overwriting.If a w x are primary keys, this new additional field which is also a primary key will hve some different value and the values will get appended.

Former Member
0 Kudos

Hello,

Use the statement "APPEND LINES OF itab1 [FROM idx1] [TO idx2] TO itab2. "

Here you can specify the index from which index you have to pick the entries from itab1 and then append to itab2.

If no index is specified, it will append all the lines of itab1 to itab2.

Thanks,

Sowmya

Mohamed_Mukhtar
Active Contributor

hi,

Delete all records of ur ZTABLE matching the primary keys like below

DELETE  FROM ZV12_SWEEP  WHERE filed = <wa-field>.
 IF sy-subrc = 0.
    INSERT ZV12_SWEEP FROM TABLE  t_data_new ACCEPTING DUPLICATE KEYS.
        IF sy-subrc EQ 0.
       MESSAGE 'Modified' TYPE 'S'..
  ELSE.
    MESSAGE 'not updated' TYPE 'E'.
  ENDIF.
  ENDIF.

Thanks & REgards

0 Kudos

Thank you so much, your code worked fine !!

Former Member
0 Kudos

>

> When I am using Modify it only appends last record into ztable

>

> Modify ZV12_SWEEP from t_data_new.

Hi,

You only get last record appended because your MODIFY statement uses t_data_new as a working area and not as a table.

To append the content of your internal table, use the FROM TABLE option as below :

MODIFY zv12_sweep FROM TABLE t_data_new.

Regards.

Nicolas

Former Member
0 Kudos

Put the code in the loop.

Ex:

loop at itab into wa.

modify ztab from wa.

endloop.

Regards,

Ajay

Former Member
0 Kudos

Hello,

Thank you for your quick response!

My issue is fixed!

I apprecaite the help/suggestions!

Regards,

Kittu