‎2006 Aug 30 10:45 AM
Re: BAPI _ CUSTOMERRETURN _ CREATE , how to fix a payer
Posted: Aug 30, 2006 5:29 AM Reply E-mail this post
Hi All,
i am passing the pricing date (in Return_header_in) and i m using doc type as ZR (Automatic return).In the sales order created.My net value is changing ie its not taking the net value as per the pricing date, i am passing !! .i want my net value to be constant here.How can i make it happen.Is it possible ? .I have tried passing 'pricing type D-(copy unchanged)" in the Logic switch of this BAPI.but not working , it says not defined !!.
Your help will be heartily appreciated.
Thanx n warm regards
Balwant
‎2006 Aug 30 11:09 AM
Hi Arora,
Check this code...
Regards,
Raj
-
FORM get_update .
DATA: l_itemno(6) TYPE n,
l_partner TYPE parvw,
l_kunnr TYPE kunnr,
l_matnr TYPE matnr,
l_mesg TYPE string,
l_kbetr TYPE p DECIMALS 2.
DATA: l_in_qty LIKE vbap-zmeng,
l_meins LIKE mara-meins,
l_factor LIKE marm-umrez,
l_qty LIKE vbap-zmeng.
CLEAR: v_correct, v_error, v_total.
SORT it_data BY loc div pdpl_order.
LOOP AT it_data.
CLEAR v_index.
v_index = sy-tabix.
*- New SalesOrder
AT NEW pdpl_order.
READ TABLE it_data INDEX v_index.
CLEAR: it_orderh, it_item, it_partner,
it_return, conditions, conditions[],
it_item[], it_partner[], it_return[].
v_total = v_total + 1. "Increment Total SalesOrders counter
CLEAR l_itemno.
l_itemno = '10'.
*- Covert date fields into Internal format
CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'
EXPORTING
datum = it_data-date
dtype = 'DATS'
IMPORTING
idate = it_data-date.
*- Populate SalesOrder header data.
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
input = it_data-auart
IMPORTING
output = it_data-auart.
it_orderh-doc_type = it_data-auart.
it_orderh-sales_org = it_data-vkorg.
it_orderh-distr_chan = it_data-vtweg.
it_orderh-division = it_data-spart.
it_orderh-doc_number = it_data-vbeln. "No external # assignment allowed
it_orderh-doc_date = it_data-date. "Doc Dt
it_orderh-purch_no_s = it_data-pdpl_order.
it_orderh-ord_reason = it_data-ord_cause. "Order reason
*- Partner data
CLEAR: l_partner, l_kunnr.
*- Convert Partner type into internal format
l_partner = 'SP'. "SoldTo Party
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
input = l_partner
IMPORTING
output = l_partner.
*- Convert Customer into internal format
l_kunnr = it_data-kunnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = l_kunnr
IMPORTING
output = l_kunnr.
it_partner-partn_role = l_partner.
it_partner-partn_numb = l_kunnr.
APPEND it_partner.
CLEAR it_partner.
ENDAT.
*- Item data
it_item-itm_number = l_itemno.
*- Convert material number into internal format
CLEAR l_matnr.
l_matnr = it_data-matnr.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = l_matnr
IMPORTING
output = l_matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
it_item-material = l_matnr.
*- Insert into Reconciliation table
PERFORM insert_record.
*- Call FM to get new qty based on SAP UOM
CLEAR: l_meins, l_qty, l_in_qty, l_factor.
l_in_qty = it_data-qty.
CALL FUNCTION 'Z_GET_QTY_FROM_UOM'
EXPORTING
matnr = it_data-matnr
in_meins = it_data-uom
in_qty = l_in_qty
IMPORTING
out_meins = l_meins
quantity = l_qty
factor = l_factor.
IF sy-subrc = 0.
it_data-qty = l_qty.
it_data-uom = l_meins.
ENDIF.
*- Call FM to get new qty based on SAP UOM
CLEAR: l_meins, l_qty, l_in_qty.
l_in_qty = it_data-free_qty.
CALL FUNCTION 'Z_GET_QTY_FROM_UOM'
EXPORTING
matnr = it_data-matnr
in_meins = it_data-uom
in_qty = l_in_qty
IMPORTING
out_meins = l_meins
quantity = l_qty
factor = l_factor.
IF sy-subrc = 0.
it_data-free_qty = l_qty.
it_data-uom = l_meins.
ENDIF.
*- Batch
it_item-batch = it_data-batch.
it_item-target_qty = it_data-qty. " * 1000.
it_item-target_qu = it_data-uom.
IF NOT it_item-material IS INITIAL.
APPEND it_item.
*- Pricing Conditions
conditions-itm_number = l_itemno.
conditions-cond_count = '01'.
conditions-cond_type = 'PR00'.
CLEAR l_kbetr.
l_kbetr = it_data-kbetr / 10. "Price (Rate)
IF l_factor > 0.
conditions-cond_value = l_kbetr / l_factor.
ENDIF.
APPEND conditions.
CLEAR conditions.
ENDIF.
*- Discount
IF NOT it_data-discount IS INITIAL.
conditions-itm_number = l_itemno.
conditions-cond_count = '02'.
conditions-cond_type = 'ZDIS'.
CLEAR l_kbetr.
l_kbetr = it_data-discount / 10.
conditions-cond_value = l_kbetr.
APPEND conditions.
CLEAR conditions.
ENDIF.
*- CD
IF NOT it_data-cd IS INITIAL.
conditions-itm_number = l_itemno.
conditions-cond_count = '03'.
conditions-cond_type = 'ZCD'.
CLEAR l_kbetr.
l_kbetr = it_data-cd / 10.
conditions-cond_value = l_kbetr.
APPEND conditions.
CLEAR conditions.
ENDIF.
*- Lst
IF NOT it_data-lst IS INITIAL.
conditions-itm_number = l_itemno.
conditions-cond_count = '04'.
conditions-cond_type = 'ZIN2'.
CLEAR l_kbetr.
l_kbetr = it_data-lst / 10.
conditions-cond_value = l_kbetr.
APPEND conditions.
CLEAR conditions.
ENDIF.
*- Surcharge
IF NOT it_data-sur IS INITIAL.
conditions-itm_number = l_itemno.
conditions-cond_count = '05'.
conditions-cond_type = 'ZIN5'.
CLEAR l_kbetr.
l_kbetr = it_data-sur / 10.
conditions-cond_value = l_kbetr.
APPEND conditions.
CLEAR conditions.
ENDIF.
**- CST
IF NOT it_data-cst IS INITIAL.
conditions-itm_number = l_itemno.
conditions-cond_count = '06'.
conditions-cond_type = 'ZIN1'.
CLEAR l_kbetr.
l_kbetr = it_data-cst.
conditions-cond_value = l_kbetr.
APPEND conditions.
CLEAR conditions.
ENDIF.
*- Freight
IF NOT it_data-freight IS INITIAL.
conditions-itm_number = l_itemno.
conditions-cond_count = '07'.
conditions-cond_type = 'ZFR1'.
CLEAR l_kbetr.
l_kbetr = it_data-freight / 10.
conditions-cond_value = l_kbetr.
APPEND conditions.
CLEAR conditions.
ENDIF.
*- Rounding Off
IF NOT it_data-roff IS INITIAL.
conditions-itm_number = l_itemno.
conditions-cond_count = '08'.
conditions-cond_type = 'ZRND'.
CLEAR l_kbetr.
l_kbetr = it_data-roff / 10.
conditions-cond_value = l_kbetr.
APPEND conditions.
CLEAR conditions.
ENDIF.
IF it_data-free_qty > '0.000'.
*- Increment Item counter.
l_itemno = l_itemno + 10.
it_item-itm_number = l_itemno.
it_item-material = l_matnr.
it_item-item_categ = 'RENN'.
it_item-target_qty = it_data-free_qty. " * 1000.
APPEND it_item.
CLEAR it_item.
ENDIF.
*- Increment Item counter.
l_itemno = l_itemno + 10.
*- At end of SalesOrder
AT END OF pdpl_order.
READ TABLE it_data INDEX v_index.
*- Call the BAPI for Credit Note creation
CALL FUNCTION 'BAPI_CUSTOMERRETURN_CREATE'
EXPORTING
return_header_in = it_orderh
TABLES
return = it_return
return_items_in = it_item
return_partners = it_partner
return_conditions_in = conditions.
IF sy-subrc = 0.
COMMIT WORK.
CLEAR v_vbeln.
SORT it_return BY type id.
READ TABLE it_return WITH KEY type = 'S'
id = 'V1'.
IF sy-subrc = 0.
v_vbeln = it_return-message_v2.
v_correct = v_correct + 1.
CLEAR l_mesg.
CONCATENATE 'Credit note'(007) v_vbeln 'successfully created.'(008)
INTO l_mesg SEPARATED BY space.
CONDENSE l_mesg.
WAIT UP TO 1 SECONDS.
*- Call VA02 for updating Qty
PERFORM call_va02.
ELSE.
v_error = v_error + 1.
READ TABLE it_return WITH KEY type = 'E'.
IF sy-subrc = 0.
CLEAR l_mesg.
l_mesg = it_return-message.
CONDENSE l_mesg.
ENDIF.
ENDIF.
ENDIF.
*- Populate the output table
CLEAR it_out.
it_out-pdpl_order = it_data-pdpl_order.
it_out-mesg = l_mesg.
APPEND it_out.
CLEAR it_out.
ENDAT.
ENDLOOP.
ENDFORM. " get_update
‎2006 Aug 30 1:08 PM
Hi ,
i have gone thru the code.but kindly be specific and let me know, what i have to pass extra in the bapi "BAPI _ CUSTOMERRETURN_CREATE" to fix this.I have basically a requiremnet in which i want my NET VALUE to be same after we do ZR on a F2 doc type.I am passing pricing date,but the net value is getting picked up as per the todays date and not the pricing date passed.
I want to exactly COPY the previous(when the doc type was F2, billing doc) CONDITION TYPES to when it became ZR.
to rephrase my requirement "How to go about this ie copying the condition type from F2 to ZR , thru this BAPI"
Kindly help its urgent n important
Promise to give u full points
Thanx and warm regards
Balwant
‎2006 Aug 30 3:00 PM
Hi ALL,
This is an importnat issue for me .. please please help!!
I promise to give u max points.
thanx
balwant
‎2006 Aug 30 3:22 PM
HI Balwant
I can advice you to create an order online in VA01
with the reference document, now you can see if this
takes conditions as per current pricing date or it takes
from the original order. If the new order can not take
old conditions then it has to be fixed here rather than
working on BAPI.
Also check user-exit MV45AFZZ if there is any
defaulting of pricing date.
Have returned from office so can only suggest you
only with my experience. I can not check the same on
system now.
Kind Regards
Eswar
‎2006 Aug 30 5:30 PM
Hi eshwar,
Thanx for your reply !!
i am able to do it correctly thru va01 ie manually its fine.
i was trying to pass all the condition types based on vbrk-vbeln>vbrk-knumv>konv-knumv , taking all the records here passing to the return_condtion_in of bapi.
but was giving errrors for some condtion type(konv-kschl) , "Condition xxxx cannot be processed manually".
i am stuck uo badly here !!
which t-code to access this user-exit MV45AFZZ .
Thanx n warm regards,
Balwant
‎2006 Aug 30 7:41 PM
Hi Balwant
Can you post your code, i think it will be better for
understanding and for our friends here to advice.
Kind Regards
Eswar
‎2006 Sep 01 5:20 AM
hi Eshwar,
i didnt code anything as such .. i was just trying passing a single record from KONV table based on vbrp-knumv, in the return_condition_in ,along with other parameters of bapi,to test .. then the bapi gave this error
"Condition XXXX cannot be processed manually".
Is there any other way out .. to copy condition types from billing doc to sales doc .. except BDC!!
I am desperate to solve this issue .. plz help!!
Thanx
Balwant
‎2006 Sep 01 12:35 PM
Hi All,
I am still waiting for anybody to help me on the above problem .. plz help .
Thanx
Balwant
‎2006 Sep 04 12:20 PM
Hi,
Kindly read the above problem and kindly let me know if you have come across this and plz let me know the solution.
Your expert advice is solicited at the earliest.
Thanx & warm regards,
Balwant
‎2006 Sep 05 7:14 AM
hi ,
was able to solve this finally!! refer to oss note 370988.
cheers !!
Balwant