Application Development and Automation 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: 
Read only

Copy data from one client to another

Former Member
0 Likes
2,310

I have some data in a database table in xxx client . I want to copy the data to another client yyy .What is the possible way .

I have some data in a database table in xxx client . I want to copy the data to another client yyy .What is the possible way .

6 REPLIES 6
Read only

Former Member
0 Likes
1,340

One possible way would be to write a program to do it. There are probably other ways to do it as well.

Rob

Read only

former_member214857
Contributor
0 Likes
1,340

Hi,

You can write an ABAP program using SELECT statment like sample below:

SELECT * FROM T001 INTO TABLE t_mytable CLIENT SPECIFIED WHERE (where condition) AND mandt = xxx.

Afte that you can replace MANDT from internal table generated with new cliente YYY.

And just update the table

Kind regards

Read only

0 Likes
1,340

hello, you could do this program. But you must also be careful with the data you want to copy. Usually, when we clic SAVE button on a transaction, several tables are updated and we, as abap programmers, doesn't know how many database tables are involved!!!

Example: if you want to copy one material from client "xxx" to client "yyy", you must copy the data from "mara" but also makt, mard, etc...

be carefull, the Integrity of ERP could be compromised. The best way to do this i guess it would be a transport order

Read only

0 Likes
1,340

Hi ,

one can not write Mandt in select statement , so passing the data from one client to another will not be accomplished with select query.

You will have to check something with BASIS person i guess.

Regards,

Uma Dave

Read only

dhirendra_pandit
Active Participant
0 Likes
1,340

Hi Anindya,

Its possible very easily, please refer the code below:-

  • Types

TYPES : BEGIN OF ty_zpmpartloc,

mandt TYPE mandt,

part_class TYPE zpmpartloc-part_class,

werks TYPE zpmpartloc-werks,

lgort TYPE zpmpartloc-lgort,

ekgrp TYPE zpmpartloc-ekgrp,

prctr TYPE zpmpartloc-prctr,

mtvfp TYPE zpmpartloc-mtvfp,

END OF ty_zpmpartloc,

BEGIN OF ty_zpmpartcls,

mandt TYPE mandt,

parts TYPE zpmpartcls-parts,

part_class TYPE zpmpartcls-part_class,

END OF ty_zpmpartcls.

  • Internal tables

DATA: it_zpmpartcls TYPE TABLE OF ty_zpmpartcls,

it_zpmpartloc TYPE TABLE OF ty_zpmpartloc,

cursor1 TYPE cursor,

cursor2 TYPE cursor.

  • Work Area

DATA : wa_zpmpartcls TYPE zpmpartcls,

wa_zpmpartloc TYPE zpmpartloc.

PARAMETER : p_mandt TYPE mandt.

START-OF-SELECTION.

  • __BEGIN_OF_PROCESSING__

OPEN CURSOR cursor1 for

SELECT mandt parts part_class FROM zpmpartcls CLIENT SPECIFIED

WHERE mandt = p_mandt.

IF sy-subrc EQ 0.

DO.

FETCH NEXT CURSOR cursor1 into wa_zpmpartcls.

IF sy-subrc <> 0.

CLOSE CURSOR cursor1.

EXIT.

ENDIF.

wa_zpmpartcls-mandt = sy-mandt.

APPEND wa_zpmpartcls to it_zpmpartcls.

ENDDO.

ELSE.

ENDIF.

OPEN CURSOR cursor2 for

SELECT mandt PART_CLASS WERKS LGORT EKGRP PRCTR MTVFP

FROM zpmpartloc CLIENT SPECIFIED

WHERE mandt = p_mandt.

IF sy-subrc EQ 0.

DO.

FETCH NEXT CURSOR cursor2 into wa_zpmpartloc.

IF sy-subrc <> 0.

CLOSE CURSOR cursor2.

EXIT.

ENDIF.

wa_zpmpartloc-mandt = sy-mandt.

APPEND wa_zpmpartloc to it_zpmpartloc.

ENDDO.

ENDIF.

END-OF-SELECTION.

MODIFY zpmpartcls FROM TABLE it_zpmpartcls.

MODIFY zpmpartloc FROM TABLE it_zpmpartloc.

COMMIT WORK.

Cheers...

Dhirendra

Read only

former_member266380
Active Participant
0 Likes
1,340

Hi,

Please go through the following link...

http://wiki.sdn.sap.com/wiki/display/Snippets/CopyTablecontentfromsourceclienttotarget+client

Hope this thing helps you in solving your problem.

Best Regarrs,

Venkat.