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.
Similar Messages
-
Change sales order using BAPI_SALESORDER_CHANGE
Hi i want to add a new line item to the existing sales order using BAPI_SALESORDER_CHANGE
but when i am trying it is giving
'Schedule line 0001 for item 000020 does not exist ' error..
please help me..*********I wanted to add an new line item.***.. this is my code..********
LOOP AT gt_input3 INTO st_input3.
*Finding Max No of line Items
IF fl_set IS INITIAL.
READ TABLE gt_vbap INTO st_vbap WITH KEY vbeln = st_input3-vbeln.
IF sy-subrc EQ 0.
lv_posnr = st_vbap-posnr.
fl_set = 'X'.
ENDIF.
ENDIF.
*Populate Item details
lv_posnr = lv_posnr + 10.
lv_vbeln = st_input3-vbeln.
lv_order_header_inx-updateflag = 'U'.
st_order_item_in-itm_number = lv_posnr.
st_order_item_in-material = st_input3-matnr.
st_order_item_in-target_qty = st_input3-imv_qty.
st_order_item_in-plant = st_input3-werks.
st_order_item_in-store_loc = st_input3-lgort.
st_order_item_in-store_loc = st_input3-lgort.
APPEND st_order_item_in TO lt_order_item_in.
*Populate item updation Details
st_order_item_inx-itm_number = lv_posnr.
st_order_item_inx-updateflag = 'U'.
st_order_item_inx-material = 'X'.
st_order_item_inx-plant = 'X'.
st_order_item_inx-store_loc = 'X'.
st_order_item_inx-target_qty = 'X'.
APPEND st_order_item_inx TO lt_order_item_inx.
*Populate the Schedule Lines
st_schedule_lines-itm_number = lv_posnr.
st_schedule_lines-sched_line = '0001'.
st_schedule_lines-req_qty = st_input3-imv_qty.
APPEND st_schedule_lines TO lt_schedule_lines.
*Populate the update details of schedule lines
st_schedule_linesx-itm_number = lv_posnr.
st_schedule_linesx-sched_line = '0001'.
st_schedule_linesx-req_qty = 'X'.
st_schedule_linesx-updateflag = 'U'.
APPEND st_schedule_linesx TO lt_schedule_linesx.
AT END OF vbeln.
*Call BAPI Sales order change
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = lv_vbeln
order_header_inx = lv_order_header_inx
TABLES
return = lt_return
order_item_in = lt_order_item_in
order_item_inx = lt_order_item_inx
schedule_lines = lt_schedule_lines
schedule_linesx = lt_schedule_linesx.
*Save Sales Order
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
CLEAR lv_posnr.
READ TABLE lt_return INTO st_return WITH KEY type = 'E'.
st_ipfile_err3-message = st_return-message.
*Error Log
LOOP AT gt_temp3 INTO st_temp3.
IF st_ipfile_err3-message IS NOT INITIAL.
MOVE st_temp3-record TO st_ipfile_err3-record.
IF fl_set1 IS INITIAL.
APPEND st_temp_err TO gt_ipfile_err3.
fl_set1 = 'X'.
ENDIF.
APPEND st_ipfile_err3 TO gt_ipfile_err3.
ELSE.
APPEND st_temp3 TO gt_audit3.
ENDIF.
CLEAR : st_temp3,
st_temp_err,
st_ipfile_err3,
fl_set.
ENDLOOP.
REFRESH : gt_zrman, -
Error while updating Ship to Address on Sales Order form
hi ,
A user is trying to update the ship to address on a standard sales orders screen, this is pretty common and never caused any issues. However with one particular order the user gets the following error :
"You cannot update Ship To Location; the standard value rule set prevents override. "
This is an Oracle shipped message and not custom code. The message name is OE_SEC_UPDATE_VIOLATION whose text is : You cannot update &ATTRIBUTE; &REASON
Seems like REASON is the message : OE_SEC_SV_VIOLATION, whose text is
" the standard value rule set prevents override. "
This is a message shipped by Oracle Order entry. I am not able to locate this message since the oracle shipped files are not available to us and this is not in any database code(i searched the code)
Does anyone know when this message is thrown. It seems like some value set error but am not able to figure out where it is being set.
Any help in this will be appreciated.
ThanksDid you check if any Processing rule is defined for Ship to location update :
Setup> Rules > Security > Processing constraint ?
Maybe this order matches condition that prevents this field from being updated. -
Update sales order using BAPI_SALESORDER_CHANGE --- URGENT!!!!
Hello,
<b> I want to update Batch, Pricing date, Header text & Item text using BAPI_SALESORDER_CHANGE.</b>
But i am not able to do it.
i have written a code, but it's still not updating:
PARAMETERS: p_vbeln LIKE vbak-vbeln.
TYPES: BEGIN OF t_return.
INCLUDE STRUCTURE bapiret2.
TYPES: END OF t_return.
TYPES: BEGIN OF t_order_item_in.
INCLUDE STRUCTURE bapisditm.
TYPES: END OF t_order_item_in.
TYPES: BEGIN OF t_order_item_inx.
INCLUDE STRUCTURE bapisditmx.
TYPES: END OF t_order_item_inx.
TYPES: BEGIN OF t_schedule_lines.
INCLUDE STRUCTURE bapischdl.
TYPES: END OF t_schedule_lines.
TYPES: BEGIN OF t_schedule_linesx.
INCLUDE STRUCTURE bapischdlx.
TYPES: END OF t_schedule_linesx.
TYPES: BEGIN OF t_order_text.
INCLUDE STRUCTURE bapisdtext.
TYPES: END OF t_order_text.
DATA: l_vbeln LIKE bapivbeln-vbeln,
i_order_header_inx LIKE bapisdh1x,
i_order_header_in LIKE bapisdh1,
i_return TYPE TABLE OF t_return,
i_order_item_in TYPE TABLE OF t_order_item_in,
wa_order_item_in LIKE LINE OF i_order_item_in,
i_order_item_inx TYPE TABLE OF t_order_item_inx,
wa_order_item_inx LIKE LINE OF i_order_item_inx,
i_schedule_lines TYPE TABLE OF t_schedule_lines,
wa_schedule_lines LIKE LINE OF i_schedule_lines,
i_schedule_linesx TYPE TABLE OF t_schedule_linesx,
wa_schedule_linesx LIKE LINE OF i_schedule_linesx,
i_order_text TYPE TABLE OF t_order_text,
wa_order_text LIKE LINE OF i_order_text,
w_return LIKE bapiret2,
l_date TYPE char10.
CLEAR l_vbeln.
l_vbeln = p_vbeln.
UPDATE REJECTION REASON IN SALES ORDER *
*WRITE sy-datum TO l_date.
i_order_header_inx-updateflag = 'U'.
REFRESH i_order_item_in.
CLEAR wa_order_item_in.
wa_order_item_in-itm_number = '000010'.
wa_order_item_in-batch = '2007450027'.
wa_order_item_in-price_date = sy-datum.
wa_order_item_in-reason_rej = '00'.
APPEND wa_order_item_in TO i_order_item_in.
REFRESH i_order_item_inx.
CLEAR wa_order_item_inx.
wa_order_item_inx-itm_number = '000010'.
wa_order_item_inx-updateflag = 'U'.
wa_order_item_in-batch = 'X'.
wa_order_item_in-price_date = 'X'.
wa_order_item_inx-reason_rej = 'X'.
APPEND wa_order_item_inx TO i_order_item_inx.
*wa_order_text-doc_number = l_vbeln.
**wa_order_text-TDOBJECT = 'EHSWA_MAN'.
***wa_order_text-text_id = '0001'.
**wa_order_text-TDTEXT = 'Header Texts'.
*wa_order_text-text_line = 'SYNGENTA HEADER'.
***wa_order_text-function = 'U'.
wa_order_text-doc_number = l_vbeln.
wa_order_text-itm_number = '000010'.
*wa_order_text-TDOBJECT = 'EBAN'.
wa_order_text-text_id = '0001'.
*wa_order_text-TDTEXT = 'Item text'.
wa_order_text-text_line = 'SYNGENTA TEXT'.
wa_order_text-function = '004'.
APPEND wa_order_text TO i_order_text.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = l_vbeln
ORDER_HEADER_IN =
order_header_inx = i_order_header_inx
SIMULATION =
BEHAVE_WHEN_ERROR = ' '
INT_NUMBER_ASSIGNMENT = ' '
LOGIC_SWITCH =
NO_STATUS_BUF_INIT = ' '
TABLES
return = i_return
order_item_in = i_order_item_in
order_item_inx = i_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 = i_schedule_lines
schedule_linesx = i_schedule_linesx
order_text = i_order_text
ORDER_KEYS =
CONDITIONS_IN =
CONDITIONS_INX =
EXTENSIONIN =
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = w_return.
ENDIF.
Please help out.
Please send the code of it.
Thanks in advance...START-OF-SELECTION.
Get Blocked Orders
PERFORM sub_select_orders.
PERFORM order_reason_for_reject.
END-OF-SELECTION.
Display output
PERFORM sub_display_output.
*& Form sub_select_orders
text
FORM sub_select_orders .
SELECT a~vbeln
a~erdat
a~erzet
a~auart
b~posnr
FROM ( vbak as A
INNER JOIN VBAP AS B
on Bvbeln = AVBELN )
INTO TABLE i_order_data
WHERE a~vbeln IN s_ordno AND
A~auart IN s_auart AND
A~erdat IN s_orddt AND
A~vkorg IN s_vkorg AND
A~vtweg IN s_vtweg AND
A~spart IN s_spart .
IF sy-subrc NE 0.
MESSAGE i001.
No data selected
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " sub_get_blocked_orders
*& Form order_reason_for_reject
text
--> p1 text
<-- p2 text
FORM order_reason_for_reject .
LOOP AT i_order_data INTO w_order_data.
w_output-vbeln = w_order_data-vbeln.
w_ordhdrx-updateflag = c_update.
Update Order Reason for rejection .
w_orditem-ITM_NUMBER = w_order_data-posnr.
w_orditem-reason_rej = p_abgru.
append w_orditem to i_orditem .
w_orditemx-ITM_NUMBER = w_order_data-posnr.
w_orditemx-updateflag = c_update.
w_orditemx-reason_rej = 'X'.
append w_orditemx to i_orditemx .
At end of vbeln .
w_output-vbeln = w_order_data-vbeln .
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = w_order_data-vbeln
order_header_in = w_ordhdr
order_header_inx = w_ordhdrx
TABLES
ORDER_ITEM_IN = i_orditem
ORDER_ITEM_INX = i_orditemx
return = i_bapiret.
READ TABLE i_bapiret WITH KEY type = c_error
TRANSPORTING NO FIELDS.
IF sy-subrc EQ '0'.
move 'Order Reason for rejection update Failed' to
w_output-message .
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_check
IMPORTING
return = i_return.
move 'Order Reason for rejection update successful' to
w_output-message .
endif .
refresh :i_orditemx , i_orditem .
Endat .
APPEND w_output TO i_output.
CLEAR w_output.
endloop .
ENDFORM. " order_reason_for_reject -
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. -
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 -
Problem while changing Sales order using 'BAPI_SALESORDER_CHANGE'
Hi all,
Below is my code to update delivery block value:
FORM call_bapi_salesorder_change .
DATA: iv_bapi_view LIKE order_view.
DATA: gt_sales_doc TYPE STANDARD TABLE OF sales_key, " Document Numbers to Be Selected
gt_items TYPE STANDARD TABLE OF bapisdit. " Order Item Data for Document Numbers
*************************************************************8
DATA:order_headers_out LIKE bapisdhd OCCURS 0 WITH HEADER LINE.
DATA:order_header_inx LIKE bapisdh1x.
DATA: lv_salesdocument LIKE bapivbeln-vbeln.
data: lv_matnr(10) type c.
DATA:
gt_schdule TYPE STANDARD TABLE OF bapischdl, " for gl date & load date
gt_schdulex TYPE STANDARD TABLE OF bapischdlx, " for partner role and partner function.
gt_return TYPE STANDARD TABLE OF bapiret2,
gt_itemin TYPE STANDARD TABLE OF bapisditm,
gt_iteminx TYPE STANDARD TABLE OF bapisditmx ,
gt_bapisdh1 TYPE STANDARD TABLE OF bapisdh1.
DATA:gs_head_bapi TYPE bapisdh1x,
gs_schdule TYPE bapischdl,
gs_schdulex TYPE bapischdlx,
gs_return TYPE bapiret2,
gs_itemin TYPE bapisditm,
gs_iteminx TYPE bapisditmx,
gs_bapisdh1 TYPE bapisdh1.
CLEAR : gt_schdule,gt_schdulex,gs_return.
REFRESH gt_return.
gs_head_bapi-updateflag = 'U'.
SORT gt_final BY vbeln.
CLEAR gs_vbep.
REFRESH gt_vbep[].
CLEAR gs_final.
LOOP AT gt_final1 INTO gs_final.
gs_itemin-itm_number = gs_final-posnr.
*move gs_final-matnr to lv_matnr."qx94162
gs_itemin-material = gs_final-matnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = gs_final-matnr
IMPORTING
output = gs_final-matnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_matnr
IMPORTING
output = lv_matnr.
gs_itemin-material = lv_matnr.
gs_itemin-material = gs_final-matnr.
gs_iteminx-itm_number = gs_final-posnr.
gs_iteminx-updateflag = 'U'.""changed to I
gs_iteminx-material = 'X'.
" gs_schdule-req_dlv_bl = gs_final-lifsp. " Delivery block
gs_schdule-itm_number = gs_final-posnr.
gs_schdulex-itm_number = gs_final-posnr.
gs_schdule-sched_line = '0001'.
gs_schdulex-sched_line = '0001'.
MOVE gs_final-lifsp to gs_schdule-req_dlv_bl.
gs_schdule-req_dlv_bl = gs_final-lifsp.
gs_schdulex-req_dlv_bl = 'X'. " Delivery block
gs_schdulex-updateflag = 'U'.
gs_bapisdh1-sales_org = gs_final-vkorg.
APPEND gs_schdule TO gt_schdule.
APPEND gs_schdulex TO gt_schdulex.
APPEND gs_itemin TO gt_itemin.
APPEND gs_iteminx TO gt_iteminx.
Append gs_BAPISDH1 to gt_BAPISDH1.
lv_salesdocument = gs_final-vbeln.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = lv_salesdocument
ORDER_HEADER_IN = gs_BAPISDH1
order_header_inx = gs_head_bapi
SIMULATION =
BEHAVE_WHEN_ERROR = ' '
INT_NUMBER_ASSIGNMENT = ' '
LOGIC_SWITCH =
NO_STATUS_BUF_INIT = ' '
TABLES
return = gt_return
order_item_in = gt_itemin
order_item_inx = gt_iteminx
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 = gt_schdule
schedule_linesx = gt_schdulex
ORDER_TEXT =
ORDER_KEYS =
CONDITIONS_IN =
CONDITIONS_INX =
EXTENSIONIN =
NFMETALLITMS =
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
REFRESH: gt_schdule, gt_schdulex, gt_itemin , gt_iteminx.
LOOP AT gt_return INTO gs_return.
WRITE / gs_return-message .
ENDLOOP .
ENDLOOP.
ENDFORM. " CALL_BAPI_SALESORDER_CHANGE
When I am using material value as 18342 using CONVERSION_EXIT_ALPHA_OUTPUT:
ORDER_HEADER_IN has been processed successfully
Material is not defined for sales org.A101, distr.chan.00, language DE
Error in ITEM_IN 000030
SCHEDULE_IN has been processed successfully
The sales document is not yet complete: Edit data
Sales document 5010000715 was not changed
and when I am using CONVERSION_EXIT_ALPHA_INPUT (000000000000018342)or while debuging when I am changing value to 0018342 :
I am getting below dump:
Runtime Errors DATA_LENGTH_0
Exception CX_SY_RANGE_OUT_OF_BOUNDS
Date and Time 21.10.2010 07:22:17
Information on where terminated
Termination occurred in the ABAP program "SAPLVBAK" - in
"MAP_VBAP_TO_BAPISDIT".
The main program was "RS_TESTFRAME_CALL ".
In the source code you have the termination point in line 168
of the (Include) program "LVBAK001".
The termination is caused because exception "CX_SY_RANGE_OUT_OF_BOUNDS"
occurred in
procedure "MAP_VBAP_TO_BAPISDIT" "(FORM)", but it was neither handled local
nor declared
in the RAISING clause of its signature.
The procedure is in program "SAPLVBAK "; its source code begins in line
99 of the (Include program "LVBAK001 ".
The same dump I am getting while executing this above BAPI from SE37 tcode with the same test data.
but I am able to change it though Va02 tcode.
Edited by: Arora26 on Oct 21, 2010 7:58 AMHi,
have you searched for OSS notes? The note 1137897 looks like related to your problem. It mentions different BAPI but I assume that both BAPI reuse same routines and therefore it might solve your problem as well.
Cheers -
Price is not being updated when creating a sales order using DTW oOrders
Hello experts,
When I create a sales Order using DTW (oOrders), the information in the input files document.csv and document_lines.csv is updated with no problem, except the price. The price is being ignored from the input files.
Is there something that I must considered when trying to update the price of a sales order using the DTW?
The field "price" was mapped in the source and target fields in DTW.
Here is the document_lines.csv
RecordKey,LineNum,AccountCode,Address,ItemCode,LineTotal,Price,Quantity,ShipDate,WarehouseCode,TaxCode
RecordKey,LineNum,AccountCode,Address,ItemCode,LineTotal,Price,Quantity,ShipDate,WarehouseCode,TaxCode
1,1,_SYS00000000059, ,30PA08-0360-25,1,11.2,3,20110702,V08,A5
1,2,_SYS00000000059, ,30PA08-0707-25,1,15.2,3,20110702,V08,A5
1,3,_SYS00000000059, ,30PA08-0707-22,1,18.3,3,20110702,V08,A5
And the document.csv:
RecordKey,DocEntry,CardCode,DocDate,DocDueDate,DocTotal
RecordKey,DocEntry,CardCode,DocDate,DocDueDate,DocTotal
1, ,c-6167,20110702,20110702,2
Thank you for your help
Jorge ManzoHi,
Try to re-create your dtw using my template,and use text tab when saving your template.
SO-Header
RecordKey CardCode CardName Comments DocDate DocDueDate DocNum
RecordKey CardCode CardName Comments DocDate DocDueDate DocNum
1 24-25 MANUFACTU 24-25 MANUFACTURING 4/5/2010 4/15/2010 11142
SO-LINE
RecordKey linenum itemcode qty uom PriceAfterVAT Price SalesPersonCode
RecordKey linenum itemcode qty uom PriceAfterVAT Price SalesPersonCode
1 0 SHAFT HEX 7/8" 1 pc 4536 4050 CRIS
Note : Line -(LINE NUM and QTY is important upon computation of Price if SO is ITEM TYPE Document.
hope this will help you!
Regards,
Darius -
When trying to change a Sales order using BAPI_SALESORDER_CHANGE, I am getting the following error.
SD document 15704 is not in the database or has been archived.
Please let me know what could be the problemyou have the error message, which is self explanatory.
SD document 15704 is not in the database or has been archived.
if you knat that the sales document indeed exists, and the message is deceiving, then check why are yopu gettign that. maybe you didn;t provide the order# will leading zeros, or you are tryingto change an order immediately after creating, in which case DB commit might not be completed. -
Delete Sales order through BAPI_SALESORDER_CHANGE
Hoi folks,..
Can we delete the entire Sales order using BAPI_SALESORDER_CHANGE. If yes, pls let me know the process?
ThxHI,
You can try to pass 'D' in the update flag of the header Structure.
ie.. ORDER_HEADER_INX-UPDATEFLAG = 'D'
and SALESDOCUMENT = 'The SO# to be deleted'.
Hope this helps.
Gary -
Quantity update into sales order using BAPI_SALESORDER_CREATEFROMDAT2
Hi All,
I am able to create a sales order using the BAPI "BAPI_SALESORDER_CREATEFROMDAT2".
But even after assinging the Target_quntity and the Target_quantity_units, the values are not getting updated into the Sales order, but the sales order gets created .
Did anyone of you had a similare problem, how was it solved.
cold some one please help me out on this.
RegardsHi
I had used below code (using <b>BAPI_SALESORDER_CREATEFROMDAT1</b>)..but never faced any problem.. you can try the same...
Regards,
Raj
REPORT z_sd_salesorder_create
NO STANDARD PAGE HEADING
LINE-SIZE 150
MESSAGE-ID zz.
S T R U C T U R E D E C L A R A T I O N S *
TYPES: BEGIN OF x_ppl,
ppl_order(18), " ppl Orderno
auart(4), " Sales Doc Type
vkorg(4), " Sales Organization
vtweg(2), " Distribution Channel
spart(2), " Division
div(3), " Division
kunnr(10), " Sold-to Party
date(10), " Doc Dt
matnr(18), " Item Matnr#
uom(3), " UOM
qty(15), " Qty
kschl(4), " Pricing condiiton type
kbetr(11), " Rate
END OF x_ppl.
TYPES: BEGIN OF x_file,
loc(30), " Location
div(3), " Division
ppl_order(18), " ppl Orderno
kunnr(10), " Sold-to Party
date(10), " Doc Dt
matnr(20), " Item Matnr#
qty(15), " Qty
uom(3), " UOM
kbetr(11), " Rate
discount(5), " Discount
END OF x_file.
TYPES: BEGIN OF x_output,
ppl_order(18), " ppl Orderno
mesg(130), " Mesg Success/Error
END OF x_output.
TYPES: BEGIN OF x_werks,
name2(30), " Location
werks TYPE werks_ext, " Plant
END OF x_werks.
TYPES: BEGIN OF x_info,
vkorg TYPE vkorg , " Sales org
vtweg TYPE vtweg, " Dist channel
werks TYPE werks_ext," Plant
spart TYPE spart, " Storage Loc
END OF x_info.
TYPES: BEGIN OF x_material,
ppl_prdid(20), " ppl Prd id
matnr TYPE matnr, " Material (SAP)
END OF x_material.
I N T E R N A L T A B L E D E C L A R A T I O N S *
DATA: it_file TYPE STANDARD TABLE OF x_file WITH HEADER LINE." File Data
DATA: it_data TYPE STANDARD TABLE OF x_ppl WITH HEADER LINE." ppl File
DATA: it_out TYPE STANDARD TABLE OF x_output WITH HEADER LINE. " Outcome
DATA: it_werks TYPE STANDARD TABLE OF x_werks WITH HEADER LINE. " Plant
DATA: it_info TYPE STANDARD TABLE OF x_info WITH HEADER LINE. " Othr Info
DATA: it_matnr TYPE STANDARD TABLE OF x_material WITH HEADER LINE. " Material Info
DATA: it_item TYPE STANDARD TABLE OF bapiitemin WITH HEADER LINE. "Order Itm data
DATA: it_partner TYPE STANDARD TABLE OF bapipartnr WITH HEADER LINE. "Order Partner data
V A R I A B L E S D E C L A R A T I O N S *
DATA : v_correct TYPE i,
v_error TYPE i,
v_total TYPE i,
v_return LIKE bapireturn1,
v_index LIKE sy-tabix.
*- Return values
DATA: it_orderh TYPE bapisdhead, "Order Hdr data
order TYPE bapivbeln-vbeln,
soldto TYPE bapisoldto,
shipto TYPE bapishipto,
return TYPE bapireturn1.
DATA: hdate TYPE sy-datum.
U S E R I N P U T S S C R E E N *
SELECTION-SCREEN: BEGIN OF BLOCK blk01 WITH FRAME TITLE text-t01.
PARAMETERS: p_file TYPE rlgrap-filename OBLIGATORY. " File name
SELECTION-SCREEN END OF BLOCK blk01.
S E L E C T I O N S C R E E N *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM get_file.
S t a r t o f S e l e c t i o n *
START-OF-SELECTION.
PERFORM get_upload.
PERFORM validate_data. " Validate the data
PERFORM data_swap. " Prepare the data for processing
IF NOT it_data[] IS INITIAL.
PERFORM get_update. " Create SalesOrders
ELSE.
MESSAGE i001(zz) WITH text-001.
STOP.
ENDIF.
E n d o f S e l e c t i o n *
END-OF-SELECTION.
IF NOT it_data[] IS INITIAL.
PERFORM get_write.
ENDIF.
*& Form get_file
Get File name
FORM get_file .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = syst-repid
mask = '*'
CHANGING
file_name = p_file
EXCEPTIONS
mask_too_long = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " get_file
*& Form get_upload
to upload the file
FORM get_upload .
DATA l_file TYPE string.
CLEAR: it_file, it_file[].
l_file = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = it_file
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSEIF sy-subrc = 0.
SORT it_file BY loc ppl_order.
ENDIF.
ENDFORM. " get_upload
*& Form get_update
Creating mapping Data in Z table
FORM get_update .
DATA: l_itemno(2) TYPE n,
l_partner TYPE parvw,
l_kunnr TYPE kunnr,
l_matnr TYPE matnr,
l_mesg TYPE string,
l_kbetr TYPE p DECIMALS 2.
DATA: l_in_qty LIKE vbap-zmeng,
l_meins LIKE mara-meins,
l_qty LIKE vbap-zmeng.
CLEAR: v_correct, v_error, v_total.
SORT it_data BY ppl_order.
LOOP AT it_data.
CLEAR v_index.
v_index = sy-tabix.
*- New SalesOrder
AT NEW ppl_order.
READ TABLE it_data INDEX v_index.
CLEAR: it_orderh, it_item, it_partner,
order, soldto, shipto, return,
it_item[], it_partner[].
v_total = v_total + 1. "Increment Total SalesOrders counter
CLEAR l_itemno.
l_itemno = '10'.
*- Covert date fields into Internal format
CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'
EXPORTING
datum = it_data-date
dtype = 'DATS'
IMPORTING
idate = it_data-date.
*- Populate SalesOrder header data.
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
input = it_data-auart
IMPORTING
output = it_data-auart.
it_orderh-doc_type = it_data-auart.
it_orderh-sales_org = it_data-vkorg.
it_orderh-distr_chan = it_data-vtweg.
it_orderh-division = it_data-spart.
it_orderh-purch_no = 'DEPOT'.
it_orderh-price_date = it_data-date. "Doc Dt
it_orderh-req_date_h = it_data-date. "Del.Dt
it_orderh-purch_no_s = it_data-ppl_order.
*- Partner data
CLEAR: l_partner, l_kunnr.
*- Convert Partner type into internal format
l_partner = 'SP'. "SoldTo Party
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
input = l_partner
IMPORTING
output = l_partner.
*- Convert Customer into internal format
l_kunnr = it_data-kunnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = l_kunnr
IMPORTING
output = l_kunnr.
it_partner-partn_role = l_partner.
it_partner-partn_numb = l_kunnr.
APPEND it_partner.
CLEAR it_partner.
ENDAT.
*- Item data
it_item-itm_number = l_itemno.
*- Convert material number into internal format
CLEAR l_matnr.
l_matnr = it_data-matnr.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = l_matnr
IMPORTING
output = l_matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
it_item-material = l_matnr.
*- Call FM to get new qty based on SAP UOM
CLEAR: l_meins, l_qty, l_in_qty.
l_in_qty = it_data-qty.
CALL FUNCTION 'Z_GET_QTY_FROM_UOM'
EXPORTING
matnr = it_item-material
in_meins = it_data-uom
in_qty = l_in_qty
IMPORTING
out_meins = l_meins
quantity = l_qty.
IF sy-subrc = 0.
it_data-qty = l_qty.
it_data-uom = l_meins.
ENDIF.
it_data-qty = it_data-qty * 1000.
it_item-req_qty = it_data-qty.
it_item-sales_unit = it_data-uom.
it_item-req_date = it_data-date.
*- Pricing data
it_item-cond_type = it_data-kschl. "Pricing condition
CLEAR l_kbetr.
l_kbetr = it_data-kbetr / 10. "Price (Rate)
it_item-cond_value = l_kbetr.
APPEND it_item.
CLEAR it_item.
*- Increment Item counter.
l_itemno = l_itemno + 10.
*- At end of SalesOrder
AT END OF ppl_order.
READ TABLE it_data INDEX v_index.
*- Call the BAPI for SalesOrder creation
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT1'
EXPORTING
order_header_in = it_orderh
IMPORTING
salesdocument = order
sold_to_party = soldto
ship_to_party = shipto
return = return
TABLES
order_items_in = it_item
order_partners = it_partner.
IF sy-subrc = 0.
COMMIT WORK.
ENDIF.
v_return = return+0(1).
IF v_return = 'E'.
v_error = v_error + 1.
CLEAR l_mesg.
l_mesg = return.
CONDENSE l_mesg.
ELSE.
v_correct = v_correct + 1.
CLEAR l_mesg.
CONCATENATE 'Salesorder'(007) order 'successfully created.'(008)
INTO l_mesg SEPARATED BY space.
CONDENSE l_mesg.
ENDIF.
*- Populate the output table
CLEAR it_out.
it_out-ppl_order = it_data-ppl_order.
it_out-mesg = l_mesg.
APPEND it_out.
CLEAR it_out.
ENDAT.
ENDLOOP.
ENDFORM. " get_update
*& Form get_write
Write the results
FORM get_write .
WRITE:/ 'Total Number of Records :'(002), v_total COLOR 1.
WRITE:/ 'Total Correct Records :'(003), v_correct COLOR 3.
WRITE:/ 'Total Error Records :'(004), v_error COLOR 6.
SKIP 3.
IF NOT it_out[] IS INITIAL.
WRITE:/5 'ppl Order #'(005),
28 'Message'(006).
ENDIF.
SKIP 1.
LOOP AT it_out.
WRITE:/5 it_out-ppl_order,
28 it_out-mesg.
ENDLOOP.
ENDFORM. " get_write
*& Form validate_data
Validate the data
FORM validate_data .
DATA: l_bstkde TYPE bstkd_e.
LOOP AT it_file.
SELECT bstkd_e INTO l_bstkde
UP TO 1 ROWS
FROM vbkd
WHERE bstkd_e = it_file-ppl_order.
ENDSELECT.
IF sy-subrc = 0. " This ppl Order is already been created in SAP, so delete record
DELETE it_file.
ENDIF.
ENDLOOP.
SORT it_file BY ppl_order.
ENDFORM. " validate_data
*& Form data_swap
Prepare the data for processing
FORM data_swap .
CLEAR: it_werks, it_info, it_matnr, it_data,
it_werks[], it_info[], it_matnr[], it_data[].
IF NOT it_file[] IS INITIAL.
*- Get the plant from location
SELECT name2
werks
INTO CORRESPONDING FIELDS OF TABLE it_werks
FROM t001w FOR ALL ENTRIES IN it_file
WHERE name2 = it_file-loc.
IF sy-subrc = 0.
SORT it_werks BY name2 werks.
*- Get the Sales Org, Division and Distribution Channel
IF NOT it_werks[] IS INITIAL.
SELECT vkorg
vtweg
werks
INTO CORRESPONDING FIELDS OF TABLE it_info
FROM tvkwz FOR ALL ENTRIES IN it_werks
WHERE werks = it_werks-werks.
IF sy-subrc = 0.
LOOP AT it_info.
it_info-spart = '99'.
MODIFY it_info INDEX sy-tabix.
ENDLOOP.
SORT it_info BY vkorg vtweg werks.
ENDIF.
ENDIF.
ENDIF.
*- Get material from ppl material
SELECT ppl_prdid
matnr
FROM zppl_master
INTO TABLE it_matnr FOR ALL ENTRIES IN it_file
WHERE ppl_prdid = it_file-matnr.
IF sy-subrc = 0.
SORT it_matnr BY ppl_prdid matnr.
ENDIF.
ENDIF.
*- Update the data in it_data
LOOP AT it_file.
CLEAR it_data.
it_data-auart = 'OR'.
it_data-auart = 'OR'. " CHANGED BY Jo ON 3103005
READ TABLE it_werks WITH KEY name2 = it_file-loc BINARY SEARCH.
IF sy-subrc = 0.
READ TABLE it_info WITH KEY werks = it_werks-werks BINARY SEARCH.
IF sy-subrc = 0.
it_data-vkorg = it_info-vkorg.
it_data-vtweg = it_info-vtweg.
ENDIF.
ENDIF.
*- Material
READ TABLE it_matnr WITH KEY ppl_prdid = it_file-matnr BINARY SEARCH.
IF sy-subrc = 0.
it_data-matnr = it_matnr-matnr.
ENDIF.
it_data-ppl_order = it_file-ppl_order.
it_data-date = it_file-date.
CONCATENATE it_file-kunnr it_file-loc+1(2) INTO it_data-kunnr.
it_data-qty = it_file-qty.
it_data-uom = it_file-uom.
it_data-kbetr = it_file-kbetr.
*- Pricing condition
it_data-kschl = 'PR00'.
CASE it_file-div.
WHEN 'BRN'.
it_data-div = '04'.
WHEN 'GEN'.
it_data-div = '03'.
WHEN 'IVF'.
it_data-div = '02'.
WHEN 'OPH'.
it_data-div = '01'.
ENDCASE.
it_data-spart = it_data-div.
APPEND it_data.
CLEAR it_data.
ENDLOOP.
ENDFORM. " data_swap -
How to update sales orders using B1WS in SAP 8.8 PL18
Hello all.
We are having a problem updating sales orders using Sap Business One Web Service ( B1WS ).
We are running SBO 8.8 PL18, MS-SQL 2008, and all is fine when using the SBO client.
But when it comes to updating sales orders through B1WS we just cannot get it to work.
We can add new orders easily without problems. Updating orders always gives this error:
\[ORDR.PayDuMonth\]\[line: 0\] , 'Field cannot be updated (ODBC -1029)'
We have checked and verified multiple times that our setup is correct.
Also the WDSL files are verified.
We can update orders just fine using the sboclient.
And using B1WS we can basically do everything, besides updating.
We have also tried this on different company db's, so we are quite sure this is not
something related to some general setting we missed, but who knows?
We have tried different ways to "assemble" the order before updating, but it always
ends with the above error.
Here is an example of one of the tests, where we load an order by docentry,
increment the quantity of all open lines by '1', and then try to update it.
protected void Page_Load(object sender, EventArgs e)
// First we login
string sessionId = "";
LoginService.LoginService l_login = new LoginService.LoginService();
LoginService.LoginDatabaseType l_dbtype = LoginService.LoginDatabaseType.dst_MSSQL2008;
LoginService.LoginLanguage _lang = LoginService.LoginLanguage.ln_English;
string _server = "SAP-8_8PL18";
string _licserver = "SAP-8_8PL18:30000";
string _db = "my_test_company";
string _user = "manager";
string _pass = "********";
try
sessionId = l_login.Login(_server, _db, l_dbtype, true, _user, _pass,
_lang, true, _licserver);
catch (Exception ex)
Response.Clear();
Response.Write(ex.Message);
Response.End();
if (sessionId == "")
Response.Clear();
Response.Write("No sessionId");
Response.End();
// We are logged in and have a sessionId
// Now load a valid open order by docentry
try
OrdersServiceRef.OrdersService orderService = new OrdersServiceRef.OrdersService();
orderService.MsgHeaderValue = new OrdersServiceRef.MsgHeader();
orderService.MsgHeaderValue.SessionID = sessionId;
orderService.MsgHeaderValue.ServiceName = OrdersServiceRef.MsgHeaderServiceName.OrdersService;
orderService.MsgHeaderValue.ServiceNameSpecified = true;
OrdersServiceRef.DocumentParams docParams = new OrdersServiceRef.DocumentParams();
docParams.DocEntry = 31; // Docentry of a known open order
docParams.DocEntrySpecified = true;
OrdersServiceRef.Document order = orderService.GetByParams(docParams);
OrdersServiceRef.DocumentDocumentLine line = null;
for (int i = 0; i < order.DocumentLines.Length; i++)
line = order.DocumentLines<i>;
if (line.LineStatus == OrdersServiceRef.DocumentDocumentLineLineStatus.bost_Open)
line.Quantity += 1;
orderService.Update(order);
catch (System.Web.Services.Protocols.SoapException ex)
Response.Clear();
Response.Write(ex.Message);
Response.End();
catch (Exception ex)
Response.Clear();
Response.Write(ex.Message);
Response.End();
Response.Clear();
Response.Write("All OK");
Response.End();
I hope that someone has an idea as to why this happens.
The customer often changes quantity or adds lines on their orders,
and the only way to solve it so far has been to make a new order and
close the old one.
Thanks in advance
J. ThomsenHi,
Welcome you post on the forum.
Have you checked if you only update a specific line instead of a loop?
Thanks,
Gordon -
Need information of Table containing Ship-to-party Partner at Sales Order
Hello SAP folks,
There is a scenario where we need to change the shipping address detail of a partner funtion "Ship-to-party" at Sales Order level. so I just wanted to know which tables stores all the data related to Address of Ship-to-party after the Sales Order is created.
Suggestions are eagerly awaited in this topic !!
Regards,
SarthakHi sarthak
As soon as you change the address for any partner in sales order, the changes are recorded in table ADRC. ( Normal address table for business partners)
Select table VBPA and for the document number (VBLEN) and item number (POSNR) get the address number ( ADRNR) for the ship to party (WE)
Now in the table ADRC with this ADRNR you can find the changed address for ship to party for the order.
regards
makarand -
Update the material quantity in the sales order using LSMW...
Hi Guru's,
I created one sales order using BAPI..now i wanted update the material quantity in the sales order using LSMW...
could you please provide the step by step process....
if anyone of you provide the program logic similar to requirement that would be helpfull to me...
thanks in advance
Srinivas....Hi Sri,
Hope it may help you.
First do the recording for VA02 transaction, in that give the existing sales order number
and update the Quantity and save it. Remaining steps are same what we used(LSMW) to upload data to applications.
Regards,
Vishvesh
if helpful, rewards it. -
Issue in creating sales order using BAPI's...?
Hi Guru's,
i had generated the sales order using the BAPI..but could please guide me how to declare the data declaratin same fields as globally and how to move internal table and how to append ....
thanks in advance...
REPORT z_bapi_salesorder_create.
Sales document type
PARAMETERS: p_auart TYPE auart OBLIGATORY.
Sales organization
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
Distribution channel
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
Division.
PARAMETERS: p_spart TYPE spart OBLIGATORY.
Sold-to
PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
Ship-to
PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
Material
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
Quantity.
PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
Plant
PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
Data declarations.
DATA: v_vbeln LIKE vbak-vbeln.
DATA: header LIKE bapisdhead1.
DATA: headerx LIKE bapisdhead1x.
DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.
DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.
DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx
WITH HEADER LINE.
DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl
WITH HEADER LINE.
Start-of-selection.
START-OF-SELECTION.
Header data
Sales document type
header-doc_type = p_auart.
headerx-doc_type = 'X'.
Sales organization
header-sales_org = p_vkorg.
headerx-sales_org = 'X'.
Distribution channel
header-distr_chan = p_vtweg.
headerx-distr_chan = 'X'.
Division
header-division = p_spart.
headerx-division = 'X'.
headerx-updateflag = 'I'.
Partner data
Sold to
partner-partn_role = 'AG'.
partner-partn_numb = p_sold.
APPEND partner.
Ship to
partner-partn_role = 'WE'.
partner-partn_numb = p_ship.
APPEND partner.
ITEM DATA
itemx-updateflag = 'I'.
Line item number.
item-itm_number = '000010'.
itemx-itm_number = 'X'.
Material
item-material = p_matnr.
itemx-material = 'X'.
Plant
item-plant = p_plant.
itemx-plant = 'X'.
Quantity
item-target_qty = p_menge.
itemx-target_qty = 'X'.
APPEND item.
APPEND itemx.
Fill schedule lines
lt_schedules_in-itm_number = '000010'.
lt_schedules_in-sched_line = '0001'.
lt_schedules_in-req_qty = p_menge.
APPEND lt_schedules_in.
Fill schedule line flags
lt_schedules_inx-itm_number = '000010'.
lt_schedules_inx-sched_line = '0001'.
lt_schedules_inx-updateflag = 'X'.
lt_schedules_inx-req_qty = 'X'.
APPEND lt_schedules_inx.
Call the BAPI to create the sales order.
CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
EXPORTING
sales_header_in = header
sales_header_inx = headerx
IMPORTING
salesdocument_ex = v_vbeln
TABLES
return = return
sales_items_in = item
sales_items_inx = itemx
sales_schedules_in = lt_schedules_in
sales_schedules_inx = lt_schedules_inx
sales_partners = partner.
Check the return table.
LOOP AT return WHERE type = 'E' OR type = 'A'.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
WRITE: / 'Error in creating document'.
ELSE.
Commit the work.
COMMIT WORK AND WAIT.
call FUNCTION 'BAPI_TRANSACTION_COMMIT'.
WRITE: / 'Document ', v_vbeln, ' created'.
ENDIF.*& Report ZAREPAS30
REPORT zarepas30.
DATA : gs_vbeln TYPE vbak-vbeln,
gs_order_header_in TYPE bapisdhd1,
gs_order_header_inx TYPE bapisdhd1x,
gt_order_items_in TYPE STANDARD TABLE OF bapisditm,
gwa_itab1 TYPE bapisditm,
gt_order_items_inx TYPE STANDARD TABLE OF bapisditmx,
gwa_itab2 TYPE bapisditmx,
gt_order_partners TYPE STANDARD TABLE OF bapiparnr,
gwa_itab3 TYPE bapiparnr,
gt_return TYPE STANDARD TABLE OF bapiret2,
gwa_itab4 TYPE bapiret2.
Sales document type
PARAMETERS: p_auart TYPE auart OBLIGATORY.
Sales organization
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
Distribution channel
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
Division.
PARAMETERS: p_spart TYPE spart OBLIGATORY.
Requested Delivery Date
PARAMETERS: p_edatu TYPE edatu OBLIGATORY.
Sold-to
PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
Ship-to
PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
Material
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
Quantity.
PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
Plant
PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
Start-of-selection.
START-OF-SELECTION.
Header data
Sales document type
gs_order_header_in-doc_type = p_auart.
gs_order_header_inx-doc_type = 'X'.
Sales organization
gs_order_header_in-sales_org = p_vkorg.
gs_order_header_inx-sales_org = 'X'.
Distribution channel
gs_order_header_in-distr_chan = p_vtweg.
gs_order_header_inx-distr_chan = 'X'.
Division
gs_order_header_in-division = p_spart.
gs_order_header_inx-division = 'X'.
Reguested Delivery Date
gs_order_header_in-req_date_h = p_edatu.
gs_order_header_inx-req_date_h = 'X'.
gs_order_header_inx-updateflag = 'I'.
Partner data
Sold to
gwa_itab3-partn_role = 'AG'.
gwa_itab3-partn_numb = p_sold.
APPEND gwa_itab3 TO gt_order_partners .
ship to
gwa_itab3-partn_role = 'WE'.
gwa_itab3-partn_numb = p_ship.
APPEND gwa_itab3 TO gt_order_partners .
ITEM DATA
gwa_itab2-updateflag = 'I'.
Line item number.
gwa_itab1-itm_number = '000010'.
gwa_itab2-itm_number = 'X'.
Material
gwa_itab1-material = p_matnr.
gwa_itab2-material = 'X'.
Plant
gwa_itab1-plant = p_plant.
gwa_itab2-plant = 'X'.
Quantity
gwa_itab1-target_qty = p_menge.
gwa_itab2-target_qty = 'X'.
APPEND gwa_itab1 TO gt_order_items_in.
APPEND gwa_itab2 TO gt_order_items_inx.
Line item number.
gwa_itab1-itm_number = '000020'.
gwa_itab2-itm_number = 'X'.
Material
gwa_itab1-material = p_matnr.
gwa_itab2-material = 'X'.
Plant
gwa_itab1-plant = p_plant.
gwa_itab2-plant = 'X'.
Quantity
gwa_itab1-target_qty = p_menge.
gwa_itab2-target_qty = 'X'.
APPEND gwa_itab1 TO gt_order_items_in.
APPEND gwa_itab2 TO gt_order_items_inx.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = gs_order_header_in
ORDER_HEADER_INX = gs_order_header_inx
IMPORTING
SALESDOCUMENT = gs_vbeln
tables
RETURN = gt_return
ORDER_ITEMS_IN = gt_order_items_in
ORDER_ITEMS_INX = gt_order_items_inx
order_partners = gt_order_partners.
Check the return table.
LOOP AT gt_return into gwa_itab4 WHERE type = 'E' OR type = 'A'.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
WRITE: / 'Error occured while creating sales order '.
ELSE.
Commit the work.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
WRITE: / 'Document ', gs_vbeln, ' created'.
ENDIF.
Maybe you are looking for
-
Error in Transformation Routine
Hi all, I have written a code in transformation routine. I have debugged the code. The code which I have written is working fine. The value in 'Result' is correct and till here the code executes without any error. After that , system throws an error
-
Old display driver for Satellite U920T-10J
Hi, My display settings say: generic pnp monitor with a driver date of 2006. Updating the display settings does not change this. What is the proper display driver for this laptop and how can i change it?
-
Hi all, For reporting purpose, I need to populate data for opening balance and the changes for all the balance sheet items after consolidation. I believe we can do this by using movement type as an indicator. My problem now is for the data extracted
-
Consumption of PIR of componentss
Hi, If B is bom component of header material A. B is externally procured item. A is inhouse produced. MTS strategy. Suppose I have sales order for material A and I have maintained PIR for component B. After MRP run, I expect that, system should not g
-
Hello! I want to deploy AD CS in a failover cluster based on Windows Server 2012 R2. All actions are performed following this manual - http://technet.microsoft.com/en-us/library/cc742450(v=ws.10).aspx On both nodes successfully installed AD CS roles