12-20-2007 5:21 PM
Hi Guys
I am new to ABAP.Ive mistakenly delted all the records of table KNA1.
I got other system where the same version is installed.
How can I take backup of the table from one system to another
We are in beginner level and now just learning ABAP. We don't know how to restore it. When we are running a program with select options, it deleted all entry's in KNA1 table. Please help me how to restore it by a beginner level student. Thanks in Advance.
Edited by: God Wings on Dec 21, 2007 3:46 PM
12-20-2007 5:25 PM
how did it allow you to delete all the entires...
in the other system u need to right a code to download all the entries into a flat file and in the system u need to right a code to upload entires..
select * from KNA1
into table it_kna1.
use gui_download to put into flat file.
in the target system
use gui upload to upload into a internal table say itab_target.
and say modify kna1 from itab_taget.
all the internal tables need to be of the structure of kna1..
award points if usefull.
12-20-2007 5:25 PM
how did it allow you to delete all the entires...
in the other system u need to right a code to download all the entries into a flat file and in the system u need to right a code to upload entires..
select * from KNA1
into table it_kna1.
use gui_download to put into flat file.
in the target system
use gui upload to upload into a internal table say itab_target.
and say modify kna1 from itab_taget.
all the internal tables need to be of the structure of kna1..
award points if usefull.
12-20-2007 5:27 PM
Try the table upload and download programs below: -
Download program: -
REPORT Y2PTABD0
MESSAGE-ID Y2.
----
Declaration of Database Tables
----
TABLES: DD02L.
----
Declaration for datatypes *
----
DATA : V_LINE(256) TYPE C,
V_PROG(8) TYPE C VALUE 'ZDYNSUB'.
----
Declaration for internal tables *
----
DATA : I_DYN_SUB(256) OCCURS 30.
----
Selection screen *
----
PARAMETERS: PATH LIKE RLGRAP-FILENAME NO-DISPLAY,
TABLE LIKE DD02L-TABNAME.
----
At Selection-Screen *
----
AT SELECTION-SCREEN.
PERFORM CHECK_TABLE_EXISTS.
----
Start of selection *
----
START-OF-SELECTION.
APPEND 'PROGRAM ZDYNSUB.' TO I_DYN_SUB.
APPEND 'FORM DYN1.' TO I_DYN_SUB.
CLEAR V_LINE.
CONCATENATE 'TABLES:' TABLE '.' INTO V_LINE SEPARATED BY SPACE.
APPEND V_LINE TO I_DYN_SUB.
CLEAR V_LINE.
CONCATENATE 'DATA: IT_TABLE LIKE' TABLE 'OCCURS 0 WITH HEADER LINE.'
INTO V_LINE SEPARATED BY SPACE.
APPEND V_LINE TO I_DYN_SUB.
APPEND 'PERFORM START_OF_SELECTION(Y2PTABD0) TABLES IT_TABLE.' TO
I_DYN_SUB.
APPEND ' ENDFORM.' TO I_DYN_SUB.
GENERATE SUBROUTINE POOL I_DYN_SUB NAME V_PROG.
PERFORM DYN1 IN PROGRAM (V_PROG) IF FOUND.
----
*& FORM START_OF_SELECTION
&----
Start of selection *
----
FORM START_OF_SELECTION TABLES P_TABLE.
DATA: V_CANC TYPE C.
DATA: FILENAME LIKE RLGRAP-FILENAME.
SELECT * FROM (TABLE) INTO TABLE P_TABLE.
IF PATH = SPACE.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
FILETYPE = 'DAT'
IMPORTING
CANCEL = V_CANC
TABLES
DATA_TAB = P_TABLE
EXCEPTIONS
INVALID_FILESIZE = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
OTHERS = 6.
ELSE.
CLEAR FILENAME.
CONCATENATE PATH TABLE '.TXT'
INTO FILENAME.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = FILENAME
FILETYPE = 'DAT'
TABLES
DATA_TAB = P_TABLE
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
OTHERS = 8.
ENDIF.
IF V_CANC = 'X'.
IF PATH = SPACE.
MESSAGE I000 WITH 'OPERATION CANCELLED'.
ENDIF.
ELSE.
IF PATH = SPACE.
MESSAGE I000 WITH 'TABLE ' TABLE ' SUCCESSFULLY DOWNLOADED'.
ENDIF.
ENDIF.
ENDFORM. " START_OF_SELECTION
&----
*& Form CHECK_TABLE_EXISTS
&----
FORM CHECK_TABLE_EXISTS.
CLEAR DD02L.
SELECT * FROM DD02L
UP TO 1 ROWS
WHERE TABNAME = TABLE.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'Table'
TABLE
'does not exist. Please Check!'.
ELSE.
CLEAR DD02L.
IF TABLE+0(1) NE 'Y' AND
TABLE+0(1) NE 'Z'.
MESSAGE E000 WITH 'Applicable for custom'
'(Y/Z) tables only!'.
ENDIF.
ENDIF.
ENDFORM. " CHECK_TABLE_EXISTS
***************************
Upload Program: -
REPORT Y2PTABU0
MESSAGE-ID Y2.
----
Declaration of Database Tables
----
TABLES: DD02L.
----
Declaration for datatypes *
----
DATA : V_LINE(256) TYPE C,
V_PROG(8) TYPE C VALUE 'ZDYNSUB'.
----
Declaration for internal tables *
----
DATA : I_DYN_SUB(256) OCCURS 30.
----
Selection screen *
----
PARAMETERS: TABLE LIKE DD02L-TABNAME.
----
Start of selection *
----
START-OF-SELECTION.
APPEND 'PROGRAM ZDYNSUB.' TO I_DYN_SUB.
APPEND 'FORM DYN1.' TO I_DYN_SUB.
CLEAR V_LINE.
CONCATENATE 'TABLES:' TABLE '.' INTO V_LINE SEPARATED BY SPACE.
APPEND V_LINE TO I_DYN_SUB.
CLEAR V_LINE.
CONCATENATE 'DATA: IT_TABLE LIKE' TABLE 'OCCURS 0 WITH HEADER LINE.'
INTO V_LINE SEPARATED BY SPACE.
APPEND V_LINE TO I_DYN_SUB.
APPEND 'PERFORM START_OF_SELECTION(Y2PTABU0) TABLES IT_TABLE.' TO
I_DYN_SUB.
APPEND ' ENDFORM.' TO I_DYN_SUB.
GENERATE SUBROUTINE POOL I_DYN_SUB NAME V_PROG.
PERFORM DYN1 IN PROGRAM (V_PROG) IF FOUND.
----
*& FORM START_OF_SELECTION
&----
Start of selection *
----
FORM START_OF_SELECTION TABLES P_TABLE.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
DATA_TAB = P_TABLE
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
OTHERS = 6.
IF SY-SUBRC <> 0.
MESSAGE I000 WITH 'OPERATION CANCELLED'.
ELSE.
MODIFY (TABLE) FROM TABLE P_TABLE.
MESSAGE I000 WITH 'TABLE ' TABLE ' SUCCESSFULLY UPLOADED'.
ENDIF.
ENDFORM. " START_OF_SELECTION
-Cheers