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: 
Read only

How to use function module BAPI_CUSTOMERRETURN_CREATE

Former Member
0 Likes
3,376

Hello,

I need to create return sales order. I am trying to use BAPI_CUSTOMERRETURN_CREATE.

Can anybody please help.

Regards.

18 REPLIES 18
Read only

Former Member
0 Likes
2,492

Hi,

Click on the Whereuse list for this FM

i.e SE37-->FM name


> click o n the wheruselist (ctrlshiftF3)--> select the check for programs and enter

Regards,

Padmasri.

Read only

Former Member
0 Likes
2,492

Hi,

Try the sample code

call function 'BAPI_CUSTOMERRETURN_CREATE'
      exporting
        salesdocumentin      = salesdocumentin
        return_header_in     = wa_return_header_in
        return_header_inx    = wa_return_header_inx
      importing
        salesdocument        = salesdocumentout
      tables
        return               = it_return
        return_items_in      = it_return_items_in
        return_items_inx     = it_return_items_inx
        return_partners      = it_return_partners
        return_schedules_in  = it_schedules_in
        return_schedules_inx = it_schedules_inx

Fill: order number in salesdocumentin

Fill following fields in "return_header_in"

DOC_TYPE, ORD_REASON, SD_DOC_CAT ='H',

REF_DOC = Reference document,

REFDOC_CAT = 'M' (If invoice is reference document)

SALES_ORG,DISTR_CHAN,DIVISION

Fill the value 'X' to corresponding fields of structure "return_header_inx"

Fill partner details in "return_partners"

While filling the structure "return_items_in" and "return_items_inx"

pass reference document number in the field "REF_DOC"

Fill Schedule line data in "return_schedules_in" and "return_schedules_inx"

Regards

Vinod

Read only

0 Likes
2,492

Thanks Vinod.

Kindly help me with RETURN_SCHEDULES_IN and RETURN_SCHEDULES_INX Values.

Regards,

Nikita Giradkar.

Read only

0 Likes
2,492

Hi, Try sample code as below

move <ls_return_item>-itm_number to wa_schedules_in-itm_number.
        move '0001'                      to wa_schedules_in-sched_line.
        move <ls_return_item>-target_qty to wa_schedules_in-req_qty.
        move ' '                         to wa_schedules_in-req_dlv_bl.
        append wa_schedules_in to it_schedules_in.

        move <ls_return_item>-itm_number to wa_schedules_inx-itm_number.
        move '0001'                      to wa_schedules_inx-sched_line.
        move 'X'                         to wa_schedules_inx-req_qty.
        move 'U'                         to wa_schedules_inx-updateflag.
        move 'X'                         to wa_schedules_inx-req_dlv_bl.
        append wa_schedules_inx to it_schedules_inx.

Regards

Vinod

Read only

0 Likes
2,492

Hi Nikita,

You have to fill given below fields.

so_header-doc_type

so_header-sales_org

so_header-distr_chan

so_header-division

so_header-pmnttrms

so_header-purch_no_c

so_header-incoterms1

so_header-incoterms2

so_header-ord_reason

w_items-itm_number

w_items-material

w_items-plant

w_items-orderid

w_items-profit_ctr

w_shedule-itm_number

w_shedule-sched_line

w_shedule-req_qty

w_partner-partn_role

w_partner-partn_numb

So you have to fill atleast these above parameters.

Ihope it will help you.

Regards,

Narendra

Read only

0 Likes
2,492

Hi,

I am getting error

331 Item 000003 does not exist

Kindly help.

Thanks & Regards.

Read only

0 Likes
2,492

You have to pass the line item number of Reference document (generally Billing document)

Regards

Vinod

Read only

0 Likes
2,492

My code is

clear : vbrp.

select * from vbrp where vbeln = zdefc_claim-vbeln and matnr = zdefc_claim-matnr.

RETURN_SCHEDULES_IN-ITM_NUMBER = vbrp-posnr.

RETURN_SCHEDULES_IN-REQ_QTY = zdefc_claim-zaccepted.

append RETURN_SCHEDULES_IN.

RETURN_SCHEDULES_INX-ITM_NUMBER = vbrp-posnr.

RETURN_SCHEDULES_INX-REQ_QTY = 'X'.

  • RETURN_SCHEDULES_INX-updateflag = 'U'.

APPEND RETURN_SCHEDULES_INX.

endselect.

Read only

0 Likes
2,492

Add following line of code while filling schedule line information.

move '0001'    to RETURN_SCHEDULES_IN-sched_line.
move '0001'    to RETURN_SCHEDULES_INX-sched_line.

Hope you are mapping following values

"zdefc_claim-vbeln" into return_items_in-ref_doc,

"vbrp-posnr" into return_items_in-ref_doc_it,

"zdefc_claim-vbeln" into return_header_in-ref_doc.

Regards

Vinod

Read only

0 Likes
2,492

Hi Nikita,

As I mentioned mandatory fields in my above point.

Kindly use SCHEUD_LINE also

Atleast fill this field by 6 characters

i.e. padd with zeros in starting

eg. instead of 0001 you have to write '000001'

Regards,

Narendra

Read only

0 Likes
2,492

Thanks a lot.

While updating Sales documnet is getting created but Quantity is Blank.

Kindly Help.

Regards.

Read only

0 Likes
2,492

Check following lines of code where quantity is assigned.

move <ls_return_item>-target_qty to return_items_in-target_qty.
move 'X'                        to return_items_inx-target_qty.

move <ls_return_item>-target_qty to return_schedules_in-req_qty.
move 'X'                        to return_schedules_inx-req_qty.

Regards

Vinod

Read only

0 Likes
2,492

Hi Nikita,

Plz check quantity field in your code.

i.e. just before calling BAPI, check ur internal table which contains quantity data.

Also check on this line of your code.

RETURN_SCHEDULES_IN-REQ_QTY = zdefc_claim-zaccepted.

or you can check by passing some constant value in quantity field. " to check the data is coming in variable or not.

Regards,

Narendra

Read only

0 Likes
2,492

Yes, I tried passing constant '10.000', but still quantity is not getting updated.

My code is:

CALL FUNCTION 'BAPI_CUSTOMERRETURN_CREATE'

EXPORTING

  • SALESDOCUMENTIN =

RETURN_HEADER_IN = RETURN_HEADER_IN

RETURN_HEADER_INX = RETURN_HEADER_INX

  • SENDER =

  • BINARY_RELATIONSHIPTYPE = 'VORA'

  • INT_NUMBER_ASSIGNMENT =

  • BEHAVE_WHEN_ERROR =

  • LOGIC_SWITCH =

  • TESTRUN =

  • CONVERT = ' '

IMPORTING

SALESDOCUMENT = SALESDOCUMENT

TABLES

RETURN = RETURN

RETURN_ITEMS_IN = RETURN_ITEMS_IN

RETURN_ITEMS_INX = RETURN_ITEMS_INX

RETURN_PARTNERS = RETURN_PARTNERS

  • RETURN_SCHEDULES_IN = RETURN_SCHEDULES_IN

  • RETURN_SCHEDULES_INX = RETURN_SCHEDULES_INX

  • RETURN_CONDITIONS_IN =

  • RETURN_CFGS_REF =

  • RETURN_CFGS_INST =

  • RETURN_CFGS_PART_OF =

  • RETURN_CFGS_VALUE =

  • RETURN_CFGS_BLOB =

  • RETURN_CFGS_VK =

  • RETURN_CFGS_REFINST =

  • RETURN_TEXT =

  • RETURN_KEYS =

  • EXTENSIONIN =

  • PARTNERADDRESSES =

.

Read only

0 Likes
2,492

Hi Nikita,

Plz uncomment the given below lines

  • RETURN_SCHEDULES_IN = RETURN_SCHEDULES_IN

  • RETURN_SCHEDULES_INX = RETURN_SCHEDULES_INX

You are filling structures but commented these lines in your code.

Uncomment this.

I hope it will help you.

Regards,

Narendra

Read only

0 Likes
2,492

RETURN_SCHEDULES_IN & RETURN_SCHEDULES_INX is commented in BAPI. Data in this structures is used to determine quantity at item level.

Regards

Vinod

Read only

0 Likes
2,492

Thank you for above answers. Now at sales order quantity is getting updated but net value is blank.

Kindly help.

Thanks & Regards.

Read only

Former Member
0 Likes
2,492

Moderator message - Please do not respond to questions like this. Correct answer is RTFM. post locked and points unassigned Rob