on 05-21-2007 1:40 PM
I am coding in Visual Studio 2005 (VB). I have written a .NET connector (in Visual Studio 2003) and am referencing it in my 2005 project.
I started out trying to call Bapi_Alm_Order_Maintain because I ultimately want to create a PM work order. But, I couldn't get that to work, initially, because I didn't have the proper privileges. Once my privs were granted, I still was not able to successfully call the BAPI. The return codes (in BAPIRET2Table) are
SAP Return Message :IWO_BAPI:121
SAP Return Type E
SAP Return Message :IWO_BAPI:121
SAP Return Type E
SAP Return Message :IWO_BAPI2:113
SAP Return Type E
This is part of my VB code:
With sapMethod
.Refnumber = "000001"
.Objecttype = "HEADER"
.Method = "CREATE"
.Objectkey = "%00000000001"
End With
sapMethodTable.Add(sapMethod)
With sapMethod
.Refnumber = "000001"
.Objecttype = ""
.Method = "SAVE"
.Objectkey = "%00000000001"
End With
sapMethodTable.Add(sapMethod)
With sapHeader
.Orderid = "%00000000001"
.Order_Type = "PM20"
.Funct_Loc = "WAY-BCF-FAC-WTR-FIW"
.Short_Text = "Test Short Text SAA"
.Pmacttype = "202"
End With
sapHeaderTable.Add(sapHeader)
With sapMethod
.Refnumber = "000001"
.Objecttype = "OPERATION"
.Method = "CREATE"
.Objectkey = "%000000000010010"
End With
sapMethodTable.Add(sapMethod)
With sapMethod
.Refnumber = "000001"
.Objecttype = ""
.Method = "SAVE"
.Objectkey = "%00000000001"
End With
sapMethodTable.Add(sapMethod)
With sapOperation
.Activity = "0010"
.Control_Key = "PM01"
.Calc_Key = "1"
.Number_Of_Capacities = 1
.Duration_Normal = "5.0"
.Work_Activity = "5.0"
End With
sapOperationTable.Add(sapOperation)
proxy.Bapi_Alm_Order_Maintain(sapNumbersTable, _
sapParexTable, _
sapOrdComponentTable, _
sapOrdComponentUpTable, _
sapHeaderTable, _
sapOrdSrvdatTable, _
sapOrdSrvdatUpTable, _
sapOrdHeaderUpTable, _
sapMethodTable, _
sapOperationTable, _
sapOrdOperationUpTable, _
sapOrdPartnerMulTable, _
sapOrdPartnerMulUpTable, _
sapOrdRelationTable, _
sapOrdRelationUpTable, _
sapAlmTextTable, _
sapAlmTextLinesTable, _
sapOrdUserStatTable, _
sapReturnTable)
Since I couldn't get the above code to work, I decided to switch gears and try to just retrieve an existing work order. But, I get a similar error when I call Bapi_Alm_Order_Get_Detail. Here's my errors for that one:
SAP Return Message :IWO_BAPI:121 91074418
SAP Return Type E
Here's my code... I am simply providing the order number in the call:
Dim cs As String = "CLIENT=510 USER=XXXXXXX PASSWD=XXXXXXXX LANG=en ASHOST=XXXXXX.xxx.xx.xxxxx.com SYSNR=1"
' Create a new proxy with connection string
Dim proxy As New SAPProxy.SAPConnectorProxy(cs)
Dim sapHeader As New SAPProxy.BAPI_ALM_ORDER_HEADER_E
Dim sapOrdSrvdatTable As New SAPProxy.BAPI_ALM_ORDER_SRVDAT_E
Dim sapOrdComponentTable As New SAPProxy.BAPI_ALM_ORDER_COMPONENT_ETable
Dim sapOrdCostsDetailTable As New SAPProxy.BAPI_ALM_ORDER_COSTS_DETAIL_ETable
Dim sapOrdCostsSumlTable As New SAPProxy.BAPI_ALM_ORDER_COSTS_SUM_ETable
Dim sapOperationTable As New SAPProxy.BAPI_ALM_ORDER_OPERATION_ETable
Dim sapOrdPartnerTable As New SAPProxy.BAPI_ALM_ORDER_PARTNERTable
Dim sapOrdPrtTable As New SAPProxy.BAPI_ALM_ORDER_PRT_ETable
Dim sapOrdRelationTable As New SAPProxy.BAPI_ALM_ORDER_RELATION_EXPORTTable
Dim sapAlmTextLinesTable As New SAPProxy.BAPI_ALM_TEXT_LINESTable
Dim sapAlmTextTable As New SAPProxy.BAPI_ALM_TEXTTable
Dim sapParexTable1 As New SAPProxy.BAPIPAREXTable
Dim sapParexTable2 As New SAPProxy.BAPIPAREXTable
Dim sapReturnTable As New SAPProxy.BAPIRET2Table
Dim strOrderId As String = "91074418"
Try
proxy.Bapi_Alm_Order_Get_Detail(strOrderId, _
sapHeader, _
sapOrdSrvdatTable, _
sapOrdComponentTable, _
sapOrdCostsDetailTable, _
sapOrdCostsSumlTable, _
sapOperationTable, _
sapOrdPartnerTable, _
sapOrdPrtTable, _
sapOrdRelationTable, _
sapAlmTextLinesTable, _
sapAlmTextTable, _
sapParexTable1, _
sapParexTable2, _
sapReturnTable)
Can you help me understand what these errors mean? There's no error text associated with them.
Thank you!
I took a quick look in our SAP Development system and found that IWO_BAPI is the message class, 121 is the message number. The message text is "Error reading the order %1% in the document tables". Which implies that the order number was not found. Are you sure that this is a good order number?
One thing to consider ... my experience with .Net Connector has been that it is necessary to left pad numeric character variables with zeros. The Order Number is a 12 character field, so you might want to try using the order number as "000091074418".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Terry,
You hit the nail on the head with the padding! THANK YOU!
So, now to my other problem... I can now get the details of an order, but I cannot create one via Bapi_Alm_Order_Maintain.
I included my full code below so that there's no confusion. When control returns after I make the Bapi_Alm_Order_Maintain call, BAPIRET2Table (sapReturnTable in my code) contains records with the following Message and Error Types:
SAP Return Message :IWO_BAPI:121
SAP Return Message Type E
SAP Return Message :IWO_BAPI:121
SAP Return Message Type E
SAP Return Message :IWO_BAPI2:113
SAP Return Message Type E
I have worked with some of my users to determine, at minimum, which fields need to be provided to create an order in the SAP GUI. Since this isn't working, however, I must conclude that either one or all of the following are true:
1) I must be filling in the RFC parameters incorrectly
2) the RFC has different minimum data requirements than the SAP GUI does when creating an order
Do you have any ideas on what I might try? The message that you found for 121 is so vague that I have no idea what might be the issue.
Thanks!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Define the connection string
Dim cs As String = "CLIENT=510 USER=XXXXXXX PASSWD=XXXXXXXX LANG=en ASHOST=xxxxxx.xxx.xx.xxxxxx.xxx SYSNR=1"
' Create a new proxy with connection string
Dim proxy As New SAPProxy.SAPConnectorProxy(cs)
Dim sapMethod As New SAPProxy.BAPI_ALM_ORDER_METHOD
Dim sapMethodTable As New SAPProxy.BAPI_ALM_ORDER_METHODTable
Dim sapHeader As New SAPProxy.BAPI_ALM_ORDER_HEADERS_I
Dim sapHeaderTable As New SAPProxy.BAPI_ALM_ORDER_HEADERS_ITable
Dim sapOperation As New SAPProxy.BAPI_ALM_ORDER_OPERATION
Dim sapOperationTable As New SAPProxy.BAPI_ALM_ORDER_OPERATIONTable
Dim sapNumbers As New SAPProxy.BAPI_ALM_NUMBERS
Dim sapNumbersTable As New SAPProxy.BAPI_ALM_NUMBERSTable
Dim sapParexTable As New SAPProxy.BAPIPAREXTable
Dim sapOrdComponentTable As New SAPProxy.BAPI_ALM_ORDER_COMPONENTTable
Dim sapOrdComponentUpTable As New SAPProxy.BAPI_ALM_ORDER_COMPONENT_UPTable
Dim sapOrdSrvdatTable As New SAPProxy.BAPI_ALM_ORDER_SRVDAT_ETable
Dim sapOrdSrvdatUpTable As New SAPProxy.BAPI_ALM_ORDER_SRVDAT_UPTable
Dim sapOrdHeaderUpTable As New SAPProxy.BAPI_ALM_ORDER_HEADERS_UPTable
Dim sapOrdOperationUpTable As New SAPProxy.BAPI_ALM_ORDER_OPERATION_UPTable
Dim sapOrdPartnerMulTable As New SAPProxy.BAPI_ALM_ORDER_PARTN_MULTable
Dim sapOrdPartnerMulUpTable As New SAPProxy.BAPI_ALM_ORDER_PARTN_MUL_UPTable
Dim sapOrdRelationTable As New SAPProxy.BAPI_ALM_ORDER_RELATIONTable
Dim sapOrdRelationUpTable As New SAPProxy.BAPI_ALM_ORDER_RELATION_UPTable
Dim sapAlmText As New SAPProxy.BAPI_ALM_TEXT
Dim sapAlmTextTable As New SAPProxy.BAPI_ALM_TEXTTable
Dim sapAlmTextLines As New SAPProxy.BAPI_ALM_TEXT_LINES
Dim sapAlmTextLinesTable As New SAPProxy.BAPI_ALM_TEXT_LINESTable
Dim sapOrdUserStatTable As New SAPProxy.BAPI_ALM_ORDER_USRSTATTable
Dim sapReturnTable As New SAPProxy.BAPIRET2Table
With sapMethod
.Refnumber = "000001"
.Objecttype = "HEADER"
.Method = "CREATE"
.Objectkey = "%00000000001"
End With
sapMethodTable.Add(sapMethod)
With sapMethod
.Refnumber = "000001"
.Objecttype = ""
.Method = "SAVE"
.Objectkey = "%00000000001"
End With
sapMethodTable.Add(sapMethod)
With sapHeader
.Orderid = "%00000000001"
.Order_Type = "PM20"
.Funct_Loc = "WAY-BCF-FAC-WTR-FIW"
.Short_Text = "Test Short Text SAA"
.Pmacttype = "202"
End With
sapHeaderTable.Add(sapHeader)
With sapMethod
.Refnumber = "000001"
.Objecttype = "OPERATION"
.Method = "CREATE"
.Objectkey = "%000000000010010"
End With
sapMethodTable.Add(sapMethod)
With sapMethod
.Refnumber = "000001"
.Objecttype = ""
.Method = "SAVE"
.Objectkey = "%00000000001"
End With
sapMethodTable.Add(sapMethod)
With sapOperation
.Activity = "0010"
.Control_Key = "PM01"
.Calc_Key = "1"
.Number_Of_Capacities = 1
.Duration_Normal = "5.0"
.Work_Activity = "5.0"
End With
sapOperationTable.Add(sapOperation)
Try
proxy.Bapi_Alm_Order_Maintain(sapNumbersTable, _
sapParexTable, _
sapOrdComponentTable, _
sapOrdComponentUpTable, _
sapHeaderTable, _
sapOrdSrvdatTable, _
sapOrdSrvdatUpTable, _
sapOrdHeaderUpTable, _
sapMethodTable, _
sapOperationTable, _
sapOrdOperationUpTable, _
sapOrdPartnerMulTable, _
sapOrdPartnerMulUpTable, _
sapOrdRelationTable, _
sapOrdRelationUpTable, _
sapAlmTextTable, _
sapAlmTextLinesTable, _
sapOrdUserStatTable, _
sapReturnTable)
Catch ex As SAP.Connector.RfcAbapException
MsgBox(ex.Message.ToString)
End Try
proxy = Nothing
End Sub
Terry,
Since last posting, I have been "playing" some more with this...making sure I had parms specified properly, etc. And I slimmed down what I was trying to create so that I could focus on just getting something created.
Anyway, I realized that I was not creating my records in the method table properly. I was not creating a new instance of the BAPI_ALM_ORDER_METHOD record before populating it and inserting it into the BAPI_ALM_ORDER_METHODTable table.
Once I did that, I get the following errors:
SAP Return Message :IWO_BAPI2:118 %00000000001
SAP Return Type E
SAP Return Message :IWO_BAPI2:113
SAP Return Type E
And, in the BAPI_ALM_NUMBERSTable, I get the following returned:
Aufnr_In%00000000001
Aufnr_New%00000000001
I am only sending the following information at this point:
With sapMethod
.Refnumber = "000001"
.Objecttype = "HEADER"
.Method = "CREATE"
.Objectkey = "%00000000001"
End With
sapMethodTable.Add(sapMethod)
sapMethod = New SAPProxy.BAPI_ALM_ORDER_METHOD
With sapMethod
.Refnumber = "000001"
.Objecttype = ""
.Method = "SAVE"
.Objectkey = "%00000000001"
End With
sapMethodTable.Add(sapMethod)
With sapHeader
.Orderid = "%00000000001"
.Order_Type = "PM20"
.Planplant = "1008"
.Mn_Wk_Ctr = "NAM"
.Plant = "1008"
.Funct_Loc = "WAY-BCF-FAC-WTR-FIW"
.Short_Text = "Test Short Text SAA"
.Pmacttype = "202"
End With
sapHeaderTable.Add(sapHeader)
Any ideas what these new error messages mean?
Thanks!
IWO_BAPI2:118 = "Order &1 cannot be saved as no operation is maintained"
IWO_BAPI2:113 = "Error &1 during processing of BAPI methods"
I would guess that means that the work order must be created with at least one operation. I was looking at how this BAPI is used by other programmers within our system. And it looks like the MethodTable usually contains records to create the Header, Operations, Partner, and then the SAVE.
So try adding your code to create the Operation and add this to the MethodTable after the Header creating and before the SAVE.
K; I tried that, and it is looking better, but still not there yet.
I sent the following in the methods table:
With sapMethod
.Refnumber = "000001"
.Objecttype = "HEADER"
.Method = "CREATE"
.Objectkey = "%00000000001"
End With
sapMethodTable.Add(sapMethod)
sapMethod = New SAPProxy.BAPI_ALM_ORDER_METHOD
With sapMethod
.Refnumber = "000001"
.Objecttype = "OPERATION"
.Method = "CREATE"
.Objectkey = "%000000000010010"
End With
sapMethodTable.Add(sapMethod)
sapMethod = New SAPProxy.BAPI_ALM_ORDER_METHOD
With sapMethod
.Refnumber = "000001"
.Objecttype = ""
.Method = "SAVE"
.Objectkey = "%00000000001"
End With
sapMethodTable.Add(sapMethod)
And this is what I get now:
SAP Return Message Order saved with number 91074421
SAP Return Type S
SAP Return Message S:IWO_BAPI2:112 %00000000001 91074421
SAP Return Type S
SAP Return Message S:IWO_BAPI2:110
SAP Return Type S
SAP Numbers Aufnr_In%00000000001
SAP Numbers Aufnr_New%00000000001
Note that when I go into the SAP GUI and try to view this order, it says it doesn't exist, so the create must have failed even tho it seems to imply that it didn't.
I'm gonna guess that there's something wrong with my order data, perhaps...
thanks so much for hanging in there with me. If there's a place that I can go look these messages up, let me know. I feel like its so close.
The messages are all type 'S' meaning the call was successful! You must call proxy.CommitWork() for the changes to be saved to the system which is why you couldn't see the work order from the GUI.
The normal programming procedure is call the BAPI, check table for any messages of type 'E', if none are found then call CommitWork.
I ran into another slight snag on the Bapi_Alm_Order_Maintain call. I have read that SAP is supposed to return the order ID number of the newly created order in the ET_Numbers parameter table. however, all I get back in ET_numbers is "%00000000001". can you help me understand why I don't get the new Order number back in this table?
the operation is successful and the order is created. I see the following information in the BAPIRET2Table:
SAP Return Message: Order saved with number 91074455
SAP Return Type: S
SAP Return Message: S:IWO_BAPI2:112 %00000000001 91074455
SAP Return Type: S
SAP Return Message: S:IWO_BAPI2:110
SAP Return Type: S
But, I don't want to have to parse the new order number out of the BAPIRET2Table.
any help would be appreciated!
I accidentally marked this un-answered. I got this post confused with another. This post was answered successfully.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I never got MY question answered. the questions that have been answered were from other users interjecting more questions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm an Independent Software Vendor just getting started developing a VB.NET app using SAP .NET Connector to integrate with SAP R/3. What do I need to add to my Visual Studio 2003 project to include the BAPI methods/tables? I would also like to use the QM-IDI interface; What do I need to include to use the RFC's and tables for that interface?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I assume you have installed the SAP .NET Connector software on your machine. Once you do that, follow these instructions:
In Visual Studio 2003 create a new Visual Basic class library project.
-- Add an SAP client proxy to your project as follows:
o From the Project menu in Visual Studio, select Add New Item.
o Select SAP Connector Proxy as a template and choose Open.
-- Switch to the VS .NET Server explorer.
-- Right-click on SAP Servers and select Add Server.
-- Complete the SAP logon information and choose ENTER.
-- The folders BOR and Functions appear. If not, recheck your logon information.
-- To add a function filter, right-click on the functions filter and select Add functions filter.
-- Change the name of the function filter to customers and set the name filter to CUST (as an example)
-- Expand the function filter you just created and you will see a list of all BAPI's whose names match your filter.
-- Highlight the BAPI that you would like to use and drag and drop it to the design surface of SAPProxy.sapwsdl. This is the proxy you added in the second step above. The message "Loading data, this may take some time" appears.
-- Save and compile your application by choosing Build / Build Solution. Note that you will not see definitions created in your SAPProxy.vb file until after you build your solution.
I don' tknow what QM-IDI is...
Sorry, I don't have any direct experience creating work orders using this BAPI, but it looks like you are trying to create the work order and and an operation to the work order all in the same function call. I would suggest breaking this into separate steps to see if you can even create the order.
The first step should be returning a valid order number and Objectkey if the order is created. You should then be able to reference the order by the object key when adding operations.
Also, it may be necessary to call the proxy.CommitWork() method between the calls. In theory this should not be required within the same transactional session, but I've found that it becomes necessary if you SAVE the same object and then want to modify it further.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is this your actual code? Because I don't see where you are opening a connection to SAP?
Try <i>proxy.Connection.Open()</i> before calling the BAPI.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, sorry... I have probably confused you by throwing in two different problems. I provided snippets of code for the call to create an order to make it shorter. Let's just look at the simple case where I try to get the Order Detail. The full code is listed below. I created the SAP .Connector piece as a DLL and I'm just referencing it to call the needed SAP functions. I have been able to use the .Connector to read other things from SAP, so I feel like I must be doing something wrong specific to the Bapi_Alm_Order_Get_Detail call.
The message that I get back in the BAPIRET2Table (sapReturnTable in my example) when returning from the Bapi_Alm_Order_Get_Detail call is:
sapReturnTable.Item(0).Message= IWO_BAPI:121 91074418
sapReturnTable.Item(0).Type = E
It seems that sapReturnTable.Item(0).Message should have a more english-type, clearer message than this coded message. I have no idea what "IWO_BAPI:121" means. Is there an english message that this refers to and why don't I see it in my return information?
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
' Define the connection string
Dim cs As String = "CLIENT=510 USER=XXXXXXXX PASSWD=XXXXXXXX LANG=en ASHOST=XXXXXX.XXX.XX.XXXXXX.XXX SYSNR=1"
' Create a new proxy with connection string
Dim proxy As New SAPProxy.SAPConnectorProxy(cs)
Dim sapHeader As New SAPProxy.BAPI_ALM_ORDER_HEADER_E
Dim sapOrdSrvdatTable As New SAPProxy.BAPI_ALM_ORDER_SRVDAT_E
Dim sapOrdComponentTable As New SAPProxy.BAPI_ALM_ORDER_COMPONENT_ETable
Dim sapOrdCostsDetailTable As New SAPProxy.BAPI_ALM_ORDER_COSTS_DETAIL_ETable
Dim sapOrdCostsSumlTable As New SAPProxy.BAPI_ALM_ORDER_COSTS_SUM_ETable
Dim sapOperationTable As New SAPProxy.BAPI_ALM_ORDER_OPERATION_ETable
Dim sapOrdPartnerTable As New SAPProxy.BAPI_ALM_ORDER_PARTNERTable
Dim sapOrdPrtTable As New SAPProxy.BAPI_ALM_ORDER_PRT_ETable
Dim sapOrdRelationTable As New SAPProxy.BAPI_ALM_ORDER_RELATION_EXPORTTable
Dim sapAlmTextLinesTable As New SAPProxy.BAPI_ALM_TEXT_LINESTable
Dim sapAlmTextTable As New SAPProxy.BAPI_ALM_TEXTTable
Dim sapParexTable1 As New SAPProxy.BAPIPAREXTable
Dim sapParexTable2 As New SAPProxy.BAPIPAREXTable
Dim sapReturnTable As New SAPProxy.BAPIRET2Table
Dim strOrderId As String = "91074418"
Try
proxy.Bapi_Alm_Order_Get_Detail(strOrderId, _
sapHeader, _
sapOrdSrvdatTable, _
sapOrdComponentTable, _
sapOrdCostsDetailTable, _
sapOrdCostsSumlTable, _
sapOperationTable, _
sapOrdPartnerTable, _
sapOrdPrtTable, _
sapOrdRelationTable, _
sapAlmTextLinesTable, _
sapAlmTextTable, _
sapParexTable1, _
sapParexTable2, _
sapReturnTable)
Catch ex As SAP.Connector.RfcAbapException
MsgBox(ex.Message.ToString)
End Try
proxy = Nothing
MANY thanks for any insight!
Hi sylvia able,
Please Giv Full Error Message. so i can help it.
SACHIN
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.