on 06-06-2014 10:40 AM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.