OverView
Users will often want Excel if they have a requirement to drop data locally.
In such a case, you can easily make it using the following general-purpose module.
The usage is almost the same as GUI_UPLOAD and GUI_DOWNLOAD, and I think that you can understand immediately because the parameters used are slightly different and the file name type is different.
One thing to note, however, is that the type RLGRAP-FILENAME used for file names is a 128-digit character type, which may cause problems if the hierarchy is deep.
Sample Code:Excel Upload
TYPE-POOLS: TRUXS. TYPES: BEGIN OF T_FILE, VAL1(10) TYPE C, VAL2(10) TYPE C, VAL3(10) TYPE C, END OF T_FILE. DATA: IT_FILE TYPE TABLE OF T_FILE. DATA: IT_ROW TYPE truxs_t_text_data. DATA: W_FILE TYPE RLGRAP-FILENAME. W_FILE = 'C:tempupload.XLSX'. CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP' EXPORTING * I_FIELD_SEPERATOR = * I_LINE_HEADER = I_TAB_RAW_DATA = IT_ROW I_FILENAME = W_FILE TABLES I_TAB_CONVERTED_DATA = IT_FILE * EXCEPTIONS * CONVERSION_FAILED = 1 * OTHERS = 2 . IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.
Sample Code:Excel Download
TYPES: BEGIN OF T_FILE, VAL1(10) TYPE C, VAL2(10) TYPE C, VAL3(10) TYPE C, END OF T_FILE. DATA: IT_FILE TYPE TABLE OF T_FILE, WA_FILE TYPE T_FILE. DATA: W_FILE TYPE RLGRAP-FILENAME. WA_FILE-VAL1 = '1'. WA_FILE-VAL2 = '2'. WA_FILE-VAL3 = '3'. APPEND WA_FILE TO IT_FILE. W_FILE = 'C:tempdownload.XLSX'. CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT' EXPORTING * I_FIELD_SEPERATOR = * I_LINE_HEADER = I_FILENAME = W_FILE TABLES I_TAB_SAP_DATA = IT_FILE * CHANGING * I_TAB_CONVERTED_DATA = * EXCEPTIONS * CONVERSION_FAILED = 1 * OTHERS = 2 . IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.
Recent Comments