当前位置:首页 > Windows程序 > 正文

BAPI 修改销售订单的方法 ‘BAPI

2021-03-25 Windows程序

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

Delete the whole order

Delete order items

Change the order

Change the configuration

Notes

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.

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

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/67570.html