Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

RFC_READ_TABLE

Former Member
0 Kudos

Hi,

I created a program to display a field ( BURKS) from the table KNB5.

This table is in R / 3, and I want to call it from another system. I used the Funtion Module "RFC_READ_TABLE " but I do not know what do I make in the parameters of this function.

The FM look like this:

CALL FUNCTION 'RFC_READ_TABLE'

destination 'destination'

EXPORTING

QUERY_TABLE = 'KNB5'

TABLES

OPTIONS = ???

FIELDS = ???

DATA = ???

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.

How can I use this FM ?

Thank you.

mll mat.

8 REPLIES 8

Former Member
0 Kudos

HI,

Refer to this link...

Edited by: avinash kodarapu on Dec 2, 2008 5:19 PM

Former Member
0 Kudos

hi,

check this:

DATA: options TYPE TABLE OF rfc_db_opt .

DATA: fields TYPE TABLE OF rfc_db_fld .

DATA: data TYPE TABLE OF tab512 .

CALL FUNCTION 'RFC_READ_TABLE'

DESTINATION rfc_target_destination

EXPORTING

query_table = node_query_tab

delimiter = ' '

no_data = ' '

rowskips = 0

rowcount = 0

TABLES

options = options

fields = fields

data = data

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.

Edited by: AD on Dec 2, 2008 12:48 PM

Edited by: AD on Dec 2, 2008 12:50 PM

Former Member
0 Kudos

Hi Matt,

you can see the sample example given in th link below:

http://www.sap-integration.net/Default.aspx?tabid=405&forumid=181&postid=49657&view=topic&language=f....

Hope it helps,

Regards,

Rahul

Former Member

Hi

DATA T_DATA TYPE STANDARD TABLE OF TAB512.

CALL FUNCTION 'RFC_READ_TABLE' destination 'destination'
  EXPORTING
     QUERY_TABLE = 'KNB5'
  TABLES
*     OPTIONS = ???
*     FIELDS = ???
     DATA = T_DATA
  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.

The query result is stored in the internal table T_DATA.

U need to transfer OPTIONS only if u need to create a filter in oder to select certain records, u need to transfer FIELDS only if u nedd to extract the data of certain fields of KNB5

See this sample:

DATA: T_OPTIONS TYPE TABLE OF RFC_DB_OPT WITH HEADER LINE.
DATA: T_FIELDS  TYPE TABLE OF RFC_DB_FLD WITH HEADER LINE.
DATA: T_DATA    TYPE TABLE OF TAB512     WITH HEADER LINE.



PERFORM FILL_OPTIONS USING: 'KUNNR' '0000000001' 'AND',
                            'BUKRS' 'MAAB' SPACE.
PERFORM FILL_FIELDS USING: 'KUNNR', 'BUKRS', 'MAHNA'.

CALL FUNCTION 'RFC_READ_TABLE'
  EXPORTING
    QUERY_TABLE                = 'KNB5'
*   DELIMITER                  = ' '
*   NO_DATA                    = ' '
*   ROWSKIPS                   = 0
*   ROWCOUNT                   = 0
  TABLES
    OPTIONS                    = T_OPTIONS
    FIELDS                     = T_FIELDS
    DATA                       = T_DATA.

LOOP AT T_DATA.
  WRITE / T_DATA.
ENDLOOP.



*&---------------------------------------------------------------------*
*&      Form  FILL_OPTIONS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_FIELD  text
*      -->P_VALUE  text
*      -->P_OPT  text
*----------------------------------------------------------------------*
FORM FILL_OPTIONS USING    P_FIELD
                           P_VALUE
                           P_OPT.
  DATA: VALUE(15).

  CONCATENATE '''' P_VALUE '''' INTO VALUE.
  CONCATENATE P_FIELD '=' VALUE P_OPT INTO T_OPTIONS SEPARATED BY SPACE.
  APPEND T_OPTIONS.
ENDFORM.                    " FILL_OPTIONS
*&---------------------------------------------------------------------*
*&      Form  FILL_FIELDS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0045   text
*----------------------------------------------------------------------*
FORM FILL_FIELDS USING   P_FIELD.

T_FIELDS-FIELDNAME = P_FIELD.
APPEND T_FIELDS.

ENDFORM.                    " FILL_FIELDS

The table T_FIELDS is usually empty, but u should consider the system store the data in a string of 512 char.

Anyway how to call this fm depends on from u need to call it

Max

Former Member
0 Kudos

Hi mat,

Check the thread below:

With luck,

Pritam.

Former Member
0 Kudos

Hi All,

Thank you very match for your replay.

If I want to read the data from the table STMP_DOKHL with a condition, I put this code:

loop at T_DATA where kunnr = '651'.

write:/ T_DATA.

endloop.

But a message appears indicating that No component exists with the name Knnr.

mll mat.

0 Kudos

Hi,

I hope you are aware that RFC_READ_TABLE was only supposed to be used for training! To be more precise, it is used by learners to see how you access the database directly. I remember reading somewhere that this function is not supported by SAP (although it is included in software releases).

Also be aware that the authorization needed to run this function includes a few admin level authorization objects - something which you will normally never get for client projects. The ability to use this function gives you complete power to read any table from the database.

Try and use something else to access the data rather than this module.

T00th.

former_member733010
Discoverer
0 Kudos

REPORT Z_TEST2.

data: it_data TYPE STANDARD TABLE OF TAB512, "TABLES PARAM
wa_data LIKE LINE OF it_data .

DATA: options TYPE TABLE OF rfc_db_opt .

DATA: fields TYPE TABLE OF rfc_db_fld .
DATA : it_data1 TYPE REF TO cl_salv_table.


CALL FUNCTION 'RFC_READ_TABLE'
EXPORTING
query_table = 'ADR6' " Table read
* delimiter = SPACE " Sign for indicating field limits in DATA
* no_data = SPACE " If <> SPACE, only FIELDS is filled
* rowskips = 0
* rowcount = 0
TABLES
options = options "*" " Selection entries, "WHERE clauses" (in)
fields = fields " Names (in) and structure (out) of fields read
data = it_data " Data read (out)
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.


CALL METHOD CL_SALV_TABLE=>FACTORY
* EXPORTING
* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
R_SALV_TABLE = it_data1
CHANGING
T_TABLE = it_data.
it_data1->display( ).