Skip to Content
avatar image
Former Member

how to use " BAPI_SALESORDER_SIMULATE "

hi,all

now have such requirement ,as below:

I need get price by call "BAPI_SALESORDER_SIMULATE".

But how to set the parameter " ORDER_ITEMS_IN ". i don't know where normal got "CUST_MAT" ,"REQ_QTY".

plz give me a hand, some sample is good for me

thanks in advance.

kevin

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Sep 11, 2004 at 12:21 PM

    Hello Kevin,

    take this one:

    REPORT  z_salesorder_simulate.
    
    DATA: order_header_in LIKE bapisdhead,
          order_items_in LIKE TABLE OF bapiitemin,
          return LIKE bapireturn,
          wa_order_items_in LIKE LINE OF order_items_in,
          order_partners LIKE TABLE OF bapipartnr,
          wa_order_partners LIKE LINE OF order_partners,
          order_items_out LIKE TABLE OF bapiitemex,
          wa_order_items_out LIKE LINE OF order_items_out.
    
    * Fill order_header_in
    order_header_in-doc_type = 'TA'.
    
    * Fill order_items_in
    wa_order_items_in-material = '000000000000000001'.
    wa_order_items_in-req_qty = '1000'.
    
    APPEND wa_order_items_in TO order_items_in.
    
    * Fill order_items_in
    wa_order_partners-partn_role = 'AG'.
    wa_order_partners-partn_numb = '0000000001'.
    
    APPEND wa_order_partners TO order_partners.
    
    * Execute Function Module BAPI_SALESORDER_SIMULATE
    CALL FUNCTION 'BAPI_SALESORDER_SIMULATE'
      EXPORTING
        order_header_in           = order_header_in
      IMPORTING
        return                    = return
      TABLES
        order_items_in            = order_items_in
        order_partners            = order_partners
        order_items_out           = order_items_out.
    
    * The return structure gives any error messages
    WRITE: return-message.
    
    * Print out the order items
    LOOP AT order_items_out INTO wa_order_items_out.
      WRITE: wa_order_items_out-material,
             wa_order_items_out-short_text,
             wa_order_items_out-subtotal_2.
    ENDLOOP.
    

    Regards

    Gregor

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Kevin,

      extend the example above with this code:

      DATA: it_vbapvb LIKE TABLE OF vbapvb,
            wa_vbapvb LIKE LINE OF it_vbapvb.
      
      * Fill it_VBAPVB
      wa_vbapvb-matnr = '000000000000000001'.
      wa_vbapvb-zmeng = 1.
      
      APPEND wa_vbapvb TO it_vbapvb.
      
      * Fill order_items_in
      LOOP AT it_vbapvb INTO wa_vbapvb.
        wa_order_items_in-material = wa_vbapvb-matnr.
        wa_order_items_in-req_qty = wa_vbapvb-zmeng * 1000.
      
        APPEND wa_order_items_in TO order_items_in.
      ENDLOOP.

      Regards

      Gregor