BAPI 'BAPI_SALESORDER_CHANGE'
Hello guru's,
I am trying to figure out why my bapi is not working. I hope that someone can help me out.
SELECT *
FROM vbak
INTO TABLE it_vbak
WHERE vbeln = '3245349'.
LOOP AT it_vbak into wa_vbak.
CLEAR : s_bapisdh1 , s_bapisdh1x.
MOVE : 'U' TO s_bapisdh1x-updateflag,
'X' TO s_bapisdh1x-dlv_block,
'Z9' TO s_bapisdh1-dlv_block.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = wa_vbak-vbeln
order_header_in = s_bapisdh1
order_header_inx = s_bapisdh1x
TABLES
return = it_bapiret2.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDLOOP
Thanks.
SELECT *
FROM vbak
INTO TABLE it_vbak
you need to append the internal table before passing it to BAPI.
WHERE vbeln = '3245349'.
LOOP AT it_vbak into wa_vbak.
CLEAR : s_bapisdh1 , s_bapisdh1x.
MOVE : 'U' TO s_bapisdh1x-updateflag,
'X' TO s_bapisdh1x-dlv_block,
'Z9' TO s_bapisdh1-dlv_block.
Append s_bapisdh1x.
Append s_bapisdh1.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = wa_vbak-vbeln
order_header_in = s_bapisdh1
order_header_inx = s_bapisdh1x
TABLES
return = it_bapiret2.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDLOOP
Similar Messages
-
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$ -
Problem in BAPI 'BAPI_SALESORDER_CHANGE'.
Hi All,
I am facing a problem in BAPI 'BAPI_SALESORDER_CHANGE'. My requirement is as below.
For a particular type of Sales Order i have to update all the ship-to PO.Basically in all these PO's we have to suffix
'old'.
I am pasting the code which I used. I am actually displaying the return message in a table.
The message says 'Schedule Order is saved'.
When i go and check the SO the ship-to PO is not updated.
Also i have one more querry.
Is thsi BAPI to be run for each item or can i collect all items in t_item_in and then call the BAPI.
Please guide me on this.
Thanks in Advance,
Saket.
LOOP AT t_vbkd INTO wa_vbkd.
CONCATENATE wa_vbkd-bstkd_e '-' v_po INTO v_po_ref.
t_item_in-purch_no_c = v_po_ref.
t_item_inx-purch_no_c = v_po_ref.
t_item_inx-updateflag = 'X'.
APPEND t_item_in.
APPEND t_item_inx.
*LOOP AT t_vbak INTO wa_vbak.
v_vbeln = wa_vbkd-vbeln.
w_headerx-updateflag = 'U'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = v_vbeln
ORDER_HEADER_INX = w_headerx
TABLES
RETURN = t_return
ORDER_ITEM_IN = t_item_in
ORDER_ITEM_INX = t_item_inx.
READ TABLE t_return WITH KEY type = 'E'.
IF sy-subrc = 0.
t_output-rmks = t_return-message.
ELSE.
t_output-rmks = t_return-message.
ENDIF.
READ TABLE t_vbak INTO wa_vbak
WITH KEY vbeln = v_vbeln.
t_output-vbeln = v_vbeln.
t_output-auart = wa_vbak-auart.
t_output-vkorg = wa_vbak-vkorg.
t_output-bstkd_e_old = wa_vbkd-bstkd_e.
t_output-bstkd_e_new = t_item_in-purch_no_c.
APPEND t_output.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN =
ENDLOOP.REPORT ZSALESORDER_CHANGE MESSAGE-ID 38.
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
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.
REFRESH: i_sched, i_schedx, i_ret.
CLEAR: i_sched, i_schedx, i_ret.
i_hdrx-updateflag = 'U'.
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.
http://abap.wikiprog.com/wiki/BAPI_SALESORDER_CHANGE
Edited by: krupa jani on Jul 30, 2009 9:22 AM -
BAPI: BAPI_SALESORDER_CHANGE - Document Change History
Hi ,
When I change a Sales Order usingthe BAPI: BAPI_SALESORDER_CHANGE, will it create the change history for the document?
Appreciate Your help.
Thanks,
Kannan.Transaction is SCDO and look at object called VERKBELEG
Check the below link :
http://help.sap.com/saphelp_nw04s/helpdata/en/c7/69bccff36611d3a6510000e835363f/content.htm
Thanks
Seshu -
Updating Condition Rate in SO using BAPI 'BAPI_SALESORDER_CHANGE'
Hi,
I want to update the price related to condtions(both automatic and manual) in Sales Order items from input file. I am using bapi 'BAPI_SALESORDER_CHANGE' to for this.
I used follwing code,
wa_so_cond-itm_number = wa_input-so_item.
wa_so_cond-cond_type = wa_input-kschl.
wa_so_cond-cond_st_no = '011'.
wa_so_cond-cond_count = '00'.
wa_so_cond-cond_value = wa_input-kbetr.
APPEND wa_so_cond TO i_so_cond.
CLEAR wa_so_cond.
wa_so_condx-itm_number = wa_input-so_item.
wa_so_condx-cond_type = wa_input-kschl.
wa_so_condx-cond_st_no = '011'.
wa_so_condx-cond_count = '00'.
wa_so_condx-updateflag = c_u.
wa_so_condx-cond_value = c_x.
APPEND wa_so_condx TO i_so_condx.
CLEAR wa_so_condx.
But this is creating a new line in conditions instead of updating the existing line, even though the existing line is a inactive by crerating a new line I want to update the exsting line with new condition rate instead of creating a new line. Please help me if you have any soultion for this.
Thanks in Advance,
Prasad JVV.Hi Sandipan,
I used APPEND to fill the conditions_in & conditions_inx, without filling the tables how can I modify?
Thanks,
Prasad JVV. -
Performance of bapi BAPI_SALESORDER_CHANGE.
Now we meet the reqeust to split the order item by quantity in order to assign wbs number to each material
For example the sales order contains one item with 10 Qty and we need to split to 10 items and each item with 1Qty
Order:
Line 0001 Material 10Qty
Change to:
Line 0001 Material 1Qty WBS-001
Line 0002 Material 1Qty WBS-002
Line 0003 Material 1Qty WBS-003
Line 0010 Material 1Qty WBS-010
We used bapi BAPI_SALESORDER_CHANGE to do above process but the run time seems very slowly (time out)
I tried to delete the schedule_lines and schedule_linessx from import for test.
it runs fast but the result is there is no quantity in each line item.
without schedule_line import, the order will be:
Line 0001 Material 0Qty WBS-001
Line 0002 Material 0Qty WBS-002
Line 0003 Material 0Qty WBS-003
Line 0010 Material 0Qty WBS-010
Does any one tried BAPI BAPI_SALESORDER_CHANGE and met the same problem (slowly)?
And any suggestion?
Thank you very much!Hi,
BAPI_SALESORDER_CHANGE should not raise time out,
unless you process huge amount of data.
Maybe some data are locked or some user-exit causes infinite loop or incorrect select on large table.
Try to perform runtime analysis with small amount of data,
and during execution check SM12 for locks and SM50 for sequential reads.
Regards,
Przemysław -
BAPI 'BAPI_SALESORDER_CHANGE' - Change a field
Hi all!
I am doing an exercise which it's necessary to change just one field (PO number) in a sales order using the BAPI from the subject. After the execution of the BAPI, "return" table shows the following message:
E |V2 |051 |Terms of delivery FH are not defined. <
E |V4 |219 |Sales document 0000001666 was not changed<
Here follows the code:
DATA: " for BAPI use
v_vbeln LIKE vbak-vbeln, " order that i would like to change
v_order_header_in LIKE bapisdh1,
v_order_header_inx LIKE bapisdh1x,
v_purch_no_c LIKE bapisdh1-purch_no_c, "
v_return LIKE TABLE OF bapiret2.
INITIALIZATION.
p_vbeln = 1666.
v_order_header_inx-updateflag = 'U'.
v_order_header_inx-purch_no_c = 'X'.
CONCATENATE 'test_' v_purch_no_c INTO v_purch_no_c.
v_order_header_in-purch_no_c = v_purch_no_c.
v_order_header_inx-purch_no_c = 'X'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = v_vbeln
order_header_in = v_order_header_in
order_header_inx = v_order_header_inx
TABLES
return = v_return.
If sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
What does the error "Terms of delivery FH are not defined" mean? Did i forget to import an obligatory entry?
Thanks a lot!Hi guys!
after a lot of tries i found what this error means. Let me explain what was the problem:
I was trying to update a single field at the sales order (po number), but l didn't see that this order had another field with a value ("FH") which was deleted and was get from another table.
So as you just specify in BAPI which fields you would like to change when in an update, problably the BAPI try to keep the rest of the fields without doing any kind of check. And this resulted in my problem with that error message.
Can i go ahead at this and ask if there is a way to make BAPI check the fields not specified at the import of the function?
Thanks a lot for everybody who tried to help me. -
Can't update Configuration via BAPI BAPI_SALESORDER_CHANGE
According to Note 562124 - Configuration change via BAPI.
I create a customer program to change characteristic value in SO by BAPI_SALESORDER_CHANGE
It is confused , I can change the 'from value' (BAPICUVA-VALUE) successfully, but I can't change the 'To value' (BAPICUVAL-VALUE_TO) for characteristic.
What is the reason, anyone come across this problem?Any suggestion?
-
Extension of BAPI - BAPI_SALESORDER_CHANGE
Hi All,
I have added some custome fields in the table VBAK. Now i want to update these fields using BAPI_SALESORDER_CHANGE which are not present in it currently. So how can i extend BAPI to update the custom fields ???Hi,
first, go to SE37 and check the BAPI's default documentation for the EXTENSIONIN table parameter. There, it explains analytically what you have to do in order to update Z fields that have been appended in VBAK or VBAP through the standard BAPI.
NOTE that you MUST have updated accordingly the tables/structures VBAKKOZ, VBAKKOZX, BAPE_VBAK, BAPE_VBAKX
So, if the sales order number is 1000000001 and your added custom field is named ZZCUST with length 5 chars and you want to set the ZZCUST value to ABCDEm, then append a line in EXTENSIOIN as follows:
EXTENSIONIN-STRUCTURE = BAPE_VBAK
EXTENSIONIN-VALUEPART1 = 1000000001ABCDE
Also, call the BAPI passing the 1000000001 (sales order document number to the SALESDOCUMENT parameter and set the UPDATEFLAG field of the structure ORDER_HEADER_INX to 'X' to make the BAPI actually update the sales document header data (includind the new Z field).
Try it and READ the BAPI's standard documentation!
Reward if it helps,
Regards,
George -
Custom fields update using BAPI: BAPI_SALESORDER_CHANGE
Hi,
I have append one field into VBAP Table, and i want to update that filed value by using BAPI_SALESORDER_CHANGE FM. I have done all the coding but still its not updating the table. I have checked with SAP fields like order quantity, its upadating the database but the custom fileds are not upadting.
steps i have done: Append field to : VBAP,BAPE_VBAP,VBAPKOZ
Append Check field to : BAPE_VBAPX,VBAPKOZX
Here is the code : plz check and add ur comments
DATA : l_wa_bapiparex TYPE bapiparex,
l_wa_ord_header TYPE bapisdh1x,
l_itab_bapiparex TYPE STANDARD TABLE OF bapiparex INITIAL SIZE 0,
l_itab_return TYPE STANDARD TABLE OF bapiret2 INITIAL SIZE 0,
l_wa_item TYPE bapisditm,
l_itab_item TYPE STANDARD TABLE OF bapisditm INITIAL SIZE 0,
l_wa_itemx TYPE bapisditmx,
l_itab_itemx TYPE STANDARD TABLE OF bapisditmx INITIAL SIZE 0,
ORDER_HEADER_IN LIKE BAPISDH1.
l_wa_ord_header-updateflag = 'U'.
ORDER_HEADER_IN-REF_DOC = '0000000244'.
*Populate Item detail
l_wa_item-itm_number = '000010'.
l_wa_item-NET_WEIGHT = '5000'.
APPEND l_wa_item TO l_itab_item.
*Populate Item detail checkbox
l_wa_itemx-itm_number = '000010'.
l_wa_itemX-NET_WEIGHT = 'X'.
l_wa_itemx-updateflag = 'U'.
APPEND l_wa_itemx TO l_itab_itemx.
l_wa_bapiparex-structure = 'BAPE_VBAP'.
l_wa_bapiparex-valuepart1+0(10) = '0000000244'.
l_wa_bapiparex-valuepart1+10(6) = '000010'.
l_wa_bapiparex-valuepart1+16(15) = 'ABCDEF'.
APPEND l_wa_bapiparex TO l_itab_bapiparex.
CLEAR l_wa_bapiparex.
l_wa_bapiparex-structure = 'BAPE_VBAPX'.
l_wa_bapiparex-valuepart1+0(10) = '0000000244'.
l_wa_bapiparex-valuepart1+10(6) = '000010'.
l_wa_bapiparex-valuepart1+17(1) = 'X'.
APPEND l_wa_bapiparex TO l_itab_bapiparex.
clear l_wa_bapiparex.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = '0000000244'
order_header_in = ORDER_HEADER_IN
order_header_inx = l_wa_ord_header
TABLES
return = return
order_item_in = l_itab_item
order_item_inx = l_itab_itemx
schedule_lines = l_itab_schedule
schedule_linesx = l_itab_schedulex
extensionin = l_itab_bapiparex.
IF SY-SUBRC = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN =
ELSE.
RAISE ERROR.
ENDIF.
I HAVE GONE THROUGH DEBUGGING AND FOUND ALL ARE GOING FINE...ITS UPDATING VBKOM AND VBKOMX STRUCTURE BUT AT LAST ITS NOT UPDATING THE CUSTOM FIELDS
Thanks,
BaidyaSorry guys........this code is correct one.......there is a problem in IDES....i tried in client server its working fine
If anyone is having this type of requirement then copy this program.
thanks,
Baidya -
Problem in creation of sales order using BAPI
Hi Guru's,
I am currently working on Minimum Order Value problem. If the ordered item is less than 5$, the requirement is to add a new material MOV to the existing order by filling the difference amount and making it to 5 pounds. I am using the bapi BAPI_SALESORDER_CHANGE to amend the existing order with the MOV material. The material is getting created successfully and the order is getting amended. When i tried to process the order for billing It shows incompletion log exist. On checking the incompletion log it shows "missing configuration". But when i go to the configuration of the material it shows green sign. <b>The most important thing is the material MOV has 2 configuration profile, I believe there is a confusion in selecting the configuration profile for creation of MOV </b>. I came to know about that problem because when i go to change mode (VA02) and try to check the configuration, It askes me to choose the configuration profile and when i choose the configuration profile incompletion log is cleared. When i save the order and send it to billing the billing happens successfully. Could any one help me on this issue.......
Parameters passed to BAPI for configuration.
st_order_cfgs_ref-posex = '900010'. "PM14/06/07
st_order_cfgs_ref-config_id = '000010'. "PM14/06/07
st_order_cfgs_ref-root_id = '10000010'. "PM14/06/07
append st_order_cfgs_ref to t_order_cfgs_ref. "PM14/06/07
st_order_cfgs_inst-config_id = '000010'. "PM14/06/07
st_order_cfgs_inst-inst_id = '10000010'. "PM14/06/07
append st_order_cfgs_inst to t_order_cfgs_inst. "PM14/06/07
st_order_cfgs_refinst-posex = '900010'. "PM14/06/07
st_order_cfgs_refinst-config_id = '000010'. "PM14/06/07
st_order_cfgs_refinst-inst_id = '10000010'. "PM14/06/07
append st_order_cfgs_refinst to t_order_cfgs_refinst. "PM14/06/07
Thanks in advance...
ShivHi,
Did u have a look at the standard programs which make use of BAPI_SALESORDER_CREATEFROMDAT1
Heres a list...
LWSSOU08
MV45WF0S
MWWMJF21_BAPI_SALESORDER_CREAT
RBUS2032
Regards,
Tanveer.
<b>Please mark helpful answers</b> -
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'. -
How to delete header condtion line of sales order by BAPI
Hi,
I want to delete the condtion line of sales order header using BAPI "BAPI_SALESORDER_CHANGE",
it is work well in item level condition type, but it is not work for header condition type. show error message "missing item number" since of pass item number "000000" for header condition line.
Below is reference source code, thanks in advance.
*& Report ZTEST_BAPI_SO_DELETECONDLINE
*& Sample program to call BAPI_SALESODRER_CHANGE to
*& delete condition line of so line item
REPORT ZTEST_BAPI_SO_DELETECONDLINE.
***--- Structures for create BAPI
DATA: SALESDOCUMENT LIKE BAPIVBELN-VBELN.
DATA: ORDER_HEADER_INX LIKE BAPISDH1X,
BEHAVE_WHEN_ERROR LIKE BAPIFLAG-BAPIFLAG,
SIMULATION LIKE BAPIFLAG-BAPIFLAG.
DATA: BEGIN OF ORDER_ITEM_IN OCCURS 2.
INCLUDE STRUCTURE BAPISDITM.
DATA: END OF ORDER_ITEM_IN.
DATA: BEGIN OF ORDER_ITEM_INX OCCURS 2.
INCLUDE STRUCTURE BAPISDITMX.
DATA: END OF ORDER_ITEM_INX.
DATA: BEGIN OF SCHEDULE_LINES OCCURS 2.
INCLUDE STRUCTURE BAPISCHDL.
DATA: END OF SCHEDULE_LINES.
DATA: BEGIN OF SCHEDULE_LINESX OCCURS 2.
INCLUDE STRUCTURE BAPISCHDLX.
DATA: END OF SCHEDULE_LINESX.
DATA: BEGIN OF ORDER_CFGS_REF OCCURS 2.
INCLUDE STRUCTURE BAPICUCFG.
DATA: END OF ORDER_CFGS_REF.
DATA: BEGIN OF ORDER_CFGS_INST OCCURS 2.
INCLUDE STRUCTURE BAPICUINS.
DATA: END OF ORDER_CFGS_INST.
DATA: BEGIN OF ORDER_CFGS_VALUE OCCURS 2.
INCLUDE STRUCTURE BAPICUVAL.
DATA: END OF ORDER_CFGS_VALUE.
DATA: BEGIN OF CONDITIONS_IN OCCURS 2.
INCLUDE STRUCTURE BAPICOND.
DATA: END OF CONDITIONS_IN.
DATA: BEGIN OF CONDITIONS_INX OCCURS 2.
INCLUDE STRUCTURE BAPICONDX.
DATA: END OF CONDITIONS_INX.
DATA: BEGIN OF EXTENSIONIN OCCURS 2.
INCLUDE STRUCTURE BAPIPAREX.
DATA: END OF EXTENSIONIN.
DATA: BEGIN OF RETURN OCCURS 2.
INCLUDE STRUCTURE BAPIRET2.
DATA: END OF RETURN.
DATA: TMP_POSNR LIKE VBAP-POSNR,
L_KNUMV LIKE VBAK-KNUMV,
L_KSCHL LIKE KONV-KSCHL,
L_STUNR LIKE KONV-STUNR,
L_ZAEHK LIKE KONV-ZAEHK.
***--- Selection
PARAMETERS: P_VBELN LIKE VBAK-VBELN OBLIGATORY MEMORY ID AUN DEFAULT '7000510', "'0001007443', " SO
P_POSNR LIKE VBAP-POSNR OBLIGATORY DEFAULT '000000' , " so item
P_CONDN LIKE KONV-KSCHL DEFAULT 'ZOSP', " condition type
P_CONDI LIKE KONV-ZAEHK DEFAULT '01', " Condition item number
P_TEST AS CHECKBOX DEFAULT 'X'. " test mode
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = P_VBELN
IMPORTING
OUTPUT = P_VBELN.
CLEAR: L_KNUMV.
SELECT SINGLE KNUMV INTO L_KNUMV
FROM VBAK
WHERE VBELN = P_VBELN.
IF SY-SUBRC = 0.
CLEAR: L_KSCHL,L_ZAEHK,L_STUNR.
SELECT SINGLE KSCHL ZAEHK STUNR INTO (L_KSCHL, L_ZAEHK, L_STUNR)
FROM KONV
WHERE KNUMV = L_KNUMV
AND KPOSN = P_POSNR
AND ZAEHK = P_CONDI
AND KSCHL = P_CONDN.
IF SY-SUBRC <> 0.
WRITE:/ 'Condition type or condition item is not exist.'.
EXIT.
ENDIF.
ELSE.
WRITE:/ 'Sales order number is not exist'.
EXIT.
ENDIF.
IF L_ZAEHK IS INITIAL.
WRITE:/ 'Condition type or condition item is not exist.'.
EXIT.
ENDIF.
SALESDOCUMENT = P_VBELN. " Sales order number
ORDER_HEADER_INX-UPDATEFLAG = 'U'. "U = change sales order
***Item Data
ORDER_ITEM_IN-ITM_NUMBER = P_POSNR.
APPEND ORDER_ITEM_IN.
ORDER_ITEM_INX-UPDATEFLAG = 'U'. "I = add, U= update, D=delete
ORDER_ITEM_INX-ITM_NUMBER = P_POSNR.
APPEND ORDER_ITEM_INX.
***--- Begin delete a condition line
***--- Make sure to use update flag 'D'. Here I = add, U= update, D=delete
CLEAR: CONDITIONS_IN,CONDITIONS_INX.
REFRESH: CONDITIONS_IN,CONDITIONS_INX.
CONDITIONS_IN-ITM_NUMBER = P_POSNR.
CONDITIONS_IN-COND_ST_NO = L_STUNR.
CONDITIONS_IN-COND_COUNT = L_ZAEHK.
CONDITIONS_IN-COND_TYPE = L_KSCHL.
APPEND CONDITIONS_IN.
CONDITIONS_INX-UPDATEFLAG = 'D'.
CONDITIONS_INX-ITM_NUMBER = P_POSNR.
CONDITIONS_INX-COND_ST_NO = L_STUNR.
CONDITIONS_INX-COND_COUNT = L_ZAEHK.
CONDITIONS_INX-COND_TYPE = L_KSCHL.
APPEND CONDITIONS_INX.
***--- End delete a condition line
BEHAVE_WHEN_ERROR = 'P'.
SIMULATION = P_TEST. " Test mode or not
"=== call BAPI
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = SALESDOCUMENT
ORDER_HEADER_INX = ORDER_HEADER_INX
LOGIC_SWITCH = ' U'
TABLES
RETURN = RETURN
ORDER_ITEM_IN = ORDER_ITEM_IN
ORDER_ITEM_INX = ORDER_ITEM_INX
CONDITIONS_IN = CONDITIONS_IN
CONDITIONS_INX = CONDITIONS_INX .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
WRITE: / 'Return code =', SY-SUBRC.
SKIP 1.
LOOP AT RETURN.
WRITE: / RETURN-MESSAGE.
ENDLOOP.
Edited by: hank jiang on May 21, 2010 5:07 AM
Edited by: hank jiang on May 21, 2010 5:25 AM
Edited by: hank jiang on May 21, 2010 5:27 AMSALESDOCUMENT = P_VBELN. "Sales order number
ORDER_HEADER_INX-UPDATEFLAG = 'U'. "U = change sales order
ORDER_ITEM_IN-ITM_NUMBER = P_POSNR.
APPEND ORDER_ITEM_IN.
ORDER_ITEM_INX-UPDATEFLAG = 'U'. "I = add, U= update, D=delete
ORDER_ITEM_INX-ITM_NUMBER = P_POSNR.
APPEND ORDER_ITEM_INX.
"Begin delete a condition line
"Make sure to use update flag 'D'. Here I = add, U= update, D=delete
CLEAR: CONDITIONS_IN,CONDITIONS_INX.
REFRESH: CONDITIONS_IN,CONDITIONS_INX.
CONDITIONS_IN-ITM_NUMBER = P_POSNR.
CONDITIONS_IN-COND_ST_NO = L_STUNR.
CONDITIONS_IN-COND_COUNT = L_ZAEHK.
CONDITIONS_IN-COND_TYPE = L_KSCHL.
APPEND CONDITIONS_IN.
CONDITIONS_INX-UPDATEFLAG = 'D'.
CONDITIONS_INX-ITM_NUMBER = P_POSNR.
CONDITIONS_INX-COND_ST_NO = L_STUNR.
CONDITIONS_INX-COND_COUNT = L_ZAEHK.
CONDITIONS_INX-COND_TYPE = L_KSCHL.
APPEND CONDITIONS_INX.
"End delete a condition line
BEHAVE_WHEN_ERROR = 'P'.
SIMULATION = P_TEST. " Test mode or not
"=== call BAPI
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = SALESDOCUMENT
ORDER_HEADER_INX = ORDER_HEADER_INX
LOGIC_SWITCH = ' U'
TABLES
RETURN = RETURN
ORDER_ITEM_IN = ORDER_ITEM_IN
ORDER_ITEM_INX = ORDER_ITEM_INX
CONDITIONS_IN = CONDITIONS_IN
CONDITIONS_INX = CONDITIONS_INX .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
WRITE: / 'Return code =', SY-SUBRC.
SKIP 1.
LOOP AT RETURN.
WRITE: / RETURN-MESSAGE.
ENDLOOP. -
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 -
Error while creating Sales Order Through BAPI
Hi Friends,
i am creating a RFC where i have to create sales order .
I am using bapi
BAPI_SALESORDER_CREATEFROMDAT2
for same and entering values to it.
I got the following return messages:
S V4 233 SALES_HEADER_IN has been processed successfully
S V4 233 SALES_ITEM_IN has been processed successfully
S V1 311 BDN Order 3112800903 has been saved
But when I go to transaction VA03 and enter the number i get the following error:
SD document 3112800903 is not in the database or has been archived
Can any one know how to resolve this error.I am also using BAPI_TRANSACTION_COMMIT with wait = 'X'.
Regards,
Santosh AlleHi,
Try to check the return message once.
SD document 3112800903 is not in the database or has been archived
You will get this message if the sales document is deleted from the database .The BAPI 'BAPI_SALESORDER_CHANGE' is used to delete salesorder.Check whether anyone has deleted it
Also, sometimes it may take few seconds to update the sales order in the database when using BAPI. Check the transaction after some time.
Regards,
Lakshman.
Edited by: Lakshman N on May 14, 2010 7:43 AM
Maybe you are looking for
-
Tables and views not visable in diagram organiser
HI Opened my SSAS project and the tables are not visable in the Diagram Organiser. When I right click on the pane and show all tables get : Error HRESULT E_FAIL has been returned from a call to COM component Then the tables appear without there relat
-
ANN: XML Parser Release V1.0.1.2
A new maintenance release of the Oracle Parser for Java is available for download. It has the following fixes and changes: Bug fixes for: #860163, parsing external DTD failed with a null pointer; #860153, when the element doesn't have any attributes,
-
I deleted a login/password and would now like to add a new one back.
-
Undo Tablespace - newbie question
Q1. Is an Undo Tablespace mandatory in a database ? I thought the only mandatories were SYSTEM, SYSAUX and TEMP ? Q2. What happens if you do not have an Undo Tablespace ? Q2. How does an Undo Tablespace relate to Undo / Rollback Segments in a databas
-
Copying + pasting single keyframes rather than whole fx/filters??
Hi there - Does anyone know of a way to copy and paste individual keyframes between clips, eg. scale, centre etc., ..like you can in Avid? The idea, obviously, is to avoid having to copy an entire move/effect/filter and then manually adjust your keyf