Skip to Content
author's profile photo Former Member
Former Member

RFC_READ_TABLE in Excel -> Column Limitation?

Hi experts,

I wrote a little VBA Code which transfers the content of a BW table into an excel worksheets via a RFC.

All in all it works fine, but If we want to import more than 14 table columns into the excle worksheet nothing happens.

With 14 (or less) columns we have no problems.

Are there any limitations. Do you know any workaround?

You can find my vba code below. If we uncomment the 2 lines

'T_I_Fields.Rows.Add

'T_I_Fields(15, "FIELDNAME") = "ENTITY"

nothing happens.

Private Sub CommandButton2_Click()

Dim rfc_read_table As Object

Dim functionCtrl As Object

Dim T_I_Options As Object

Dim T_I_Fields As Object

Dim T_E_Data As Object

Dim i, x As Integer

Dim strDataRow As String

Dim DataRow As Variant

Dim Col As Boolean

Col = False

Set functionCtrl = CreateObject("SAP.Functions")

Set rfc_read_table = functionCtrl.Add("RFC_READ_TABLE")

With rfc_read_table

.exports("QUERY_TABLE") = "/1CPMB/PGFXEJRDT"

.exports("DELIMITER") = "|" 'Delimiter

End With

Set T_I_Options = rfc_read_table.tables("OPTIONS")

Set T_I_Fields = rfc_read_table.tables("FIELDS")

Set T_E_Data = rfc_read_table.tables("DATA")

'Einschränken

' <<<<< Importtabellen füllen >>>>>

' Welche Felder sollen gelesen werden

T_I_Fields.Rows.Add

T_I_Fields(1, "FIELDNAME") = "JRN_ID"

T_I_Fields.Rows.Add

T_I_Fields(2, "FIELDNAME") = "APPSET_ID"

T_I_Fields.Rows.Add

T_I_Fields(3, "FIELDNAME") = "APPL_ID"

T_I_Fields.Rows.Add

T_I_Fields(4, "FIELDNAME") = "JRN_TMPL_ID"

T_I_Fields.Rows.Add

T_I_Fields(5, "FIELDNAME") = "ROW_NUM"

T_I_Fields.Rows.Add

T_I_Fields(6, "FIELDNAME") = "DEBIT"

T_I_Fields.Rows.Add

T_I_Fields(7, "FIELDNAME") = "CREDIT"

T_I_Fields.Rows.Add

T_I_Fields(8, "FIELDNAME") = "REMARK"

T_I_Fields.Rows.Add

T_I_Fields(9, "FIELDNAME") = "ACCOUNT"

T_I_Fields.Rows.Add

T_I_Fields(10, "FIELDNAME") = "ACCTDETAIL"

T_I_Fields.Rows.Add

T_I_Fields(11, "FIELDNAME") = "CATEGORY"

T_I_Fields.Rows.Add

T_I_Fields(12, "FIELDNAME") = "CONSOSCOPE"

T_I_Fields.Rows.Add

T_I_Fields(13, "FIELDNAME") = "CURRENCY"

T_I_Fields.Rows.Add

T_I_Fields(14, "FIELDNAME") = "DATASRC"

'T_I_Fields.Rows.Add

'T_I_Fields(15, "FIELDNAME") = "ENTITY"

ret = rfc_read_table.Call

If T_E_Data.RowCount > 0 And ret = True Then

For i = 1 To T_E_Data.RowCount

strDataRow = T_E_Data(i, 1)

DataRow = Split(strDataRow, "|")

If Col = False Then

For x = 0 To UBound(DataRow)

Worksheets("Details").Cells(1, x + 1).Value = T_I_Fields(x + 1, 1)

Next x

Col = True

End If

For x = 0 To UBound(DataRow)

Worksheets("Details").Cells(i + 1, x + 1).Value = DataRow(x)

Next x

Next i

End If

End Sub



Kind regards and many thanks

Tobias

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 06, 2014 at 12:43 PM

    This is my guess:

    RFC_READ_TABLE returns all table fields in a single string row for each record.

    This row has a limit of 512 chars (Data Element: SYCHAR512)

    If this is the case, you have two alternatives:

    1) Write your own RFC Function Module that fetch a single table and return a single column for each table field. (Recommended)

    2) Call RFC_READ_TABLE twice. First call to retrieve the first columns, second call to return primary key and the other columns.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 11, 2014 at 02:55 PM

    I've created a copy of the RFC_READ_TABLE Remote Function Call and changed the datatype to a Char with 8000 signs. Now I'm able to transfer the whole table into excel😊

    KR

    Tobias

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.