0

I have a query for me which requires to clear. I am using Excel 2003. The sheet contains 12 columns. I need to do export data from Excel to SAP software. Before exporting I need to check if the record is exist or not, if exist then delete and insert.

I have two BAPIs for this one is import table, which needs to be filled the parameters, after filling this table the BAPI searches for the relevant records.

The list will be displayed in a table. I need to search that table with values from excel then import one field value to excel.

I write this code but, it is not working the BAPI giving Error 0.

Thanks in advance for any help...

Public Function Import_Order() As Boolean

    Dim oBAPIGetOrder As Object
    Dim oBAPIVariant1 As Object
    Dim oBAPIVariant2 As Object
    Dim oBAPIVariant3 As Object
    Dim oBAPIImpOrder As Variant
    Dim oBAPIRet As Boolean
    Dim oDoNothing As Variant
    gBAPIPlanOrder = 0
    
    Set oBAPIGetPlOrder = sBAPIControl.Add("PLANED_GET_DET_LIST")   'BAPI
    Set oBAPIVariant1 = oBAPIGetPlOrder.exports.Item("SELECTIONCRITERIA")      'Internal table
    Set oBAPIVariant2 = oBAPIGetPlOrder.Tables.Item("DETAILEDLIST")            'Table
    
    oBAPIVariant1.Value("MATERIAL") = eMaterial
    oBAPIVariant1.Value("PLANT") = ePlnPlant
    
    lBAPIRet = oBAPIGetPlOrder.call
    If lBAPIRet Then
        'oBAPIImpOrder = oBAPIGetPlOrder.imports.Item("PLANNEDORDER_NUM")
        a = oBAPIVariant2.Rows.Count
        oBAPIImpOrder = oBAPIVariant2.Value("PLANNEDORDER_NUM")
        Import_PlannedOrder = True
    Else
        oBAPIImpOrder = 0
        Import_PlannedOrder = False
    End If

End Function
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
user1049518
  • 291
  • 7
  • 13
  • 25
  • I have never worked with the API (had never heard of it before) but what I have learnt from the research on the web is BAPI error#:0 can occur owing to many reasons. Try searching Google for `bapi error 0` Also did you try debugging then code and seeing which line is failing? – Siddharth Rout Mar 27 '12 at 20:57
  • I'm trying to call the BAPI "PLANED_GET_DET_LIST" from VBA(Excel). Below a part of the coding. The Problem is at the line Set oBAPIVariant1 = oBAPIGetPlOrder.exports.Item("SELECTIONCRITERIA"). The Importparameter "SELECTIONCRITERIA" of the BAPI is a structure. When the Macro runs over the above coding line I will see an error = 0(The Cursor is over the variable"oBAPIVariant1"). If the Importparameter isn't a Structure but a dataelement it will run. Please tell me if I make a mistake in the coding – user1049518 Mar 28 '12 at 07:20
  • Hi! I see this is quite an old topic. Did you ever figure it out? I think you could try to replace oBAPIGetPlOrder.exports.Item("SELECTIONCRITERIA") with oBAPIGetPlOrder.exports("SELECTIONCRITERIA") – Havard Kleven Feb 16 '22 at 06:36

1 Answers1

-3

please place the call function statement lBAPIRet = oBAPIGetPlOrder.call after directly the exports statement and before the tables and importstatements