07-27-2005 12:48 PM
I am trying to use a FM from SAP BW with two tables (Options and Fields) in VBA and fill these tables with some paramters.
The first one (with only one column named TEXT) works fine, but the second one with more than one column brings up an exception.
This is the VBA-Coding I am using:
Dim BW, MyFunc, App As Object
Set BW = CreateObject("SAP.Functions")
If BW.Connection.logon(0, False) <> True Then
Exit Sub
End If
Set MyFunc = BW.Add("ZDU_READ_BWTDATA_RFC")
This works:
Set oParam1 = MyFunc.exports("TABLE")
oParam1.Value = "/BI0/TMATERIAL"
This works:
'OPTIONS
'Where-CLAUSE
Dim tOPTIONS As Object
Dim Options_Text As Object
Set tOPTIONS = MyFunc.Tables.Item("OPTIONS")
Set Options_Text = tOPTIONS.Rows.Add
Options_Text.Value("TEXT") = "LANGU eq 'E'"
This does not work:
'FIELDS
Dim tFIELDS As Object
Dim FIELDS_FIELDNAME As Object
Set tFIELDS = MyFunc.Tables.Item("FIELDS")
Set FIELDS_FIELDNAME = tFIELDS.Rows.Add
FIELDS_FIELDNAME.Value("FIELDNAME") = "MATERIAL"
Set FIELDS_FIELDNAME = tFIELDS.Rows.Add
FIELDS_FIELDNAME.Value("FIELDNAME") = "LANGU"
Set FIELDS_FIELDNAME = tFIELDS.Rows.Add
FIELDS_FIELDNAME.Value("FIELDNAME") = "TXTMD"
I found these links but they are using the same coding...
Any hints are welcome!
Message was edited by: Markus Fischer
07-27-2005 1:00 PM
Hi,
Check this.May be this can help you.If so,reward points by clicking the star button next to reply.
http://www.sap-img.com/abap/vb-codes-or-vba-macro-code-for-access-sap-and-run-one-rfc.htm
07-27-2005 1:16 PM
Hello,
thanks for the link - nice coding, but it does not provide the informations I am searching.
The coding uses disconnected recordsets to hand over values and I do not know how to hand over theses recordsets to the RFC-Mdoule. the way the author used in the coding does not work.
Main Question is also why the first fill-up of the table options works and the secodn does not.
Thanks for the link anyway!
07-28-2005 6:39 AM
07-27-2005 1:04 PM
Hi Markus,
here comes some "any hint" (hope it helps):
http://www.sap-img.com/abap/vb-codes-or-vba-macro-code-for-access-sap-and-run-one-rfc.htm
regards
Andreas
07-28-2005 7:49 AM
Hi,
Try to use such coding:
Set MyFunc = Funct.Add("ZDU_READ_BWTDATA_RFC")
Set Options = MyFunc.Tables("OPTIONS")
Set Row = Options.Rows.Add
Row("FIELDNAME") = "MATERIAL"
Set Row = Options.Rows.Add
Row("FIELDNAME") = "LANGU"
Result = MyFunc.Call
Maybe first you should add row, then make assignment...
Krzys
07-14-2006 3:58 PM
You were almost there, try this:
Set tFIELDS = MyFunc.Tables.Item("FIELDS")
Set FIELDS_FIELDNAME = tFIELDS.Rows.Add
FIELDS_FIELDNAME.Value(1,"FIELDNAME") = "MATERIAL"
Set FIELDS_FIELDNAME = tFIELDS.Rows.Add
FIELDS_FIELDNAME.Value(2,"FIELDNAME") = "LANGU"
Set FIELDS_FIELDNAME = tFIELDS.Rows.Add
FIELDS_FIELDNAME.Value(3,"FIELDNAME") = "TXTMD"
Please note the unique index number before the text FIELDNAME to uniquley identify your parameters to the FM. Hope this helps.
Regards
Ashley Day