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: 

Reg BAPI to select table entries

Former Member
0 Kudos

Hi,

Is there any bapi/FM which will select data from any database table, based on a selection criteria we provide as import parameter and display any table entries satisfying the criteria?

i know RFC_GET_TABLE_ENTIRES but here we cant give a selection criteria.. is there any other FM/BAPI to do this task?

5 REPLIES 5

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please check FM RFC_READ_TABLE.

Regards,

Ferry Lianto

naimesh_patel
Active Contributor
0 Kudos

Hello Sreejith,

you can use the FM RFC_READ_TABLE where you can pass the where conditions in the options.

See this sample code:

 DATA: BEGIN OF rfc_options OCCURS 0.
          INCLUDE STRUCTURE rfc_db_opt.
  DATA: END OF rfc_options.

  DATA: BEGIN OF rfc_fields OCCURS 0.
          INCLUDE STRUCTURE rfc_db_fld.
  DATA: END OF rfc_fields.

  DATA: BEGIN OF rfc_data OCCURS 0.
          INCLUDE STRUCTURE tab512.
  DATA: END OF rfc_data.
* read inbound partner-agreements
  tab_name = 'EDP13'.
  REFRESH rfc_options.
  REFRESH rfc_fields.
  REFRESH rfc_data.
  REFRESH rfc_options.
  REFRESH rfc_fields.
  REFRESH rfc_data.

rfc_options = 'RCVPRN = P_RCVPRN'.
append rfc_options.

  rfc_fields-fieldname = 'MANDT'.
  rfc_fields-offset = 0.
  rfc_fields-length = 3.
  rfc_fields-type = 'C'.
  APPEND rfc_fields.
  rfc_fields-fieldname = 'RCVPRN'.
  rfc_fields-offset = 3.
  rfc_fields-length = 10.
  rfc_fields-type = 'C'.
  APPEND rfc_fields.
  rfc_fields-fieldname = 'RCVPRT'.
  rfc_fields-offset = 13.
  rfc_fields-length = 2.
  rfc_fields-type = 'C'.
  APPEND rfc_fields.
  rfc_fields-fieldname = 'RCVPFC'.
  rfc_fields-offset = 15.
  rfc_fields-length = 2.
  rfc_fields-type = 'C'.
  APPEND rfc_fields.
  CALL FUNCTION 'RFC_READ_TABLE'
    DESTINATION g_rfcdest
    EXPORTING
      query_table          = tab_name
    TABLES
      options              = rfc_options
      fields               = rfc_fields
      data                 = rfc_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.

Regards,

Naimesh Patel

Former Member
0 Kudos

Hi,

This does not meet my requirement as we cant give a selection criteria as input to this FM

0 Kudos

You can give as many where conditions in the OPTIONS table.

Regards,

Naimesh

Former Member
0 Kudos

I want a fm which i can directly execute and see the table entries in Simulation clients. I cant do any coding .