cancel
Showing results for 
Search instead for 
Did you mean: 

Reference original Sales document when creating a Return

chris_mowl
Participant
0 Kudos

Hello all,

We are creating Return documents using function module J_4A_IDOC_INPUT_ORDERS. In order to credit the correct amount to the customer, we need to get the price of the item from the original sales document and populate the Return document with that price.

I have tried populating the KONV structure but the way I did it didn't work. Can I populate field VGBEL with the original document number and will SAP use that to retrieve the value?

To clarify, I am an ABAP developer looking for a coding solution if that is what is needed. Our functional person has done what he feels is the needed configuration.

We can also reference the Billing Document if that is standard SAP procedure.

Any help would be greatly appreciated.

Thank you,

Chris Mowl

Edited by: Chris Mowl on Feb 25, 2011 1:08 PM

Accepted Solutions (0)

Answers (2)

Answers (2)

chris_mowl
Participant
0 Kudos

Thank you all for your answers so far but our problem has not been solved. Configuration alone doesn't seem to work.

I will elaborate on our issue:

We are processing Returns by using an IDoc. We have a custom function module that starts the process then the Return is created using function module J_4A_IDOC_INPUT_ORDERS. To insure that we credit the customer the amount they paid for the item, we want the Return to reference the original Sales doc or Billing doc.

So, my question is, what structures and fields in J_4A_IDOC_INPUT_ORDERS need to be populated in order to do that?

Thanks for any help.

Kind regards,

Chris Mowl

***Update with solution *** 18 March 2011

The following code was written in a custom function module before calling J_4A_IDOC_INPUT_ORDERS.

We got the data from the original sales order by using the P.O. # in e1edk02-belnr (that is what is in field return_auth).

I then created an E1EDP05 segment and inserted it into the IDOC_DATA table.


* Add E1EDP05 segment to contain the item price from the original
* Sales Document
      IF ord_type = 'ZRE'.

        LOOP AT t_idoc_data INTO s_idoc_data
                                  WHERE docnum = idoc_contrl-docnum
                                  AND   segnam = 'E1J3AIM'.

          e1j3aim = s_idoc_data-sdata.

          CLEAR: lv_vbeln, lv_knumv, lv_posnr,
                 lv_matnr, lv_waers, lv_kbetr.

          SELECT SINGLE vbeln knumv FROM vbak
          INTO (lv_vbeln, lv_knumv)
            WHERE auart = 'ZRO'
              AND vtweg = '05'             "ECOM orders only, not wholesale
              AND bstnk = return_auth.

          IF sy-subrc = 0.

            SELECT SINGLE posnr matnr FROM vbap
            INTO (lv_posnr, lv_matnr)
            WHERE vbeln = lv_vbeln
              AND matnr = e1j3aim-j_3aidtnr.

            SELECT SINGLE kbetr waers FROM konv
            INTO (lv_kbetr, lv_waers)
              WHERE knumv = lv_knumv
                AND kposn = lv_posnr
                AND kschl = 'ZRTL'
                AND kinak = ' '.


            MOVE: lv_waers TO e1edp05-koein,
                  lv_kbetr TO e1edp05-krate.

            e1edp05-kschl = 'ZRTL'.

            s_idoc_data-segnam = 'E1EDP05'.

            s_idoc_data-sdata  =  e1edp05.

            lv_tabix = sy-tabix + 1.

            INSERT s_idoc_data INTO t_idoc_data INDEX lv_tabix.

          ENDIF.

        ENDLOOP.

      ENDIF.

Kind regards,

Chris Mowl

Edited by: Chris Mowl on Mar 18, 2011 2:40 PM

Edited by: Chris Mowl on Mar 18, 2011 2:51 PM

Former Member
0 Kudos

Hi Chris,

We have a similar requirement. We have to create a return order with reference to invoice. Will it be possible to share the code?.

Thanks for your help..

chris_mowl
Participant
0 Kudos

Hi Narasimha,

I listed my solution in my last post in the thread. I basically looked up the purchase order by using the po number in e1edk02-belnr. I got the needed data to look up the condition record in KONV and passed that to the E1EDP05 segment.

Let me know if you have any further questions.

Thanks,

Chris

Former Member
0 Kudos

Hello,

To get the price components in your Returns Order from your Original Sales order you have to do Copy Control using T.code VTAA.

In this your Returns Order will be target entry and Original Sales Order will be the source entry. Do the settings for Header & Item.

To keep the same pricing maintain "D" in Price List at Item level. By this customizing your data of the Original Sales Order gets copied into Returns Order along with the Original sales order pricing.

Same you can do when referencing Billing document for Returns Order using T. Code VTAF. In this your your Returns Order will be target entry and Billing Document type will be the source entry.

This is the standard SAP.

Hope this will help you.

Ramchandra

Former Member
0 Kudos

Hello ,

Please see this link.

http://help.sap.com/bp_bl604/BBLibrary/HTML/111_EN_US.htm.

Thnaks,

venkataswamy

chris_mowl
Participant
0 Kudos

Hi Ramchandra,

Thank you for your response. I spoke with our SD person and he has that configuration in place and it works fine when he creates a return manually. Since we are using function module J_4A_IDOC_INPUT_ORDERS, do you know if any code is required in addition to the configuration changes you mentioned?

Kind regards,

Chris Mowl

Former Member
0 Kudos

Hi Chris,

The problem is that you are creating Return order via FM & so the Pricing in the Return order will be new & not the one in the earlier sales order or billing document.

As you said when done manually the Pricing is fine.

So yes definitely you will need some code to populate the prices in Return order with the same prices as in reference sales order.

Maybe you need to store the pricing of sales order in internal table & then when Retun order is getting created then you fill the values of prices accordingly.

Or you try & find a Function module which creates Orders(Returns order) by referencing an earlier order.

regards