Skip to Content

BAPI_SALESORDER_CREATEFROMDAT2 and Commit-Issue

Hi,

I've a problem with BAPI_TRANSACTION_COMMIT after BAPI_SALESORDER_CREATEFROMDAT2.

BAPI_SALESORDER_CREATEFROMDAT2 is working fine.

In the Return-Vars I've a message "Salesorder create Number 9999999'.

The Salesordernumbers are reserved in the system.

But the BAPI_TRANSACTION_COMMIT gives no result back and the Salesorder is not created.

I've read somewhere that the two BAPIs have to be called in one Process, but I don't know how to do this.

Many many thanks in advance for helping.

CODE:

Dim _ecc = RfcDestinationManager.GetDestination(strSAPSystem)

Dim setOrderAPI As IRfcFunction = _ecc.Repository.CreateFunction("BAPI_SALESORDER_CREATEFROMDAT2")

Dim setCommit As IRfcFunction = _ecc.Repository.CreateFunction("BAPI_TRANSACTION_COMMIT")


Dim SAPStrucOrder_Header_In As SAP.Middleware.Connector.IRfcStructure = setOrderAPI.GetStructure("ORDER_HEADER_IN")


SAPStrucOrder_Header_In.SetValue("DOC_TYPE", "ZEDI")

SAPStrucOrder_Header_In.SetValue("SALES_ORG", "0100")

SAPStrucOrder_Header_In.SetValue("DISTR_CHAN", "10")

SAPStrucOrder_Header_In.SetValue("DIVISION", "10")

Dim datLieferdatum As Date

datLieferdatum = strLieferdatum

SAPStrucOrder_Header_In.SetValue("REQ_DATE_H", datLieferdatum)


Dim SAPTableOrder_Partners As SAP.Middleware.Connector.IRfcTable = setOrderAPI.GetTable("ORDER_PARTNERS")

SAPTableOrder_Partners.Append()

SAPTableOrder_Partners.SetValue("PARTN_ROLE", "AG")

SAPTableOrder_Partners.SetValue("PARTN_NUMB", gstrSAPKDNR)

SAPTableOrder_Partners.Append()

SAPTableOrder_Partners.SetValue("PARTN_ROLE", "WE")

SAPTableOrder_Partners.SetValue("PARTN_NUMB", strSAPKunnrWE)


Dim SAPTableOrder_Items_In As SAP.Middleware.Connector.IRfcTable = setOrderAPI.GetTable("ORDER_ITEMS_IN")

Dim SAPTableOrder_Schedule_In As SAP.Middleware.Connector.IRfcTable = setOrderAPI.GetTable("ORDER_SCHEDULES_IN")


lngTmpPosNr = 0

For z4 As Integer = 0 To PosTabelle.lngPosnr.Length - 1

lngTmpPosNr = PosTabelle.lngPosnr(z4) * 10

SAPTableOrder_Items_In.Append()

SAPTableOrder_Items_In.SetValue("ITM_NUMBER", lngTmpPosNr)

SAPTableOrder_Items_In.SetValue("MATERIAL", PosTabelle.strSAPArtNr(z4))

SAPTableOrder_Schedule_In.Append()

SAPTableOrder_Schedule_In.SetValue("ITM_NUMBER", lngTmpPosNr)

SAPTableOrder_Schedule_In.SetValue("REQ_QTY", PosTabelle.lngMenge(z4))

SAPTableOrder_Schedule_In.SetValue("REQ_DATE", datLieferdatum)

Next


setOrderAPI.Invoke(_ecc)
setCommit.Invoke(_ecc)


Dim strVBELN As String

Dim strReturnType As String

Dim strReturnID As String

Dim strReturnNumber As String

Dim strReturnMessage As String

Dim strReturnType2 As String

Dim strReturnID2 As String

Dim strReturnNumber2 As String

Dim strReturnMessage2 As String


Try

strVBELN = setOrderAPI.GetValue("SALESDOCUMENT").ToString

strReturnType = setOrderAPI.GetTable("RETURN").GetString("TYPE")

strReturnID = setOrderAPI.GetTable("RETURN").GetString("ID")

strReturnNumber = setOrderAPI.GetTable("RETURN").GetString("NUMBER")

strReturnMessage = setOrderAPI.GetTable("RETURN").GetString("MESSAGE")

strReturnType2 = setCommit.GetStructure("RETURN").GetString("TYPE")

strReturnID2 = setCommit.GetStructure("RETURN").GetString("ID")

strReturnNumber2 = setCommit.GetStructure("RETURN").GetString("NUMBER")

strReturnMessage2 = setCommit.GetStructure("RETURN").GetString("MESSAGE")

Catch

'nix

End Try

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jun 21, 2012 at 02:14 PM

    I believe this is accomplished by using the following "wrapper" --

    RfcSessionManager.BeginContext(_ecc)

    setOrderAPI.Invoke(_ecc)
    setCommit.Invoke(_ecc)

    RfcSessionManager.EndContext(_ecc)

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 11, 2012 at 03:04 PM

    Hello. I have a question. I get your sample and it worked but why did the transaction class not work? Is that an issue in the connector code? If not then what is the transaction class to be used for?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.