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: 

copy standard table contents to custom table

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

15 REPLIES 15

Former Member
0 Kudos

Hi Nani,

Try following Query.

Select * from mara into table it_mara.

I hope this will work.

Regards,

Pratik Vora

Former Member
0 Kudos

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

Former Member
0 Kudos

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

prasanth_kasturi
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

Hi Nani

are u checked the primary key field in your ztable and standard table

may that is the mistake there

0 Kudos

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

Former Member
0 Kudos

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.