Application Development 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: 

order with referance to a contract using BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Kudos

Hi All,

I tried to create an order with reference to a sales contract .

1) I passed the contract number to the field REF_DOC at header level , But I got the error message" Document 4000003639 doesn't have document " where 4000003639 was the contract number . am i missing anything ? Is there any other values that has to be passed ?Can anyone help me on this ?

2) I also tried passing the contract number at item level as suggested in earlier posts on this subject , but the sales order was created without any reference to the contract .

Please help me on this issue .

Thanks & Regards

Beena

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Beena,

The reference should be at the line item level of the BAPI (BAPISDITM). And you should specify both REF_DOC, REF_DOC_IT (Doc no and line item no. of the contract).

Try this and let me know.

Regards,

Ravi

Note : Please mark the helpful answers.

13 REPLIES 13

Former Member
0 Kudos

Hi,

Any update??

Thanks

Beena

Former Member
0 Kudos

Beena,

The reference should be at the line item level of the BAPI (BAPISDITM). And you should specify both REF_DOC, REF_DOC_IT (Doc no and line item no. of the contract).

Try this and let me know.

Regards,

Ravi

Note : Please mark the helpful answers.

Former Member
0 Kudos

Hi Beena,

You can use this piece of code as reference,

*Fill the header information for the order.

wa_order_header_in-doc_type = Sales Doc type of order to be created.

wa_order_header_in-sales_org = sales org.

wa_order_header_in-distr_chan = distribution channel.

wa_order_header_in-division = division.

wa_order_header_in-ref_doc = contract number(This is the contract u refer to).

wa_order_header_in-refdoc_cat = 'G' (G stands for contract).

*Fill the item level information for the order.

wa_order_items_in-itm_number = item number.

wa_order_items_in-material = material number.

wa_order_items_in-ref_doc = contract number(This is the contract u refer to).

wa_order_items_in-ref_doc_it = Item number of contract u create.

wa_order_items_in-ref_doc_ca = 'G'.

APPEND wa_order_items_in TO i_order_items_in.

*Fill the schedule line information for the order.

wa_order_schedules_in-itm_number = item number.

wa_order_schedules_in-sched_line = 1.

wa_order_schedules_in-req_qty = order quantity.

APPEND wa_order_schedules_in TO i_order_schedules_in.

CLEAR: lwa_order_items_in,

lwa_order_schedules_in.

*Fill the partner information for the order.

wa_order_partners-partn_role = partner function.

wa_order_partners-partn_numb = partner number.

APPEND wa_order_partners TO i_order_partners.

wa_order_partners.

CLEAR w_vbeln.

*Call the order creation BAPI.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

  • salesdocumentin =

order_header_in = wa_order_header_in

  • order_header_inx = wa_order_header_inx

  • sender =

  • binary_relationshiptype =

  • int_number_assignment =

  • behave_when_error =

  • logic_switch = lv_logic_switch

  • testrun =

  • convert = ' '

IMPORTING

salesdocument = w_vbeln

TABLES

return = i_return

order_items_in = i_order_items_in

  • order_items_inx =

order_partners = i_order_partners

order_schedules_in = i_order_schedules_in

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

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • wait =

  • IMPORTING

.

Former Member
0 Kudos

Hi Ravi/Saji.

Thanks for your reply.

I tried passing the contract number to the item level

and also replicated the logic as specified by saji

This case sales order has been created without any reference to the contract . I.e. , The contract number field in the order remained blank and the order quantity didn't get reduced from the open quantity of the contract . But this sales order number got updated in the document flow of the contract .

Thanks

Beena

0 Kudos

Hi Beena,

Are you looking at VBAK-VGBEL to find the contract number of the sales order?

The open quantity in contract will not updated by SAP. Even if you create an order manully with reference to a contract you can see this.

Regards,

Saji.

Former Member
0 Kudos

Hi Sajith ,

My requirement is that for a particular soldto shipto material a contract number will be maintained in Ztable . I need to create the sales order with referance to that contract. So it is that contract number pass to the REF_DOC field .

No , Manually through when we create sales order with referance to a contract the open order quantity do get updated . I have tested that .

Regards

Beena

0 Kudos

Hi Beena,

Where is it that you are not able to see the contract number?

Rgds,

Saji.

0 Kudos

Hi Beena

When you create a sales order with reference to a contract, the quantity does NOT get updated on the contract. It gets reflected on the document flow and once you have exhausted the qty, the system will not let you create new sales order with reference to that contract.

I dont have access to the system right now, but from what I remember you would need to pass at the item level, ref doc no, ref doc category, item category and preceeding doc type.

On the sales order the contract number is only shown on the document flow.

Do let me know if you are still stuck and I will try and send you the code.

Maninder..

0 Kudos

Look at OSS note # 774346

Hope this’ll give you idea!!

<b>P.S award the points.</b>

Good luck

Thanks

Saquib Khan

"Some are wise and some are otherwise"

0 Kudos

Maninder,

Thanks for the reply .

The quantity do get updated when we create with reference through Va01 . This i had tested and found out that each time we create a sales order with reference to a contract in va01 , order quantity get reduced from open quantity of the contract.

Yes , i passed the data at item level and sales order is created and also the contract number is displayed in the document flow . But the contract didn't get update .

Just came to know that BAPI_SALESORDER_CREATEFROMDAT2 will not update contract quantity and that we need to use another BAPI to update the contract . I am exploring that option now

Sajith ,

Contract number is displayed as an enhancment field at ITEM-SALES A .A VBAP extension field . To populte value to that i need to pass the values in EXTENSION field of the BAPI

Thanks

Beena

0 Kudos

Hi all ,

I solved the issue.There was a mismatch in the order line item number and contract line item number which i passed to the BAPI. Instead of '0001' I passed '0010' to ITEM_DATA-REF_DOC_IT.

Thus BAPI_SALESORDER_CREATEFROMDAT2 was successful in creating the order with reference to the contract . It also updates the contract ( reduces the open quantity) once the order is created .

Thanks all for the timely response. I have given the reward points .

Thanks once again

Regards

Beena

0 Kudos

Ravi/Beena/Hari/All,

Thank You very much for the solution. It worked for us. There is a note in SAP 370988 saying we cannot do this.But you guys did it.

Thumbsup

Thanks,

Mathew

0 Kudos

Hi Beena Prabha,

We are also facing the same problem while creating Sales Order from BAPI_SALESORDER_CREATEFROMDAT2 with reference to contract, As Sales Order gets created but Contract related information is not updated and document is incomplete.

Although we have maintained all the related fields for Reference Doc, related fields for SO creation and also checked the Item no. related things you have mentioned in your post but no changes observed.

We have maintaied following fields in BAPI for SO Creation, Please let us know if something is missing/not maintained.

Order_Header_In:

DOC_TYPE

SALES_ORG

DISTR_CHAN

DIVISION

REFDOCTYPE

Order_Items_In:

MATERIAL

REF_DOC

ITM_NUMBER

REF_DOC_IT

REF_DOC_CA

ORDER_PARTNERS

PARTN_ROLE

PARTN_NUMB

ORDER_SCHEDULES_IN

ITM_NUMBER

REQ_QTY

Your help will be highly appreciated.

Regards,

Nitin Patil