码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2015-09-09 01:04:36      阅读:336      评论:0      收藏:0      [点我收藏+]

标签:

分类: Linux

 

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  

 

 

 

 

TransactionBAPI
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

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

标签:

原文地址:http://www.cnblogs.com/lojamm/p/4793412.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!