Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

BAPI_SALESORDER_CREATEFROMDAT1

When I run this BAPI with the following item table the item quantity, in the sales order, is always 0. What could be wrong? wa_item-quantity holds the correct quantity and so does item-target_qty but they aren't being transfered to the order.

 LOOP AT it_item INTO wa_item.
    item_number = item_number + 10.
    itemx-updateflag = 'I'.
    item-itm_number = item_number.
    itemx-itm_number = 'X'.
    item-material = wa_item-matnr.
    itemx-material = 'X'.
    item-plant = '0010'.
    itemx-plant = 'X'.
    item-target_qty = wa_item-quantity.
    itemx-target_qty = 'X'.
    item-target_qu = 'ROL'.
    itemx-target_qu = 'X'.
    item-sales_unit = 'ROL'.
    itemx-sales_unit = 'X'.
*    item-item_categ = 'NORM'.
*    itemx-item_categ = 'X'.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = item-target_qty
      IMPORTING
        output = item-target_qty.

    APPEND item.
    APPEND itemx.
  ENDLOOP.

Davis

Tags:
replied

I pass the qty. in the field req_qty. I am on ECC6.0 and the orders are created without any problems.

Here is the code for the item table:

LOOP AT x_upload ASSIGNING <fs_upload>.

ls_item-material = <fs_upload>-matnr.

ls_item-req_qty = <fs_upload>-quantity.

  • process the quantity, it needs to be three decimals, because it

  • will be moved into a string in the BAPI and divided by 1000 before

  • it is moved back into a number field (1.500 => 001500 => 1.5)

ls_item-req_qty = ls_item-req_qty * 1000.

  • truncate remaining decimal places if exist (1.2525 => 1252.5 => 1252 => 1.252)

ls_item-req_qty = trunc( ls_item-req_qty ).

ls_item-item_categ = ls_screen-item_cat.

append ls_item to lt_item.

  • now we can get rid of the entry and save memory

DELETE x_upload.

ENDLOOP.

CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA'

EXPORTING

order_header_in = ls_header

business_object = gc_bus_obj

IMPORTING

SALESDOCUMENT = lv_vbeln

RETURN = ls_return

tables

order_items_in = lt_item

order_partners = lt_partner.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question