Skip to Content

Discount condition record exit not in Return SO using BAPI_CUSTOMERRETURN_CREATE ref to Billing

Sep 28, 2017 at 01:43 PM


avatar image
Former Member

Dear Friend,

could you guide.....

Basic price updated wrongly and discount conditon record as missed in Return SO.

return_header_in = gw_header
return_header_inx = gw_headerx
* CONVERT = ' '
salesdocument = gv_salesdoc
return = gt_ret
return_items_in = gt_ord_item
return_items_inx = gt_ord_itemx
return_partners = gt_part
return_schedules_in = gt_schld
return_schedules_inx = gt_schldx
return_conditions_in = gt_condition

Details :

following requiment to creat Return Sales order reference to Billing Documents.

I facing one issue regarding Condition record. if i pass condition record having base price and discount record. Then it throw an error like "Condition ZB2C is missing in pricing procedure A V YHTSO2".

But i remove gt_condition record then Return SO was created success fully. But only base price condition are copied with different base price. it want not fetching discount condition record.

Reference No:

Return SO:


Bhagaban Pradhan

invoice-ref.jpg (78.6 kB)
return-so.jpg (81.0 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Veselina Peykova
Sep 28, 2017 at 05:32 PM

I am not a developer, just a functional consultant, so please forgive me if I ask stupid questions.

What is the outcome if you try creating the return document not via the bapi, but from VA01 and use the same billing as reference - is the discount determined?

For the document, which you managed to create, but the condition is missing - what do you see in the determination log for pricing for ZB2C?

Normally, when you create a return order and reference billing, the prices are fixed (this a setting in VTAF per item category for a combination of source billing type and target order type), but it is worth double-checking, especially when I see that your base price YKP0 also does not correspond to what was in the billing. Did you reprice the document by any chance? I can see that you do not use logic_switch, but if repricing comes from customizing...

I do not really know how exactly one needs to call the bapi to create return order referencing a billing document and whether this is supported at all, but did you check if you have referenced the right billing document (VBAP, VBFA)?

Also, check if the pricing procedure in your document (created from the bapi) is the same as the pricing procedure when you try creating a document referencing the same billing. This could be a result of not correctly referencing the billing document via the FM. Normally, the referencing document inherits the pricing procedure from the referenced document (in your case - the billing). If you create without reference, the determined pricing procedure could be different.

Show 6 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Vaselina,

what you said was correct. I m able to create Return order mannuallly vi VA01 and all the pricing condition are comming correct.

But When i tried same things via BAPI, i getting this unsuccessful result.



This is a good news, now you can compare the dates, pricing procedure and references between the two documents (the one created via bapi and the one from va01).

If they are identical, but you still get different outcome in pricing via the bapi: is there a possibility that there is some custom logic someplace (routines or exits), which checks for sy-tcode? In some companies they do this...

Edit: I came across SAP note 370988 - BAPIs in SD: Creation with reference, explaining some specifics when you create SD document by referencing via BAPI. There is also an example attached as a txt file. I know that it is not specifically about your business object type, but I would expect that the concept is similar. Have you come across it and is this what your program does (option 2 in the note)? If yes, then maybe you need at least to use logic_switch if you are updating conditions, because from what I read, you need to do manually in your code what va01 achieves via copy control.

Former Member


As per your concern i pass correct date. If i create return SO using VA01 it was picking exact pricing procedure which was similar to billing document. if i create using bapi it was picking some other pricing procedure.

one intresting ...if i didn't given any conditon record to bapi, then return order was created, but only base price was picking except disocunt record. Also base price was wrong as per billing doc.



You can try something else, just to confirm a suspicion - from VA01 try to create the same return order type for the same customer and sales area, but do not specify a reference document.

You can do this only if it is permitted by customizing, though.

I suppose that in this case you will end up with something similar to what you created via the bapi (as long as you use the same dates).

What I suspect is that when you reference a document via bapi, it just updates the document flow and a few more fields, but does not perform a true 'copy'.


As I cannot think of a workaround for the pricing procedure determination problem with the bapi, which you are using - maybe you can try BAPI_SALESDOCUMENT_COPY (as explained in the note that I mentioned) and subsequently perform a document change if you need to edit or delete specific items.

Former Member


what you said correct, i m able to create return order using BAPI_SALESDOCUMENT_COPY. But my requirement was slite different.

What my concern that, i want to updated 'Order Reason', 'Storage Location', 'Usage' as per input. But as you reference bapi will update as per billing doucument.

point - 2: i want update these details all the line item level.

If follow BAPI_SALESDOCUMENT_COPY, then i have write enhancemnet MV45AFZZ.

So, i tring alternate way without enhancement using BAPI_CUSTOMERRETURN_CREATE, but i m stop here due to above reason.


input-details.jpg (28.0 kB)

After you create the document as an exact copy, it is possible to modify storage location, usage and order reason via document change bapi (e.g. bapi_customerreturn_change). It is not the most elegant solution, but you do not have a way to guarantee the right pricing procedure with the other bapi and you are stuck.