cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI to Create Sales order with reference to Contract

Former Member
0 Kudos
1,517

Hi,

I am using bapi 'BAPI_SALESORDER_CREATEFROMDAT2' to create a sales order with reference to contract. I am getting a error 'Address category does not exist '. Am i missing any thing in my code.

e_contract_header_in-refdoc_cat = 'G'.

e_contract_header_in-ref_doc = gv_vbeln.

e_contract_header_in-refdoctype = 'ZDIR'.

e_contract_header_in-doc_type = 'ZSH'.

e_contract_header_in-sales_org = vbak-vkorg.

e_contract_header_in-distr_chan = 'ZD'.

e_contract_header_in-division = 'CA'.

  • Header data check list

e_contract_header_inx-updateflag = 'I'.

  • e_contract_header_inx-refdoc_cat = c_x.

e_contract_header_inx-ref_doc = c_x.

e_contract_header_inx-doc_type = c_x.

e_contract_header_inx-sales_org = c_x.

e_contract_header_inx-distr_chan = c_x.

e_contract_header_inx-division = c_x.

LOOP AT t_vbap.

s_contract_items_in-ref_doc = t_vbap-vbeln.

s_contract_items_in-ref_doc_it = t_vbap-posnr.

s_contract_items_in-ref_doc_ca = 'G'.

s_contract_items_in-target_qty = t_vbap-fmeng.

s_contract_items_in-material = t_vbap-matnr.

APPEND s_contract_items_in TO i_contract_items_in.

  • Fill item update table

s_contract_items_inx-itm_number = t_vbap-posnr.

s_contract_items_inx-material = c_x.

s_contract_items_inx-target_qty = c_x.

s_contract_items_inx-refobjtype = c_x.

s_contract_items_inx-ref_doc = c_x.

s_contract_items_inx-ref_doc_it = c_x.

s_contract_items_inx-ref_doc_ca = c_x.

APPEND s_contract_items_inx TO i_contract_items_inx.

s_contract_schedule-itm_number = t_vbap-posnr.

s_contract_schedule-sched_line = sy-tabix.

s_contract_schedule-req_qty = t_vbap-fmeng.

APPEND s_contract_schedule TO i_contract_schedule.

s_contract_schedulex-itm_number = t_vbap-posnr.

s_contract_schedulex-sched_line = sy-tabix.

s_contract_schedulex-updateflag = 'X'.

s_contract_schedulex-req_qty = 'X'.

APPEND s_contract_schedulex TO i_contract_schedulex.

ENDLOOP.

    • Fill Partner Table

s_contract_partners-partn_role = 'AG'.

s_contract_partners-partn_numb = vbak-kunnr.

APPEND s_contract_partners TO i_contract_partners.

s_contract_partners-partn_role = 'WE'.

s_contract_partners-partn_numb = vbak-kunnr.

APPEND s_contract_partners TO i_contract_partners.

  • Call Bapi to create sales order

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

  • SALESDOCUMENTIN =

order_header_in = e_contract_header_in

order_header_inx = e_contract_header_inx

  • SENDER =

  • BINARY_RELATIONSHIPTYPE =

  • INT_NUMBER_ASSIGNMENT =

  • BEHAVE_WHEN_ERROR =

  • LOGIC_SWITCH =

  • TESTRUN =

  • CONVERT = ' '

IMPORTING

salesdocument = iv_sales_doc

TABLES

return = i_return

order_items_in = i_contract_items_in

order_items_inx = i_contract_items_inx

order_partners = i_contract_partners

order_schedules_in = i_contract_schedule

order_schedules_inx = i_contract_schedulex.

Please help me to reslove the issue.

Regards,

Satya.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

No one encountered such kind of problem?

Satya

Former Member
0 Kudos

I got the solution for creating the Sales document with ref to contract...

<b>Now the issue is when there is Sub line items on contract there are not copied up in to the sales order.</b>

Do any body know the reason for this and have the solution of this same?

Thanks in advance.

Satya.

Former Member
0 Kudos

Hi Satya,

Can you share how you were able to create the SO with ref to contract using a BAPI. It will very helpful for all.

Thanks,

Shailesh