08-22-2009 1:34 PM
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....
08-22-2009 2:20 PM
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
08-24-2009 5:26 AM
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
08-24-2009 5:49 AM
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
08-24-2009 1:06 PM
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.....
08-24-2009 1:09 PM
HI,
In ecc 6.0 it is not allowed.. Both should be of same structure.
Regards,
Nagaraj
08-24-2009 1:10 PM
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
08-22-2009 2:27 PM
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.
08-23-2009 11:13 AM
08-24-2009 2:37 AM
Inside a LOOP on the internal table, do UPDATE..SET for the custom table.
08-24-2009 1:25 PM
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