cancel
Showing results for 
Search instead for 
Did you mean: 

Return Order Number with Bapi_Alm_Order_Maintain

Former Member
0 Kudos

I have written an app with Visual Studio and the SAP .NET Connector that calls Bapi_Alm_Order_Maintain to create a PM work order in SAP. It is working properly, however, I have read that SAP is supposed to return the order ID number of the newly created order in the parameter ET_Numbers. 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. This doesn't seem reliable, especially when my code will be running on different installations of SAP around the world.

any help would be appreciated!

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

You wouldn't need to parse the BAPIRET2 since the order number would be in the Message_V2 property. I've seen programmers just grab the order number from there.

ET_NUMBERS should have two properties the incoming number (Aufnr_In) and the order number issued (Aufnr_New). Are both properties coming back "%00000000001"?

Former Member
0 Kudos

thanks for responding, Terry.

yes, both ET_Number properties are coming back with the following:

ET_Numbers Aufnr_In %00000000001

ET_Numbers Aufnr_New %00000000001

I worry about pulling the order number out of the BAPIRET2 data because I'm afraid it won't always be consistent. This code will be running on different SAP installations, and it doesn't seem like an iron clad way to get the new ID. I pasted below exactly what comes back in BAPIRET2. As you see, there are 3 records...the ID number is in V1 in one record and V2 in another.

I wondered if there was some other parameter that I am not passing in that would make SAP pass the ID back in the ET_Numbers table properly? I must be doing something wrong since the documentation says it should contain the new Order Id.

One other thing to note is that I do NOT initialize BAPIRET2 with anything. I pass an empty structure into the Bapi_Alm_Order_Maintain call. I have tried populating it with different things, but nothing seems to work....

?BAPIRET2.Item(0)

{SAPConnectorClassLib.BAPIRET2}

Field: ""

Id: "IW"

Log_Msg_No: "000000"

Log_No: ""

Message: "Order saved with number 91074469"

Message_V1: "91074469"

Message_V2: ""

Message_V3: ""

Message_V4: ""

Number: "080"

Parameter: ""

Row: 0

System: "TD2510"

Type: "S"

?BAPIRET2.Item(1)

{SAPConnectorClassLib.BAPIRET2}

Field: ""

Id: "IWO_BAPI2"

Log_Msg_No: "000000"

Log_No: ""

Message: "S:IWO_BAPI2:112 %00000000001 91074469"

Message_V1: "%00000000001"

Message_V2: "91074469"

Message_V3: ""

Message_V4: ""

Number: "112"

Parameter: ""

Row: 0

System: "TD2510"

Type: "S"

?BAPIRET2.Item(2)

{SAPConnectorClassLib.BAPIRET2}

Field: ""

Id: "IWO_BAPI2"

Log_Msg_No: "000000"

Log_No: ""

Message: "S:IWO_BAPI2:110"

Message_V1: ""

Message_V2: ""

Message_V3: ""

Message_V4: ""

Number: "110"

Parameter: ""

Row: 0

System: "TD2510"

Type: "S"

Thanks for any insight you might have!

Former Member
0 Kudos

That's odd because it works when I run it on our system. Although I only the last two messages and not message 080.

Former Member
0 Kudos

I would probably try a couple things. First, Re-build the proxy objects in VS. Try running the program with the .Net CO trace file enabled so you can see what is actually be passed back and forth between SAP and your program. Try executing the BAPI manually in the Function Builder (SE37) and see if you get the same results.

Former Member
0 Kudos

Terry,

I have tried the SE37 and I see the same thing there that I see when I run my program. I don't really know how to run the program with the .NET Co trace file enabled. I have the .NET Connector calls built in a Visual Studio 2003 class library and then I reference that class lib from a Visual Studio 2005 forms project. Can you tell me how I'd turn that trace on?

You mentioned that when you run this BAPI in your environment that the number is passed back properly. I was curious if there's some parameter I'm not passing in that is needed. Currently, I populate and pass in the following tables:

BAPI_ALM_ORDER_METHODTable,

BAPI_ALM_ORDER_HEADERS_ITable

BAPI_ALM_ORDER_OPERATIONTable

BAPI_ALM_TEXT_LINESTable

BAPI_ALM_TEXTTable.

I populate nothing in any other table (including the BAPI_ALM_NUMBERSTable).

Many Thanks for your continued help!