‎2008 Apr 15 4:16 PM
Dear friends,
I need sample code for the BAPI: BAPI_CUSTOMERQUOTATION_CHANGE
My intention is to change the condition rate (KONV-KBETR) for a condition type (say KONV-KSCHL = ZXYZ) of all the Quotation items with some new values.
Please reply at the earliest, as I need this code for my program.
Sincere thanks,
sap fan
‎2008 Apr 15 4:29 PM
Hi,
here is a sample!
method delete_delivery_block.
data: ls_vbak type vbak.
data: ls_vbakkom type vbakkom.
data: lt_vbpakom type table of vbpakom.
data: ls_vbakkomx type vbakkomx.
*
data: ls_header type bapisdh1.
data: ls_headerx type bapisdh1x.
data: lt_ret2 type table of bapiret2.
data: lv_error type xfeld.
field-symbols: <fs> type bapiret2.
ls_header-dlv_block = new_block.
ls_headerx-updateflag = 'U'.
ls_headerx-dlv_block = 'X'.
*Possible UPDATEFLAGS:
*U = change
*D = delete
*I = add
call function 'BAPI_CUSTOMERQUOTATION_CHANGE'
exporting
salesdocument = me->vbeln
quotation_header_in = ls_header
quotation_header_inx = ls_headerx
simulation = testrun
* BEHAVE_WHEN_ERROR =
* INT_NUMBER_ASSIGNMENT =
* LOGIC_SWITCH =
* NO_STATUS_BUF_INIT = ' '
tables
return = lt_ret2
* QUOTATION_ITEM_IN =
* QUOTATION_ITEM_INX =
* PARTNERS =
* PARTNERCHANGES =
* PARTNERADDRESSES =
* CONDITIONS_IN =
* CONDITIONS_INX =
* QUOTATION_CFGS_REF =
* QUOTATION_CFGS_INST =
* QUOTATION_CFGS_PART_OF =
* QUOTATION_CFGS_VALUE =
* QUOTATION_CFGS_BLOB =
* QUOTATION_CFGS_VK =
* QUOTATION_CFGS_REFINST =
* SCHEDULE_LINES =
* SCHEDULE_LINESX =
* QUOTATION_TEXT =
* QUOTATION_KEYS =
* EXTENSIONIN =
.
if testrun is initial.
lv_error = zcl_bapi=>check_for_errors( lt_ret2 ).
if lv_error is initial.
commit work.
endif.
endif.
loop at lt_ret2 assigning <fs>.
<fs>-message_v1 = me->vbeln.
endloop.
bapireturn[] = lt_ret2[].
endmethod.
‎2008 Apr 15 4:29 PM
Hi,
here is a sample!
method delete_delivery_block.
data: ls_vbak type vbak.
data: ls_vbakkom type vbakkom.
data: lt_vbpakom type table of vbpakom.
data: ls_vbakkomx type vbakkomx.
*
data: ls_header type bapisdh1.
data: ls_headerx type bapisdh1x.
data: lt_ret2 type table of bapiret2.
data: lv_error type xfeld.
field-symbols: <fs> type bapiret2.
ls_header-dlv_block = new_block.
ls_headerx-updateflag = 'U'.
ls_headerx-dlv_block = 'X'.
*Possible UPDATEFLAGS:
*U = change
*D = delete
*I = add
call function 'BAPI_CUSTOMERQUOTATION_CHANGE'
exporting
salesdocument = me->vbeln
quotation_header_in = ls_header
quotation_header_inx = ls_headerx
simulation = testrun
* BEHAVE_WHEN_ERROR =
* INT_NUMBER_ASSIGNMENT =
* LOGIC_SWITCH =
* NO_STATUS_BUF_INIT = ' '
tables
return = lt_ret2
* QUOTATION_ITEM_IN =
* QUOTATION_ITEM_INX =
* PARTNERS =
* PARTNERCHANGES =
* PARTNERADDRESSES =
* CONDITIONS_IN =
* CONDITIONS_INX =
* QUOTATION_CFGS_REF =
* QUOTATION_CFGS_INST =
* QUOTATION_CFGS_PART_OF =
* QUOTATION_CFGS_VALUE =
* QUOTATION_CFGS_BLOB =
* QUOTATION_CFGS_VK =
* QUOTATION_CFGS_REFINST =
* SCHEDULE_LINES =
* SCHEDULE_LINESX =
* QUOTATION_TEXT =
* QUOTATION_KEYS =
* EXTENSIONIN =
.
if testrun is initial.
lv_error = zcl_bapi=>check_for_errors( lt_ret2 ).
if lv_error is initial.
commit work.
endif.
endif.
loop at lt_ret2 assigning <fs>.
<fs>-message_v1 = me->vbeln.
endloop.
bapireturn[] = lt_ret2[].
endmethod.
‎2008 Apr 16 6:08 AM
Thanks for the post Bert!!
But it will not help me, as I want to change the condition rate of items, and not looking for some other header level change.
Let me breifly tell you what I have tried:
I populated the fields: ITM_NUMBER, COND_ST_NO, COND_COUNT, COND_TYPE and COND_VALUE in the table CONDITIONS_IN. And CONDITIONS_INX with the respective fields...
Flag 'U' wherever needed.
The function module runs succesfully but the changes values are not reflected in the Quotation.
Looking for suitable reply still....
Thanks
‎2008 Apr 16 6:14 AM
Hi,
Perform Commit by calling the bapi BAPI_TRANSACTION_COMMIT after the change bapi.
It does the saving work.
And also do send your code so that it will be easy fr us to find out where you might have gone wrong.
1. Minimum specifications:
The quotation number must definitely be entered in the SALESDOCUMENT structure.
Always enter key fields when you make a change.
The update indicator QUOTATION_HEADER_INX must always be entered.
2. Commit control
The BAPI does not have a database. This means that the relevant application must leave the commit, in order that changes can be carried out on the database. The BAPI BAPI_TRANSACTION_COMMIT is available for this.
Go through the documentation of the BAPI for more info
Reward points if you find it helpful.
Regards,
Prasanna
‎2008 Apr 16 1:53 PM
Thanks for pointing out that I should have sent my code for quick replies. And ofcourse! I did call the 2nd func. module for COMMIT WORK...
Thanks guys, Its solved... I was using the flag as 'X' instead of 'U' in the field - CONDITIONS_INX-UPDATEFLAG.
Thanks again,
sap fan