‎2008 Nov 11 6:47 PM
Hi,
I have a requirement to download all critical custom table data into a directory in application server. My idea is just enter the table name in selection screen and execute the program to download the data. Actually this is going to be a batch job once in a week to make sure critical data is not lost. Can you please suggest me a solution for this requirement? I appreciate your help in advance. Please share with me if you have the code or logics to accomplish the task. Is there any SAP Standard program that can do this task?
Thanks,
Kannan
.
‎2008 Nov 11 7:09 PM
Hi,
to backup any ddic table I am using the following code. It is backuping to presentation server. Simple replace GUI_DOWNLOAD with DATASET will solve the thing.
*&---------------------------------------------------------------------*
*& Report ZBACKUPANYTABLETOCSV
*&
*& SHORT DESCRIPTION
*& the program is used to copy whole content of ANY DDIC table "TAB_NAME"
*& into file "FILENAME".
PARAMETERS: TAB_NAME type SY-TNAME. " table name
PARAMETERS: FILENAME TYPE string. " output file name
FIELD-SYMBOLS <wa> TYPE ANY. " work area for line of table TAB_NAME
FIELD-SYMBOLS <field> TYPE ANY. " field of work area
DATA: BEGIN OF BUFFER,
ALIGNMENT TYPE F, " Alignment
C(8000) TYPE C, " Table content
END OF BUFFER.
DATA: l_index TYPE i. " Field index
DATA: gt_file TYPE TABLE OF rtxline WITH HEADER LINE. " output file content
DATA: h_field TYPE string. " help field for casting
ASSIGN BUFFER TO <WA> CASTING TYPE (TAB_NAME). " get structure of table
SELECT * from (TAB_NAME) into <wa>. " get all table records
l_index = 0.
gt_file = ''.
WHILE sy-subrc = 0.
ADD 1 to l_index.
ASSIGN COMPONENT l_index OF STRUCTURE <wa> to <field>.
h_field = <field>.
IF sy-subrc = 0.
IF l_index = 1.
gt_file = h_field.
ELSE.
CONCATENATE gt_file ';' h_field INTO gt_file.
ENDIF.
ENDIF.
ENDWHILE.
APPEND gt_file.
ENDSELECT.
CALL FUNCTION 'GUI_DOWNLOAD' " download output to file FILENAME
EXPORTING
FILENAME = FILENAME
TABLES
DATA_TAB = gt_file .
There also exists great program to backup whole DDIC table with possibility to recreate it then. This really makes sence for backuping. For more information check http://sap4.com/wiki/index.php?title=Copiar_definici%C3%B3n_de_tablas
Regards,
Karol
‎2008 Nov 11 6:57 PM
1. Use fm RFC_READ_TABLE and give table name and you will get table entries
2. Use OPEN DATASET and TRANFSER to application server.
( It will not good practice to copying the custom table into app server. My question is what will be end result for this? )
a®
‎2008 Nov 11 7:09 PM
Hi,
to backup any ddic table I am using the following code. It is backuping to presentation server. Simple replace GUI_DOWNLOAD with DATASET will solve the thing.
*&---------------------------------------------------------------------*
*& Report ZBACKUPANYTABLETOCSV
*&
*& SHORT DESCRIPTION
*& the program is used to copy whole content of ANY DDIC table "TAB_NAME"
*& into file "FILENAME".
PARAMETERS: TAB_NAME type SY-TNAME. " table name
PARAMETERS: FILENAME TYPE string. " output file name
FIELD-SYMBOLS <wa> TYPE ANY. " work area for line of table TAB_NAME
FIELD-SYMBOLS <field> TYPE ANY. " field of work area
DATA: BEGIN OF BUFFER,
ALIGNMENT TYPE F, " Alignment
C(8000) TYPE C, " Table content
END OF BUFFER.
DATA: l_index TYPE i. " Field index
DATA: gt_file TYPE TABLE OF rtxline WITH HEADER LINE. " output file content
DATA: h_field TYPE string. " help field for casting
ASSIGN BUFFER TO <WA> CASTING TYPE (TAB_NAME). " get structure of table
SELECT * from (TAB_NAME) into <wa>. " get all table records
l_index = 0.
gt_file = ''.
WHILE sy-subrc = 0.
ADD 1 to l_index.
ASSIGN COMPONENT l_index OF STRUCTURE <wa> to <field>.
h_field = <field>.
IF sy-subrc = 0.
IF l_index = 1.
gt_file = h_field.
ELSE.
CONCATENATE gt_file ';' h_field INTO gt_file.
ENDIF.
ENDIF.
ENDWHILE.
APPEND gt_file.
ENDSELECT.
CALL FUNCTION 'GUI_DOWNLOAD' " download output to file FILENAME
EXPORTING
FILENAME = FILENAME
TABLES
DATA_TAB = gt_file .
There also exists great program to backup whole DDIC table with possibility to recreate it then. This really makes sence for backuping. For more information check http://sap4.com/wiki/index.php?title=Copiar_definici%C3%B3n_de_tablas
Regards,
Karol
‎2008 Nov 11 7:29 PM
Hi a®s,
Thanks for your reply. It is just to make sure we have the table dump just in case Transports moved to Production caused any Issues (deleting the data).
Thanks,
Kannan.