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

Database table copying

Former Member
0 Likes
737

Hi,

If I create Z-Table in one server and Can I copy it into other server ?

I am working on demo system and after that I have upload into customer system?

Is it possible ?

Thanks...

6 REPLIES 6
Read only

MarcinPciak
Active Contributor
0 Likes
680

You could:

- export table to flat file from server A -> in server B record batch input for customer table entry via SM31 -> run your batch giving this flat file for input

- in server B -> SE16N write table name -> in command line write &sap_edit (this will open the table in write mode). Copy paste exported table from server A

- write small ABAP program which will upload exported file and insert it to customer table in server B

Pros and cons :

The first solution is let's say best practise, as you are sure what your are entering and will avoid errors

The second one is most error prone, you must keep in mind all formats etc

The third one is not be worst, but there is not point in creating separate program for doing single task, unless it is generic (uses parametrized table name and data).

Regards

Marcin

Read only

Former Member
0 Likes
680

Hi SRIDHAR ,

If you aware of the SAP link program you can use it to download or upload ,Tables,Programs,Function modules,Classes...etc

you can find further information in

http://code.google.com/p/saplink/

Hope this helps...

Read only

former_member434229
Active Participant
0 Likes
680

Hi Sridhar,

Use this code to upload data from flat file into whichever system you want to.

&----


*& Report ZPRG_INSERT_DATA

*&

&----


*&

*&

&----


REPORT zprg_insert_data.

TABLES : dd02l.

TYPES: fieldref TYPE REF TO data.

DATA: dyn_table TYPE fieldref.

FIELD-SYMBOLS : <fs_data> TYPE STANDARD TABLE.

SELECTION-SCREEN : BEGIN OF BLOCK a1 WITH FRAME.

PARAMETERS : p_tab TYPE dd02l-tabname.

PARAMETERS : p_file TYPE ibipparms-path.

SELECTION-SCREEN : END OF BLOCK a1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'

  • EXPORTING

  • program_name = syst-cprog

  • dynpro_number = syst-dynnr

  • field_name = ''

IMPORTING

file_name = p_file.

START-OF-SELECTION.

PERFORM table_check.

PERFORM data_upload.

PERFORM data_insert.

&----


*& Form data_upload

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM data_upload .

DATA : str TYPE string.

CREATE DATA dyn_table TYPE TABLE OF (p_tab).

ASSIGN dyn_table->* TO <fs_data>.

str = p_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = str

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = <fs_data>

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDFORM. " data_upload

&----


*& Form data_insert

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM data_insert .

INSERT (p_tab) FROM TABLE <fs_data>.

CHECK sy-subrc = 0.

COMMIT WORK.

MESSAGE s002(sy) WITH 'Data Successfully uploaded'.

ENDFORM. " data_insert

&----


*& Form table_check

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM table_check .

SELECT SINGLE * FROM dd02l

WHERE tabname = P_tab.

CHECK sy-subrc <> 0.

MESSAGE i002(sy) WITH 'Table does not exist. Check name'.

EXIT.

ENDFORM. " table_check

Regards,

Ni3

Read only

Former Member
0 Likes
680

Do you have transport connection between these two systems? If yes - it will be done automatically after you will release the transport.

If you want to transport also the content of the table - you should set the type of the table to C - customer table

Read only

0 Likes
680

HI,

I think sridhar wants to copy the table not the contents!!. If this is the case then according to best of my knowledge only way out is transporting it, but since you are saying you have created in demo system so i believe you can't transport it. Then simply create there again

If you want to transport data then check the first reply, and my suggestion in that is create the program to do so. It will be a very small program of few lines.

Cheers

Anurag

Read only

Former Member
0 Likes
680

Was helpful answer