SAP程序论坛

 找回密码
 立即注册
搜索
热搜: alv sap gui
查看: 401|回复: 1

[增强代码] 过账BAPI增强配合BTE:EXTENSION1 for accounting BAPIS

[复制链接]

22

主题

28

帖子

186

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
186
发表于 2019-6-16 22:49:09 | 显示全部楼层 |阅读模式
For the F-47 posting, it only post to 1 line item whereby BAPI “BAPI_ACC_DOCUMENT_POST” have to post in 2 lines for balance the account. Here are the steps to do posting F-47 (Down Payment Request) via BAPI and BTE with 1 line item:

1) Create a new function group using transaction code SE80.

2) Copy the standard function module of BTE “SAMPLE_INTERFACE_RWBAPI01” to a Z Function module, say “ZSAMPLE_INTERFACE_RWBAPI01”

3) Goto transaction code FIBF to create the BTE for process “RWBAPI01”.

4) Before call the BAPI “BAPI_ACC_DOCUMENT_POST”, prepare the table for extension1 as below:

  DEFINE mac_assign_extension.
    clear lv_string.
    concatenate &1 &2
       into lv_string.
    concatenate &3 lv_string
           into &3
      separated by ‘;’.
  END-OF-DEFINITION.

*-> prepare extension
    CONCATENATE ‘0001’ ls_accountpayable-itemno_acc
           INTO ls_extension1-field1.   ” 0001 => running number for different purpose to triggering BTE “RWBAPI01”
    CONCATENATE ‘BSTAT’ ‘S’  INTO ls_extension1-field2.
    mac_assign_extension ‘BSCHL’ ’39’ ls_extension1-field2.
    mac_assign_extension ‘UMSKZ’ ‘F’ ls_extension1-field2.
    mac_assign_extension ‘ZUMSK’ ‘Z’ ls_extension1-field2.
    mac_assign_extension ‘SHKZG’ ‘H’ ls_extension1-field2.
    APPEND ls_extension1 TO lt_extension1.

5) In the function module “ZSAMPLE_INTERFACE_RWBAPI01”, read the table extension1 and populate the field into table IT_ACCIT.

  TYPES : BEGIN OF ty_extension,
            field TYPE char50,
          END OF ty_extension.

  TYPES : tty_extension TYPE STANDARD TABLE OF ty_extension.

  DATA : ls_extension TYPE bapiacextc,
         ws_extension TYPE ty_extension,
         lt_extension TYPE tty_extension,
         lv_tabix     TYPE sytabix,
         lv_len       TYPE i.

  DATA : lv_bstat TYPE char01,
         lv_bschl TYPE char01,
         lv_umskz TYPE char01,
         lv_zumsk TYPE char01,
         lv_shkzg TYPE char01.

  DEFINE mac_assign_value.
    clear lv_len.
    if &4 is initial.
      find first occurrence of &1 in &2 match length lv_len.
      if sy-subrc = 0.
        &3 = &2+lv_len.
        &4 = ‘X’.
      endif.
    endif.
  END-OF-DEFINITION.

  LOOP AT extension INTO ls_extension.
    CASE ls_extension-field1(4).
      WHEN ‘0001’.  “For down payment request
        MOVE ‘RFST’ TO document_header-glvor.

        READ TABLE it_accit WITH KEY posnr = ls_extension-field1+4(10).
        IF sy-subrc = 0.
          lv_tabix = sy-tabix.
          SPLIT ls_extension-field2 AT ‘;’
           INTO TABLE lt_extension
             IN CHARACTER MODE.
          LOOP AT lt_extension INTO ws_extension.
            mac_assign_value ‘BSTAT’ ws_extension-field it_accit-bstat lv_bstat.
            mac_assign_value ‘BSCHL’ ws_extension-field it_accit-bschl lv_bschl.
            mac_assign_value ‘UMSKZ’ ws_extension-field it_accit-umskz lv_umskz.
            mac_assign_value ‘ZUMSK’ ws_extension-field it_accit-zumsk lv_zumsk.
            mac_assign_value ‘SHKZG’ ws_extension-field it_accit-shkzg lv_shkzg.
          ENDLOOP.

          MODIFY it_accit INDEX lv_tabix.
        ENDIF.
      WHEN OTHERS.
    ENDCASE.
  ENDLOOP.



------------------------------------------------------------------------
NOTES:
https://launchpad.support.sap.com/#/notes/487722

When you implement an accounting BAPI, fields are missing in the transfer structure. However, this information has to be transferred.




Other Terms

AC interface, CMOD, SMOD, ACBAPI01, EXTENSION1
BAPIs:
BAPI_ACC_DOCUMENT_POST         BAPI_ACC_DOCUMENT_CHECK
BAPI_ACC_GL_POSTING_POST       BAPI_ACC_GL_POSTING_CHECK
BAPI_ACC_BILLING_POST          BAPI_ACC_BILLING_CHECK
BAPI_ACC_INVOICE_RECEIPT_POST  BAPI_ACC_INVOICE_RECEIPT_CHECK
BAPI_ACC_GOODS_MOVEMENT_POST   BAPI_ACC_GOODS_MOVEMENT_CHECK

Message types:
ACC_DOCUMENT
ACC_GL_POSTING
ACC_BILLING
ACC_INVOICE_RECEIPT
ACC_GOODS_MOVEMENT




Reason and Prerequisites

The fields do not exist in the required structure.




Solution

  • If this situation involves an error (this business transaction was not considered during the development of the BAPI), contact SAP Development. However, an enhancement is possible for the next release since it is not possible to change the stable BAPI interfaces in a current release.For the current project, you have to use enhancement structure EXTENSION1 and implement the CMOD exit ACBAPI01.
  • If the requirements are not relevant for the SAP Standard System (the business transaction to be implemented is very unusual and company-specific), do not contact SAP and implement the above-mentioned exit.

Implementing CMOD/SMOD exit ACBAPI01 with enhancement structure EXTENSION1:
Transaction CMOD: Select your project or create one.Assign enhancement ACBAPI01 to the project.You can branch to the source code via "Components".Navigate to function module EXIT_SAPLACC4_001.This function module indicates the parameters that are available to change the document.In INCLUDE ZXACCU15 (Customer namespace), carry out your implementation as an ABAP program.
When the BAPI is called, parameter EXTENSION1 is available with the following fields:FIELD1, FIELD2, FIELD3, FIELD4, each with 250 characters.Fill the structure with offset specification, for example, a text is to be transferred to line item 5 (ITEMNO_ACC):
DATA: wa_extension TYPE bapiextc,
      it_extension TYPE STANDARD TABLE OF bapiextc.
wa_extension(3) = '005'.               "ITEMNO_ACC
wa_extension+3(11) = 'Note 487722'.    "Data, not in standard interface
APPEND wa_extension TO it_extension.

Internal table IT_EXTENSION is assigned to the BAPI during the access.
In the implementation of the exit, you have to read the same offset again:
* Determine line item
READ TABLE t_accit WITH KEY posnr = extension(3).
IF sy-subrc IS INITIAL.
* Update the line item text
  t_accit-sgtxt = extension+3(11).
  MODIFY t_accit INDEX sy-tabix.
ENDIF.
Implementing the Business Transaction Event (BTE, also OPEN FI) RWBAPI01 with enhancement structure EXTENSION1 at BAPI_ACC_DOCUMENT_POST
As for CMOD/SMOD exit ACBAPI01, it is possible to change the accounting document in this case. Access: Transaction FIBF:





    1. Call the menu path "Settings > Products -> ...of a customer" and create a product that mirrors the function which is to be mapped in the BTE.





    2. Create a function module that contains the same interface, such as example module SAMPLE_INTERFACE_RWBAPI01.





    3. Call menu path "Settings -> Process function modules > ...of a customer" enter process = RWBAPI01, the function module created and the product.





    4. Finally, activate the product you have created in the first step so that the module will run.





回复

使用道具 举报

0

主题

2

帖子

16

积分

禁止发言

积分
16
发表于 2019-9-20 11:48:25 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|SAPCODE

GMT+8, 2019-10-17 04:24 , Processed in 0.080224 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表