‎2008 Mar 12 9:43 AM
Hi gurus,
I created one Ztable with the same structure of internal table.Please can any one tell me How can i insert the data in the internal table into that ZTable.
Thanks in Advance.
Thanks and Regards
Siri...
‎2008 Mar 12 9:48 AM
do this way...
data : itab like ztable occurs 0 with header line,
w_itab like ztable.
loop at itab.
w_itab = itab.
insert into ztable values w_itab.
endloop. else
loop at itab.
modify ztable from table itab.
endloop. Edited by: Santosh Kumar Patha on Mar 12, 2008 3:19 PM
‎2008 Mar 12 9:50 AM
Hi,
First Loop at internal Table into work area
Then Insert into data base table By
INSERT INTO <DAtabse Table> VALUES <workarea> .
Regards
Sandipan
‎2008 Mar 12 9:50 AM
hi ,
In this example, a new airline is added to the database table SCARR.
DATA scarr_wa TYPE scarr.
scarr_wa-carrid = 'FF'.
scarr_wa-carrname = 'Funny Flyers'.
scarr_wa-currcode = 'EUR'.
scarr_wa-url = 'http://www.funnyfly.com'.
INSERT INTO scarr VALUES scarr_wa.
regards,
venkat.
‎2008 Mar 12 9:51 AM
Hi
yes you can do like this
MODIFY ztable FROM TABLE internaltable
BEFORE MODIFYING THE DATBASE TABLE YOU NEED TO LOCK THAT TABLE
AND MODIFY IT
AND UNLOCK IT AGAIN
example here
modifying datbase table useing internal table
advises before updating this datbase table plz lock that table to avoid incosistency
write the logic for modifying
Modify the database table as per new dunning procedure
MODIFY fkkvkp FROM TABLE lt_fkkvkp .
and finally unlock the table
example
*To lock table for further operations
constants: lc_tabname TYPE rstable-tabname VALUE 'FKKVKP' . "FKKVKP
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
tabname = lc_tabname
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc EQ 0.
To fetch all the contract accounts for customers of the segment
Households/SME.
PERFORM fetch_contract_accounts using lc_tabname .
ENDIF. " IF sy-subrc EQ 0.
*wrote the logic
Modify the database table as per new dunning procedure from internal table
MODIFY fkkvkp FROM TABLE lt_fkkvkp .
*unlock the tbale
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
TABNAME = uc_tabname .
‎2008 Mar 12 9:55 AM
Hi,
You can use insert and modify commands.But modify is best.because modify take care of adding and editing records.
modify will not give any shortdomp
Syntex:
1. modify ztable from <workarea>
2. modify ztable from table <itab>
L.Velu
‎2008 Mar 12 10:09 AM
Hi,
You can do as below:
loop at itab into wa.
INSERT ztable FROM wa.
endloop.
loop at itab into wa.
MODIFY ztable FROM wa.
endloop.
Thanks,
Sriram Ponna.
‎2008 Mar 12 10:12 AM
Hi,
simply do like this.
modify ztable from table itab.
rgds,
bharat.
‎2008 Mar 12 12:26 PM
Hi,
When you insert a value into a table you should check whether the value is already in the table or not. So use the following code for inerting the values.
Examle, i am going to insert 5 more part munbers in my z-table named zmara. The structure of the internal which is same as the z-table as
MATNR - Part Number,
MAKTX - Part Description.
LOOP AT ITAB INTO WA.
CLEAR ZMARA.
SELECT SINGLE * FROM ZMARA WHERE MATNR = ITAB-MATNR.
IF SY-SUBRC EQ 0.
INSERT ZMARA VALUES ITAB.
ELSE.
UPDATE ZMARA FROM ITAB.
ENDIF.
CLEAR ITAB.
ENDLOOP.
Reward points if it is useful.
Regards,
P.sankar.