10-17-2008 5:36 AM
Hi Experts,
I need to copy standard table contents to custom table in the same server.
please provide logic for this.
Thanks in advance.
Nani
10-17-2008 5:52 AM
Hi Nani
Try this for your tables. ZT001 is the custom table which is a copy of the standard table T001. Both structures has to be same in this case
DATA : IT_T001 TYPE TABLE OF T001,
WA_T001 TYPE T001.
SELECT * FROM
T001
INTO TABLE IT_T001.
INSERT ZT001 FROM TABLE IT_T001.
Regards
Edited by: Rajvansh Ravi on Oct 17, 2008 6:52 AM
10-17-2008 5:50 AM
Hi Nani,
Try following Query.
Select * from mara into table it_mara.
I hope this will work.
Regards,
Pratik Vora
10-17-2008 5:52 AM
Hi Nani
Try this for your tables. ZT001 is the custom table which is a copy of the standard table T001. Both structures has to be same in this case
DATA : IT_T001 TYPE TABLE OF T001,
WA_T001 TYPE T001.
SELECT * FROM
T001
INTO TABLE IT_T001.
INSERT ZT001 FROM TABLE IT_T001.
Regards
Edited by: Rajvansh Ravi on Oct 17, 2008 6:52 AM
10-17-2008 5:53 AM
Declare an internal table with similar structure of the custom data base table.
Populate the internal table from the standard data base table ( Using select quiry ).
Using INSERT or MODIFY command populate the custom data base table.
Cheers,
Murthy
Edited by: pr murthy on Oct 17, 2008 6:57 AM
10-17-2008 5:54 AM
Hi,
You can write a simple report program and can use MODIFY statemnt to update your z database table.
pusedo code :
declare a internal table and get all the data in standard table to internal table.
Loop the internal table and use the modify/insert statemnts to upload the custom table.
If the data is pretty large the above logic will not work as it will lead to dump.
So in the standard table display the contents and in the EDIT menu you have DOWNLOAD ( shift + F8 )
you can download to text file.
and you create tcode for your database table and
through BDC you can upload the data
regards
prasanth
10-17-2008 5:56 AM
10-17-2008 6:23 AM
hi,
we can create a structure like the same structure as database table and we can use
select * from database table itno table itab
or
insert into itab values database table
regards,
Praveena.
10-17-2008 6:38 AM
Please correct the below code to copy standard table contents of Mara to custom table zmara.
DATA: Begin of IT_MARA OCCURS 0.
include structure mara.
data: end of it_mara.
DATA : WA_MARA TYPE MARA.
SELECT * FROM
MARA INTO TABLE IT_MARA.
LOOP AT IT_MARA.
INSERT ZMARA FROM TABLE IT_MARA.
ENDLOOP.
10-17-2008 6:41 AM
Hi nani
Try this
No need to put LOOP . See my previous post
DATA: Begin of IT_MARA OCCURS 0.
include structure mara.
data: end of it_mara.
DATA : WA_MARA TYPE MARA.
SELECT * FROM
MARA INTO TABLE IT_MARA.
INSERT ZMARA FROM TABLE IT_MARA.
Regards
Edited by: Rajvansh Ravi on Oct 17, 2008 7:41 AM
10-17-2008 6:45 AM
Hi Ravi,
still there is a problem ..the following error is displayed
The type of the database table and work area (or internal table) "IT_MARA" are not Unicode convertible.
Nani
10-17-2008 6:50 AM
Hi Nani
Try This code
DATA : IT_ZMARA TYPE TABLE OF ZMARA.
SELECT * FROM
MARA INTO CORRESPONDING FIELDS OF TABLE IT_ZMARA.
INSERT ZMARA FROM TABLE IT_ZMARA.
Let me know if you get any syntax error as i dont have the structure of ZMARA..
Regards
Edited by: Rajvansh Ravi on Oct 17, 2008 7:51 AM
10-17-2008 7:25 AM
Hi Ravi,
the program is going into dump and following error is displayed..
The ABAP/4 Open SQL array insert results in duplicate database records.
Nani
10-17-2008 7:29 AM
Hi Nai,
Delete all entries in your ZMARA table and try again. Dump is because of duplicate entries as the message suggests
Use something like
DELETE FROM ZMARA.
and try my code again.
Also let me know if you have modified any field names in your new table ZMARA. The CORRESPONDING addition only works for similar fieldnames.
Regards
Edited by: Rajvansh Ravi on Oct 17, 2008 8:30 AM
10-17-2008 7:34 AM
Hi Nani
are u checked the primary key field in your ztable and standard table
may that is the mistake there
10-17-2008 7:35 AM
Hi Ravi,
Thanks for ur reply's.
The code is working for other Standard tables.
I have changed the fields name is custom table.
Hope it will work fine once i rename to standard one..
Regards,
Nani
10-17-2008 7:33 AM
Hi ,
1st you have to select the data from the DB table & then you have to insert in in your Ztable .
or if you know the ALE then you can transfer it Directly inbound and by outbound.
Regards,
Tarak.