Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Confirmed Quantity

Former Member
0 Likes
533

Hello Everbody,

i´m using the Bapi_Salesorder_Simulate to get net price of a material. But i have a problem.

The confirmed quantity that returns the bapi is 0 when i enter a higher quantity that the available stock. When i enter a lower or equal quantity that the available stock, the bapi returns the correct confirmed quantity. I need that when i enter a higher quantity, the bapi returns me the max quantity available. Is this possible?

Thank you!

1 REPLY 1
Read only

Former Member
0 Likes
408

try to this


REPORT  ZSALESORDER_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 = '000000000000020927'.
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.