Skip to main content
 
developerWorks
AIX and UNIX
Information Mgmt
Lotus
New to Lotus
Products
How to buy
Downloads
Live demos
Technical library
Training
Support
Forums & community
Events
Rational
Tivoli
WebSphere
Java™ technology
Linux
Open source
SOA and Web services
Web development
XML
My developerWorks
About dW
Submit content
Feedback



developerWorks  >  Lotus  >  Forums & community  >  Enterprise Integration Forum

Enterprise Integration Forum

developerWorks

  

Sign in to participate PreviousPrevious NextNext


Sean Bannister 15.Mar.07 09:53 PM a Web browser
LC LSX Domino SAP R/3 Integration - SAP Connector - 1.7 All 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

'PO HEADER
SelectStatement = _
|POHEADER.COMP_CODE = "| & main.txCompanyCode(0) & |",| & _
|POHEADER.DOC_TYPE = "NB",| & _
|POHEADER.VENDOR = "| & main.txVendorID(0) & |",| & _
|POHEADER.LANGU = "EN",| & _
|POHEADER.LANGU_ISO = "EN",| & _
|POHEADER.PURCH_ORG = "| & main.txPurchasingOrg(0) & |",| & _
|POHEADER.PUR_GROUP = "| & main.txPurchasingGrp(0) & |",| & _
|POHEADER.DOC_DATE = "| & Format(Today, "yyyymmdd") & |",| & _
|POHEADER.OUR_REF = "| & Right(main.txRequestNumber(0), Len(main.txRequestNumber(0))-2) & |",| & _
|POHEADER.CURRENCY_ISO = "| & main.txCurrency(0) & |"|


Prefix = Left(Main.txPurchasingOrg(0), 2)

'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


'* * * * * * PO ITEMS TABLE * * * * *
SelectStatement = SelectStatement & |,| & _
|POITEM.| & RecNo & |.PO_ITEM = | & Cstr(RecNo) & |,| & _
|POITEM.| & RecNo & |.PLANT = "| & Prefix & |01",| & _
|POITEM.| & RecNo & |.QUANTITY = | & main.cxQuantity(ctr) & |,| & _
|POITEM.| & RecNo & |.PO_UNIT = "EA",| & _
|POITEM.| & RecNo & |.NET_PRICE = | & main.cxUnitPrice(ctr) & |,| & _
|POITEM.| & RecNo & |.PRICE_UNIT = | & main.cxUnitPrice(ctr) & |,| & _
|POITEM.| & RecNo & |.ACCTASSCAT = "| & AssCode & |",| & _
|POITEM.| & RecNo & |.PREQ_NAME = "| & Requestor & |",|

'SET DELIVERY ADDRESS DETAILS
If (main.txStoreLocation(0)<>"<--Select-->") Then
SelectStatement = SelectStatement & _
|POITEM.| & RecNo & |.STGE_LOC = "| & main.txStoreLocation(0) & |",|
Else
SelectStatement = SelectStatement & _
|POADDRDELIVER.| & RecNo & |.PO_ITEM = | & Cstr(RecNo) & |,| & _
|POADDRDELIVER.| & RecNo & |.NAME = "| & main.txDelCompanyName(0) & |",|& _
|POADDRDELIVER.| & RecNo & |.NAME2 = "| & main.txDelCareOfname(0) & |",|& _
|POADDRDELIVER.| & RecNo & |.STREET = "| & main.txDelStreet1(0) & |",|& _
|POADDRDELIVER.| & RecNo & |.CITY= "| & main.txDelSuburb(0) & |",|& _
|POADDRDELIVER.| & RecNo & |.REGION = "| & main.txDelState(0) & |",|& _
|POADDRDELIVER.| & RecNo & |.POSTL_CODE1 = "| & main.txDelPostCode(0) & |",|& _
|POADDRDELIVER.| & RecNo & |.COUNTRY = "| & main.txDelCountry(0) & |",|

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

If Main.cxItemNumber(ctr) = "-" Then
SelectStatement = SelectStatement & _
|POITEM.| & RecNo & |.SHORT_TEXT = "| & ShortDesc & |",| & _
|POITEM.| & RecNo & |.MATL_GROUP = "|& Prefix & |07",|
Else
SelectStatement = SelectStatement & _
|POITEM.| & RecNo & |.MATERIAL = "| & main.cxItemNumber(ctr) & |",| & _
|POITEM.| & RecNo & |.MATL_GROUP = "|& Prefix & |06",|
End If

'Add AED no to tracking no if aed exists
If Main.txAED(0) <> "" Then
SelectStatement = SelectStatement & _
|POITEM.| & RecNo & |.TRACKINGNO = "| & main.txAED(0) & |",|
End If
'* * * * * * END PO ITEMS TABLE * * * * * * * * *

'* * * * * * PO TEXTS TABLE * * * * * * * * * * *
'Only add long description if its available
If LongDesc <> "" Then
SelectStatement = SelectStatement & _
|POTEXTITEM.| & RecNo & |.PO_ITEM = | & Cstr(RecNo) & |,| & _
|POTEXTITEM.| & RecNo & |.TEXT_ID = "F01",| & _
|POTEXTITEM.| & RecNo & |.TEXT_LINE = "| & LongDesc & |",|
End If
'* * * * * * END TEXTS TABLE * * * * * * * * *

'* * * * * * PO ACOUNT TABLE * * * * * * * * * * *
SelectStatement = SelectStatement & _
|POACCOUNT.| & RecNo & |.PO_ITEM = | & Cstr(RecNo) & |,| & _
|POACCOUNT.| & RecNo & |.QUANTITY = | & main.cxQuantity(ctr) & |,| & _
|POACCOUNT.| & RecNo & |.GL_ACCOUNT = "| & main.cxGLCode(ctr) & |",|

If Main.cxCostCentre(ctr)<>"-" Then
SelectStatement = SelectStatement & _
|POACCOUNT.| & RecNo & |.COSTCENTER = "| & Main.cxCostCentre(ctr) & |",|
End If

If Main.cxInternalOrder(ctr)<>"-" Then
SelectStatement = SelectStatement & _
|POACCOUNT.| & RecNo & |.ORDERID = "| & Main.cxInternalOrder(ctr) & |",|
End If
'* * * * * * END PO ACCOUNT TABLE * * * * * *

'* * * * * * PO SCHEDULE TABLE * * * * * * * *
SelectStatement = SelectStatement & _
|POSCHEDULE.| & RecNo & |.PO_ITEM = | & Cstr(RecNo) & |,| &_
|POSCHEDULE.| & RecNo & |.DELIVERY_DATE = "| & Format(main.cxDelivery(ctr), "yyyymmdd" )& |",| & _
|POSCHEDULE.| & RecNo & |.QUANTITY = | & main.cxQuantity(ctr) & ||
'* * * * * * END PO SCHEDULE TABLE * * * * *

Next


target.Database = "BAPI_PO_CREATE1"

'Get Login details
CreatePO = SetLogin(Target, CustomSubroutine, Errortext)

target.Connect

If target.Isconnected = False Then
ErrorText = "Can't connect to SAP"
CustomSubroutine = False
CreatePO = False
Exit Function
End If


target.Metadata = "*"

session.ClearStatus
target.MapByName = True
count = target.execute(SelectStatement, fldresult)

-----> 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






SAP & LC LSX committing BAPI_PO_CRE... (Sean Bannister 15.Mar.07)
. . RE: SAP & LC LSX committing BAPI_PO... (Brian Jamieson 20.Mar.07)





  Document options
Print this pagePrint this page

 Search this forum

  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Author
Category
Platform
Release
Advanced search

 Sign In or Register
Sign in
Forgot your password?
Forgot your user name?
Create new registration

 RSS feedsRSS
All forum posts RSS
All main topics RSS
More Lotus RSS feeds

Resources

 Resources
Forum use and etiquette
Native Notes Access
Web site Feedback

Lotus Support

 Lotus Support
IBM Support Portal - Lotus software
Lotus Support documents
Lotus support by product
Lotus support downloads
Lotus support RSS feeds

Wikis

 Wikis
IBM Composite Applications
IBM Mashup Center
IBM Connections
IBM Docs
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud for Social Business
IBM Web Experience Factory
Lotus Domino
Lotus Domino Designer
Lotus Expeditor
Lotus Foundations
Lotus iNotes
Lotus Instructor Community Courseware
Lotus Notes
Lotus Notes & Domino Application Development
Lotus Notes Traveler
Lotus Protector
Lotus Quickr
Lotus Symphony
IBM Web Content Manager
WebSphere Portal

Lotus Forums


 Lotus Forums
Notes/Domino 9.0
Notes/Domino 8.5 + Traveler
Notes/Domino XPages development forum
Notes/Domino 8
Notes/Domino 6 and 7
Notes/Domino 4 and 5
IBM Connections
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud Notes
IBM SmartCloud Meetings
IBM Web Content Manager
Lotus Domino Document Manager
Lotus e-learning
Lotus Enterprise Integration
Lotus Expeditor
Lotus Protector
Lotus Quickr
Lotus SmartSuite
Lotus Symphony
Lotus Symphony Developer Toolkit Support
Lotus Workflow