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

BAPI_SALESORDER_CREATEFROMDAT1

Former Member
0 Likes
2,530

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,108

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.

10 REPLIES 10
Read only

Former Member
0 Likes
2,108

Davis,

try using 'CONVERSION_EXIT_ALPHA_OUTPUT'.

reward if it helps,

Satish

Read only

0 Likes
2,108

Satish,

That didn't do anything, thanks though.

Davis

Read only

Former Member
0 Likes
2,108

For the CREATEFROMDAT1 to accept the quantity you have to pass in the qty on the schedule line level, then it is put into the sales order.

In my case I didn't want to pass in schedule line information therefore I used BAPI 'BAPI_SALESDOCU_CREATEFROMDATA'. This accepts the qty on item level (req_qty). The only thin is you have to multiply the qty. by 1000 because the BAPI divides it by 1000.

Use 'BUS2032' as business object. This is for Sales Orders.

Hope that helps,

Michael

Read only

0 Likes
2,108

Michael,

Thanks but that didn't seem to work either.

Davis

Read only

0 Likes
2,108

Davis,

Why don't you use SAP BAPI_SALESORDER_CREATEFROMDAT2 ?

is your version is older than 4.6C ?

Check the sample code on BAPI_SALESORDER_CREATEFROMDAT2 :

REPORT ZSO_TEST no standard page heading.

data so_header like bapisdhd1. " sales doc header

data so_item like bapisditm occurs 0 with header line. " sales doc item

data so_partnr like bapiparnr occurs 0 with header line." partner detail

data so_return like bapiret2 occurs 0 with header line.

data : g_vbeln like bapivbeln-vbeln.

*filling the header details .

so_header-doc_type = 'TA'.

so_header-sales_org = '1000'.

so_header-distr_chan = '01'.

so_header-division = '01'.

so_header-CREATED_BY = 'DEV09'.

so_header_PURCH_NO_C = ''.

break-point.

*filling the item data.

so_item-material = 'H10002000'.

so_item-target_qty = '10'.

so_item-target_qu = 'EA'.

so_item-PURCH_NO_C = '*'.

append so_item.

*filling the partner details

so_partnr-PARTN_ROLE = 'AG'.

so_partnr-PARTN_NUMB = '0000000457'.

append so_partnr.

*calling the bapi function module .

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

  • SALESDOCUMENTIN =

order_header_in = so_header

  • ORDER_HEADER_INX =

  • SENDER =

  • BINARY_RELATIONSHIPTYPE =

  • INT_NUMBER_ASSIGNMENT =

  • BEHAVE_WHEN_ERROR =

  • LOGIC_SWITCH =

  • TESTRUN =

  • CONVERT = ' '

IMPORTING

SALESDOCUMENT = g_vbeln

tables

RETURN = so_return

ORDER_ITEMS_IN = so_item

  • ORDER_ITEMS_INX =

order_partners = so_partnr

  • ORDER_SCHEDULES_IN =

  • ORDER_SCHEDULES_INX =

  • ORDER_CONDITIONS_IN =

  • ORDER_CFGS_REF =

  • ORDER_CFGS_INST =

  • ORDER_CFGS_PART_OF =

  • ORDER_CFGS_VALUE =

  • ORDER_CFGS_BLOB =

  • ORDER_CFGS_VK =

  • ORDER_CFGS_REFINST =

  • ORDER_CCARD =

  • ORDER_TEXT =

  • ORDER_KEYS =

  • EXTENSIONIN =

  • PARTNERADDRESSES =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = space

  • IMPORTING

  • RETURN = so_return

.

Thanks

Seshu

Read only

Former Member
0 Likes
2,108

Here is every piece of code that touches the data in question:

TYPES: BEGIN OF ty_item,
  matnr LIKE vbap-matnr,
  size(5) TYPE c,
  quantity LIKE bapiitemin-target_qty,
 END OF ty_item.

DATA: it_item TYPE TABLE OF ty_item,
      wa_item LIKE LINE OF it_item.

...

* this is in a loop
SPLIT filestring AT character INTO: wa_item-matnr wa_item-size quantity.
        wa_item-quantity = quantity.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = wa_item-matnr
          IMPORTING
            output = wa_item-matnr.

        APPEND wa_item TO it_item.
* end loop

...

FORM fillitems .

  DATA: item_number TYPE i VALUE 0.

  CLEAR: wa_item, item, itemx.
  REFRESH: item, itemx.

  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'.
    wa_item-quantity = wa_item-quantity * 1000.
    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_OUTPUT'
*      EXPORTING
*        input  = item-target_qty
*      IMPORTING
*        output = item-target_qty.


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

    APPEND item.
    APPEND itemx.
  ENDLOOP.

...

  CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA'
    EXPORTING
      order_header_in           = header
      business_object           = 'BUS2032'
*     WITHOUT_COMMIT            = ' '
*     CONVERT_PARVW_AUART       = ' '
   IMPORTING
     salesdocument             = z_vbeln
*     SOLD_TO_PARTY             =
*     SHIP_TO_PARTY             =
*     BILLING_PARTY             =
     return                    = return
    TABLES
      order_items_in            = item
      order_partners            = partner
*     ORDER_ITEMS_OUT           =
*     ORDER_CFGS_REF            =
*     ORDER_CFGS_INST           =
*     ORDER_CFGS_PART_OF        =
*     ORDER_CFGS_VALUE          =
*     ORDER_CFGS_BLOB           =
*     ORDER_CCARD               =
*     ORDER_SCHEDULE_EX         =
            .

Any ideas?

Regards,

Davis

Read only

0 Likes
2,108

Hi Davis,

one more try...

can u declare a variable as like wa_item-matnr and pass the value to that variable before calling the FM CONVERSION_EXIT_*. use same variable for I/P & O/P.

this is just a try i am not sure...

Satish

Read only

0 Likes
2,108

You have to fill the structure BAPISDHEDU ,field name REQ_QTY

Thanks

Seshu

Read only

Former Member
0 Likes
2,109

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.

Read only

0 Likes
2,108

Michael,

Thanks, I am using the wrong field for the quantity.

Davis