Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a table from Excel VBA to RFC FM?

Former Member
0 Kudos
1,012

Calling an RFC function module from Excel/VBA I am trying o pass an array of text strings to one of the tables of the unction module and I am getting Run-time error '13' which says "Type mismatch".

In the following example 'myarray' is the array which has been defined as Dim myarray(999) As String and 'intab' is the table.

If call_dynamic Then

result = fns.Z_JE_VALIDATE(Exception, file_name:=file_name, _

errors:=errors, intab:=myarray, messages:=messages)

the_exception = Exception

Else

MyFunc.exports("FILE_NAME") = file_name

MyFunc.exports("INTAB") = myarray

MyFunc.imports("ERRORS") = errors

MyFunc.imports("MESSAGES") = messages

result = MyFunc.Call

the_exception = MyFunc.Exception

What is the correct syntax for defining and passing an array to the rfc function?

Any help will be greatly appreciated.

Thanks ... Jameel

3 REPLIES 3

mnicolai_77
Active Participant
0 Kudos
145

hi jameel,

i don't knw is is useful for you but i have create an excel document that call a bapi.

Pass value to a structure

> MyFunc.exports.Item("DOCUMENTHEADER").Value("OBJ_SYS") = "CSS_300"

> MyFunc.exports.Item("DOCUMENTHEADER").Value("USERNAME") = conn.User

> MyFunc.exports.Item("DOCUMENTHEADER").Value("HEADER_TXT") = ActiveCell.Offset(2, 0).Value

> MyFunc.exports.Item("DOCUMENTHEADER").Value("COMP_CODE") = ActiveCell.Offset(6, 0).Value

> MyFunc.exports.Item("DOCUMENTHEADER").Value("AC_DOC_NO") = ""

> MyFunc.exports.Item("DOCUMENTHEADER").Value("FISC_YEAR") = ActiveCell.Offset(3, 0).Value

> MyFunc.exports.Item("DOCUMENTHEADER").Value("DOC_DATE") = data2

> MyFunc.exports.Item("DOCUMENTHEADER").Value("TRANS_DATE") = data1

> MyFunc.exports.Item("DOCUMENTHEADER").Value("PSTNG_DATE") = data1

> MyFunc.exports.Item("DOCUMENTHEADER").Value("FIS_PERIOD") = ActiveCell.Offset(4, 0).Value

> MyFunc.exports.Item("DOCUMENTHEADER").Value("DOC_TYPE") = ActiveCell.Offset(5, 0).Value

> MyFunc.exports.Item("DOCUMENTHEADER").Value("REF_DOC_NO") = ActiveCell.Offset(7, 0).Value

pass value to a table

> Do

> zrownum = zrownum + 1

> Foglio1.Bar.Value = zrownum

>

> MyFunc.TABLES.Item("ACCOUNTGL").Rows.Add

> MyFunc.TABLES.Item("ACCOUNTGL").Value(zrownum, "ITEMNO_ACC") = zrownum

> MyFunc.TABLES.Item("ACCOUNTGL").Value(zrownum, "GL_ACCOUNT") = ActiveCell.Offset(0, 0).Value

> MyFunc.TABLES.Item("ACCOUNTGL").Value(zrownum, "BUS_AREA") = ActiveCell.Offset(0, 1).Value

> MyFunc.TABLES.Item("ACCOUNTGL").Value(zrownum, "WBS_ELEMENT") = ActiveCell.Offset(0, 3).Value

> If ActiveCell.Offset(0, 4).Value <> "" Then

> MyFunc.TABLES.Item("ACCOUNTGL").Value(zrownum, "COSTCENTER") = "00" & ActiveCell.Offset(0, 4).Value

> End If

> MyFunc.TABLES.Item("ACCOUNTGL").Value(zrownum, "ORDERID") = ActiveCell.Offset(0, 5).Value

> MyFunc.TABLES.Item("ACCOUNTGL").Value(zrownum, "ITEM_TEXT") = ActiveCell.Offset(0, 7).Value

>

> MyFunc.TABLES.Item("CURRENCYAMOUNT").Rows.Add

> MyFunc.TABLES.Item("CURRENCYAMOUNT").Value(zrownum, "ITEMNO_ACC") = zrownum

> MyFunc.TABLES.Item("CURRENCYAMOUNT").Value(zrownum, "CURR_TYPE") = ""

> MyFunc.TABLES.Item("CURRENCYAMOUNT").Value(zrownum, "CURRENCY") = "EUR"

> MyFunc.TABLES.Item("CURRENCYAMOUNT").Value(zrownum, "AMT_DOCCUR") = ActiveCell.Offset(0, 2).Value

>Loop Until ActiveCell.Value = ""

> Set ret = Nothing

> result = MyFunc.Call

> Set ret = MyFunc.TABLES.Item("RETURN")

hope that is huseful for you

Bye

Marco

0 Kudos
145

Thanks Marco.

Your example helped a lot. I also found that I was missing rfcsdk on my pc, so the table object was not getting instantiated correctly. Once I fixed that problem it all worked just as you had explained.

Thanks again ... Jameel

Former Member
0 Kudos
145

Hello Jameel and Marco,

MyFunc.TABLES.Item("CURRENCYAMOUNT").Value(zrownum, "AMT_DOCCUR") =


What should be the format of the amounts (both "plus" and "minus")?

Could u pls give an example?