‎2006 Apr 04 2:46 PM
Hai i was un able to create a sales order using the BAPI can you help me out
‎2006 Apr 04 2:49 PM
‎2006 Apr 04 2:54 PM
Hi,
Check interface repository.
http://ifr.sap.com Go to Logistics->Sales and Distribution -> Sales
or u can varify this also
With a where-used list you can find, where this FM is used, and in the debugger you can see the passed values.
(OK, you still have to find in which transaction it's used, but you can use the where used list.)
Eg it's used in FM IDOC_INPUT_SALESORDER_CREATEFR, I guess it's called during Idoc creation, so put a break-point there and check what happens....may be you need to set up your ALE for this.
‎2006 Apr 04 2:57 PM
Sample Code:
clear: l_order_header,
l_salesdocument,
l_order_partners,
l_order_items,
l_order_schdl.
refresh: it_order_items,
it_order_partners,
it_order_schdl,
it_return.
???????? get from material ...
Order header
l_order_header-doc_type = 'ZQBV'.
l_order_header-distr_chan = '10'.
l_order_header-division = '00'.
if g_qals-werk eq '1100'.
l_order_header-sales_org = '1000'.
else.
if g_qals-werk eq '3100'.
l_order_header-sales_org = '3000'.
else.
message i001(00) with text-005.
endif.
endif.
l_order_header-purch_no_c = g_qals-prueflos. " <= lot
Partner data
l_order_partners-partn_role = 'AG'.
l_order_partners-partn_numb = g_qals-kunnr.
append l_order_partners to it_order_partners.
Order items => only one
l_order_items-itm_number = 10.
l_order_items-material = g_qals-matnr.
l_order_items-target_qty = 1.
append l_order_items to it_order_items.
Schedules for quantity
l_order_schdl-itm_number = 10.
l_order_schdl-req_qty = 1. " <= only 1 !
append l_order_schdl to it_order_schdl.
Conditions for value
l_order_conditions-itm_number = 10.
l_order_conditions-cond_type = 'PR00'.
l_order_conditions-cond_value = g_effort_sum.
l_order_conditions-currency = g_effort_unit.
append l_order_conditions to it_order_conditions.
BAPI to create sales order
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
SALESDOCUMENTIN =
ORDER_HEADER_IN = l_order_header
ORDER_HEADER_INX =
SENDER =
BINARY_RELATIONSHIPTYPE =
INT_NUMBER_ASSIGNMENT =
BEHAVE_WHEN_ERROR =
LOGIC_SWITCH =
TESTRUN =
CONVERT = ' '
IMPORTING
SALESDOCUMENT = l_salesdocument
TABLES
RETURN = it_return
ORDER_ITEMS_IN = it_order_items
ORDER_ITEMS_INX =
ORDER_PARTNERS = it_order_partners
ORDER_SCHEDULES_IN = it_order_schdl
ORDER_SCHEDULES_INX =
ORDER_CONDITIONS_IN = it_order_conditions
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 =
.
if not l_salesdocument is initial.
order successfully created
message i001(00) with text-001 l_salesdocument.
call function 'BAPI_TRANSACTION_COMMIT'.
endif.
Regards,
Ravi
‎2006 Apr 04 6:58 PM
Hi Srikanth,
Can you check whether you are calling the function module BAPI_TRANSACTION_COMMIT after calling BAPI_SALESORDER_CREATEFROMDAT2.
Thanks,
Sreekanth
‎2006 Apr 04 10:29 PM
Instead of saying 'I am unable to', it will help if you specify the exact problem you are facing.
Try using, 'I am getting such and such error' or
'everything looks ok and no error messages returned, but when I check in VA03, it says document does not exist'.. etc.(commit not done)
This way you will have a better chance of getting a correct answer quickly.