cancel
Showing results for 
Search instead for 
Did you mean: 

RFC_READ_TABLE in Excel -> Column Limitation?

Former Member

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

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.

Former Member
0 Kudos

Hi,

thank you very much for your answer.

Sounds plausible!


I will try to write my own RFC Function Module - Alternative 2 is a good backup solution (because I'm a complete RFC-newbie).


KR

Tobias



tursko
Participant
0 Kudos

Picking your delimiter is also really important. Depending on the type of information you are dealing with, it might be better to have a custom RFC Function Module that actually pulls columns instead of concatenating the columns.

Answers (1)

Answers (1)

Former Member

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