0
votes

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

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

Thanks in advance for any help...

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

1 Answers

-2
votes

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