Skip to Content
0
Nov 24, 2009 at 12:31 AM

VBA to pass data to BAPI

304 Views

We are in the process of developing an Excel file that can be used to update purchase requisitions. I have successfully created the VBA code required to open a connection, call the BAPI, and close the connection. However, I cannot figure out how to pass the table information to the BAPI. Below is a subset of my code:

Sub ChangeReq()

'******************************************

'Call BAPI_PR_CHANGE and change quantity

'******************************************

Set ReqChange = R3.Add("BAPI_PR_CHANGE")

Dim ReqNumber As Object

Dim Item As Object

Dim ItemChanges As Object

Dim Sht1 As Worksheet

Dim Sht2 As Worksheet

Dim Sht3 As Worksheet

Set Sht1 = Sheets("Requisitions")

Set Sht2 = Sheets("PRITEM")

Set Sht3 = Sheets("PRITEMX")

Set ReqNumber = ReqChange.exports("NUMBER")

Set Item = ReqChange.Tables("PRITEM")

Set ItemChanges = ReqChange.Tables("PRITEMX")

ReqNumber = Sht1.Range("A2").Value

Item = Sht2.Range("A2:CN2").Value >>>This is isn't correct

ItemChanges = Sht3.Range("A2:CO2").Value >>>This is isn't correct

Result = ReqChange.CALL

If Result = True Then

MsgBox (ReqNumber)

Else

End If

End Sub

For the life of me, I cannot figure out how to Pass the PRITEM and the PRITEMX data. Any suggestions? My PRITEM data is being stored in a worksheet in cells A2:CN2. PRITEMX is being stored in a separate worksheet in cells A2:CO2.