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 BAPI_CUSTOMERRETURN_CHANGE

0 Likes
1,412

Hi

I have used BAPI_CUSTOMERRETURN_CHANGE to modify an return order. It works fine, except than new quantity for w_schedule-req_qty is added, instead of replaced it. I suppose that w_headerinx-updateflag must be 'U', but I don´t know if is needed another flag (by example 'R'). Any suggestions will be grateful.

Thanks in advanced

Here my code:

DATA l_documento TYPE bapivbeln-vbeln.

DATA l_docret TYPE bapivbeln-vbeln.

DATA w_headerin TYPE bapisdhd1.

DATA w_headerinx TYPE bapisdhd1x.

DATA lt_returnbapi TYPE TABLE OF bapiret2.

DATA w_returnbapi LIKE LINE OF lt_returnbapi.

DATA lt_items TYPE TABLE OF bapisditm.

DATA lt_itemsx TYPE TABLE OF bapisditmx.

DATA w_items LIKE LINE OF lt_items.

DATA w_itemsx LIKE LINE OF lt_itemsx.

DATA lt_partners TYPE TABLE OF bapiparnr.

DATA w_partners LIKE LINE OF lt_partners.

DATA lt_key TYPE TABLE OF bapisdkey.

DATA w_key LIKE LINE OF lt_key.

DATA lt_schedule TYPE TABLE OF bapischdl.

DATA w_schedule LIKE LINE OF lt_schedule.

DATA lt_schedulex TYPE TABLE OF bapischdlx.

DATA w_schedulex LIKE LINE OF lt_schedulex.

DATA l_fecha TYPE sy-datum.

DATA l_cantidad(10).

                  • PRUEBA DE BAPI BAPI_CUSTOMERRETURN_CHANGE ***********

*MODIFICACIÓN DE PEDIDO DE DEVOLUCIÓN

"Llenado del encabezado

CLEAR l_documento.

CLEAR l_docret.

MOVE '0187000283' TO l_documento.

"Llenado de la estructura

CLEAR w_headerinx.

w_headerinx-updateflag = 'U'.

"Llenado de la tabla de items

CLEAR w_items.

CLEAR lt_items.

w_items-itm_number = '10'.

w_items-material = '000000000000008670'.

w_items-plant = 'MCAA'.

l_cantidad = '5'.

CONDENSE l_cantidad.

w_items-target_qty = l_cantidad.

w_items-target_qu = 'CAJ'.

w_items-sales_unit = 'CAJ'.

APPEND w_items TO lt_items.

CLEAR w_itemsx.

CLEAR lt_itemsx.

w_itemsx-itm_number = '10'.

w_itemsx-updateflag = 'U'.

w_itemsx-material = 'X'.

w_itemsx-plant = 'X'.

w_itemsx-target_qty = 'X'.

w_itemsx-target_qu = 'X'.

w_itemsx-sales_unit = 'X'.

APPEND w_itemsx TO lt_itemsx.

"Llenado del schedule

CLEAR w_schedule.

CLEAR lt_schedule.

w_schedule-itm_number = '10'.

w_schedule-req_date = l_fecha.

w_schedule-req_qty = l_cantidad.

APPEND w_schedule TO lt_schedule.

CLEAR w_schedulex.

CLEAR lt_schedulex.

w_schedulex-updateflag = 'X'.

w_schedulex-itm_number = '10'.

w_schedulex-req_date = 'X'.

w_schedulex-req_qty = 'X'.

APPEND w_schedulex TO lt_schedulex.

"Llenado de la tabla de partners

CLEAR w_partners.

CLEAR lt_partners.

w_partners-partn_role = 'AG'.

w_partners-partn_numb = 'F0836727'.

APPEND w_partners TO lt_partners.

CLEAR w_partners.

w_partners-partn_role = 'WE'.

w_partners-partn_numb = 'F0836727'.

APPEND w_partners TO lt_partners.

CALL FUNCTION 'BAPI_CUSTOMERRETURN_CHANGE'

EXPORTING

salesdocument = l_documento

return_header_inx = w_headerinx

TABLES

return = lt_returnbapi

return_items_in = lt_items

return_items_inx = lt_itemsx

schedule_lines = lt_schedule

schedule_linesx = lt_schedulex.

BREAK-POINT.

READ TABLE lt_returnbapi INTO w_returnbapi WITH KEY type = c_mtipo id = c_mida1

number = c_mnuma1.

IF sy-subrc = 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = c_d1.

ENDIF.

Hi

I have used BAPI_CUSTOMERRETURN_CHANGE to modify an return order. It works fine, except than new quantity for w_schedule-req_qty is added, instead of replaced it. I suppose that w_headerinx-updateflag must be 'U', but I don´t know if is needed another flag (by example 'R'). Any suggestions will be grateful.

Thanks in advanced

Here my code:

DATA l_documento TYPE bapivbeln-vbeln.

DATA l_docret TYPE bapivbeln-vbeln.

DATA w_headerin TYPE bapisdhd1.

DATA w_headerinx TYPE bapisdhd1x.

DATA lt_returnbapi TYPE TABLE OF bapiret2.

DATA w_returnbapi LIKE LINE OF lt_returnbapi.

DATA lt_items TYPE TABLE OF bapisditm.

DATA lt_itemsx TYPE TABLE OF bapisditmx.

DATA w_items LIKE LINE OF lt_items.

DATA w_itemsx LIKE LINE OF lt_itemsx.

DATA lt_partners TYPE TABLE OF bapiparnr.

DATA w_partners LIKE LINE OF lt_partners.

DATA lt_key TYPE TABLE OF bapisdkey.

DATA w_key LIKE LINE OF lt_key.

DATA lt_schedule TYPE TABLE OF bapischdl.

DATA w_schedule LIKE LINE OF lt_schedule.

DATA lt_schedulex TYPE TABLE OF bapischdlx.

DATA w_schedulex LIKE LINE OF lt_schedulex.

DATA l_fecha TYPE sy-datum.

DATA l_cantidad(10).

                  • PRUEBA DE BAPI BAPI_CUSTOMERRETURN_CHANGE ***********

*MODIFICACIÓN DE PEDIDO DE DEVOLUCIÓN

"Llenado del encabezado

CLEAR l_documento.

CLEAR l_docret.

MOVE '0187000283' TO l_documento.

"Llenado de la estructura

CLEAR w_headerinx.

w_headerinx-updateflag = 'U'.

"Llenado de la tabla de items

CLEAR w_items.

CLEAR lt_items.

w_items-itm_number = '10'.

w_items-material = '000000000000008670'.

w_items-plant = 'MCAA'.

l_cantidad = '5'.

CONDENSE l_cantidad.

w_items-target_qty = l_cantidad.

w_items-target_qu = 'CAJ'.

w_items-sales_unit = 'CAJ'.

APPEND w_items TO lt_items.

CLEAR w_itemsx.

CLEAR lt_itemsx.

w_itemsx-itm_number = '10'.

w_itemsx-updateflag = 'U'.

w_itemsx-material = 'X'.

w_itemsx-plant = 'X'.

w_itemsx-target_qty = 'X'.

w_itemsx-target_qu = 'X'.

w_itemsx-sales_unit = 'X'.

APPEND w_itemsx TO lt_itemsx.

"Llenado del schedule

CLEAR w_schedule.

CLEAR lt_schedule.

w_schedule-itm_number = '10'.

w_schedule-req_date = l_fecha.

w_schedule-req_qty = l_cantidad.

APPEND w_schedule TO lt_schedule.

CLEAR w_schedulex.

CLEAR lt_schedulex.

w_schedulex-updateflag = 'X'.

w_schedulex-itm_number = '10'.

w_schedulex-req_date = 'X'.

w_schedulex-req_qty = 'X'.

APPEND w_schedulex TO lt_schedulex.

"Llenado de la tabla de partners

CLEAR w_partners.

CLEAR lt_partners.

w_partners-partn_role = 'AG'.

w_partners-partn_numb = 'F0836727'.

APPEND w_partners TO lt_partners.

CLEAR w_partners.

w_partners-partn_role = 'WE'.

w_partners-partn_numb = 'F0836727'.

APPEND w_partners TO lt_partners.

CALL FUNCTION 'BAPI_CUSTOMERRETURN_CHANGE'

EXPORTING

salesdocument = l_documento

return_header_inx = w_headerinx

TABLES

return = lt_returnbapi

return_items_in = lt_items

return_items_inx = lt_itemsx

schedule_lines = lt_schedule

schedule_linesx = lt_schedulex.

BREAK-POINT.

READ TABLE lt_returnbapi INTO w_returnbapi WITH KEY type = c_mtipo id = c_mida1

number = c_mnuma1.

IF sy-subrc = 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = c_d1.

ENDIF.

4 REPLIES 4
Read only

mvoros
Active Contributor
0 Likes
1,063

Hi,

have you tried updateflag to 'U' on schedule line? Replace this line w_schedulex-updateflag = 'X' by w_schedulex-updateflag = 'U'/ It might help.

BTW could you use tag code for your code posting. It;s really hard to read without it.

Cheers

Read only

0 Likes
1,063

Thanks for your answer.

I have changed 'X' to 'U', but now it leaves same quantity.

Any suggestion?

Thanks in advanced.

Read only

mvoros
Active Contributor
0 Likes
1,063

Hi,

Another try. Have a look at OSS note 366265. It looks like you need to fill field SCHED_LINE on schedule line level as well.

Cheers

Read only

0 Likes
1,063

Thanks Martin. Best Regards