FORM FRM_GET_DATA .
DATA L_FILE_NAME TYPE RLGRAP-FILENAME.
DATA L_TAB_RAW_DATA TYPE TRUXS_T_TEXT_DATA.
L_FILE_NAME = P_PATH.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_TAB_RAW_DATA = L_TAB_RAW_DATA
I_FILENAME = L_FILE_NAME
TABLES
I_TAB_CONVERTED_DATA = IT_POST
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE S001(00) WITH TEXT-E01 DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
DELETE IT_POST INDEX 1."删除导入模板标题
PERFORM FRM_GET_TBSL TABLES IT_TBSL.
ENDFORM. " FRM_GET_DATA
*&---------------------------------------------------------------------*
*& Form F_GET_FILEPATH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM F_GET_FILEPATH .
DATA: LIT_FILE TYPE FILETABLE,
LWA_FILE LIKE LINE OF LIT_FILE.
DATA L_FILE_COUNT TYPE I.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = '选择导入文件'
DEFAULT_EXTENSION = 'XLS'
CHANGING
FILE_TABLE = LIT_FILE
RC = L_FILE_COUNT.
IF L_FILE_COUNT <> -1.
READ TABLE LIT_FILE INDEX 1 INTO LWA_FILE.
P_PATH = LWA_FILE-FILENAME.
ENDIF.
ENDFORM. " F_GET_FILEPATH
*&---------------------------------------------------------------------*
*& Form FRM_RUN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_RUN .
DATA:
W_BELNR TYPE BAPIACHE09-OBJ_KEY,
WA_ZEXTEN TYPE ZEXTEN,
L_HEADER TYPE BAPIACHE09, "抬头信息
L_ACCOUNTGL TYPE BAPIACGL09, "总帐工作区
L_RECEIVABLE TYPE BAPIACAR09, "客户工作区
L_PAYBLE TYPE BAPIACAP09, "供应商工作区
L_RETURN TYPE BAPIRET2, "返回信息工作区
L_CURRENCYAMOUNT TYPE BAPIACCR09, "金额工作区
L_EXTENSION TYPE BAPIACEXTC,
L_EXTENSION2 TYPE BAPIPAREX,
LI_ACCOUNTGL TYPE TABLE OF BAPIACGL09, "总帐内表
LI_RECEIVABLE TYPE TABLE OF BAPIACAR09, "客户内表
LI_PAYBLE TYPE TABLE OF BAPIACAP09, "供应商内表
LI_RETURN TYPE TABLE OF BAPIRET2, "返回信息内表
LI_CURRENCYAMOUNT TYPE TABLE OF BAPIACCR09, "金额内表
LI_EXTENSION2 TYPE TABLE OF BAPIPAREX WITH HEADER LINE.
DATA:L_DMBTR TYPE BAPIWRBTR,
L_WRBTR TYPE BAPIWRBTR.
DATA L_ITEM TYPE POSNR_ACC VALUE 1.
DATA L_BUZEI TYPE TA_POST-BUZEI.
DATA LI_POST TYPE TABLE OF TA_POST.
DATA L_POST TYPE TA_POST.
DATA L_MWAER TYPE T000-MWAER.
SORT IT_POST BY BUZEI.
LI_POST[] = IT_POST[].
DELETE ADJACENT DUPLICATES FROM LI_POST COMPARING BUZEI.
SELECT SINGLE MWAER INTO L_MWAER FROM T000 WHERE MANDT = SY-MANDT. "获取本集团货币、
IF SY-SUBRC <> 0.
MESSAGE E001 .
ENDIF.
SORT IT_