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_CREATEFROMDAT2 conditions problem

Former Member
0 Likes
1,053

Hi ppl,

Im getting a problem with "BAPI_SALESORDER_CREATEFROMDAT2", when creating a new document some conditions are created automaticaly when using "VA01", but with the bapi they are not created, that particular conditions are calculated based on the result os other conditions, i've already tried to pass the conditions in the appropriate structure but when i do so, the conditions are created with value zero. Can anyone help me out ?

Thx in advance .

4 REPLIES 4
Read only

Former Member
0 Likes
679

Ricardo,

What are the conditions?

Read only

0 Likes
679

John,

The conditions were created by us, with price determination generated by SAP. Aditionally i can tell you that when I consult the sales order with transaction "VA03" the condition is red (with no value) and with the message "Inactive via formlae of incorrect".

Best regards.

Read only

Former Member
0 Likes
679

Hi,

Here is the whole program...

TYPES:

  • Type declaration for the internal table containing MMLS record set

  • from the file at application server.

BEGIN OF ty_infile,

dirid(2) TYPE c, "Data ID

dienp(6) TYPE c, "Employee number

dimcu(6) TYPE c, "Warehouse code

didoco(8) TYPE c, "ST order number

dicus(8) TYPE c, "Customer/Hospital/Sales rep #

dimdel(14) TYPE c, "Item number

disal(15) TYPE c, "Lot/Serial number

diubd(8) TYPE c, "Use-by-date

diqty(3) TYPE c, "Quantity

diupdt(8) TYPE c, "Update date

diuptm(6) TYPE c, "Update time

END OF ty_infile.

constants: c_checked(1) type c value 'X'.

  • local data declaration.

DATA:

  • Internal table for return messages from BAPI FM.

l_t_return TYPE STANDARD TABLE OF bapiret2 INITIAL SIZE 0,

  • Internal table for mail content.

t_mail_body TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0,

  • Internal table for Sales and Distribution Document Item.

l_t_sd_item TYPE STANDARD TABLE OF bapisditm INITIAL SIZE 0,

  • Internal table for Sales and Distribution Document Item Data

  • Checkbox.

l_t_sd_item_x TYPE STANDARD TABLE OF bapisditmx INITIAL SIZE 0,

  • Internal table for SD Document Partner.

l_t_sd_partner TYPE STANDARD TABLE OF bapiparnr INITIAL SIZE 0,

  • Internal table for SD Doc. Schedule Lines.

l_t_sd_schedules TYPE STANDARD TABLE OF bapischdl INITIAL SIZE 0,

  • Structure for Sales and Distribution Document Header.

l_x_sd_header TYPE bapisdhd1,

  • Structure for Sales and Distribution Document Header Check List.

l_x_sd_header_x TYPE bapisdhd1x,

  • Work area for internal table l_t_sd_item.

l_w_sd_item TYPE bapisditm,

  • Work area for internal table l_t_sd_item_x.

l_w_sd_item_x TYPE bapisditmx,

  • Work area for internal table l_t_sd_partner.

l_w_sd_partner TYPE bapiparnr,

  • Work area for internal table t_infile.

l_w_infile TYPE ty_infile,

  • Work area for internal table l_t_sd_schedules.

l_w_sd_schedules TYPE bapischdl,

l_w_content TYPE solisti1, "Mail body heading.

  • Valiable for created sales order number.

l_vbeln TYPE vbeln_va, "Sales order number

l_index TYPE sytabix. "Index of current record

  • Populate the SD header data.

l_x_sd_header-doc_type = 'KA'. "ZKB (Order type)

l_x_sd_header-sales_org = 'S003'. "Sales organization

l_x_sd_header-distr_chan = '10'. "Distribution channel

l_x_sd_header-division = '00'. "Sales division

  • l_x_sd_header-created_by = c_author. "'MMLS'

  • Populate the SD header data check list.

l_x_sd_header_x-doc_type = c_checked.

l_x_sd_header_x-sales_org = c_checked.

l_x_sd_header_x-distr_chan = c_checked.

l_x_sd_header_x-division = c_checked.

  • l_x_sd_header-created_by = c_checked.

  • Populate SD item data check list.

l_w_sd_item_x-itm_number = c_checked.

l_w_sd_item_x-material = c_checked.

l_w_sd_item_x-batch = c_checked.

l_w_sd_item_x-store_loc = c_checked.

l_w_sd_item_x-plant = c_checked.

APPEND l_w_sd_item_x TO l_t_sd_item_x.

  • Populate SD item data

l_w_sd_item-itm_number = 10. "Item number

l_w_sd_item-material = '00721902285240'. "Material Number

l_w_sd_item-batch = '0000002479'. "Batch number

l_w_sd_item-store_loc = '4000'. "Storage location

l_w_sd_item-plant = '1012'. "Plant(MMLS)'1115'

APPEND l_w_sd_item TO l_t_sd_item.

l_w_sd_partner-partn_numb = '0001000002'.

l_w_sd_partner-partn_role = 'AG'.

APPEND l_w_sd_partner TO l_t_sd_partner.

l_w_sd_partner-partn_numb = '0000100024'.

l_w_sd_partner-partn_role = 'SB'.

APPEND l_w_sd_partner TO l_t_sd_partner.

  • Populating the sales order schedule line item data

l_w_sd_schedules-itm_number = 10 . "Item number

l_w_sd_schedules-req_qty = '1'. "Quantity

APPEND l_w_sd_schedules TO l_t_sd_schedules.

call function 'BAPI_SALESORDER_CREATEFROMDAT2'

exporting

  • SALESDOCUMENTIN =

order_header_in = l_x_sd_header

ORDER_HEADER_INX = l_x_sd_header_x

  • SENDER =

  • BINARY_RELATIONSHIPTYPE =

  • INT_NUMBER_ASSIGNMENT =

  • BEHAVE_WHEN_ERROR =

  • LOGIC_SWITCH =

  • TESTRUN =

  • CONVERT = ' '

IMPORTING

SALESDOCUMENT = l_vbeln

tables

RETURN = l_t_return

ORDER_ITEMS_IN = l_t_sd_item

ORDER_ITEMS_INX = l_t_sd_item_x

order_partners = l_t_sd_partner

ORDER_SCHEDULES_IN = l_t_sd_schedules.

  • ORDER_SCHEDULES_INX =

  • ORDER_CONDITIONS_IN =

  • ORDER_CONDITIONS_INX =

  • 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 =

  • .

  • Check for success of sales order creation.

DELETE l_t_return WHERE type EQ 'S' OR

type EQ 'I'.

  • If no data is left then sales order successfully created.

IF l_t_return[] IS INITIAL.

  • Commit work and exit from the subroutine.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = c_checked.

write l_vbeln.

else.

  • Prepare the heading of mail subject.

WRITE 'Row id' TO l_w_content+2. "Row ID

WRITE '|' TO l_w_content+9. "Vertical bar ' | '

WRITE 'status' TO l_w_content+12. "Status

WRITE '|' TO l_w_content+19. "Vertical bar ' | '

WRITE 'Sales order' TO l_w_content+22. "Sales order

WRITE '|' TO l_w_content+32. "Vertical bar ' | '

WRITE 'Message' TO l_w_content+34. "Message

  • The header of the report to the mail body

INSERT l_w_content INTO t_mail_body INDEX 1.

call function 'ZZZCAP_EMAIL_ADDR'

exporting

i_devid = 'IDD0107'

I_SUBJECT = 'ERROR RECORD'

TABLES

T_BODY = t_mail_body

EXCEPTIONS

INVALID_ID = 1

MAIL_NOT_SENT = 2

OTHERS = 3.

IF sy-subrc <> 0.

  • Set the error flag for error in sending mails.

write:/ 'not success'.

ENDIF.

endif.

Read only

Former Member
0 Likes
679

Hi there,

Aditionally, i can tell you that the conditions are created with value zero and i'n the purchase order when i doble-click on the conditions i get the message "Condition type is not determined using condition records".

Thx.