Google Translator
Hi,
I have implemented a program with the BAPI_SALESORDER_CREATEFROMDAT2, and although properly filled all the required fields, including the field of quantity with the value 1, the document is created correctly but the position appears 0 and therefore the document does not calculate the value field overall.
He sought any notes or other OSS thread describing the problem and nothing found.
Sending the code of the test program.
Regards,
Jhonny
REPORT zpruebajm08.
DATA:
* Order partners
li_order_partners TYPE STANDARD TABLE OF bapiparnr,
l_order_partners LIKE bapiparnr,
* Structures for order header
l_order_header_in LIKE bapisdhd1,
l_order_header_inx LIKE bapisdhd1x,
* Tables for order items
li_order_items_in TYPE STANDARD TABLE OF bapisditm,
l_order_items_in LIKE bapisditm,
li_order_items_inx TYPE STANDARD TABLE OF bapisditmx,
l_order_items_inx LIKE bapisditmx,
* Return table from bapi call
li_return TYPE STANDARD TABLE OF bapiret2,
l_return TYPE bapiret2,
* Sales document number
l_vbeln LIKE bapivbeln-vbeln,
* Error flag
l_errflag(1) TYPE c.
*------------------------------------------------------------------
* Build partner information
*------------------------------------------------------------------
CLEAR l_order_partners.
l_order_partners-partn_role = 'AG'.
l_order_partners-partn_numb = '0000001000'.
APPEND l_order_partners TO li_order_partners.
*------------------------------------------------------------------
* Build order header
*------------------------------------------------------------------
* Update flag
l_order_header_inx-updateflag = 'I'.
* Sales document type
l_order_header_in-doc_type = 'TA'.
l_order_header_inx-doc_type = 'X'.
* Sales organization
l_order_header_in-sales_org = '1000'.
l_order_header_inx-sales_org = 'X'.
* Distribution channel
l_order_header_in-distr_chan = '10'.
l_order_header_inx-distr_chan = 'X'.
* Division
l_order_header_in-division = '00'.
l_order_header_inx-division = 'X'.
*------------------------------------------------------------------
* Build order item(s) - Only 1 is used in this example
*------------------------------------------------------------------
l_order_items_in-itm_number = '10'.
l_order_items_inx-itm_number = '10'.
l_order_items_in-material = 'GTS-14001'.
l_order_items_inx-material = 'X'.
l_order_items_in-target_qty = '1.000'.
l_order_items_inx-target_qty = 'X'.
APPEND l_order_items_in TO li_order_items_in.
l_order_items_inx-updateflag = 'I'.
APPEND l_order_items_inx TO li_order_items_inx.
*------------------------------------------------------------------
* CALL Bapi
*------------------------------------------------------------------
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = l_order_header_in
order_header_inx = l_order_header_inx
* testrun = 'X'
IMPORTING
salesdocument = l_vbeln
TABLES
return = li_return
order_items_in = li_order_items_in
order_items_inx = li_order_items_inx
order_partners = li_order_partners.
*------------------------------------------------------------------
* Check and write Return table
*------------------------------------------------------------------
CLEAR l_errflag.
WRITE: / 'Sales document: ', l_vbeln.
LOOP AT li_return INTO l_return.
WRITE: / l_return-type, l_return-message.
IF l_return-type = 'E'.
l_errflag = 'X'.
ENDIF.
ENDLOOP.
*------------------------------------------------------------------
* No errors - Commit
*------------------------------------------------------------------
IF l_errflag IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
.
ENDIF.