• 关于BAPI


    1 BAPI的优点

    bapi是面向对象的设计;
    bapi是固定的,一般不能修改;
    bapi可以被sap内部部件和非sap程序使用;
    bapi的成功和错误信息始终通过RETURN返回;
    bapi可以被许多开发平台使用;

    2 何时该考虑使用BAPI设计程序

    用VB/JAVA?C++等语言编写非SAPGUI程序访问和处理sap数据;
    SAP不同部件之间通讯;
    与非sap程序或者老系统交换数据:
    使用异步通信分发数据如:ALE
    可以通过SAP Business Connector or Internet Application Components 与因特网程序集成;

    3 关于RETURN

    RETURN用于BAPI返回错误和成功的消息,它可以是BAPIRETURN,BAPIRETURN,BAPIRET1,BAPIRET2和BAPIRET2_FIX中的一种类型.这些结构一般都包括以下字段:

    TYPE

    CHAR 1

    S

    = success message
    E = error message
    W = warning message
    I = information message
    A = termination message (abort)

    ID

    CHAR 20

    Message ID The structure BAPIRET2 takes into account the name space extension for the message class as of Release 4.0. If you want messages to be compatible with earlier R/3 Releases, use the message classes before Release 4.0.

    NUMBER

    NUMC 3

    Message number

    MESSAGE

    CHAR 220

    Full message text from the message table. All variables (in fields Message_V1 to Message_V4) have been replaced with text.

    MESSAGE_V1
    MESSAGE_V2
    MESSAGE_V3 MESSAGE_V4

    CHAR 50

    Fields for the variable texts of the message

     

    4 BAPI的程序框架

    Log on
           (Source code)
       Call BAPI
    (Source code)
       Call BAPI
           (Source code)
    Call BAPI BapiService.TransactionCommit()
           (Source code)
       Call BAPI
           (Source code)
       Call BAPI
           (Source code)
    Call BAPI BapiService.TransactionCommit()
           (Source code)
    Log off

    5 相关函数

    'BALW_BAPIRETURN_GET2':取生成返回消息
        CALL FUNCTION 'BALW_BAPIRETURN_GET2'
             EXPORTING
                  TYPE   = 'E'
                  CL     = 'BC_BOR'
                  NUMBER = 163
                  PAR1   = MSG1_HLP
                  PAR2   = MSG2_HLP
             IMPORTING
                  RETURN = RETURN.
    BAPI_TRANSACTION_COMMIT 和 API_TRANSACTION_ROLLBACK: BAPI事务函数

    BUFFER_SUBSCRIBE_FOR_REFRESH和BUFFER_REFRESH_ALL: 缓冲区处理函数

    'TRANSACTION_BEGIN ,'TRANSACTION_STATUS' 和'TRANSACTION_END' 的调用示例
        call function 'TRANSACTION_BEGIN'  "94702/KB
             importing                     "94702/KB
                  transaction_id = transaction_id                  "94702/KB
             exceptions                    "94702/KB
                  others         = 1.      "94702/KB
        call function 'BAPI_PO_CREATE'     "94702/KB
             exporting                     "94702/KB
                  po_header                  = po_head             "94702/KB
             importing                     "94702/KB
                  purchaseorder              = h_ebeln             "94702/KB
             tables                        "94702/KB
                  po_items                   = po_item             "94702/KB
                  po_item_schedules          = po_sched            "94702/KB
                  po_item_account_assignment = po_acct             "94702/KB
                  po_item_text               = po_text             "94702/KB
                  return                     = return              "94702/KB
             exceptions                    "94702/KB
                  others                     = 0.                  "94702/KB
        call function 'TRANSACTION_STATUS' "94702/KB
             importing                     "94702/KB
                  status  = status_of_transaction                  "94702/KB
             exceptions                    "94702/KB
                  others  = 1.             "94702/KB
        if status_of_transaction = commit_work.                    "94702/KB
          commit work and wait.            "94702/KB
        endif.                             "94702/KB
        call function 'TRANSACTION_END'    "94702/KB
             exporting                     "94702/KB
                  transaction_id = transaction_id                  "94702/KB
             exceptions                    "94702/KB
                  others         = 1.      "94702/KB

  • 相关阅读:
    支付宝沙箱环境应用
    七牛云视频托管
    腾讯云短息验证码接口
    git远程连接(码云)
    git
    字间距
    html文本保留空格
    mysql重启导致AUTO_INCREMENT从1开始
    js保留两位小数
    vue中watch的基本用法
  • 原文地址:https://www.cnblogs.com/xiaomaohai/p/6157467.html
Copyright © 2020-2023  润新知