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. Thomsen
Hi,
Welcome you post on the forum.
Have you checked if you only update a specific line instead of a loop?
Thanks,
Gordon
Similar Messages
-
How to update Sales Order status using BAPI_SALESORDER_CHANGE
Hi,
I want to update Sales Order status using BAPI_SALESORDER_CHANGE, this BAPI is called from middle ware, but there is no parameter to pass the status value to this function, please help me how to update sales order status using BAPI only.
Thanks
RKHi,
Can u give me details of what status u would like to update in sales order.
If we are able to update the status from VA02, Then BAPI will assist for the same.
Regards. -
How to update sale order haeder conditions
hi
how to update header conditions using sale order bapi ' create from data 2'.
regards
Siva Shanmugam.A.V.u can use 'BAPI_SALESORDER_CHANGE'
and see the following link
http://abap.wikiprog.com/wiki/BAPI_SALESORDER_CHANGE
Edited by: krupa jani on Nov 25, 2008 11:15 AM -
How to create sales order using BAPI.
Hi all,
I am trying to create sales order using standard BAPI
"BAPI_SALESORDER_CREATEFROMDAT2". But, even I had entered all mandatory fields, I am unable to create sales order sucessfully.
I had gone through the documentaion of this BAPI and entered these fields.
These are the mandatory fields that which I had tried to create,
ORDER_HEADER_IN :
DOC_TYPE Sales document type
SALES_ORG Sales organization
DISTR_CHAN Distribution channel
DIVISION Division
ORDER_PARTNERS..:
PARTN_ROLE Partner role, SP sold-to party
PARTN_NUMB Customer number
ORDER_ITEMS_IN..:
MATERIAL Material number
Do we have anymore fields to give as inputs? I am getting this error message as below :
Msg: Personal number 00007176 does not exit.
But, I am not giving any personal number manually. This personal number was having connection with partner role field,
I had reffered this from the VBPA (Sales Document: Partner Table). Now, please suggest me how to solve this?
Can anyone tell me how to solve this problem and create sales order sucessfully.
Thanks in advance,
Surender Batlanki.hi surendra ,
chech with below code.
REPORT z_bapi_salesorder_create.
Parameters
Sales document type
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
PARAMETERS: p_auart TYPE auart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Sales organization
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Distribution channel
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Division.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
PARAMETERS: p_spart TYPE spart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Sold-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Ship-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Material
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_matnr.
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Quantity.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text7 FOR FIELD p_menge.
PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Plant
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
SELECTION-SCREEN END OF LINE.
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.
Initialization.
INITIALIZATION.
v_text = 'Order type'.
v_text1 = 'Sales Org'.
v_text2 = 'Distribution channel'.
v_text3 = 'Division'.
v_text4 = 'Sold-to'.
v_text5 = 'Ship-to'.
v_text6 = 'Material'.
v_text7 = 'Quantity'.
v_text9 = 'Plant'.
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.
WRITE: / 'Document ', v_vbeln, ' created'.
ENDIF.
let us know if you have any qauistions.
~linganna -
How to update Sales Order Delivery Block while saving Delivery ?
Hi,
I have a requirement wherein i need to update sales order delivery block field(VBAK-LIFSK) while saving the delivery for the order.
Also I need to remove this block while execution of Backorder Rescheduling program SDV03V02 (Tcode : V_V2),
Can anybody help me out in this?
regards,
NitinHI,
try using BAPI_SALESORDER_CHANGE
pass ur vbeln in SALESDOCUMENT
pass an 'X' to BAPISDH1-DLV_BLOCK
and 'X' to BAPISDH1X-DLV_BLOCK
Also add the UPDATE task clause, you will want to set the flag only when delivery is being saved, not before that. -
How to create sales order using bapi( test purpose)
Hi all,
while i was creating sales order using the BAPI_SALESORDER_CREATEFROMDAT1 it is giving some error,
version 0 is not defined for the fiscal year ****.
I have given the fallowing parameters as input
ORDER_HEADER_IN
DOC_TYPE OR
SALES_ORG 1000
DISTR_CHAN 10
DIVISION 00
ORDER_PATNERS
PARTN_ROLE SP
PARTN_NUMB 1000
ORDER_ITEMSIN
MATERIAL M-13
I need to create sample sales order . Please help me how to create sales order with an example( for test purpose).
Regards
Deviprasad.Hi Prasad,
Try using BAPI_SALESORDER_CREATEFROMDAT2.
While creating sales order using FM: BAPI_SALESORDER_CREATEFROMDAT2, please make sure ORDER_ITEMS_IN, ORDER_ITEMS_INX, ORDER_SCHEDULES_IN, ORDER_SCHEDULES_INX.
Pricing Conditions will not be mandatory to create a sales order via BAPI.
As you were saying, you can create a sales order but not with items. Do populate the internal tables that i have specified above.
Also try to pass the item number internally, this will help you in identifying the schedule lines.
Regards,
Priyanka. -
How to Create Sales Order using BAPI with Variant configurations
Hi All,
I need to create a sales order using BAPI BAPI_SALESORDER_CREATEFROMDAT2 with Varaint confiugartions. I will get Header ITEM and variant configuration items in the flat file. Kindly help me in this regard.
One more thing, is there any way to findout all the Varaint classifications for a particular Material?
I have done the below coding. Sales order is getting created but variant configurations are not populating.
*...Configuration: Reference Data
DATA: gt_order_cfgs_ref TYPE TABLE OF bapicucfg,
wa_order_cfgs_ref TYPE bapicucfg.
*...Configuration: Instances
DATA: gt_order_cfgs_inst TYPE TABLE OF bapicuins,
wa_order_cfgs_inst TYPE bapicuins.
*...Configuration: Part-of Specifications
DATA: gt_order_cfgs_part_of TYPE TABLE OF bapicuprt,
wa_order_cfgs_part_of TYPE bapicuprt .
*...Configuration: Characteristic Values
DATA: gt_order_cfgs_value TYPE TABLE OF bapicuval,
wa_order_cfgs_value TYPE bapicuval.
*...Configuration: BLOB Internal Data (SCE)
DATA: gt_order_cfgs_blob TYPE TABLE OF bapicublb ,
wa_order_cfgs_blob TYPE bapicublb.
*...Configuration: Variant Condition Key
DATA: gt_order_cfgs_vk TYPE TABLE OF bapicuvk,
wa_order_cfgs_vk TYPE bapicuvk.
*...Configuration: Reference Item / Instance
DATA: gt_order_cfgs_refinst TYPE TABLE OF bapicuref,
wa_order_cfgs_refinst TYPE bapicuref.
*...Configuration: Reference Data
wa_order_cfgs_ref-posex = '10'.
wa_order_cfgs_ref-config_id = '1'.
wa_order_cfgs_ref-root_id = '1'.
wa_order_cfgs_ref-SCE = '1'.
wa_order_cfgs_ref-CBASE_ID_TYPE = 'G'.
wa_order_cfgs_ref-CONSISTENT = 'T'.
wa_order_cfgs_ref-COMPLETE = 'T'.
APPEND wa_order_cfgs_ref TO gt_order_cfgs_ref.
*..2nd item
wa_order_cfgs_ref-posex = '20'.
wa_order_cfgs_ref-config_id = '2'.
wa_order_cfgs_ref-root_id = '1'.
wa_order_cfgs_ref-SCE = '1'.
wa_order_cfgs_ref-CBASE_ID_TYPE = 'G'.
wa_order_cfgs_ref-CONSISTENT = 'T'.
wa_order_cfgs_ref-COMPLETE = 'T'.
APPEND wa_order_cfgs_ref TO gt_order_cfgs_ref.
*...Configuration: Instances
wa_order_cfgs_inst-config_id = '1'.
wa_order_cfgs_inst-inst_id = '1'.
wa_order_cfgs_inst-obj_type = 'MARA'.
wa_order_cfgs_inst-class_type = '300'.
wa_order_cfgs_inst-obj_key = '2021B'.
wa_order_cfgs_inst-quantity = 1.
wa_order_cfgs_inst-PERSIST_ID_TYPE = 'G'.
wa_order_cfgs_inst-CONSISTENT = 'T'.
wa_order_cfgs_inst-COMPLETE = 'T'.
APPEND wa_order_cfgs_inst TO gt_order_cfgs_inst.
*..2nd item
wa_order_cfgs_inst-config_id = '2'.
wa_order_cfgs_inst-inst_id = '1'.
wa_order_cfgs_inst-obj_type = 'MARA'.
wa_order_cfgs_inst-class_type = '300'.
wa_order_cfgs_inst-obj_key = '2021B'.
wa_order_cfgs_inst-quantity = 1.
wa_order_cfgs_inst-PERSIST_ID_TYPE = 'G'.
wa_order_cfgs_inst-CONSISTENT = 'T'.
wa_order_cfgs_inst-COMPLETE = 'T'.
APPEND wa_order_cfgs_inst TO gt_order_cfgs_inst.
*...Configuration: Characteristic Values
wa_order_cfgs_value-config_id = '1'.
wa_order_cfgs_value-inst_id = '1'.
wa_order_cfgs_value-charc = 'BASIC_MACHINE'.
wa_order_cfgs_value-value = 'L28'.
wa_order_cfgs_value-VALCODE = '1'.
APPEND wa_order_cfgs_value TO gt_order_cfgs_value.
wa_order_cfgs_value-config_id = '1'.
wa_order_cfgs_value-inst_id = '1'.
wa_order_cfgs_value-charc = 'BUCKET'.
wa_order_cfgs_value-value = 'PL1001'.
wa_order_cfgs_value-VALCODE = '1'.
APPEND wa_order_cfgs_value TO gt_order_cfgs_value.
*..2nd item
wa_order_cfgs_value-config_id = '2'.
wa_order_cfgs_value-inst_id = '1'.
wa_order_cfgs_value-charc = 'BUCKET_FOC'.
wa_order_cfgs_value-value = '023OP0049'.
wa_order_cfgs_value-VALCODE = '1'.
APPEND wa_order_cfgs_value TO gt_order_cfgs_value.
wa_order_cfgs_value-config_id = '2'.
wa_order_cfgs_value-inst_id = '1'.
wa_order_cfgs_value-charc = 'BUCKET_HOE'.
wa_order_cfgs_value-value = '028MS0004'.
wa_order_cfgs_value-VALCODE = '1'.
APPEND wa_order_cfgs_value TO gt_order_cfgs_value.
wa_order_cfgs_value-config_id = '2'.
wa_order_cfgs_value-inst_id = '1'.
wa_order_cfgs_value-charc = 'TYRE_PRESSURE_GAUGE'.
wa_order_cfgs_value-value = '81004402'.
APPEND wa_order_cfgs_value TO gt_order_cfgs_value.
*...Configuration: Reference Item / Instance
wa_order_cfgs_refinst-posex = '10'.
wa_order_cfgs_refinst-config_id = '1'.
wa_order_cfgs_refinst-inst_id = '1'.
APPEND wa_order_cfgs_refinst TO gt_order_cfgs_refinst.
*..2nd item
wa_order_cfgs_refinst-posex = '20'.
wa_order_cfgs_refinst-config_id = '2'.
wa_order_cfgs_refinst-inst_id = '1'.
APPEND wa_order_cfgs_refinst TO gt_order_cfgs_refinst.
Regards,
RajeshHi all,
Please help me in solving the issue.
Rajesh -
Hi,
We have a scenario wherein we create shipment cost documents against delivery. As a result of shipments fully transferred, a PO for freight vendor is automatically created and a service entry sheet confirmation happens. As a result of service entry sheet confirmation, we have Financial accounting, Controlling and profitability analysis documents created. We have a requirement wherein we need to have the characteristic “sales order number (KAUFN)” populated in the profitability analysis document created as a result of service entry sheet confirmation.
Could someone please advice how could this be attained in COPA. Thanks for your help in advance.
Regards,
SandeepHi Ajay,
Thank you for the quick update.
The document is updated to COPA through OKB9 settings. The profitability segment is updated with fields like customer, product, company code, plant, sales area data, profit center, etc; however the sales order number is missing.
Could you please elaborate further how could FI substitution be implemented to call for the FM COPA_PROFITABILITY_SEGMENT through user exit? Are you recommending the substitution through GGB1? What could be the possible validation to call for the user exit to be implemented?
Regards,
Sandeep Kulkarni -
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 -
How to find sales order using material???
hi guyz,
i have a mateial and i want to check the sales order created with this material, I am using VBAP table in SE16,could you plz advice how can i check sales order for this material using table.appreciate immediate reply.
Thanks.
MdHi Md,
If you want to find the sales orders with the material number then go to SE16 and go to VBAP table.In the VBAP table selection screen give the material number which you want then press F8 you will get the all sales orders with your material number.
Thanks,
shyla -
How to create Billing Plan in sales order using Function module /BAPI
hi,
How to create Billing Plan in sales order using Function module /BAPI
i hv check few FM such
BILLING_SCHEDULE_READ
BILLING_SCHEDULE_GET_NUMBER
BILLING_SCHEDULE_SAVE
But unable to create billing plan for a sales order.....any other method to create???Hi,
Use this link.
Create sales order with billing plan via LSMW and BAPI BUS2032
BAPI or Function to update Billing Plan in Sales Order Items
Hope this will help you.
Regards,
Vijay -
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 -
Inbound IDoc used for updating Sales order status
I have a requirements to set use standard IDoc to send out the Sales order to a non-SAP software as well as receiving Inbound IDoc to update the status of sales order in SAP. Could someone comment on my questions below:
1. What are the difference between all the ORDERSxx Idoc types?
2. What IDoc should be used for Inbound IDoc to update the sales order stataus in SAP?
3. Can the same IDoc type be used for both Inbound and Outbound with only the difference in the segment of Direction?
Thank you. Points will be awarded appropriately for helpful comments.Hi,
1.Intially standard IDOC types "ORDERS01" is having limited
segments. After few months the requirement got increased to
add more fields to "ORDERS01".So,once you release the IDOC
type you can not add any more fields .So SAP come up
with "ORDERS02" with new fields.Like that all IDocs types have
some more new seg ments.
2.You can use ORDER05
3. Yes you can use same IDOC type -
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.
-
How to create a sales order using a catlog numer
hi,
is it possible to create a sales order using a catlog number of the material .. did any one work on this type ... and how to maintain catalog number for a material?
thank you
mmnDo NOT USE BAPI_SALESORDER_CREATEFROMDATA, that FM is obsolete!
Use BAPI_SALESORDER_CREATEFROMDAT1 .
To build a reference to your contract you have to supply ORDER_HEADER_IN.
Here´s a sample:
MOVE:
gs_vbak-vbeln TO ls_bapisdhd1-refobjkey,
gs_vbak-vbeln TO ls_bapisdhd1-ref_doc,
gs_vbak-vbtyp TO ls_bapisdhd1-refdoc_cat,
gs_vbak-auart TO ls_bapisdhd1-refdoctype.
also gothrouh the links
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap%2b-%2bsimple%2bprogram%2bto%2bcreate%2bsales%2border%2busing%2bbapi
Maybe you are looking for
-
ITunes: Seperating music from other media
I recently bought an external HD which I have connected to a new Airport Extreme. I want to move only my movies and TV shows to that external drive. Even though the external HD streams fast, iTunes seems to be more responsive switching files when the
-
After upgrade iphone4 to ios5 cannot find contacts in iphone.
After upgrade my iphone 4 to IOS5, I cannot locate the contacts icon in the iphone. Can anyone please help me solve this problem? Thank you.
-
When syncing my iPad Mini I notice "other" in the status bar. It is taking over 4gb of space. What is "Other" and how do I get rid of it.
-
Need help choosing new laptop, please.
Hello, I am in the market for a new laptop. My late 2008 MacBook Pro with C2D 2.66 GHz and 4 GB RAM. I think it is one its last leg and it is showing its age. In fact, I am really in fear that it will give out on me soon. It just shuts down randomly
-
Hi , I am trying to find existing enterprise structure on an IDES system. Apart from looking into the assignment node , is there any other way of finding about the org structure. E.g wher we get a graphical diagram kidn of view? Thanks in advance