ITPub博客

首页 > Linux操作系统 > Linux操作系统 > (原创)BAPI 修改销售订单的方法 ‘BAPI_SALESORDER_CHANGE’

(原创)BAPI 修改销售订单的方法 ‘BAPI_SALESORDER_CHANGE’

原创 Linux操作系统 作者:SAP骑士 时间:2009-08-21 16:22:55 0 删除 编辑
sap 标准程序中可以使用VA02来修改销售订单 change sales order,也可以在程序中调用BAPI来更改订单(如物料编号material,订购数量 order quantity等),用到的函数是 BAPI_SALESORDER_CHANGE.
sap bapi Explorer中的文档。



Method

SalesOrder.ChangeFromData

Change Sales Order

Functionality

You can use this method to change or delete sales orders.

You can change header, item, schedule line and configuration data.

In general, note that you should:

  • Only specify fields that should be changed
  • Select these fields by entering an X in the checkboxes
  • Enter a U in the UPDATEFLAG field
  • Always specify key fields when changing the data, including in the checkboxes
  • The configuration is an exception here. If this needs to be changed, you need to complete it again fully.
  • Maintain quantities and dates in the schedule line data
  • 修改订单数量要用schedule_lines 这个参数
  • Possible UPDATEFLAGS:
  • U = change  flg值的三种不同意义
  • D = delete
  • I = add
  • Example

    1. Delete the whole order
    2. Delete order items
    3. Change the order
    4. Change the configuration

    Notes

    1. Minimum entry:

    You must enter the order number in the SALESDOCUMENT structure.
    You must always enter key fields for changes.
    You must always specify the update indicator in the ORDER_HEADER_INX.

    1. Commit control:

    The BAPI does not run a database Commit, which means that the application must trigger the Commit so that the changes are read to the database. To do this, use the BAPI_TRANSACTION_COMMIT BAPI.使用完了bapi记得要用commit提交

  •  

  • *****************************************************************************
    贴一段程序帮助编写bapi
    * BAPI Logic for sales order creation
    *---------------------------------------------------------------
    * Header data
      PERFORM FILL_ORDER_HEADER_CHANGE  USING  ORDER_HEADER_IN
                                               ORDER_HEADER_INX
                                               LS_SORDER.

    * Partner
      PERFORM FILL_PARTNER_CHANGE       TABLES PARTNERCHANGES
                                               PT_ITEMS
                                        USING  LS_SORDER.

    * Items
      PERFORM FILL_ORDER_ITEM_CHANGE    TABLES ORDER_ITEMS_IN
                                               ORDER_ITEMS_INX
                                               PT_ITEMS.

    * Price condition
      IF PS_SORDER-MIG_FLG  = ' '.
      PERFORM FILL_CONDITIONS_CHANGE    TABLES CONDITIONS_IN
                                               CONDITIONS_INX
                                               PT_ITEMS
                                        USING  LS_SORDER.
      ELSE.
        CONDITIONS_IN[]  = PT_CONDTION[].
        CONDITIONS_INX[] = PT_CONDTIONX[].
      ENDIF.


      CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
        EXPORTING
          SALESDOCUMENT    = LS_SORDER-VBELN
          ORDER_HEADER_IN  = ORDER_HEADER_IN     (抬头数据)
          ORDER_HEADER_INX = ORDER_HEADER_INX
        TABLES
          RETURN           = PT_RETURN
          ORDER_ITEM_IN    = ORDER_ITEMS_IN
          ORDER_ITEM_INX   = ORDER_ITEMS_INX
          CONDITIONS_IN    = CONDITIONS_IN
          CONDITIONS_INX   = CONDITIONS_INX
          PARTNERCHANGES   = PARTNERCHANGES.   


      READ TABLE PT_RETURN WITH KEY TYPE    = 'S'
                                    ID      = 'V1'
                                    NUMBER  = '311'.


      IF SY-SUBRC EQ 0.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            WAIT = 'X'.
      ELSE.
        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
      ENDIF.

    **************************************************************

    更改订单文本信息的bapi

    lt_order_header_inx-updateflag = 'U'.
            APPEND lt_order_header_inx.

            CONDENSE gt_out-headtext.
            lt_order_text-doc_number = lt_salesdocument.
            lt_order_text-text_id = 'Z002'.
            lt_order_text-langu = 1.
            lt_order_text-text_line = gt_out-headtext.
            APPEND lt_order_text.

            CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
              EXPORTING
                salesdocument    = lt_salesdocument
                order_header_inx = lt_order_header_inx
              TABLES
                return           = lt_return
                order_text       = lt_order_text.

            CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
              EXPORTING
                wait = 'X'.
    *****************************************************************************

    tcode对应的bapi

    Here is a list of the BAPIs which can be used instead of BDC for a transaction.

    Transaction  BAPI 
    MM01  BAPI_MATERIAL_SAVEDATA 
    MM02  BAPI_MATERIAL_SAVEDATA 
    VA01  BAPI_SALESORDER_CREATEFROMDAT2 
    VA02  BAPI_SALESORDER_CHANGE 
    ME21/ME21n  BAPI_PO_CREATE1 
    ME22/ME22n  BAPI_PO_CHANGE 
    ME51  BAPI_REQUISITION_CREATE 
    AS01  BAPI_FIXEDASSET_CREATE1 
    AS02  BAPI_FIXEDASSET_CHANGE 

     

     

     

    Transaction BAPI
    MM01 BAPI_MATERIAL_SAVEDATA
    MM02 BAPI_MATERIAL_SAVEDATA
    VA01 BAPI_SALESORDER_CREATEFROMDAT2
    VA02 BAPI_SALESORDER_CHANGE
    ME21/ME21n BAPI_PO_CREATE1
    ME22/ME22n BAPI_PO_CHANGE
    ME51 BAPI_REQUISITION_CREATE
    AS01 BAPI_FIXEDASSET_CREATE1
    AS02 BAPI_FIXEDASSET_CHANGE

    来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17204926/viewspace-612853/,如需转载,请注明出处,否则将追究法律责任。

    请登录后发表评论 登录
    全部评论

    注册时间:2009-01-01

    • 博文量
      59
    • 访问量
      311516