‎2006 Jul 28 8:26 AM
Hi
I try to create a salesorder with FM: SD_SALESDOCUMENT_CREATE
I haven't any problem by creating only one line, but when I have more than one line, I got problems.
I guess it is something with the itemlines, but not sure... And can't see what the problem is.
My code looks like this:
DATA: order_header_in LIKE bapisdhd1.
DATA: order_items_in TYPE STANDARD TABLE OF bapisditm WITH HEADER LINE.
DATA: order_schedules_in
TYPE STANDARD TABLE OF bapischdl WITH HEADER LINE.
DATA: order_partners TYPE STANDARD TABLE OF bapiparnr WITH HEADER LINE.
DATA: return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.
data: itemx like bapisditmx occurs 10 with header line.
order_header_in-doc_type = 'ZWV'.
order_header_in-sales_org = '1000'.
order_header_in-distr_chan = '10'.
order_header_in-division = '10'.
order_header_in-purch_date = sy-datum.
order_header_in-purch_no_c = 'BAPITEST'.
order_partners-partn_role = 'AG'.
order_partners-partn_numb = '0001000005'.
APPEND order_partners.
order_partners-partn_role = 'ZS'.
order_partners-partn_numb = '1046'.
APPEND order_partners.
IF ORDER_HEADER_IN-DOC_TYPE = 'ZWV'.
ORDER_PARTNERS-ITM_NUMBER = '10'.
order_partners-partn_role = 'ZO'.
order_partners-partn_numb = '0001000005'.
APPEND order_partners.
ENDIF.
*** add next line with more than one item
order_items_in-itm_number = '000010'.
order_items_in-material = '000000000000111111'.
order_items_in-target_qty = '1.000'.
order_items_in-target_qu = 'ST'.
order_items_in-sales_unit = 'ST'.
APPEND order_items_in.
order_schedules_in-req_qty = '1.000'.
APPEND order_schedules_in.
*Add following lines with more than one line
itemx-itm_number = '000010'.
itemx-updateflag = 'I'.
itemx-material = 'X'.
itemx-target_qty = 'X'.
append itemx.
order_items_in-itm_number = '000020'.
order_items_in-material = '000000000000111111'.
order_items_in-target_qty = '1.000'.
order_items_in-target_qu = 'ST'.
order_items_in-sales_unit = 'ST'.
APPEND order_items_in.
order_schedules_in-req_qty = '1.000'.
APPEND order_schedules_in.
itemx-itm_number = '000020'.
itemx-updateflag = 'I'.
itemx-material = 'X'.
itemx-target_qty = 'X'.
append itemx.
*stop add more lines
REFRESH return.
BREAK-POINT.
CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
EXPORTING
sales_header_in = order_header_in
TABLES
return = return
sales_items_in = order_items_in
sales_items_inx = itemx
sales_partners = order_partners
sales_schedules_in = order_schedules_in.
COMMIT WORK AND WAIT.
LOOP AT return.
WRITE: / return.
ENDLOOP.
Hope somebody can/will help me
Message was edited by: Lars Majlund
‎2006 Jul 28 8:30 AM
Hi,
u need to enter item nunber in Schedule lines structure also.
If this works fine...ok... else try passing schedule lines X structures also.
Sreedhar
‎2006 Jul 28 8:30 AM
Hi,
u need to enter item nunber in Schedule lines structure also.
If this works fine...ok... else try passing schedule lines X structures also.
Sreedhar
‎2006 Jul 28 8:49 AM
Hi Lars,
Point-1:
Instead of this FM, you should use <b>BAPI_SALESORDER_CREATEFROMDAT2</b> as the FM which you are using is internal FM used by SAP.
This same FM is used by the BAPI which I have mentioned above. SO i do not think there will be much change in your code.
Point-2:
As you are creating line items , try not using ORDER_ITEMS_INX table, simply use <b>ORDER_ITEMS_IN</b> table only.
Point-3:
For <b>ORDER_SCHEDULES_IN</b> table, also populate Item number along with reqd qty.
Point-4:
Could you pls let us know whether any error/ warning msg you are getting in <b>Return</b> table once you take care of all above points?
Regds,
Akshay Bhagwat
‎2020 Jan 07 12:33 PM
S V4 233 SALES_HEADER_IN has been processed successfully E 00 055 Fill in all required entry fields E V4 248 Error in SALES_ITEM_IN 000010 W V1 555 The sales document is not yet complete: Edit data E 00 055 Fill in all required entry fields