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: 

Create Sales Order from a contract ( passing net value )

former_member806481
Participant
0 Kudos
1,126

I need to create a sales order for a sales contract and then create a proforma invoice for that sales order however i am getting a pricing error when creating the proforma invoice

Can some tell me what might be going wrong

bellow is the data i am passing to the BAPI_SALESORDER_CREATEFROMDAT2
order_header_in-doc_type = 'ZREX'.
order_header_in-ref_doc = ls_vbak-vbeln.
order_header_in-sd_doc_cat = 'C'.
order_header_in-refdoc_cat = 'G'.
order_header_in-sales_org = ls_vbak-vkorg.
order_header_in-distr_chan = ls_vbak-vtweg.
order_header_in-division = ls_vbak-spart.
* order_items_in-purch_no_c = ls_vbak-ebeln.
order_header_in-sales_off = ls_vbak-vkbur.
order_header_in-purch_no_c = ls_vbak-bstnk.
order_header_in-pmnttrms = ls_vbkd-zterm.
order_header_in-incoterms1 = ls_vbkd-inco1.
order_header_in-price_date = sy-datum.
order_header_in-ord_reason = 'PER'.
order_header_in-bill_date = sy-datum.
order_header_in-purch_no_c = ls_vbkd-bstkd.
order_header_in-purch_no_s = ls_vbkd-bstkd_e.
order_header_in-name = ls_vbak-bname.
order_header_in-po_meth_s = ls_vbkd-bsark_e.

order_header_inx-doc_type = 'X'.
order_header_inx-sales_org = 'X'.
order_header_inx-distr_chan = 'X'.
order_header_inx-division = 'X'.
order_header_inx-sales_off = 'X'.
order_header_inx-purch_no_c = 'X'.
order_header_inx-pmnttrms = 'X'.
order_header_inx-incoterms1 = 'X'.
* order_header_inx-price_date = 'X'.
order_header_inx-sd_doc_cat = 'X'.
order_header_inx-ord_reason = 'X'.
order_header_inx-ref_doc = 'X'.
order_header_inx-refdoc_cat = 'X'.
order_header_inx-bill_date = 'X'.
order_header_inx-purch_no_s = 'X'.
order_header_inx-name = 'X'.
order_header_inx-po_meth_s = 'X'.


*---Partner Details---
order_partners-partn_role = 'AG'.
order_partners-partn_numb = ls_vbpa-kunnr.
APPEND order_partners.
CLEAR : order_partners.

order_partners-partn_role = 'WE'.
order_partners-partn_numb = ls_vbpa-kunnr.
APPEND order_partners.
CLEAR : order_partners.

order_partners-partn_role = 'RE'.
order_partners-partn_numb = ls_vbpa-kunnr.
APPEND order_partners.
CLEAR : order_partners.

order_partners-partn_role = 'RG'.
order_partners-partn_numb = ls_vbpa-kunnr.
APPEND order_partners.
CLEAR : order_partners.

*---Line Items---
order_items_in-itm_number = ls_vbap-posnr.
order_items_in-material = ls_vbap-matnr.
* order_items_in-target_qty = ls_vbap-zmeng.
order_items_in-target_qu = ls_vbap-zieme.
order_items_in-bill_date = lv_to_date.
order_items_in-pmnttrms = ls_vbkd-zterm.
order_items_in-incoterms1 = ls_vbkd-inco1.
*---Convert the WBS element---
CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
EXPORTING
input = ls_vbap-ps_psp_pnr
IMPORTING
OUTPUT = lv_wbs.

*---Convert the WBS element---
order_items_in-wbs_elem = lv_wbs.
order_items_in-plant = ls_vbap-werks.
order_items_in-store_loc = ls_vbap-lgort.
* order_items_in-target_val = ls_vbak-netwr.
order_items_in-ref_doc = ls_vbap-vbeln.
order_items_in-ref_doc_ca = 'G'.
* order_items_in-ref_doc_it = ls_vbap-posnr.
APPEND order_items_in.
CLEAR order_items_in.

order_items_inx-itm_number = ls_vbap-posnr.
order_items_inx-material = 'X'.
* order_items_inx-target_qty = 'X'.
order_items_inx-target_qu = 'X'.
order_items_inx-target_val = 'X'.
order_items_inx-bill_date = 'X'.
order_items_inx-pmnttrms = 'X'.
order_items_inx-incoterms1 = 'X'.
order_items_inx-wbs_elem = 'X'.
order_items_inx-plant = 'X'.
order_items_inx-store_loc = 'X'.
order_items_in-ref_doc = 'X'.
order_items_in-ref_doc_ca = 'X'.
order_items_in-ref_doc_it = 'X'.
APPEND order_items_inx.
CLEAR : order_items_inx.

*---schedul el lines---
order_schedules_in-itm_number = ls_vbap-posnr.
order_schedules_in-req_qty = ls_vbap-zmeng.
APPEND order_schedules_in.
CLEAR : order_schedules_in.

order_schedules_inx-itm_number = ls_vbap-posnr.
order_schedules_inx-req_qty = 'X'.
APPEND order_schedules_inx.
CLEAR : order_schedules_inx.

order_conditions_in-itm_number = ls_vbap-posnr.
order_conditions_in-cond_type = 'PR00'.
order_conditions_in-condvalue = ls_vbak-netwr.
order_conditions_in-cond_value = ls_vbap-netpr.
APPEND order_conditions_in.
CLEAR order_conditions_in.
*
order_conditions_inx-itm_number = ls_vbap-posnr..
order_conditions_inx-cond_type = 'PR00'.
order_conditions_inx-cond_value = 'X'.
APPEND order_conditions_inx.
CLEAR order_conditions_inx.
1 ACCEPTED SOLUTION

venkateswaran_k
Active Contributor
0 Kudos
1,016

Hi atharva12k

atharva12kIt looks like you need to maintain the condition records for the Condition type ZIND - in VK11 ( for the required combination ). In your example the Customer - material or viz..

In my example for ZPD1 - we need to maintain as below. Then it will automatically picks up in SO and put price there.

In your case, check for ZIND for the required combination is the price is maintained here in VK11.

Regards,

Venkat

8 REPLIES 8

venkateswaran_k
Active Contributor
0 Kudos
1,016

Please update your code using CODE option ( code button in toolbar ). This will help us to read with clarity.

Secondly, what was the error message. Please provide the error message you receieved.

venkateswaran_k
Active Contributor
0 Kudos
1,016

Hi atharva12k

The problem you are getting is in invoice, - so creating sales order BAPI may not be a issue.

  1. What is the error you are getting while creating invoice?
  2. How you are creating invoice ( using BAPI or T-code? )
  3. Is your Sales order (incomplete log) is okay?
  4. Is there any copy control rules blocking ?

Regards.

Venkat

former_member806481
Participant
0 Kudos
1,016

this is the error i am getting when creating a PROFORMA INVOICE ( ZTF5 ).

i am creating the invoice using SHDB recording

i shared the code for the BAPI because i wanted to make sure that the data i am passing is correct

venkateswaran_k
Active Contributor
0 Kudos
1,016

Hi

I assume, the billing document is saved. If so Please open the billing document and go to condition tab of the item and select the pricing condition and press analysis button and review it.

Or check with the pricing procedure / validity date of the condition.

former_member806481
Participant
0 Kudos
1,016

after the bapi commit when i check the sales order it shows this error however if i manually save it twice then it saves the sales order correctly and also the proforma invoice is genereated correctly

we need automated process without manual intervention

venkateswaran_k
Active Contributor
0 Kudos
1,017

Hi atharva12k

atharva12kIt looks like you need to maintain the condition records for the Condition type ZIND - in VK11 ( for the required combination ). In your example the Customer - material or viz..

In my example for ZPD1 - we need to maintain as below. Then it will automatically picks up in SO and put price there.

In your case, check for ZIND for the required combination is the price is maintained here in VK11.

Regards,

Venkat

0 Kudos
1,016

I will check this thank you

0 Kudos
1,016

The routine used for pricing condition had a condition because of which it was giving the error