QUESTION
I'm using VBA for retrieving data from SAP via BAPI. What RFC should I use, and how, to retrieve PO details at the "each SIZE for each ITEM" level.
EXAMPLE
In this screenshot you see that the PO includes 3 ITEMs. Each of these ITEMs includes several SIZEs/EANs. And for each of the SIZEs/EANs, the specific QUANTITIES are indicated
I want to retrieve this data into Excel. So I create all the needed objects for working with SAP, connect to BAPI_PO_GETITEMS, fill in PURCHASEORDER-parameter, indicate the table PO_ITEMS:
Option Explicit
Public Functions As SAPFunctionsOCX.SAPFunctions
Private LogonControl As SAPLogonCtrl.SAPLogonControl
Private objConnection As SAPLogonCtrl.Connection
Dim Func As SAPFunctionsOCX.Function
Public eNUMBER_OF_ENTRIES As SAPFunctionsOCX.Parameter
Public tENTRIES As SAPTableFactoryCtrl.Table
Public TableFactory As SAPTableFactory
Sub BAPI_PO_GETDETAIL()
Dim i As Integer, j As Integer
Dim retcd As Boolean
Dim SilentLogon As Boolean
Set LogonControl = CreateObject("SAP.LogonControl.1")
Set Functions = CreateObject("SAP.Functions")
Set TableFactory = CreateObject("SAP.TableFactory.1")
Set objConnection = LogonControl.NewConnection
SilentLogon = True
'Use the below block to hardcode system connection and connect automatically
objConnection.Client = ""
objConnection.ApplicationServer = ""
objConnection.Language = ""
objConnection.User = ""
objConnection.Password = ""
objConnection.System = ""
objConnection.SystemNumber = ""
'Logging into SAP
If objConnection.Logon(0, SilentLogon) Then
'Logon was successful
MsgBox "Logged on!"
'Create an object to call the RFC FM
Functions.Connection = objConnection
'Actual FM is added here
Set Func = Functions.Add("BAPI_PO_GETITEMS")
'Populate the importing parameters
Func.Exports("PURCHASEORDER").Value = "2845158864"
'Indicate the TABLE needed
Set tENTRIES = Func.Tables("PO_ITEMS")
'Call FM
Func.Call
'Dump onto the worksheet
For i = 1 To tENTRIES.ColumnCount 'cells(R, C)
cells(1, i).Value = tENTRIES.ColumnName(i)
Next i
For i = 1 To tENTRIES.RowCount
For j = 1 To tENTRIES.ColumnCount
cells(i + 1, j).Value = tENTRIES.Value(i, j)
Next j
Next i
Else
MsgBox "Not Logged on"
End If
End Sub
and get only 3 rows - for each of the 3 ITEMS, without the breakdown by SIZE/EAN:
How to retrieve the breakdown by SIZE/EAN, like on this screenshot: