BAPI_SALESORDER_CHANGE
Hi All,
I have a requirement to change the reasons for rejection for selective items in the sales order.
but when i use BAPI_SALESORDER_CHANGE. i get the error:
Field ABGRU cannot be changed VBAPKOM 0003000ready for input.
Sales document not changed.
These are the following values i pass:
IMPORT PARAMETERS:
Salesdocument :' 100000356'
Order_header_inx-Updateflag = 'X'
TABLES:
order_item_in-item_number = '003000'.
order_item_in-plant = '1000'.
order_item_in-reason_rej = ' '.
order_item_inx-item_number = '003000'.
order_item_inx-updateflag = 'U'.
order_item_inx-reason_rej = 'X'.
order_item_inx-plant = 'X'.
do i have to input any other values .Pls help.
thanks,
Kavitha
REPORT ZSALESORDER_CHANGE MESSAGE-ID 38.
Selection Screen Definitions *
PARAMETERS: p_vbeln TYPE vbap-vbeln OBLIGATORY, "Order Number
p_posnr TYPE vbap-posnr OBLIGATORY, "Order Item
p_etenr TYPE vbep-etenr OBLIGATORY, "Schedule Line
p_reqqty TYPE bapischdl-req_qty OBLIGATORY. " Order Qty
Internal Tables/Structures/Variables for calling BAPI. *
DATA: i_hdr TYPE bapisdh1,
i_hdrx TYPE bapisdh1x,
i_ret TYPE bapiret2 OCCURS 0 WITH HEADER LINE,
wa_ret TYPE bapiret2.
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.
START-OF-SELECTION Event *
START-OF-SELECTION.
*" Initialize internal tables.
REFRESH: i_sched, i_schedx, i_ret.
CLEAR: i_sched, i_schedx, i_ret.
*" Fill required ORDER_HEADER_IN data.
i_hdrx-updateflag = 'U'.
*" Fill required SCHEDULE_LINES data.
*P_POSNR = P_POSNR + 10.
i_sched-itm_number = p_posnr.
i_sched-sched_line = p_etenr.
i_sched-req_qty = p_reqqty.
i_schedx-updateflag = 'U'.
i_schedx-itm_number = p_posnr.
i_schedx-sched_line = p_etenr.
i_schedx-req_qty = 'X'.
*i_schedx-ITM_NUMBER = 'X'.
*i_schedx-SCHED_LINE = 'X'.
APPEND i_sched.
APPEND i_schedx.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = p_vbeln
order_header_in = i_hdr
order_header_inx = i_hdrx
TABLES
return = i_ret
schedule_lines = i_sched
schedule_linesx = i_schedx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
LOOP AT i_ret.
WRITE / i_ret-message.
ENDLOOP.
Similar Messages
-
BAPI_SALESORDER_CHANGE to update reason for rejection of sales order item
Hi,
The FM BAPI_SALESORDER_CHANGE is not working properly as I am getting below error when try to update the reason for rejection at sales order item level.
The delivery is done for this salesorder. Is it because the reason for rejection field is not as an input field when delivery done?
error in return table is " Field 'ABGRU' cannot be changed, VBAPKOM 000010 ready for input"
Request your suggestions to avoid this error.
Thanks>
anikaushi wrote:
> Hi,
> The delivery is done for this salesorder. Is it because the reason for rejection field is not as an input field when delivery done?
>
> error in return table is " Field 'ABGRU' cannot be changed, VBAPKOM 000010 ready for input"
>
>
> Thanks
Yes, Most likely.. You can confirm this by trying to change a order without delivery and see if it goes thru (to ensure that you have passed correct parameters)...
you may have to delete the delivery (and if billing document exist, cancel it), before you can reject the line item... it would be safer to raise an error message and let the users manually delete delivery document as long as you don't have large volumes of this scenario..
Please see the SDN thread for how you can avoid this error...
Re: Cancel Sale Order after Issued Billing -
Schedule lines creation with BAPI_SALESORDER_CHANGE
Dear All,
1. I'm trying to create a new Schedule Lines to an already existing Scheduling Agreement.
2. For this, I'm using the BAPI --> BAPI_SALESORDER_CHANGE.
3. This BAPI returns me a message saying that the Schedule line processed successfully.
4. When I check the VBEP Table with the Scheduling Agreement number, I'm able to see the newly created schedule line.
5. But, when I see the Transaction VA33, I'm not able to see the schedule lines.
I checked in SDN and OSS notes. I found 1647069 which says to pass the line number and Item number which I'm already doing it.
Can any one help me out ?
Regards,
Deepu.KI verified in my system that the below should work. Here, I am inserting a new schedule 0002 for item 10 with qty 1 and another date.
Of course, you should ensure that there is sufficient quantity that is not yet confirmed by existing schedule lines.
BAPI_SALESORDER_CHANGE
SALESDOCUMENT = '0011827125'
ORDER_HEADER_INX
UPDATEFLAG = 'U'
ORDER_ITEM_IN
ITM_NUMBER = '000010'
ORDER_ITEM_INX
ITM_NUMBER = '000010'
UPDATEFLAG = 'U'
SCHEDULE_LINES
ITM_NUMBER = '000010'
SCHED_LINE = '0002'
REQ_DATE = '20120104'
REQ_QTY = '1'
SCHEDULE_LINESX
ITM_NUMBER = '000010'
SCHED_LINE = '0002'
UPDATEFLAG = 'I'
REQ_DATE = 'X'
REQ_QTY = 'X'. -
BAPI_SALESORDER_CHANGE schedule_lines
Hi experts.
I'm doing a simple order update, using FM BAPI_SALESORDER_CHANGE.
The goal is to change header data (with order_header_in and order_header_inx structures), schedule lines data (with schedule_lines and schedule_linesx structures) and text data (with order_text structure).
The problem is that header and text data is actually changed, but schedulle data doesn't.
Can anyone help?
Best regards.
Valter Oliveira.
SAMPLE CODE:
HEADER
CLEAR: wa_header_in.
wa_header_in-po_dat_s = wa_pub-data.
wa_header_in-ref_1 = wa_pub-diario.
wa_header_in-ref_1_s = wa_pub-suplemento.
wa_header_in-dlv_block = space.
CLEAR: wa_header_inx.
wa_header_inx-updateflag = 'U'.
wa_header_inx-po_dat_s = 'X'.
wa_header_inx-ref_1 = 'X'.
wa_header_inx-ref_1_s = 'X'.
wa_header_inx-dlv_block = 'X'.
SCHEDULE
SELECT posnr FROM vbap
INTO (vl_posnr)
WHERE vbeln = wa_pub-vbeln.
SELECT etenr FROM vbep
INTO (vl_etenr)
WHERE vbeln = wa_pub-vbeln
AND posnr = vl_posnr.
ti_sched-itm_number = vl_posnr.
ti_sched-sched_line = vl_etenr.
ti_sched-req_dlv_bl = space.
ti_sched-req_date = wa_pub-data.
ti_sched-sched_type = 'CN'.
ti_schedx-itm_number = vl_posnr.
ti_schedx-sched_line = vl_etenr.
ti_schedx-req_dlv_bl = 'X'.
ti_schedx-sched_type = 'X'.
ti_schedx-req_date = 'X'.
APPEND ti_sched. APPEND ti_schedx.
ENDSELECT.
ENDSELECT.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = wa_pub-vbeln
order_header_in = wa_header_in
order_header_inx = wa_header_inx
TABLES
schedule_lines = ti_sched
schedule_linesx = ti_schedx
order_text = ti_texts
return = ti_ret.Hi experts.
I'm doing a simple order update, using FM BAPI_SALESORDER_CHANGE.
The goal is to change header data (with order_header_in and order_header_inx structures), schedule lines data (with schedule_lines and schedule_linesx structures) and text data (with order_text structure).
The problem is that header and text data is actually changed, but schedulle data doesn't.
Can anyone help?
Best regards.
Valter Oliveira.
SAMPLE CODE:
HEADER
CLEAR: wa_header_in.
wa_header_in-po_dat_s = wa_pub-data.
wa_header_in-ref_1 = wa_pub-diario.
wa_header_in-ref_1_s = wa_pub-suplemento.
wa_header_in-dlv_block = space.
CLEAR: wa_header_inx.
wa_header_inx-updateflag = 'U'.
wa_header_inx-po_dat_s = 'X'.
wa_header_inx-ref_1 = 'X'.
wa_header_inx-ref_1_s = 'X'.
wa_header_inx-dlv_block = 'X'.
SCHEDULE
SELECT posnr FROM vbap
INTO (vl_posnr)
WHERE vbeln = wa_pub-vbeln.
SELECT etenr FROM vbep
INTO (vl_etenr)
WHERE vbeln = wa_pub-vbeln
AND posnr = vl_posnr.
ti_sched-itm_number = vl_posnr.
ti_sched-sched_line = vl_etenr.
ti_sched-req_dlv_bl = space.
ti_sched-req_date = wa_pub-data.
ti_sched-sched_type = 'CN'.
ti_schedx-itm_number = vl_posnr.
ti_schedx-sched_line = vl_etenr.
ti_schedx-req_dlv_bl = 'X'.
ti_schedx-sched_type = 'X'.
ti_schedx-req_date = 'X'.
APPEND ti_sched. APPEND ti_schedx.
ENDSELECT.
ENDSELECT.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = wa_pub-vbeln
order_header_in = wa_header_in
order_header_inx = wa_header_inx
TABLES
schedule_lines = ti_sched
schedule_linesx = ti_schedx
order_text = ti_texts
return = ti_ret. -
To delete sales order using BAPI_SALESORDER_CHANGE
HI ,
I am using BAPI_SALESORDER_CHANGE to delete a bulk of order lines for an order.But the issue is...the entries are deleted in VBEP and VBUP tables for all the order lines where in VBAP only few order lines are deleted.This is happening repeatedly.
I am passing data like this...
CLEAR: l_vbap_inx.
l_vbap_inx-itm_number = t_vbap-posnr. " will have value
l_vbap_inx-updateflag = 'D'.
APPEND l_vbap_inx.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = i_vbeln "will have order number
order_header_inx = l_vbak_inx " will be paased with values 'U'
order_header_in = header "will not hold any value
simulation = i_simulate "space
TABLES
return = l_return
order_item_in = l_vbap "bulk of order lines with 'D' flag
order_item_inx = l_vbap_inx
extensionin = l_vbap_ext.
can you please suggest on this......
Thanks in advance.HI ,
Can any one of you please suggest me to amend the below given code which is used to delete bulk of order lines from VBAP table.presently it is deleting first few order lines from VBAP and all order lines from VBEP and VBUP tables.when i execute the same program for second time first left out order lines are getting deleted again.So..can any one please check the below code and suggest me something on this.
REFRESH: l_return, l_vbap, l_vbap_inx, l_vbap_ext.
IF xorder_delete = 'X'.
l_vbak_inx-updateflag = 'D'.
Even though all the order lines are to be deleted, the delete complete
order flag says don't delete the header data
IF i_cleanup = space.
l_vbak_inx-updateflag = 'U'.
PERFORM validate_line_count TABLES l_vbap_ext "iw150709
USING i_vbeln. "iw150709
ENDIF.
ELSE.
l_vbak_inx-updateflag = 'U'.
PERFORM validate_line_count TABLES l_vbap_ext "iw150709
USING i_vbeln. "iw150709
ENDIF.
LOOP AT t_vbap WHERE delete = 'X'.
CLEAR: l_vbap.
l_vbap-itm_number = t_vbap-posnr.
APPEND l_vbap.
CLEAR: l_vbap_inx.
l_vbap_inx-itm_number = t_vbap-posnr.
l_vbap_inx-updateflag = 'D'.
APPEND l_vbap_inx.
CLEAR: l_vbap_ext, l_extension_vbapx.
l_vbap_ext-structure = 'BAPE_VBAPX'.
l_extension_vbapx-vbeln = i_vbeln.
l_extension_vbapx-posnr = t_vbap-posnr.
l_extension_vbapx-zzco_reason = 'X'.
l_vbap_ext+30 = l_extension_vbapx.
APPEND l_vbap_ext.
CLEAR: l_vbap_ext, l_extension_vbap.
l_vbap_ext-structure = 'BAPE_VBAP'.
l_extension_vbap-vbeln = i_vbeln.
l_extension_vbap-posnr = t_vbap-posnr.
l_extension_vbap-zzco_reason = i_reason.
l_vbap_ext+30 = l_extension_vbap.
APPEND l_vbap_ext.
ENDLOOP.
Only call BAPI if NOT in test mode.
IF i_simulate = space.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = i_vbeln
order_header_inx = l_vbak_inx
order_header_in = header
simulation = i_simulate
TABLES
return = l_return
order_item_in = l_vbap
order_item_inx = l_vbap_inx
extensionin = l_vbap_ext.
ENDIF.
LOOP AT l_return WHERE type = 'E' OR type = 'A'.
MOVE-CORRESPONDING l_return TO t_messages.
t_messages-field = 'VBELN'.
APPEND t_messages.
ENDLOOP.
No ERRORs
IF sy-subrc <> 0.
IF i_simulate = space.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
IMPORTING
return = l_return.
Edited by: manj1325 on Apr 9, 2010 8:19 AM -
How to pass Itab to "BAPI_SALESORDER_CHANGE"
Requirment : We cancel sales order that have been created but not fulfilled within 7 days.
At present, we do this manually. Can we configure to have the system auto cancel the sales order
after the said period?
selection screen
u2022 Sales organization (P_VKORG like ZSD_REJECT-VKORG)
u2022 Sales office (S_VKBUR for ZSD_REJECT-VKBUR)
u2022 Plant (S_WERKS for ZSD_REJECT-WERKS)
u2022 Sales order type (S_AUART for ZSD_REJECT-AUART)
u2022 Sales order no. (S_VBELN for ZSD_REJECT-VBELN)
u2022 Customer no. (S_KUNNR for ZSD_REJECT-KUNNR)
u2022 Rejection date (S_REJDTE for ZSD_REJECT-REJDATE)
Report format/columns should be as follows:
1. Sales organization (ZSD_REJECT-VKORG)
2. Sales office (ZSD_REJECT-VKBUR)
3. Plant (ZSD_REJECT-WERKS)
4. Customer no. (ZSD_REJECT-KUNNR)
5. Customer name (KNA1-NAME1)
6. Sales order no. (ZSD_REJECT-VBELN)
7. Sales order item (ZSD_REJECT-POSNR)
8. Material no. (VBAP-MATNR)
9. Material description (VBAP-ARKTX)
10. Order quantity (VBAP-KWMENG)
11. Rejected quantity (ZSD_REJECT-REJQTY)
12. Unit of measure (VBAP-VRKME)
13. Rejected net value (ZSD_REJECT-REJVAL)
14. Currency (VBAK-WAERK)
15. Rejection date (ZSD_REJECT-REJDATE)
16. Rejection time (ZSD_REJECT-REJTIME)
17. Rejection user (ZSD_REJECT-REJUSER)
Program : I have created one report & calling bapi BAPI_SALESORDER_CHANGE
TYPES: BEGIN OF t_tab,
vkorg TYPE zsd_reject-vkorg ,
vkbur TYPE zsd_reject-vkbur ,
auart TYPE zsd_reject-auart ,
END OF t_tab.
TYPES: BEGIN OF t_vbak,
vbeln TYPE vbak-vbeln ,
erdat TYPE vbak-erdat ,
waerk TYPE vbak-waerk,
vbtyp TYPE vbak-vbtyp,
auart TYPE vbak-auart,
vkorg TYPE vbak-vkorg ,
vkbur TYPE vbak-vkbur ,
kunnr TYPE vbak-kunnr ,
cmfre TYPE vbak-cmfre ,
gbsta type vpup-gbsta,
costa TYPE vbuk-costa ,
fkstk TYPE vbuk-fkstk,
END OF t_vbak.
TYPES: BEGIN OF t_data,
vbeln TYPE vbak-vbeln ,
waerk TYPE vbak-waerk,
auart TYPE vbak-auart,
vkorg TYPE vbak-vkorg ,
vkbur TYPE vbak-vkbur ,
kunnr TYPE vbak-kunnr ,
cmfre TYPE vbak-cmfre ,
END OF t_data.
TYPES: BEGIN OF t_vbap,
matnr TYPE vbap-matnr ,
vbeln TYPE vbap-vbeln ,
posnr TYPE vbap-posnr,
arktx TYPE vbap-arktx ,
pstyv TYPE vbap-pstyv,
abgru TYPE vbap-abgru,
kwmeng TYPE vbap-kwmeng,
werks TYPE vbap-werks ,
END OF t_vbap.
TABLES *
TABLES : zsd_reject.
INTERNAL TABLES, STRUCTURES & WORK AREAS *
DATA: it_vbak TYPE STANDARD TABLE OF t_vbak WITH HEADER LINE,
it_data TYPE STANDARD TABLE OF t_data WITH HEADER LINE ,
it_vbap TYPE STANDARD TABLE OF t_vbap ,
wa_vbak TYPE t_vbak ,
wa_vbap TYPE t_vbap ,
wa_data TYPE t_data.
PARAMETERS & SELECT-OPTIONS *
DUE TO AN SAP LIMITATION WITH CREATING / CHANGING VARIANTS,
selection screen fields over 45 characters in length should be avoided
SELECTION-SCREEN: BEGIN OF BLOCK a01 WITH FRAME TITLE text-001.
PARAMETERS: p_vkorg LIKE zsd_reject-vkorg.
SELECT-OPTIONS: s_vkbur FOR zsd_reject-vkbur,
s_werks FOR zsd_reject-werks,
s_auart FOR zsd_reject-auart,
s_vbeln FOR zsd_reject-vbeln,
s_kunnr FOR zsd_reject-kunnr,
s_rejdte FOR zsd_reject-rejdate.
SELECTION-SCREEN: END OF BLOCK a01.
DATA : p_days TYPE i VALUE 7,
l_checkdate LIKE sy-datum.
START-OF-SELECTION.
l_checkdate = sy-datum - p_days.
SELECT vbak~vbeln
vbak~erdat
vbak~waerk
vbak~vbtyp
vbak~auart
vbak~vkorg
vbak~vkbur
vbak~kunnr
vbak~cmfre
vbup~gbsta
vbuk~costa
vbuk~fkstk
INTO TABLE it_vbak
FROM vbak INNER JOIN vbuk
ON vbakvbeln = vbukvbeln
WHERE vbak~vkorg = p_vkorg
AND vbak~vkbur IN s_vkbur
AND vbak~auart IN s_auart
AND vbak~vbtyp = 'C'
AND vbuk~gbstk NE 'C'.
Requirment :
This checking is only for those order were previously blocked and has been released, which means credit release date not equal to 00.00.0000 and hence program will check rejection logic based on credit release date vs system date > 7 calendar days. For those orders which holding credit release date equals to 00.00.0000 will go through rejection checking
based on order creation date vs system date > 7 calendar days respectively.
LOOP AT it_vbak INTO wa_vbak.
IF NOT wa_vbak-cmfre IS INITIAL.
IF wa_vbak-cmfre > l_checkdate.
DELETE it_vbak FROM wa_vbak.
ENDIF.
ELSE.
IF wa_vbak-erdat > l_checkdate.
DELETE it_vbak FROM wa_vbak.
ENDIF.
ENDIF.
ENDLOOP.
SELECT vbapmatnr vbapvbeln vbapposnr vbaparktx vbap~pstyv
vbapabgru vbapkwmeng vbap~werks INTO TABLE it_vbap
FROM vbap INNER JOIN vbup ON
vbapvbeln = vbupvbeln AND vbapposnr = vbupposnr
FOR ALL entries
IN it_vbak WHERE vbap~vbeln = it_vbak-vbeln AND
gbsta NE 'C'.
I have taken the records in two internal table for header & item it_vbak & it_vbap
now I need to call the BAPI_SALESORDER_CHANGE and pass the internal table to Bapi .
Can anyone please let me know how to pass this into Bapi?
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument =
ORDER_HEADER_IN =
order_header_inx =
SIMULATION =
BEHAVE_WHEN_ERROR = ' '
INT_NUMBER_ASSIGNMENT = ' '
LOGIC_SWITCH =
tables
return =
ORDER_ITEM_IN =
ORDER_ITEM_INX =
PARTNERS =
PARTNERCHANGES =
PARTNERADDRESSES =
ORDER_CFGS_REF =
ORDER_CFGS_INST =
ORDER_CFGS_PART_OF =
ORDER_CFGS_VALUE =
ORDER_CFGS_BLOB =
ORDER_CFGS_VK =
ORDER_CFGS_REFINST =
SCHEDULE_LINES =
SCHEDULE_LINESX =
ORDER_TEXT =
ORDER_KEYS =
CONDITIONS_IN =
CONDITIONS_INX =
EXTENSIONIN =
Thanks in advance
Regards
RahulHi,
I am trying to cancel the sales order that have been created but not fulfilled within 7 days.
If this condition is true dump is coming (when I am trying to delete the records from internal table)
if wa_vbak-erdat > l_checkdate.
delete it_vbak from wa_vbak.
endif.
Error analysis
The program attempted to interp 70000200KL " as a number, but since the value contravenes the
this was not possible.
types: begin of t_vbak,
vbeln type vbak-vbeln ,
erdat type vbak-erdat ,
waerk type vbak-waerk,
vbtyp type vbak-vbtyp,
auart type vbak-auart,
vkorg type vbak-vkorg ,
vtweg type vbak-vtweg,
spart type vbak-spart,
vkbur type vbak-vkbur ,
kunnr type vbak-kunnr ,
cmfre type vbak-cmfre ,
gbsta type vpup-gbsta,
costa type vbuk-costa ,
fkstk type vbuk-fkstk,
end of t_vbak.
data : p_days type i value 7,
l_checkdate like sy-datum.
DATA: it_vbak TYPE STANDARD TABLE OF t_vbak WITH HEADER LINE,
it_data TYPE STANDARD TABLE OF t_data WITH HEADER LINE ,
start-of-selection.
l_checkdate = sy-datum - p_days.
select vbak~vbeln
vbak~erdat
vbak~waerk
vbak~vbtyp
vbak~auart
vbak~vkorg
vbak~vtweg
vbak~spart
vbak~vkbur
vbak~kunnr
vbak~cmfre
vbup~gbsta
vbuk~costa
vbuk~fkstk
into corresponding fields of table it_vbak
from vbak inner join vbuk
on vbakvbeln = vbukvbeln
where vbak~vkorg = p_vkorg
and vbak~vkbur in s_vkbur
and vbak~auart in s_auart
and vbak~vbtyp = 'C'
and vbuk~gbstk ne 'C'
and vbak~vbeln = '0000003549'.
sort it_vbak by vbeln.
if not it_vbak[] is initial.
loop at it_vbak into wa_vbak.
if not wa_vbak-cmfre is initial.
if wa_vbak-cmfre > l_checkdate.
delete it_vbak from wa_vbak.
endif.
else.
******Error (short dump here if condition true )***************************
if wa_vbak-erdat > l_checkdate.
delete it_vbak from wa_vbak.
endif.
endif.
endloop.
endif.
Regards
Rahul -
BAPI_SALESORDER_CHANGE. Error V1 045 -- Indicate number of document.
Hi Experts.
When a pre-order (ZAG) it's confirmed in SAP, we make an oficial order (TA), then, when save the oficial order I need delete the field LCNUM in pre-order.
I'm using this BAPI, in a USER EXIT inside program SAPVM45A, when the number of document it's the pre-order.. but it failed, and return to me the message error that I don't indicate the number of document.
I find where it's the fail, when called to this function
call function 'SD_SALES_DOCUMENT_READ'
there is a moment in the code with that
VBAK-VBELN = DOCUMENT_NUMBER.
PERFORM BELEG_LESEN(SAPMV45A).
PERFORM KONV_SELECT(SAPFV45P).
Well, when called the perform BELEG_LESEN, ---> VBAK-VBELN LOST , yes I tell you the true..., LOST the value of the pre-Order...
I think that when I call this function it's while save a order, program lost the value
Example of the code:
l_saledocument = v_vbelv. "Number of pre-po
l_order_header_in-doc_num_fi = l_lcnum. "l_lcnum it's empty because I want update INITIAL in pre-po
l_order_header_inx-doc_num_fi = 'X'.
l_order_header_inx-updateflag = 'U'.
Llamada a la bapi
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = l_saledocument
order_header_in = l_order_header_in
order_header_inx = l_order_header_inx
TABLES
return = li_return.
READ TABLE li_return WITH KEY type = 'E'.Hi Pedro,
have a look to SAP Note 1232196.
You have to call FM SD_SALES_DOCUMENT_INIT before calling BAPI
Hope it helps
Lorenzo -
BAPI_SALESORDER_CHANGE add new line and conditions with a condition value
Hi,
I am using BAPI_SALESORDER_CHANGE to add new lines to a credit memo. All works fine except that I can not seem to put a condition value on the new lines. The condition is created but with a value of 0. I can popluate the condition amount field, KBETR but not KWERT. BAPICONDX seems to only have the COND_VALUE field in it and not CONDVALUE as in BAPICOND. Does anyone have any idea how to do this? In the code below I just want to change the material on the first line of the credit memo and not add the condition. Then add new lines with the the condition.
lw_order_header_inx-updateflag = 'U'.
LOOP AT i_accru INTO wa_accru.
lv_count = lv_count + 1.
lv_posnr = lv_count * 10.
* Order Items
lw_order_item_inx-itm_number = lv_posnr.
lw_order_item_inx-material = 'X'.
IF lv_count = 1.
lw_order_item_inx-updateflag = 'U'.
ELSE.
lw_order_item_inx-updateflag = 'I'.
ENDIF.
APPEND lw_order_item_inx TO lt_order_item_inx.
lw_order_item_in-itm_number = lv_posnr.
lw_order_item_in-material = wa_accru-vakey.
APPEND lw_order_item_in TO lt_order_item_in.
* Conditions
IF lv_count <> 1.
lw_conditions_inx-itm_number = lv_posnr.
lw_conditions_inx-cond_st_no = '905'.
lw_conditions_inx-cond_count = '01'.
lw_conditions_inx-cond_type = 'ZHIE'.
lw_conditions_inx-currency = 'X'.
lw_conditions_inx-updateflag = 'I'.
APPEND lw_conditions_inx TO lt_conditions_inx.
lw_conditions_in-itm_number = lv_posnr.
lw_conditions_in-cond_st_no = '905' .
lw_conditions_in-cond_count = '01'.
lw_conditions_in-cond_type = 'ZHIE'.
lw_conditions_in-condvalue = wa_accru-accru.
lw_conditions_in-currency = 'GBP'.
APPEND lw_conditions_in TO lt_conditions_in.
ENDIF.
ENDLOOP.
* Change the credit memo
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = lv_vbeln
order_header_in = lw_order_header_in
order_header_inx = lw_order_header_inx
* SIMULATION =
* BEHAVE_WHEN_ERROR = ' '
* INT_NUMBER_ASSIGNMENT = ' '
* LOGIC_SWITCH =
* NO_STATUS_BUF_INIT = ' '
TABLES
return = lt_return
order_item_in = lt_order_item_in
order_item_inx = lt_order_item_inx
* PARTNERS =
* PARTNERCHANGES =
* PARTNERADDRESSES =
* ORDER_CFGS_REF =
* ORDER_CFGS_INST =
* ORDER_CFGS_PART_OF =
* ORDER_CFGS_VALUE =
* ORDER_CFGS_BLOB =
* ORDER_CFGS_VK =
* ORDER_CFGS_REFINST =
* SCHEDULE_LINES =
* SCHEDULE_LINESX =
* ORDER_TEXT =
* ORDER_KEYS =
conditions_in = lt_conditions_in
conditions_inx = lt_conditions_inx
* EXTENSIONIN =
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
ENDIF.Hi Rob,
Have you managed to solve this issue. If so, could you please share the solution.
I am also facing similar problem.
Thanks for your help.
Anoop -
LOGIC_SWITCH-SCHEDULING in BAPI_SALESORDER_CHANGE
Hello,
What's the function of the parameter LOGIC_SWITCH-SCHEDULING in BAPI_SALESORDER_CHANGE?
ThanksPeter,
Give this a look.
REPORT ZR_SANDBOX_PROG.
data: vb like BAPIVBELN-VBELN.
data: cl like BAPISDH1X.
data: rt type table of BAPIRET2 with header line.
data: rt2 type BAPIRET2.
data: pt type table of BAPIPARNRC with header line.
vb = '0000153147'. " your sales order here
cl-updateflag = 'U'.
pt-DOCUMENT = vb.
pt-ITM_NUMBER = '000000'. "header line item = 000000
pt-UPDATEFLAG = 'U'.
pt-PARTN_ROLE = 'WE'. "ship-to
pt-P_NUMB_OLD = '0003300744'. "original number
pt-P_NUMB_NEW = '0003300074'. "new number
append pt.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = vb
ORDER_HEADER_INX = cl
TABLES
RETURN = rt
PARTNERCHANGES = pt.
loop at rt.
write: / rt-MESSAGE.
endloop.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = rt2.
Reward points accordingly. -
Deleting Sales Order Details using BAPI_SALESORDER_CHANGE And Reinserting
Hi All,
I need to <b>change a Sales Order</b> in such a way that I would <b>delete all the existing Line Items</b> of that SO And <b>then reinsert new Line Items</b> as generally is the practice of saving a document.(Update Header-Delete Old Item Entries-Reinsert New Present Entries).
I coded a small test program in ABAP using the <b>BAPI_SALESORDER_GETLIST And BAPI_SALESORDER_CHANGE</b>.
In order to affect the Qty I have to update the Schedule Parameter also of the BAPI_SALESORDER_CHANGE Function.But this causes a new entry in VBEP.
eg:
<b>Before BAPI Calls</b>
SO-Number:9001
Header:9001,etc......
Detail:ItemNo=10,Material=xyz,TargetQty=100,etc..
Scedule:ItemNo=10,Scheduleline=1,Req_Qty=100,etc...
I coded the program such that
1.I <b>Get the List of Items</b> using BAPI_SALESORDER_GETLIST.
2.Call the <b>BAPI_SALESORDER_CHANGE</b> filling appropraite values in Parameters <b>with UpdateFlag = 'D'</b>
3.<b>Insert new values</b> in OrderItems And Schedule Parameters
say:
Detail:ItemNo=10,Material=xyz,TargetQty=25,etc..
Scedule:ItemNo=10,Scheduleline=1,Req_Qty=25,etc...
4.<b>Call the BAPI_SALESORDER_CHANGE</b> filling appropraite values in Parameters <b>with UpdateFlag = 'I'</b>
<b>The output now becomes.</b>Header:9001,etc......
Detail:ItemNo=10,Material=xyz,TargetQty=100,etc..
Scedule:ItemNo=10,Scheduleline=1,Req_Qty=100,etc...
ItemNo=10,Scheduleline=2,Req_Qty=25,etc...
Now After Commit when I see my <b>SO it shows me a qty of
125</b>.
I am attaching the code for your analysis.
Thanx in advance.
*& Report ZSM_CHANGESALESORDER *
REPORT ZSM_CHANGESALESORDER .
DATA:
For Calling the GetList BAPI Function
CUSTOMER_NUMBER LIKE BAPI1007-CUSTOMER,
SALES_ORGANIZATION LIKE BAPIORDERS-SALES_ORG,
IT_SALES_ORDERS LIKE TABLE OF BAPIORDERS,
WA_SALES_ORDERS LIKE LINE OF IT_SALES_ORDERS,
IT_RETURN LIKE TABLE OF BAPIRETURN,
WA_RETURN LIKE LINE OF IT_RETURN.
For Calling the ChangeFromData BAPI Function
DATA:
SALESDOCUMENT LIKE BAPIVBELN-VBELN,
WA_ORDER_HEADER_IN LIKE BAPISDH1,
WA_ORDER_HEADER_INX LIKE BAPISDH1X,
IT_ORDER_ITEM_IN LIKE TABLE OF BAPISDITM ,
WA_ORDER_ITEM_IN LIKE LINE OF IT_ORDER_ITEM_IN,
IT_ORDER_ITEM_INX LIKE TABLE OF BAPISDITMX ,
WA_ORDER_ITEM_INX LIKE LINE OF IT_ORDER_ITEM_INX,
IT_SCHEDULE_LINES LIKE TABLE OF BAPISCHDL ,
WA_SCHEDULE_LINES LIKE LINE OF IT_SCHEDULE_LINES,
IT_SCHEDULE_LINESX LIKE TABLE OF BAPISCHDLX ,
WA_SCHEDULE_LINESX LIKE LINE OF IT_SCHEDULE_LINESX,
IT_RETURN_CHG LIKE TABLE OF BAPIRET2,
WA_RETURN_CHG LIKE LINE OF IT_RETURN_CHG.
DATA:
IT_RETURN_CT LIKE BAPIRET2.
PARAMETERS:
P_SO LIKE VBAK-VBELN,
P_CUSTNO LIKE BAPI1007-CUSTOMER,
P_SORG LIKE BAPIORDERS-SALES_ORG.
START-OF-SELECTION.
SALESDOCUMENT = P_SO.
CUSTOMER_NUMBER = P_CUSTNO.
SALES_ORGANIZATION = P_SORG.
Retrieve the Existing Sales Order details for that Sales Order.
PERFORM GETREQSODETAILS.
Delete the Existing Sales Order details from that Sales Order.
PERFORM DELETEOLDSODETAILS.
Insert New details for that Sales Order.
PERFORM ADDNEWSODETAILS.
END-OF-SELECTION.
PERFORM COMMITTRANS.
*& Form GetReqSODetails
FORM GETREQSODETAILS .
CALL FUNCTION 'BAPI_SALESORDER_GETLIST'
EXPORTING
CUSTOMER_NUMBER = CUSTOMER_NUMBER
SALES_ORGANIZATION = SALES_ORGANIZATION
IMPORTING
RETURN = WA_RETURN
TABLES
SALES_ORDERS = IT_SALES_ORDERS.
*delete the Sales Order Details of Sales Orders other than the req.One
IF NOT IT_SALES_ORDERS[] IS INITIAL.
SORT IT_SALES_ORDERS BY SD_DOC.
LOOP AT IT_SALES_ORDERS INTO WA_SALES_ORDERS.
IF WA_SALES_ORDERS-SD_DOC NE SALESDOCUMENT.
DELETE IT_SALES_ORDERS.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " GetReqSODetails
*& Form deleteOldSODetails
FORM DELETEOLDSODETAILS .
DATA: IRECCOUNT TYPE I.
IRECCOUNT = 1.
*Clear all the Inernal Tables And Work Areas
*and Update the SO Header Index
PERFORM CLEARDATA.
PERFORM SOHEADERINDEX.
LOOP AT IT_SALES_ORDERS INTO WA_SALES_ORDERS.
*Fill the Order Details Index Internal Table
PERFORM FILLSODELETEDTLS_INDEX_PARAM
USING WA_SALES_ORDERS-ITM_NUMBER 'D'.
*Fill the Order Scedule Index Internal Table
PERFORM FILLSODELETESCH_INDEX_PARAM
USING WA_SALES_ORDERS-ITM_NUMBER IRECCOUNT 'D'.
ENDLOOP.
*call the Sales Order Change Fumction to delete the Existing Data
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = SALESDOCUMENT
ORDER_HEADER_INX = WA_ORDER_HEADER_INX
TABLES
RETURN = IT_RETURN_CHG
ORDER_ITEM_INX = IT_ORDER_ITEM_INX
SCHEDULE_LINESX = IT_SCHEDULE_LINESX.
ENDFORM. " deleteOldSODetails
*& Form SOHeaderIndex
FORM SOHEADERINDEX .
WA_ORDER_HEADER_INX-UPDATEFLAG = 'U'.
ENDFORM. " SOHeaderIndex
*& Form FillSODeleteDtls_Index_param
FORM FILLSODELETEDTLS_INDEX_PARAM
USING VALUE(P_ITM_NUMBER) VALUE(P_FLAG).
WA_ORDER_ITEM_INX-ITM_NUMBER = P_ITM_NUMBER.
WA_ORDER_ITEM_INX-UPDATEFLAG = P_FLAG.
APPEND WA_ORDER_ITEM_INX TO IT_ORDER_ITEM_INX.
ENDFORM. " FillSODeleteDtls_Index_param
*& Form FILLSODELETEsch_Index_PARAM
FORM FILLSODELETESCH_INDEX_PARAM
USING VALUE(P_ITM_NUMBER) VALUE(P_RECCOUNT) VALUE(P_FLAG).
WA_SCHEDULE_LINESX-ITM_NUMBER = P_ITM_NUMBER.
WA_SCHEDULE_LINESX-SCHED_LINE = P_RECCOUNT.
WA_SCHEDULE_LINESX-UPDATEFLAG = P_FLAG.
APPEND WA_SCHEDULE_LINESX TO IT_SCHEDULE_LINESX.
ENDFORM. " FILLSODELETEsch_Index_PARAM
*& Form addnewSODETAILS
FORM ADDNEWSODETAILS .
DATA: IRECCOUNT TYPE I, ITEMNO TYPE I.
IRECCOUNT = 1.
*Clear all the Inernal Tables And Work Areas
*and Update the SO Header Index
PERFORM CLEARDATA.
PERFORM SOHEADERINDEX.
WHILE IRECCOUNT <= 1.
ITEMNO = IRECCOUNT * 10.
*Fill the New Order Details in the Internal Table
PERFORM FILLSODTLDATA USING ITEMNO 'TEST FG' 37 .
*Fill the Order Details Index Internal Table
PERFORM FILLSODELETEDTLS_INDEX_PARAM USING ITEMNO 'I'.
*Fill the New Schedule Details in the Internal Table
PERFORM FILLSOSCHDATA USING ITEMNO IRECCOUNT 37 .
*Fill the Order Scedule Index Internal Table
PERFORM FILLSODELETESCH_INDEX_PARAM
USING ITEMNO IRECCOUNT 'I'.
IRECCOUNT = IRECCOUNT + 1.
ENDWHILE.
*call the Sales Order Change Fumction to Insert New Data
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = SALESDOCUMENT
ORDER_HEADER_INX = WA_ORDER_HEADER_INX
TABLES
RETURN = IT_RETURN_CHG
ORDER_ITEM_IN = IT_ORDER_ITEM_IN
ORDER_ITEM_INX = IT_ORDER_ITEM_INX
SCHEDULE_LINES = IT_SCHEDULE_LINES
SCHEDULE_LINESX = IT_SCHEDULE_LINESX.
ENDFORM. " addnewSODETAILS
*& Form clearData
FORM CLEARDATA .
CLEAR WA_ORDER_HEADER_INX.
CLEAR WA_ORDER_ITEM_INX.
REFRESH IT_ORDER_ITEM_INX.
CLEAR WA_SCHEDULE_LINESX.
REFRESH IT_SCHEDULE_LINESX.
CLEAR WA_RETURN.
REFRESH IT_RETURN.
CLEAR WA_ORDER_ITEM_IN.
REFRESH IT_ORDER_ITEM_IN.
CLEAR WA_SCHEDULE_LINES.
REFRESH IT_SCHEDULE_LINES.
ENDFORM. " clearData
*& Form FILLSODTLDATA
FORM FILLSODTLDATA USING VALUE(P_ITEMNO) VALUE(P_MATERIAL)
VALUE(P_TARGET_QTY) .
WA_ORDER_ITEM_IN-ITM_NUMBER = P_ITEMNO.
WA_ORDER_ITEM_IN-MATERIAL = P_MATERIAL.
WA_ORDER_ITEM_IN-TARGET_QTY = P_TARGET_QTY.
APPEND WA_ORDER_ITEM_IN TO IT_ORDER_ITEM_IN.
ENDFORM. " FILLSODTLDATA
*& Form FILLSOschDATA
FORM FILLSOSCHDATA USING VALUE(P_ITEMNO)
VALUE(P_RECCOUNT)
VALUE(P_REQ_QTY) .
WA_SCHEDULE_LINES-ITM_NUMBER = P_ITEMNO.
WA_SCHEDULE_LINES-SCHED_LINE = P_RECCOUNT.
WA_SCHEDULE_LINES-REQ_QTY = P_REQ_QTY.
APPEND WA_SCHEDULE_LINES TO IT_SCHEDULE_LINES.
ENDFORM. " FILLSOschDATA
*& Form committrans
FORM COMMITTRANS .
DATA:SUCCESSFLAG(1).
LOOP AT IT_RETURN_CHG INTO WA_RETURN_CHG.
IF WA_RETURN_CHG-TYPE = 'S'
AND WA_RETURN_CHG-ID = 'V1'
AND WA_RETURN_CHG-NUMBER = 311
AND SUCCESSFLAG IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = IT_RETURN_CT.
SUCCESSFLAG = 'X'.
ENDIF.
ENDLOOP.
IF SUCCESSFLAG IS INITIAL.
WRITE: 'SORRY SOME ERROR'.
ELSE.
WRITE: 'SUCCESSFUL'.
ENDIF.
ENDFORM. " committransThanx wolfgang,
I needed that info.
As I had mentioned in the earlier posts, I want to delete the old Sales Order Item Details,
Schedule Details,Basic Price data And Reinsert data in the same.
I am giving u the algo that I have used.
1.<b>Get the SalesOrder Details</b> for a particular Sales Order using BAPI_SALESORDER_GETLIST(para:customer & sales Org and then deleting unwanted SO data).
2.<b>Delete</b> the Sales Order <b>Item Details,Schedule Details</b> using BAPI_SALESORDER_CHANGE.
3.<b>Commit</b> Transaction(<b>If I dont use this commit Error comes in Step No.7 while Commiting</b>)
using BAPI_TRANSACTION_COMMIT.
4.Check <b>Return Table</b> of both BAPI_SALESORDER_CHANGE and BAPI_TRANSACTION_COMMIT.
5.if Step No.4 is <b>Not okay</b> <b>then Rollback</b>(BAPI_TRANSACTION_TRANSACTIN) <b>and Exit</b> <b>else move to step 6</b>.
6.<b>Add New</b> Sales Order <b>Item Details,Schedule Details, Basic Price</b> using BAPI_SALESORDER_CHANGE.
7.<b>Commit Transaction</b> using BAPI_TRANSACTION_COMMIT.
8.<b>Check Return</b> Log of both BAPI_SALESORDER_CHANGE and BAPI_TRANSACTION_COMMIT.
9.if Step No.9 is okay then Exit else Rollback(BAPI_TRANSACTION_TRANSACTIN) and move to step 10.
10.Add Old Sales Order Item Details,Schedule Details, Basic Price from Data available in Internal
table(Filled in step.1 ) using BAPI_SALESORDER_CHANGE.
11.Commit Transaction using BAPI_TRANSACTION_COMMIT.
This <b>works fine in 1 server in which I get the message of Incomplete Data,etc...when I make a Sales Order from va01</b>.
But in another server where I dont this message,I get <b>error in step 7 or 11 as per the flow</b>.
The return structure of BAPI_TRANSACTION_COMMIT contains error with Message 'Updating was not possible'. Also the message 'Updation was terminated' cms frm the SAP server.
What could be the reason?
Thanx in advance -
Update ship-to partner in sales order using BAPI_SALESORDER_CHANGE
Dear all,
We are trying to update the ship-to partner in a sales order using BAPI_SALESORDER_CHANGE. This is working correctly for most of our orders, so we do fill the BAPI correctly. However for some of our orders on item level a different payer is specified than on header level. However in that case the BAPI will not update the ship-to partner, but given an error message VPD 034 u2018The document must contain the same credit control areas for all payersu2019. Debugging already learned that actually the message is given not because of different credit control areas, but due to the fact that the payers and therefore the credit customers are different (although in the same credit control areas). For this reason we can not update the ship-to party of a large number of our sales orders with this BAPI. Actually we have 2 questions:
· Has somebody experienced the same issue and did you manage to solve it somehow, so the BAPI could be used for this purpose of updating partner data?
· Do you know other ways of updating the partners or partner address of an existing sales order in the background?
Thanks in advance for your assistance.
Regards,
Satish.It was caused by standard SAP.
-
Unable to update sales order unsing the BAPI 'BAPI_SALESORDER_CHANGE'
Hi All,
I am unable to update the payment method field for some sales orders using the bapi 'BAPI_SALESORDER_CHANGE'. I am getting the reason in the table RETURN as 'Field 'ZLSCH' cannot be changed, VBAPKOM 000050 ready for input'.
Could anyone throw some light on it.
Thanks a ton.
Regards,
Santosh Kotra.Hi
Without reversing invoice we can't update price and this is standard bevaior which is logical too. For your scenario I am wondering why would you want to change price for a line item or order which is alrady invoiced and posted to FI. What difference would it make to change price in sale order when this has already been posted in FI?
Thank$ -
Change sold-to party BAPI_SALESORDER_CHANGE
Hello,
Does anyone know how to change partner function AG (sold-to-party) in a sales order header from within ABAP code ?
I'm using BAPI_SALESORDER_CHANGE function module to change partner functions. It works well for all other partner functions, but for the AG ("sold-to-party") function it yields a message saying that changing AG function is impossible.
Although changing "sold-to-party" partner function is disabled in user interface (VA02 transaction -> order header details), but the user DOES have the possibility to change "sold-to-party": he can change field KUNNR in main screen of transaction VA02 (this field is mapped to VBAK-KUNNR) - after changing it, the AG partner function in header details changes to the value set in it. Does anyone have an idea how to achieve the same from ABAP code ?
Regards,
Flavio.REPORT ZSALESORDER_CHANGE MESSAGE-ID 38.
Selection Screen Definitions *
PARAMETERS: p_vbeln TYPE vbap-vbeln OBLIGATORY, "Order Number
p_posnr TYPE vbap-posnr OBLIGATORY, "Order Item
p_etenr TYPE vbep-etenr OBLIGATORY, "Schedule Line
p_reqqty TYPE bapischdl-req_qty OBLIGATORY. " Order Qty
Internal Tables/Structures/Variables for calling BAPI. *
DATA: i_hdr TYPE bapisdh1,
i_hdrx TYPE bapisdh1x,
i_ret TYPE bapiret2 OCCURS 0 WITH HEADER LINE,
wa_ret TYPE bapiret2.
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.
START-OF-SELECTION Event *
START-OF-SELECTION.
*" Initialize internal tables.
REFRESH: i_sched, i_schedx, i_ret.
CLEAR: i_sched, i_schedx, i_ret.
*" Fill required ORDER_HEADER_IN data.
i_hdrx-updateflag = 'U'.
*" Fill required SCHEDULE_LINES data.
i_sched-itm_number = p_posnr.
i_sched-sched_line = p_etenr.
i_sched-req_qty = p_reqqty.
i_schedx-updateflag = 'U'.
i_schedx-itm_number = p_posnr.
i_schedx-sched_line = p_etenr.
i_schedx-req_qty = 'X'.
APPEND i_sched.
APPEND i_schedx.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = p_vbeln
order_header_in = i_hdr
order_header_inx = i_hdrx
TABLES
return = i_ret
schedule_lines = i_sched
schedule_linesx = i_schedx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
LOOP AT i_ret.
WRITE / i_ret-message.
ENDLOOP. -
Error in BAPI_SALESORDER_CHANGE
I need to post the changed incoterm value by using BAPI_SALESORDER_CHANGE. But everytime I used to get the error:
Field header_inx-updateflag is not an input field.
I have written the below mentioned code :
*& Report ZBAPI1 *
REPORT ZBAPI1 .
TABLES: VBBE.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBBE-VBELN,
POSNR LIKE VBBE-POSNR,
END OF ITAB.
DATA: WA_ITAB LIKE LINE OF ITAB.
DATA:BEGIN OF I_VBELN OCCURS 0.
INCLUDE STRUCTURE BAPIVBELN.
DATA:END OF I_VBELN.
DATA: WA_I_VBELN LIKE LINE OF I_VBELN.
DATA:BEGIN OF I_SHEADER OCCURS 0.
INCLUDE STRUCTURE BAPISDH1X.
DATA:END OF I_SHEADER.
DATA: WA_I_SHEADER LIKE LINE OF I_SHEADER.
DATA:BEGIN OF ZRETURN OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA:END OF ZRETURN.
DATA: WA_ZRETURN LIKE LINE OF ZRETURN.
DATA:BEGIN OF I_SITEM OCCURS 0.
INCLUDE STRUCTURE BAPISDITM.
DATA:END OF I_SITEM.
DATA: WA_I_SITEM LIKE LINE OF I_SITEM.
DATA:BEGIN OF I_SITEMX OCCURS 0.
INCLUDE STRUCTURE BAPISDITMX.
DATA:END OF I_SITEMX.
DATA: WA_I_SITEMX LIKE LINE OF I_SITEMX.
DATA:BEGIN OF ZRETURN1 OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA:END OF ZRETURN1.
DATA: WA_ZRETURN1 LIKE LINE OF ZRETURN1.
PARAMETERS: P_VBELN LIKE BAPIVBELN-VBELN,
P_INCO1 LIKE BAPISDITEM-INCOTERMS1.
SELECT VBELN
POSNR FROM VBBE INTO TABLE ITAB
WHERE VBELN = P_VBELN.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING VBELN POSNR.
CLEAR: I_SHEADER, I_VBELN, I_SITEM,I_SITEMX,
ZRETURN, ZRETURN1.
REFRESH: I_SHEADER, I_VBELN, I_SITEM,I_SITEMX,
ZRETURN, ZRETURN1.
LOOP AT ITAB INTO WA_ITAB.
WA_I_SHEADER-UPDATEFLAG = 'U'.
WA_I_SHEADER-INCOTERMS1 = 'X'.
APPEND WA_I_SHEADER TO I_SHEADER.
WA_I_VBELN-VBELN = WA_ITAB-VBELN.
APPEND WA_I_VBELN TO I_VBELN.
WA_I_SITEM-ITM_NUMBER = WA_ITAB-POSNR.
WA_I_SITEM-INCOTERMS1 = P_INCO1.
APPEND WA_I_SITEM TO I_SITEM.
WA_I_SITEMX-ITM_NUMBER = WA_ITAB-POSNR.
WA_I_SITEMX-INCOTERMS1 = 'X'.
APPEND WA_I_SITEMX TO I_SITEMX.
CLEAR: WA_ITAB, WA_I_VBELN, WA_I_SHEADER, WA_ZRETURN, WA_ZRETURN1,
WA_I_SITEM, WA_I_SITEMX.
ENDLOOP.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = I_VBELN
ORDER_HEADER_IN =
ORDER_HEADER_INX = I_SHEADER
SIMULATION =
BEHAVE_WHEN_ERROR = ' '
INT_NUMBER_ASSIGNMENT = ' '
LOGIC_SWITCH =
TABLES
RETURN = ZRETURN
ORDER_ITEM_IN = I_SITEM
ORDER_ITEM_INX = I_SITEMX
PARTNERS =
PARTNERCHANGES =
PARTNERADDRESSES =
ORDER_CFGS_REF =
ORDER_CFGS_INST =
ORDER_CFGS_PART_OF =
ORDER_CFGS_VALUE =
ORDER_CFGS_BLOB =
ORDER_CFGS_VK =
ORDER_CFGS_REFINST =
SCHEDULE_LINES =
SCHEDULE_LINESX =
ORDER_TEXT =
ORDER_KEYS =
CONDITIONS_IN =
CONDITIONS_INX =
EXTENSIONIN =
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = ' '
IMPORTING
RETURN = ZRETURN1.
WRITE:/'SY_SUBRC: ', SY-SUBRC.
LOOP AT ZRETURN.
WRITE:/ ZRETURN-MESSAGE, ZRETURN-TYPE.
ENDLOOP.
IF SY-SUBRC EQ 0.
LOOP AT ZRETURN1.
WRITE:/ ZRETURN1-MESSAGE, ZRETURN1-TYPE.
ENDLOOP.
ENDIF.
CLEAR: I_SHEADER, I_VBELN, I_SITEM,I_SITEMX,
ZRETURN, ZRETURN1.
REFRESH: I_SHEADER, I_VBELN, I_SITEM,I_SITEMX,
ZRETURN, ZRETURN1.
Please do help me in solving the problem.
thanks & regards,
nityaI have added the order_header_inx but still the same error comes. I am sending you the code :
*& Report ZBAPI1 *
REPORT ZBAPI1 .
TABLES: VBBE, VBKD.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBBE-VBELN,
POSNR LIKE VBBE-POSNR,
END OF ITAB.
DATA: WA_ITAB LIKE LINE OF ITAB.
DATA: BEGIN OF ITAB1 OCCURS 0.
INCLUDE STRUCTURE VBKD.
DATA: END OF ITAB1.
DATA: ITAB2 LIKE ITAB1.
DATA:BEGIN OF I_VBELN OCCURS 0.
INCLUDE STRUCTURE BAPIVBELN.
DATA:END OF I_VBELN.
DATA: WA_I_VBELN LIKE LINE OF I_VBELN.
DATA:BEGIN OF I_SHEADERX OCCURS 0.
INCLUDE STRUCTURE BAPISDH1X.
DATA:END OF I_SHEADERX.
DATA: WA_I_SHEADERX LIKE LINE OF I_SHEADERX.
DATA: BEGIN OF I_SHEADER OCCURS 0.
INCLUDE STRUCTURE BAPISDH1.
DATA: END OF I_SHEADER.
DATA: WA_I_SHEADER LIKE LINE OF I_SHEADER.
DATA:BEGIN OF ZRETURN OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA:END OF ZRETURN.
DATA: WA_ZRETURN LIKE LINE OF ZRETURN.
DATA:BEGIN OF I_SITEM OCCURS 0.
INCLUDE STRUCTURE BAPISDITM.
DATA:END OF I_SITEM.
DATA: WA_I_SITEM LIKE LINE OF I_SITEM.
DATA:BEGIN OF I_SITEMX OCCURS 0.
INCLUDE STRUCTURE BAPISDITMX.
DATA:END OF I_SITEMX.
DATA: WA_I_SITEMX LIKE LINE OF I_SITEMX.
DATA:BEGIN OF ZRETURN1 OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA:END OF ZRETURN1.
DATA: WA_ZRETURN1 LIKE LINE OF ZRETURN1.
SELECTION-SCREEN BEGIN OF BLOCK A.
PARAMETERS: P_VBELN LIKE BAPIVBELN-VBELN,
P_INCO1 LIKE BAPISDITEM-INCOTERMS1.
SELECTION-SCREEN END OF BLOCK A.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF NOT P_VBELN IS INITIAL.
READ TABLE ITAB1 INTO ITAB2 WITH KEY VBELN = P_VBELN.
MOVE ITAB2-INCO1 TO P_INCO1.
MODIFY SCREEN.
ENDIF.
EXIT.
ENDLOOP.
SELECT * FROM VBKD INTO TABLE ITAB1.
START-OF-SELECTION.
SELECT VBELN
POSNR FROM VBBE INTO TABLE ITAB
WHERE VBELN = P_VBELN.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING VBELN POSNR.
END-OF-SELECTION.
CLEAR: I_SHEADERX, I_VBELN, I_SITEM,I_SITEMX,I_SHEADER,
ZRETURN, ZRETURN1.
REFRESH: I_SHEADERX, I_VBELN, I_SITEM,I_SITEMX,I_SHEADER,
ZRETURN, ZRETURN1.
LOOP AT ITAB INTO WA_ITAB.
WA_I_SHEADERX-UPDATEFLAG ='U'.
APPEND WA_I_SHEADERX TO I_SHEADERX.
WA_I_SHEADER-INCOTERMS1 = P_INCO1.
APPEND WA_I_SHEADER TO I_SHEADER.
WA_I_VBELN-VBELN = WA_ITAB-VBELN.
APPEND WA_I_VBELN TO I_VBELN.
WA_I_SITEM-ITM_NUMBER = WA_ITAB-POSNR.
WA_I_SITEM-INCOTERMS1 = P_INCO1.
APPEND WA_I_SHEADER TO I_SHEADER.
WA_I_SITEMX-ITM_NUMBER = WA_ITAB-POSNR.
WA_I_SITEMX-UPDATEFLAG ='U'.
WA_I_SITEMX-INCOTERMS1 ='X'.
APPEND WA_I_SITEMX TO I_SITEMX.
CLEAR: WA_ITAB, WA_I_VBELN, WA_I_SHEADERX, WA_ZRETURN, WA_ZRETURN1,
WA_I_SITEM, WA_I_SITEMX.
ENDLOOP.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = I_VBELN
ORDER_HEADER_IN = I_SHEADER
ORDER_HEADER_INX = I_SHEADERX
* SIMULATION =
* BEHAVE_WHEN_ERROR = ' '
* INT_NUMBER_ASSIGNMENT = ' '
* LOGIC_SWITCH =
TABLES
RETURN = ZRETURN
ORDER_ITEM_IN = I_SITEM
ORDER_ITEM_INX = I_SITEMX
* PARTNERS =
* PARTNERCHANGES =
* PARTNERADDRESSES =
* ORDER_CFGS_REF =
* ORDER_CFGS_INST =
* ORDER_CFGS_PART_OF =
* ORDER_CFGS_VALUE =
* ORDER_CFGS_BLOB =
* ORDER_CFGS_VK =
* ORDER_CFGS_REFINST =
* SCHEDULE_LINES =
* SCHEDULE_LINESX =
* ORDER_TEXT =
* ORDER_KEYS =
* CONDITIONS_IN =
* CONDITIONS_INX =
* EXTENSIONIN =
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT
='X'
IMPORTING
RETURN = ZRETURN1.
WRITE:/'SY_SUBRC: ', SY-SUBRC.
LOOP AT ZRETURN.
WRITE:/ ZRETURN-MESSAGE, ZRETURN-TYPE.
ENDLOOP.
IF SY-SUBRC EQ 0.
LOOP AT ZRETURN1.
WRITE:/ ZRETURN1-MESSAGE, ZRETURN1-TYPE.
ENDLOOP.
ENDIF.
CLEAR: I_SHEADER, I_VBELN, I_SITEM,I_SITEMX,
ZRETURN, ZRETURN1.
REFRESH: I_SHEADER, I_VBELN, I_SITEM,I_SITEMX,
ZRETURN, ZRETURN1.
Thanks for your valuable time
regards,
nitya -
Error in BAPI_SALESORDER_CHANGE while updating condition
Hi,
I am using this BAPI to change an existing pricing condition. However, I am getting an error " Manual change of condition type is not possible". I'm not sure whether this is a coding error or is it related to configuration. this is how I am populating the structures:
so_cond_in-itm_number = wa_vbap1-posnr.
so_cond_in-cond_count = wa_konv-zaehk.
so_cond_in-cond_st_no = wa_konv-STUNR.
so_cond_in-cond_type = wa_konv-kschl.
so_cond_in-cond_value = wa_konv-kbetr.
so_cond_in-currency = wa_konv-waers.
so_condx_in-itm_number = wa_vbap1-posnr.
so_condx_in-updateflag = 'U'.
so_condx_in-cond_st_no = wa_konv-STUNR.
so_condx_in-cond_count = wa_konv-zaehk.
so_condx_in-cond_type = wa_konv-kschl.
so_condx_in-cond_value = 'X'.
so_condx_in-currency = 'X'.
APPEND so_condx_in.
CLEAR so_condx_in.
APPEND so_cond_in.
CLEAR so_cond_in.
st_logswitch-cond_handl = 'X'.
Any help would be appreciated.
Thanks
SMHi Sneha ,
Can you please check the code for using the BAPI_SALESORDER_CHANGE bapi. this is similar to your chase. Please compare with the passing parameters
then you will get some idea on your code.
*- Population of Order Item data
ls_order_item-itm_number = ls_submit-posnr. "Item
ls_order_item-prc_group5 = '003'."lc_004. "Material Group5
IF ls_submit-zmeng = 0.
ls_order_item-reason_rej = lc_99. "Reason for Rejection
ENDIF.
APPEND ls_order_item TO lt_order_item.
*-Population of update flag for Order Item
ls_order_itemx-itm_number = ls_submit-posnr."Item
ls_order_itemx-updateflag = lc_u. "Update flag
ls_order_itemx-prc_group5 = gc_x. "Material Group5 update
*- if the required quanity is zero then reject the line
IF ls_submit-zmeng = 0.
ls_order_itemx-reason_rej = gc_x. "Reason for Rejection
ENDIF.
APPEND ls_order_itemx TO lt_order_itemx.
*-Population of
ls_schedule_lines-itm_number = ls_submit-posnr.
ls_schedule_lines-sched_line = ls_submit-etenr.
ls_schedule_lines-req_qty = ls_submit-zmeng.
APPEND ls_schedule_lines TO lt_schedule_lines.
*-Population of update flag for Schedule line data
ls_schedule_linesx-itm_number = ls_submit-posnr.
ls_schedule_linesx-sched_line = ls_submit-etenr.
ls_schedule_linesx-updateflag = lc_u.
ls_schedule_linesx-req_qty = gc_x.
APPEND ls_schedule_linesx TO lt_schedule_linesx.
*- at the end of Order call the BAPI to Update the Order
ls_order_head-collect_no = ls_submit-vbeln.
ls_order_headx-updateflag = lc_u.
ls_order_headx-collect_no = gc_x.
*- BAPI Call to Update the Order
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = ls_submit-vbeln
order_header_in = ls_order_head
order_header_inx = ls_order_headx
TABLES
return = lt_return
order_item_in = lt_order_item
order_item_inx = lt_order_itemx
schedule_lines = lt_schedule_lines
schedule_linesx = lt_schedule_linesx.
*- Check for the errors and based on that populate the log
READ TABLE lt_return INTO ls_return WITH KEY type = lc_e.
IF sy-subrc EQ 0.
LOOP AT lt_return INTO ls_return WHERE type = lc_e.
ls_log-excep = 1.
ls_log-vbeln = ls_submit-vbeln.
ls_log-message = ls_return-message.
APPEND ls_log TO gt_log.
CLEAR: ls_log,
ls_submit-vbeln .
ENDLOOP.
ELSE.
*- Commit the Changes
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = gc_x.
*- Check for the success message and populate the log
LOOP AT lt_return INTO ls_return WHERE number = lc_311.
ls_log-excep = 3.
ls_log-vbeln = ls_submit-vbeln.
ls_log-message = ls_return-message.
APPEND ls_log TO gt_log.
CLEAR: ls_log,
ls_submit-vbeln .
ENDLOOP.
ENDIF.
Thanks
Sekhar -
Remove Reason For Rejection From Sales Order Using BAPI_SALESORDER_CHANGE
Hi
I have a sales order and would like to remove the rejection reason.
I am trying to use BAPI_SALESORDER_CHANGE with the following code:
(0000xxxxxxx is my material #. i just removed the actual #).
MOVE: '0000050106' TO SALESDOCUMENT.
MOVE: 'U' TO T_HEADER_INX-UPDATEFLAG.
MOVE: 30 to t_order_item_in-ITM_NUMBER,
' ' to t_order_item_in-REASON_REJ,
'0000000000xxxxxxxx' to t_order_item_in-material.
APPEND t_order_item_in.
MOVE: 'U' TO t_order_item_inx-updateflag.
MOVE: 'X' to t_order_item_inx-REASON_REJ,
'X' TO t_order_item_inx-material.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = SALESDOCUMENT
order_header_inx = T_HEADER_INX
tables
RETURN = T_RETURN
ORDER_ITEM_IN = T_ORDER_ITEM_IN
ORDER_ITEM_INX = T_ORDER_ITEM_INX
WAIT UP TO 5 SECONDS.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = t_return
WAIT UP TO 5 SECONDS.
can anybody help?
the BAPI returns success messages saying the item was processed successfully but the reason code is still there.
However, if i pass in any other reason code like 02 or 06, it works!.
thanks.Thanks for your help. =)
I also realized that I forgot to add the SO Item # into the T_ORDER_ITEM_INX-ITM_NUMBER fields.
But now it works.
Maybe you are looking for
-
Chinese text while downloading to excel
Hello Everyone, I have one alv report in which text is coming into Chinese language. When i download my alv data to excel, chinese text is getting converted into #### characters. Anyone having idea how to download the chinese text from alv into excel
-
Hi, I have setup a HQ and Branch office. HQ is setup as Customer service location and Branch as Sales location. When PSTN calls Customer Service 800 number, the application runs fine. But when PSTN calls Sales 888 number, the call gets disconne
-
Display font problem after synchronization
On my handheld device, i have both Chinese and French appointment. When I did a hot sync. to my new netbook with window 7 Starter and Palm Desktop by Access, v6.2.2. All the Chinese font become "?" and all the French accent, ie "ç" and "é" became "?"
-
LDOM on ZFS - ZVOL or mkfile ... which is better ?
Curious which approach is better for using LDOMs on ZFS ... Using a ZVOL specific to each LDOM or a mkfile in a ZFS file system specific to each LDOM ? Both can be snapped but curious which is the better approach and why.
-
What services are created?
When I try to install Forms 6.0.8, the installer says that it has to create and start some services. What does it create? A Forms Server Listener? Any other services? I've never actually successfully installed this version of Forms and there doesn't