2

I'm using Excel and VBA to get SAP to download data from SAP through RFC using INST_EXECUTE_REPORT.

It works like a charm when I have specific input parameters. I just build up .Tables("PARA") with the screen name of the parameter and the desired value. I can even use this method for date ranges.

The challenge is when I don't know exactly the input parameters. For example, I wanted to identify all internal orders with a specific text in the description, e.g. CODE40.

Is there any way to use wildcards with INST_EXECUTE_REPORT? When the program passed into INST_EXECUTE_REPORT is executed normally as a transaction on screen, I can set the parameter to *CODE40* and SAP automatically applies a wildcard search. But I can't get that to work with VBA.

I can simulate using wildcards when accessing individual tables with BBP_RFC_READ_TABLE by using LIKE statements in the selection option, but I need a similar functionality for whole reports, not individual tables.

Can anyone help?

Best regards,

The code I'm using is as follows:

Set ObjR3_EXECUTE_REPORT = ObjR3.Add("INST_EXECUTE_REPORT")

With ObjR3_EXECUTE_REPORT
    Set ObjR3_EXECUTE_REPORT_Name = .Exports("PROGRAM")
    Set ObjR3_EXECUTE_REPORT_Para = .Tables("PARA")
    Set ObjR3_EXECUTE_REPORT_Result = .Tables("RESULT_TAB")
    Set ObjR3_EXECUTE_REPORT_Output = .Tables("OUTPUT_TAB")
End With

ObjR3_EXECUTE_REPORT_Name.Value = ReportName

'Build up the table with the fields to be selected
f = 1
For a = LBound(aParameters) To UBound(aParameters)
    aParameterPair = aParameters(a)
    aParameterInput = aParameterPair(UBound(aParameterPair))
    sParameterName = aParameterPair(LBound(aParameterPair))
    
    For c = LBound(aParameterInput) To UBound(aParameterInput)
        sParameterInput = aParameterInput(c)
        ObjR3_EXECUTE_REPORT_Para.AppendRow
        ObjR3_EXECUTE_REPORT_Para(f, "PARA_NAME") = sParameterName
        ObjR3_EXECUTE_REPORT_Para(f, "PARA_VALUE") = sParameterInput
        Debug.Print sParameterName & " " & sParameterInput
        
        f = f + 1
    Next c
    
Next a
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Tyro
  • 45
  • 1
  • 8

0 Answers0