Forum Discussion

PrithviK's avatar
PrithviK
New Contributor III
10 months ago

Extract data from BAPI_AP_ACC_OPENITEMS

Hello Everyone,

Has anyone done an extract for BAPI "BAPI_AP_ACC_OPENITEMS" using RFC connection from SAP. I have below code, any suggestions here. What will be the Imports if we have to extract 7-10 columns in the extract ?

Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Transformer, ByVal args As ConnectorArgs) As Object
Dim r3Conn As R3Connection
Try
'Create and open the R3 Connection
r3Conn = Me.GetConnection(si, globals, api)
r3Conn.Open()

Dim r3Func As RFCFunction = r3Conn.CreateFunction("BAPI_AP_ACC_GETOPENITEMS")

r3Func.Exports("CompanyCode").ParamValue = "1000"

r3Func.Execute()

Return r3Func.Imports("").ToTable()

' End Select
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
Finally
If Not r3Conn Is Nothing Then r3Conn.Close
End Try
End Function

 

  • Krishna's avatar
    Krishna
    Valued Contributor

    PrithviK  - The Below is the example for the imports 

    Return r3Func.Imports("TB").ParamValue.ToADOTable() 

    The above Function then will be return to the Data Table in the  ConnectorActionTypes.GetData

     

    • PrithviK's avatar
      PrithviK
      New Contributor III

      If I add the above line. Replaced TB with LINEITEMS for AP Open Items table.
      Return r3Func.Imports("LINEITEMS").ParamValue.ToADOTable(). I am getting below error

      Public member 'ToADOTable' on type 'RFCStructure' not found.

      • Krishna's avatar
        Krishna
        Valued Contributor

        PrithviK  - Could you please let me know which BR are you using SIC or Extender?

  • Hi Prithvi,

    I assume you are running a SIC Rule, Can you give this a try:

    ' Define which columns to import
            Dim imports As New RFCStructure()
            imports.AddField("Field1") ' Example: Field1
            imports.AddField("Field2") ' Example: Field2
            ' Add more fields as needed
    
            ' Import the specified columns into a table
            Dim dataTable As DataTable = r3Func.Imports("").ToTable(imports)
    

    Replace "Field1", "Field2"  with the actual field names you want to extract from the BAPI response. Make sure these fields correspond to the fields available in the BAPI result set. This should allow you to extract the desired columns from the BAPI response.

    Thanks,
    Nikhil 




     

    • PrithviK's avatar
      PrithviK
      New Contributor III

      Hi Nikhil, this is not SIC, rather am using Connector rule for this export