Problem solve Get help with specific problems with your technologies, process and projects.

Getting around RFC_READ_TABLE limitations

This tip provides code to help developers get around RFC_READ_TABLE limitations.

RFC_READ_TABLE is an RFC that allows users to read a table remotely. This is important particularly to Java developers...

using JCO to communicate with an ABAP back-end. Unfortunately, RFC_READ_TABLE has size limitations; it also incorrectly reads binary data. The code below gets around those limitations. Note: no authorization checking takes place; that will need to be embedded in your version of the code. Also, you will need to define a table type with FIELDNAME as a line type. function zrvc_read_table. *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" VALUE(IV_TABNAME) TYPE TABNAME *" VALUE(IT_FIELDNAMES) TYPE ZRVC_TT_FIELDNAMES *" VALUE(IT_SELECT_OPTIONS) TYPE STRINGTAB *" EXPORTING *" VALUE(EV_RC) TYPE INT4 *" VALUE(EV_MSG) TYPE STRING *" VALUE(ET_STRINGTAB) TYPE STRINGTAB *"---------------------------------------------------------------------- */References data: lr_error type ref to cx_root, lr_dataref type ref to data. */Variables data: lv_string type string, lv_temp type string, ls_dfies type dfies, lt_dfies type ddfields, lt_alldfies type ddfields. field-symbols: type any table, type any, type any. */Initialize if iv_tabname is initial. ev_rc = 4. ev_msg = 'Missing table name.'. return. endif. */Since this is an RFC, embed everything in a try/catch; catch any */exception and pass message along to caller try. */Get meta data for table call function 'DDIF_NAMETAB_GET' exporting tabname = iv_tabname tables dfies_tab = lt_alldfies exceptions others = 2. if sy-subrc <> 0. ev_rc = 4. ev_msg = 'Table not found; please try again.'. return. endif. if it_fieldnames is initial. */No restrictions provided; use all fields lt_dfies = lt_alldfies. else. */Verify that all fieldnames specified exist in table loop at it_fieldnames assigning . read table lt_alldfies into ls_dfies with key fieldname = . if sy-subrc <> 0. */Specified field not found in table ev_rc = 4. concatenate 'Field' 'not found in table' iv_tabname into ev_msg separated by space. return. endif. */Fieldname found; insert line into working dfies table insert ls_dfies into table lt_dfies. endloop. endif. create data lr_dataref type standard table of (iv_tabname). assign lr_dataref->* to . select * from (iv_tabname) into table where (it_select_options). loop at assigning . clear: lv_string. loop at lt_dfies into ls_dfies. clear: lv_temp. assign component ls_dfies-position of structure to . lv_temp = . "force the type conversion if lv_string is initial. lv_string = lv_temp. else. concatenate lv_string '|' lv_temp into lv_string. endif. endloop. insert lv_string into table et_stringtab. endloop. catch cx_root into lr_error. ev_rc = 4. ev_msg = lr_error->get_text( ). endtry. endfunction.  

This was last published in August 2004

Dig Deeper on SAP interface technologies

PRO+

Content

Find more PRO+ content and other member only offers, here.

Join the conversation

1 comment

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

hi i have tried the same Code. but i am getting the following error.

Reference parameters are not allowed with RFC
Message no. FL381

Diagnosis
You have defined a reference parameter for a remotely called function module. However, only value parameters are allowed in this kind of function module.


Procedure
Change the reference parameter to a value parameter.
Cancel

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close