BAPI_ACC_DOCUMENT_POST 导入外币金额全

本文档详细介绍了如何通过BAPI_ACC_DOCUMENT_POST函数模块导入包含外币金额的会计凭证数据。首先从Excel文件读取数据,然后进行数据转换,最后调用函数模块进行导入操作,并处理可能出现的错误。
摘要由CSDN通过智能技术生成

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_
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值