Application Development 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: 

How to change the Quantity in the Credit Memo using BAPI

former_member194747
Participant
0 Kudos

Hi All,

I have a requirement in which i need to change the Quantity Value field available in the Credit Memo using BAPI.

Can anyone help me out to get any available BAPI to perform this action or any Solution to change the Quantity in the Credit Memo ?.

Regards,

Muruganand.K

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI,

You can make use of BAPI BAPI_SALESORDER_CHANGE

Pass your Credit Memo within SALESDOCUMENT

Under ORDER_ITEM_IN, you will find ITM_NUMBER and TARGET_QTY.Pass the appropriate values here.

Also, under ORDER_ITEM_INX, map the correspoding values to be 'X', the BAPI will itself identfy that the fields markeds 'X' are to be updated.

so it would be -

ORDER_ITEM_IN-TM_NUMBER = 'Your Item number

ORDER_ITEM_IN-TARGET_QTY = 'New Value

ORDER_ITEM_INX-TM_NUMBER = 'Your Item number

ORDER_ITEM_INX-TARGET_QTY = 'X'

Also,

do not forget to check the RETURN value, if it contains 'A' or 'E' roll back your work. else if evrything is fine, then you can make use of the BAPI_TRANSACTION_COMMIT.

Hope this helps

3 REPLIES 3

Former Member
0 Kudos

HI,

You can make use of BAPI BAPI_SALESORDER_CHANGE

Pass your Credit Memo within SALESDOCUMENT

Under ORDER_ITEM_IN, you will find ITM_NUMBER and TARGET_QTY.Pass the appropriate values here.

Also, under ORDER_ITEM_INX, map the correspoding values to be 'X', the BAPI will itself identfy that the fields markeds 'X' are to be updated.

so it would be -

ORDER_ITEM_IN-TM_NUMBER = 'Your Item number

ORDER_ITEM_IN-TARGET_QTY = 'New Value

ORDER_ITEM_INX-TM_NUMBER = 'Your Item number

ORDER_ITEM_INX-TARGET_QTY = 'X'

Also,

do not forget to check the RETURN value, if it contains 'A' or 'E' roll back your work. else if evrything is fine, then you can make use of the BAPI_TRANSACTION_COMMIT.

Hope this helps

0 Kudos

Hi,

Try using BAPI_SALESORDER_CHANGE.

DATA: s_order_header_in LIKE bapisdh1.
DATA: s_order_header_inx LIKE bapisdh1x.

DATA: BEGIN OF i_order_item_in OCCURS 0.
INCLUDE STRUCTURE bapisditm.
DATA: END OF i_order_item_in.
DATA: BEGIN OF i_order_item_inx OCCURS 0.
INCLUDE STRUCTURE bapisditmx.
DATA: END OF i_order_item_inx.
DATA: BEGIN OF it_return OCCURS 0.
INCLUDE STRUCTURE bapiret2.
DATA: END OF it_return.

DATA: BEGIN OF i_sched OCCURS 10.
INCLUDE STRUCTURE bapischdl.
DATA: END OF i_sched.

DATA: BEGIN OF i_schedx OCCURS 10.
INCLUDE STRUCTURE bapischdlx.
DATA: END OF i_schedx.

s_order_header_inx-updateflag = 'U'.

i_order_item_in-itm_number = vbap-posnr.
i_order_item_in-TARGET_QTY = rv45a-zzqty.
i_order_item_inx-updateflag = 'U'.
i_order_item_inx-itm_number = vbap-posnr.
i_order_item_inx-TARGET_QTY = 'X'.
APPEND: i_order_item_in, i_order_item_inx.

i_sched-itm_number = vbap-posnr.
i_sched-sched_line = '0002'.
i_sched-req_qty = rv45a-zzqty.
APPEND i_sched.
i_schedx-itm_number = vbap-posnr.
i_schedx-sched_line = '0002'.
i_schedx-updateflag = 'U'.
i_schedx-req_qty = 'X'.
APPEND i_schedx.

IF sy-subrc = 0.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = xvbap-vbeln
order_header_in = s_order_header_in
order_header_inx = s_order_header_inx
behave_when_error = 'P'
TABLES
return = it_return
order_item_in = i_order_item_in
order_item_inx = i_order_item_inx
schedule_lines = i_sched
schedule_linesx = i_schedx.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.

Change the fields as per your logic before populating orders item and schedule line data.

You have to pass the quantity in schedule line items as well in case you want to change quanity in order.

KR Jaideep,

Edited by: Jaideep Sharma on Jun 22, 2009 7:35 PM

former_member194747
Participant
0 Kudos

Hi All,

Thanks for your reply.

I want to change the Quantity in credit memo ,not in credit memo request.

credit memo will refer to billing document.