2007 Jul 16 4:50 AM
Hello guys!
I am trying to duplicate a table but the Copy function in SE11 only provides duplication of the fields and not the records. The new table is therefore empty.
How do I quickly duplicate the records?
Thank you!
2007 Jul 16 4:56 AM
Hi Ricardo,
This is for client to client but u can use it for the same client also pls try this..
Use the following procedure to copy table contents between two clients:
After verifying the client copy log, due to some storage probslems in table MOFF, this table could not be completely copied. To avoid having to perform the whole client copy process, just hte entries on table MOFF from the source client will be copied to the table MOFF on the target client 010 in thte target system T12.
1. In the source system (C12), create a control file, for example, expmoff.ctrl with the following contents:
export client
select * from moff where mandt = '002".
2. Run the R3trans utility with the previous control file:
R3trans -w expmoff.log -u 18 expmoff.ctrl
The -w flag indicates the log file, the -u flag sets unconditional modes for the transport. In the export phonase, unconditional mode 1 indicates the system to ignore the wrong status of transport requests.
Mode 8 allows direct selection of tables when the default modes are not allowed. By default, the previous command generates the data file trans.dat in the directory where the export has been executed. If both source and target systems share the transport directory, it wont be necessary to copy the trans.dat file. Otherwise you must use ftp.
3. Check the export log file, expmoff.log and verify it did not contain any errors.
4. Once in the target system, create the import control file, for example impmoff.ctrl with the following content: import client
5. Then execute it with the R3trans tool: R3trans -w impmoff.log -u 248 impmoff.ctrl
By default it uses the data file trans.dat generated by the previous commnad file. The unconditional modes used in the import phase are :
2 for enabling the overwriting of the original, 4 which ignores that the transport request was intended for a different target system, and
8 which allows for importing tables which are restricted by their table types. If you use the default options for the import, you do not need a control file.
The import can be performed directly with R3trans -i <file>.
6. Check the import log file, impmoff.log to check that the import runs fine without errors. You can also log on to the target client, 010, in the target system and look up the table contents with se16.
Reward pts if found usefull
Regards
Sathish
2007 Jul 16 4:56 AM
Hi Ricardo,
This is for client to client but u can use it for the same client also pls try this..
Use the following procedure to copy table contents between two clients:
After verifying the client copy log, due to some storage probslems in table MOFF, this table could not be completely copied. To avoid having to perform the whole client copy process, just hte entries on table MOFF from the source client will be copied to the table MOFF on the target client 010 in thte target system T12.
1. In the source system (C12), create a control file, for example, expmoff.ctrl with the following contents:
export client
select * from moff where mandt = '002".
2. Run the R3trans utility with the previous control file:
R3trans -w expmoff.log -u 18 expmoff.ctrl
The -w flag indicates the log file, the -u flag sets unconditional modes for the transport. In the export phonase, unconditional mode 1 indicates the system to ignore the wrong status of transport requests.
Mode 8 allows direct selection of tables when the default modes are not allowed. By default, the previous command generates the data file trans.dat in the directory where the export has been executed. If both source and target systems share the transport directory, it wont be necessary to copy the trans.dat file. Otherwise you must use ftp.
3. Check the export log file, expmoff.log and verify it did not contain any errors.
4. Once in the target system, create the import control file, for example impmoff.ctrl with the following content: import client
5. Then execute it with the R3trans tool: R3trans -w impmoff.log -u 248 impmoff.ctrl
By default it uses the data file trans.dat generated by the previous commnad file. The unconditional modes used in the import phase are :
2 for enabling the overwriting of the original, 4 which ignores that the transport request was intended for a different target system, and
8 which allows for importing tables which are restricted by their table types. If you use the default options for the import, you do not need a control file.
The import can be performed directly with R3trans -i <file>.
6. Check the import log file, impmoff.log to check that the import runs fine without errors. You can also log on to the target client, 010, in the target system and look up the table contents with se16.
Reward pts if found usefull
Regards
Sathish
2007 Jul 16 5:02 AM
Hi,
You can try this if it is in development system.
Data : itab type standard table of db1.
select * from itab into table itab.
insert db2 from table itab.
2007 Jul 16 5:20 AM
Here is the program for that ....
Use this tip to make a dynamic table copy from a production system to a test system.
The solution consists of two programs -- a function-module named z_bcsag_tablecopy_remote and a report named zbcsag_tablecopy. In the report you can specify the name of the table to be copied and the destination, which is used to get the connection to the productive system.
In order to get it to work on your system, you first have to create the two programs in your test system. Then you have to create two objects -- zchar45 and zchar1000 -- with SE11. Click DATA-TYPE, then button create, and chose TABLE-TYPE / Built-in TYPE / DATA-TYPE CHAR / No. of Characters 45 and 1000.
Then transport the function-module into your productive system. After this you must create a destination to your production system. That's all!
FUNCTION z_bcsag_tablecopy_remote.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(QUELL_TAB_NAME) LIKE DD02L-TABNAME
*" VALUE(TAB_CONDITION) TYPE ZCHAR45
*" EXPORTING
*" VALUE(TAB_RESULT) TYPE ZCHAR1000
*" EXCEPTIONS
*" ERROR
*"----------------------------------------------------------------------
SELECT * FROM (quell_tab_name) INTO TABLE tab_result
WHERE (tab_condition).
ENDFUNCTION.
REPORT zbcsag_tablecopy LINE-SIZE 132
NO STANDARD PAGE HEADING.
*"----------------------------------------------------------------------
*" Report to copy a table from another system.
*"----------------------------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK outer_block WITH FRAME.
PARAMETERS: tabelle LIKE dd02l-tabname OBLIGATORY, "Tabellenname
rfc_dest LIKE rfcdes-rfcdest, "Destination
simu TYPE tst_on DEFAULT 'X'. "Simulation
SELECTION-SCREEN BEGIN OF BLOCK cond_block WITH FRAME TITLE text-001.
PARAMETERS: cond1(45), "Where-Klausel 1
cond2(45), "Where-Klausel 2
cond3(45), "Where-Klausel 3
cond4(45), "Where-Klausel 4
cond5(45). "Where-Klausel 5
SELECTION-SCREEN END OF BLOCK cond_block.
SELECTION-SCREEN END OF BLOCK outer_block.
DATA: it_condition TYPE zchar45.
DATA: it_tab TYPE zchar1000.
DATA: wa_it_tab(1000).
DATA: d_ref TYPE REF TO data.
FIELD-SYMBOLS: <cond> TYPE c,
<copytab> TYPE ANY.
DATA: feldname(5),
i TYPE n,
count_commit TYPE i.
TABLES: tddat.
* Prüfung auf Berechtigung
SELECT SINGLE * FROM tddat WHERE tabname = tabelle.
AUTHORITY-CHECK OBJECT 'S_TABU_DIS'
ID 'DICBERCLS' FIELD tddat-cclass
ID 'ACTVT' FIELD '02'.
if sy-subrc < > 0.
MESSAGE ID 'ZS-ALLG' TYPE 'E' NUMBER 000
WITH 'Tabellenberechtigung fehlt!!!' .
endif.
* Kopiert werden darf nur in Testsysteme!!!!!!
IF sy-sysid(1) < > 'C'.
MESSAGE ID 'ZS-ALLG' TYPE 'E' NUMBER 000
WITH 'Report nur im Testsystem verwenden!!' .
ENDIF.
* Tabelle für Where-Bedingung zusammenbauen REFRESH it_condition.
DO 5 TIMES.
i = sy-index.
CONCATENATE 'cond' i INTO feldname.
ASSIGN (feldname) TO <cond>.
IF NOT ( <cond> IS INITIAL ).
INSERT <cond> INTO TABLE it_condition.
ENDIF.
ENDDO.
* Daten aus dem Remote-System holen über RFC-Destination CALL FUNCTION 'Z_BCSAG_TABLECOPY_REMOTE' DESTINATION rfc_dest
EXPORTING
quell_tab_name = tabelle "Name der Tabelle
tab_condition = it_condition "Where-Bedingung
IMPORTING
tab_result = it_tab "Result-Set
EXCEPTIONS
error = 1
OTHERS = 2.
* Programmabbruch wenn remote-lesen nicht funktioniert hat.
IF sy-subrc < > 0.
IF simu = 'X'.
WRITE: /'Returncode: ', sy-subrc.
ELSE.
MESSAGE ID 'ZS-ALLG' TYPE 'A' NUMBER 000
WITH 'Lesefehler in Funktionsbaustein' .
ENDIF.
ENDIF.
* Datenreferenz auf Struktur der gewünschten Tabelle erstellen CREATE DATA d_ref TYPE (tabelle).
ASSIGN d_ref->* TO <copytab>.
* Result-Set satzweise im lokalen System wegschreiben.
LOOP AT it_tab INTO <copytab>.
* Bei Simulation Sätze nur ausgeben.
WRITE: / <copytab>(70).
IF simu NE 'X'.
INSERT INTO (tabelle) VALUES .
IF sy-subrc NE 0 .
UPDATE (tabelle) FROM .
ENDIF .
ADD 1 TO count_commit .
IF count_commit = '1000' .
COMMIT WORK .
count_commit = 0 .
ENDIF.
ENDIF.
ENDLOOP.
*----------------------------------------------------------------------*
TOP-OF-PAGE.
*----------------------------------------------------------------------*
WRITE: sy-datum DD/MM/YYYY,
43 'Tabellen zw. Systemen kopieren',
'System:', sy-sysid,
123 'Seite:', (3) sy-pagno NO-SIGN.
ULINE.
WRITE: / 'Kopierte Sätze aus Tabelle ', tabelle.
ULINE.
reward points if it is usefulll ....
Girish