Académique Documents
Professionnel Documents
Culture Documents
*
*
*
*
*---------------------------------------------------------------------* TEXTS
*
* List Header...: For SAP Table: &1............................
*
* Column Heading: | Function
*
* Selection Texts: PATH
P_CLEAR
P_EXP
Export to PC File
P_IMP
TABNAME
*
* Text Symbols:
PGE Page
*----------------------------------------------------------------------
* This program once created will allow you to download or upload table
* data from any SAP table. It has the functionality to allow you to
* select whether data should be appended or original data cleaed before
* inserting new data.
* This is very useful when attempting to transfer data from one client
* to another
*----------------------------------------------------------------------
* selection screen
SELECTION-SCREEN BEGIN OF BLOCK b00 WITH FRAME TITLE text-b00.
*
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01.
PARAMETERS: tabname
AS CHECKBOX.
* data
DATA: q_return
LIKE syst-subrc,
err_flag(1) TYPE c,
answer(1)
TYPE c,
w_text1(62) TYPE c,
w_text2(40) TYPE c,
winfile(128) TYPE c,
w_system(40) TYPE c,
winsys(7)
TYPE c,
zname(8)
TYPE c,
w_line(80)
TYPE c.
* internal tables
DATA : BEGIN OF textpool_tab OCCURS 0.
INCLUDE STRUCTURE textpool.
DATA : END OF textpool_tab.
* events
INITIALIZATION.
PERFORM check_system.
*
AT SELECTION-SCREEN ON tabname.
PERFORM check_table_exists.
*
START-OF-SELECTION.
PERFORM init_report_texts.
PERFORM request_confirmation.
*
END-OF-SELECTION.
IF answer = 'J'.
PERFORM execute_program_function.
ENDIF.
*
TOP-OF-PAGE.
PERFORM process_top_of_page.
* forms
*---------------------------------------------------------------------*
*
FORM CHECK_TABLE_EXISTS
*---------------------------------------------------------------------*
FORM check_table_exists.
SELECT SINGLE * FROM dd02l
INTO CORRESPONDING FIELDS OF dd02l
WHERE tabname = tabname.
CHECK syst-subrc NE 0.
MESSAGE e402(mo) WITH tabname.
ENDFORM.
*---------------------------------------------------------------------*
*
FORM INIT_REPORT_TEXTS
*---------------------------------------------------------------------*
FORM init_report_texts.
READ TEXTPOOL syst-repid
INTO textpool_tab LANGUAGE syst-langu.
LOOP AT textpool_tab
FORM REQUEST_CONFIRMATION
*---------------------------------------------------------------------*
FORM request_confirmation.
= w_text1
textline2
= w_text2
titel
= answer
EXCEPTIONS
OTHERS
= 1.
ELSE.
*
ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
*
FORM EXECUTE_PROGRAM_FUNCTION
*---------------------------------------------------------------------*
FORM execute_program_function.
PERFORM build_file_name.
CLEAR: q_return,err_flag.
IF p_imp = 'X'.
PERFORM check_file_exists.
CHECK err_flag = ' '.
PERFORM func_import.
ELSE.
PERFORM func_export.
ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
*
FORM BUILD_FILE_NAME
*---------------------------------------------------------------------*
FORM build_file_name.
MOVE path TO winfile.
FORM CHECK_FILE_EXISTS
*---------------------------------------------------------------------*
FORM check_file_exists.
= 'FE'
IMPORTING
return
= q_return
EXCEPTIONS
OTHERS
= 1.
IF syst-subrc NE 0 OR q_return NE 1.
err_flag = 'X'.
ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
*
FORM func_export
*---------------------------------------------------------------------*
FORM func_export.
CLEAR itab. REFRESH itab.
FORM func_import
*---------------------------------------------------------------------*
FORM func_import.
CLEAR itab. REFRESH itab.
APPEND 'PROGRAM SUBPOOL.' TO itab.
IF p_clear = 'X'.
CONCATENATE 'SELECT * FROM'
tabname
'INTO TABLE IT_TAB2.' INTO w_line SEPARATED BY space.
APPEND w_line TO itab.
Form CHECK_SYSTEM
You could change the logic to only use the first 8 chars
of the table name for the filename, but you could possibly
*---------------------------------------------------------------------*
FORM check_system.
CALL FUNCTION 'WS_QUERY'
EXPORTING
query = 'WS'
IMPORTING
return = winsys.
IF winsys NE 'WN32_95'.
WRITE: 'Windows NT or Windows 95/98 is required'.
EXIT.
ENDIF.
ENDFORM.
" CHECK_SYSTEM
*---------------------------------------------------------------------*
*
FORM PROCESS_TOP_OF_PAGE
*---------------------------------------------------------------------*
FORM process_top_of_page.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
ULINE.
CONCATENATE syst-sysid
syst-saprl
syst-host INTO w_system SEPARATED BY space.
ULINE.
ENDFORM.