03-05-2015 11:03 AM
Hi Experts,
A file with the Contract details is uploaded in the ZProgram and the Problem which i face is ...
1. When i create the Sale Order manualy..with that reference data...Item Category displays as ZWAN ...
2. but, via program it populates Item category as TAN ...it should be ZWAN.
Can suggest an idea on the same ..
I have listed the available code for it ...
*C--Populating the Sales order Header data.
wa_order_header_in-doc_type = 'TA'.
wa_order_header_in-sales_org = wa_data-vkorg.
wa_order_header_in-distr_chan = wa_data-vtweg.
wa_order_header_in-division = wa_data-spart.
wa_order_header_in-req_date_h = wa_data-req_del_dt.
wa_order_header_in-ref_doc = wa_data-contract.
* wa_order_header_in-ref_doc_l = wa_data-contract."Add kar
wa_order_header_in-refdoc_cat = 'G'.
IF l_flag_po IS NOT INITIAL.
wa_order_header_in-purch_no_c = wa_data-po_num.
wa_order_header_in-purch_date = wa_data-po_date.
wa_order_header_inx-purch_no_c = c_x.
wa_order_header_inx-purch_date = c_x.
ENDIF.
CLEAR l_flag_po.
wa_order_header_in-ship_cond = wa_data-shp_cond.
wa_order_header_in-cust_grp5 = wa_data-cust_grp5.
wa_order_header_in-incoterms1 = wa_data-incoterms1.
wa_order_header_in-incoterms2 = wa_data-incoterms2.
wa_order_header_in-pmnttrms = wa_data-pmnttrms.
wa_order_header_inx-doc_type = c_x.
wa_order_header_inx-sales_org = c_x.
wa_order_header_inx-distr_chan = c_x.
wa_order_header_inx-division = c_x.
wa_order_header_inx-req_date_h = c_x.
wa_order_header_inx-ref_doc = c_x.
wa_order_header_inx-refdoc_cat = c_x.
*C--Populating the Sales order Item data.
wa_order_item-material = wa_data-matnr.
wa_order_item-ref_doc = wa_data-contract.
wa_order_item-ref_doc_it = wa_data-contract_item.
wa_order_item-itm_number = wa_data-posnr.
wa_order_item-ref_doc_ca = 'G'.
wa_order_item-sales_unit = wa_data-uom.
wa_order_item-purch_no_c = wa_data-po_num.
wa_order_item-purch_date = wa_data-po_date.
*C--Begin of Change DF-3508950 TR#CIDK9A0FPG
*C--Read Plant from Contract & pass to BAPI
CLEAR l_werk.
SELECT SINGLE werks INTO l_werk FROM vbap
WHERE vbeln EQ wa_data-contract AND
posnr EQ wa_data-contract_item.
IF sy-subrc = 0.
wa_order_item-plant = l_werk.
ENDIF.
*C--End of Change DF-3508950 TR#CIDK9A0FPG
APPEND wa_order_item TO t_order_item.
wa_order_itemx-material = c_x.
wa_order_itemx-item_categ = c_x.
wa_order_itemx-ref_doc = c_x.
wa_order_itemx-ref_doc_it = c_x.
wa_order_itemx-ref_doc_ca = c_x.
wa_order_itemx-purch_no_c = c_x.
wa_order_itemx-purch_date = c_x.
*C--Begin of Change DF-3508950 TR#CIDK9A0FPG
*C--Set flag for Plant in line item data
IF wa_order_item-plant IS NOT INITIAL.
wa_order_item-plant = c_x.
ENDIF.
*C--End of Change DF-3508950 TR#CIDK9A0FPG
APPEND wa_order_itemx TO t_order_itemx.
*C--Populate Sold-to party and ship-to party numbers
*C--Begin of Change DF-3508950 TR#CIDK9A0FPG
*C--Read Sold-to Party from Contract & pass to BAPI
SELECT SINGLE kunnr INTO l_soldto FROM vbpa
WHERE vbeln EQ wa_data-contract AND
parvw EQ c_ag.
IF sy-subrc = 0.
wa_parnr-partn_role = c_ag. " 'AG' .
wa_parnr-partn_numb = l_soldto.
APPEND wa_parnr TO t_prtnr.
CLEAR: wa_parnr, l_soldto.
ENDIF.
*C--End of Change DF-3508950 TR#CIDK9A0FPG
wa_parnr-partn_role = c_we. " 'WE' .
wa_parnr-partn_numb = wa_data-shipto.
APPEND wa_parnr TO t_prtnr.
CLEAR wa_parnr.
*C--Populate Hon Sales Person
wa_parnr-partn_role = c_zs. "'ZS' .
wa_parnr-partn_numb = wa_data-salesperson.
APPEND wa_parnr TO t_prtnr.
CLEAR wa_parnr.
*C--Populate End user
wa_parnr-partn_role = c_zu. "'ZU' .
wa_parnr-partn_numb = wa_data-enduser.
APPEND wa_parnr TO t_prtnr.
CLEAR wa_parnr.
**C--Populate schedule lines data for sales order
wa_shline-req_qty = wa_data-req_qty.
wa_shline-itm_number = wa_data-posnr.
APPEND wa_shline TO t_shline.
wa_shlinex-req_qty = c_x.
wa_shlinex-itm_number = wa_data-posnr.
APPEND wa_shlinex TO t_shlinex.
AT END OF key.
IF l_mandt_chk EQ c_x.
ELSE.
wa_err_handling = c_p.
*C--BAPI to create Sales order( VAO1 )
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = wa_order_header_in
order_header_inx = wa_order_header_inx
behave_when_error = wa_err_handling
IMPORTING
salesdocument = wa_vbeln
TABLES
return = t_return
order_items_in = t_order_item
order_items_inx = t_order_itemx
order_partners = t_prtnr
order_schedules_in = t_shline
order_schedules_inx = t_shlinex.
Regards,
Karthik S
03-05-2015 10:12 PM
I'm really not sure why item category would be determined differently online vs. BAPI. Although there could be some differences, I'd expect at least item category to work the same way... The only thing I can imagine - maybe there is some user exit / enhancement that gets triggered only in transaction.
03-10-2015 11:05 AM
Hi Jelena,
There is no Exit / Custom available inbetween the trigger ..
Is there any idea on this ?
Regards,
KArthik s
03-06-2015 8:33 AM
Hi,
What is the order type that you use when you create the document manually. I see in your code that the doc type is TA . Is this the same you use for manual creation ?
03-10-2015 11:11 AM
Hi Andrei,
Thanks for your reply .
We use the Order Type as "OR" wen v create it manually ...
Is there any other option to solve it ...
I expected , if i pass "Item Category" to the input of BAPI...but was not happening ...
Regards,
KArthik S
03-10-2015 11:16 AM
Then use the same order type...
Original
wa_order_header_in-doc_type = 'TA'.
Modified
wa_order_header_in-doc_type = 'OR'.
03-10-2015 11:28 AM
Hi Andrei,
If i pass the below code, it displays doc_type not available in my background job
wa_order_header_in-doc_type = 'OR'.
Is there any other option ?
Regards,
KArthik S
03-10-2015 4:38 PM
My bad. TA and OR are the same...
1.Don't pass this :
wa_order_itemx-item_categ = c_x.
because i don't see where you popupate wa_order_item-item_categ.
2. Check in tcode VTAA the customization for copy control between contract type ??? and order type OR .
There check if item categ ZWAN is maintained.
If it's maintained then the problem persists.
If it's not maintained check user exists in include MV45AFZZ if item categ (pstyv) is populated .
PS. Check the user exist anyway .
03-10-2015 5:43 PM
I'd say enter an incident with SAP. Get a screenshot of everything, i.e. here is the transaction, here is the data entered and here is the item category determined. And the same for BAPI - same data, different item category. Make sure to check in SE16 that the data is indeed identical.
I'm assuming you've already checked with the SD consultant and confirmed that configuration is correct.
03-10-2015 8:41 PM
Andrei Sosea wrote:
1.Don't pass this :
wa_order_itemx-item_categ = c_x.
Good catch, somehow I missed it. Karthik, try just removing this one and it might as well solve your issue.
03-16-2015 11:57 AM
Hi Jelena,
Functional Team have done the proper Configuration setup in VTAA transaction...
I have removed the below code ..still problem persist ...
wa_order_itemx-item_categ = c_x.
Regards,
KArthik S