Skip to Content
-1
Jul 04, 2018 at 01:52 PM

RFC_READ_TABLE

580 Views

Dear Experts,

I try to utilize "RFC_READ_TABLE" FM in one of myprograms, but it dumps an error:

"A dynamically specified column name is unknown.

An error occurred when executing a REMOTE FUNCTION CALL. It was logged under the name "SAPSQL_INVALID_FIELDNAME" on the called page."

Please may you help me out.

DATA: 
lt_fields  TYPE TABLE OF rfc_db_fld,
ls_fields  LIKE LINE OF lt_fields,
gt_matnr   TYPE TABLE OF tab512,
ls_options TYPE rfc_db_opt,
lt_options TYPE TABLE OF rfc_db_opt,


ls_options-text = 'WHERE MATNR = "000000233440000234"'.
APPEND ls_options TO lt_options.

MOVE: 
'MATNR' TO ls_fields-fieldname,
'18' TO ls_fields-length.
APPEND ls_fields TO lt_fields.

MOVE: 
'BESKZ' TO ls_fields-fieldname,
'1' TO ls_fields-length.
APPEND ls_fields TO lt_fields.

CLEAR ls_fields.

CALL FUNCTION 'RFC_READ_TABLE' DESTINATION 'DERCLNT100'
  EXPORTING
   query_table                = 'MARC'
   delimiter                  = ' '
   no_data                    = ' '
   rowskips                   = 0
   rowcount                   = 0
  TABLES
    OPTIONS                    = lt_options
    fields                     = lt_fields
    data                       = gt_matnr

* EXCEPTIONS

*   TABLE_NOT_AVAILABLE        = 1

*   TABLE_WITHOUT_DATA         = 2

*   OPTION_NOT_VALID           = 3

*   FIELD_NOT_VALID            = 4

*   NOT_AUTHORIZED             = 5

*   DATA_BUFFER_EXCEEDED       = 6

*   OTHERS                     = 7

          .

IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.