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 existing records of a custom table ??

Former Member
0 Kudos

Hi guys,

i have to modify existing records of a custom table having 5 fields from an internal table having 2 fields....

how to do this...???

thanks in advance....

10 REPLIES 10

faisal_altaf2
Active Contributor
0 Kudos

Hi, Mayyank

You must have to use the SAME Structure of Internal table as your DB Table.

So you can use the following way to declare you Internal Table

DATA: it_ztable LIKE STANDARD TABLE OF ztable_name WITH HEADER LINE.

Please Reply in case of any Misunderstanding

Faisal

0 Kudos

Hi Faizal,

thanks for the reply.....but the problem is that if i use the same structure of the internal table as that of the

DB table all the fields will get modified but i want to change only 2 record in the DB table.

what i wanted to know is that is there any way we can update particular fields of DB table form internal

table instead of all the fields.

thanks

Mayank

0 Kudos

Hi, Mayyank

Suppose you table having Fields from f1 to f10 and you only want to change F3 and F8 than do the following way.

DATA: it LIKE ztable.

SELECT SINGLE * INTO CORRESPONDING FIELDS OF it
  FROM ztable
  WHERE " Your Conditions for That Record here

it-f3 = 500. " Change here only in FIeld3 and in Bellow Line in Field9 all Other are unchanged 
it-f9 = 10.  " Now it will Change only these Two Fields not the all
UPDATE ztable FROM it.

Please Reply in case of any Issue,

Regards,

Faisal

0 Kudos

Thnx buddy.....so i have to make an internal having the same structure as that of the DB...there is no way

like we use into corresponding fields to update data from one internal table to another internal table though

they have different structure.....

0 Kudos

HI,

In ecc 6.0 it is not allowed.. Both should be of same structure.

Regards,

Nagaraj

0 Kudos

because MODIFY <dbtab> doesnt support any thing like transporting. tranporting works only for internal tables.

you have to make a similar structure.

i have given a sample code above. hope that helps.

Edited by: soumya prakash mishra on Aug 24, 2009 6:05 PM

Former Member
0 Kudos
data : gt_itab type standard table of ztable,
      gs_itab type ztable.

select * from ztable into table gt_table.

loop at gt_itab into gs_itab.
  gs_itab-xyz = <changed values>.
  modify gt_itab from gs_Itab.
endloop.

modify ztable from table gt_itab.

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

Inside a LOOP on the internal table, do UPDATE..SET for the custom table.

Former Member
0 Kudos

you can do one thing

you have your itab

now make a n_itab of ztab.

fetch the records from ztab into n_itab for all intries in itab.

modify n_itab from your itab transproting these two fields.

now n_itab have your updated values

now modify ztab from n_itab.

Edited by: mayank jain on Aug 24, 2009 2:37 PM