As data growth is constantly increasing handling such amount of data requires more and more time. Most logical way of solving this issue is to handle data in parallel. Currently for parallel processing ABAP offers only one way – RFC enabled functional modules. This approach is quite old and mostly known. But … there are some limitations exist in RFC FM’s. One of it : it doesn’t allow to pass references. Usually it’s not a problem, but in my case tool is working with multiple data structures, that usually stored as ref to data.
It’s impossible to pass such data directly in RFC FM, so here is the trick:
- Assign variable with ref to data to field symbol
- Export this field symbol to buffer as XString
- Pass xstring to RFC FM
- Perform backward transformation
There are two small tricks with import/export: first one is that you have to explicitly name objects that you export, and during import use same names. Even if data buffer contains data for exactly one object. Other thing is the compression : in this small test without compression data buffer have length 190 bytes, and with compression just 95.
Documentation says that this export routine could fail in case of out of memory, but current limits are not described.
Here is the simple example how it works:
REPORT Z_BINARY_TRANSFORM. data: lr_data type ref to data, lt_test type table of string, wa_string type string, x_buffer type xstring. FIELD-SYMBOLS: <fs1> type any, <fs2> type any. INITIALIZATION. ** Fill source table with test data DO 5 TIMES. wa_string = sy-index. CONDENSE wa_string. CONCATENATE 'test' wa_string into wa_string SEPARATED BY '_'. append wa_string to lt_test. ENDDO. create data lr_data like lt_test. assign lt_test to <fs1>. assign lr_data->* to <fs2>. <fs2> = <fs1>. export rep_tab = <fs2> to data buffer x_buffer compression on. PERFORM abc using x_buffer. form abc using in_buffer type xstring. data: lr_data2 type ref to data, lt_test2 type table of string. field-symbols: <fs3> type standard table, <fs4> type any. create data lr_data2 type table of string. assign lr_data2->* to <fs3>. * append 'test' to <fs3>. import rep_tab = <fs3> from data buffer in_buffer. " Import must be performed on the same variable name that was used for export **** Output supplied table LOOP AT <fs3> ASSIGNING <fs4>. write: <fs4>. NEW-LINE. ENDLOOP. ENDFORM.