Sean Bannister 15.Mar.07 09:53 PM a Web browser LC LSXDomino SAP R/3 Integration - SAP Connector - 1.7All Platforms
I am trying to create a PO in SAP using LC LSX and the SAP Connector. I know I have to commit the transaction after BAPI_POCREATE1 as executed by executing/calling BAPI_TRANSACTION_COMMIT. I also need to get the SAP PO number to store in notes. I am just not sure how to go about it. Following is my code thus far, hopefully someone can point me in the right direction:
Function CreatePO(main As NotesDocument, CustomSubroutine As Integer, Errortext As String) As Integer
On Error Goto errorhandler
Dim notessession As New NotesSession
Dim session As New lcsession
Dim target As New LCConnection("sap")
Dim fldLst As New LCFieldList
Dim fldresult As New LCFieldList
Dim field As LCField
Dim number As New LCNumeric
Dim SelectStatement As String
Dim count As Integer
Dim index As Long
Dim ctr As Integer
Dim RecNo As Integer
Dim AssCode As String
Dim Prefix As String
Dim ReqName As NotesName
Dim ArrRequestor As Variant
Dim Requestor As String
Dim ShortDesc As String
Dim LongDesc As String
Dim arrDesc As Variant
Dim ctr2 As Integer
'Build requestor Name
Set Reqname = New notesName(main.txRequester(0))
ArrRequestor = Split(Reqname.Common)
Requestor = Lcase(Left(ArrRequestor(0), 1) & "." & Left(ArrRequestor(Ubound(ArrRequestor)), 10))
For ctr = 0 To Ubound(Main.GetItemValue("cxGLCode"))
'Set record number
RecNo = ctr + 1
'Determine the assignment code
If Main.cxCostCentre(ctr) = "-" And Main.cxInternalOrder(ctr) = "-" Then
AssCode = "Z"
Elseif Main.cxInternalOrder(ctr) <> "-" Then
AssCode = "F"
Elseif Main.cxCostCentre(ctr) <> "-" Then
AssCode = "K"
End If
'Set Properties depending on material no
If Len(main.cxDescription(ctr)) > 40 Then
ArrDesc = Split(main.cxDescription(ctr))
ShortDesc = ""
LongDesc = ""
'Build words upto 40 chars
For ctr2 = 0 To Ubound(ArrDesc)
If Len(ShortDesc+" "+ArrDesc(ctr2))<=40 Then
ShortDesc = ShortDesc+" "+ArrDesc(ctr2)
Else
Exit For
End If
Next
'Add the rest of the words to extend desc
For ctr2 = ctr2 To Ubound(ArrDesc)
LongDesc = LongDesc+" "+ArrDesc(ctr2)
Next
Else
ShortDec = main.cxDescription(ctr)
LongDesc = ""
End If
-----> THIS IS WHERE I GET STUCK ON HOW TO COMMIT THE TRANSACTION AND RETRIEVE THE PO NUMBER.
Call target.Disconnect
Exit Function
errorhandler:
Dim Msg As String
Dim Msgcode As Long
Dim status As Integer
Dim result As String
Msgbox Error$ & "at line " & Erl
If session.status <> LCSUCCESS Then
status = session.GetStatus(result, Msgcode, Msg)
End If
ErrorText = "SAP ERROR: " & Msg
CustomSubroutine = False
CreatePO = False
If target.Isconnected = True Then
Call target.Disconnect
End If
Exit Function
Exit Function
End Function