Purpose
Read an SAP table via "rfc_read_table


SAP provides the standard function module "rfc_read_table" as a general interface for database access via RFC. This function is  less powerful and flexible than "/guixt/dbselect":  it does not support table joins,  ordering of the result table, input/output format conversions, or CDS views. But in a situation where /guixt/dbselect cannot be installed in a SAP system the use of "rfc_read_table" might be helpful.

Solution
Prepare the interface data for rfc_read table and then call  up the function via the GuiXT "Call" statement.

Example
In transaction SU01 (Display User) we add the last logon date and time which we read from table USR02:

 

GuiXT Script

// Tab "Logon Data" ?
if
Q[Page=Logon Data]

  // read last logon data via RFC

  // Field list for rfc_read_table
  Set V[fieldname] "TRDAT"
   CopyText fromString="fieldname" toText="fields"
   Set V[fieldname] "LTIME"
 
CopyText fromString="fieldname" toText="fields" -appendline

  // condition, take user name from screen
   Set text[options] "BNAME = '&F[SUID_ST_BNAME-BNAME]'"

  // Read table USR02
   clear text[data]
   call "RFC_READ_TABLE" _
      
in.QUERY_TABLE="USR02" _
      
table.OPTIONS="options" _
 
  table.FIELDS="fields" _
      
table.DATA="data"

    // result into GuiXT variable, format is YYMMDDDDHHMMSS
   Set V[data] "&text[data]"

    // format date and time
    Set V[logondate] "&V[data](7-8).&V[data](5-6).&V[data](1-4)"
  
Set V[logontime] "&V[data](9-10):&V[data](11-12)"

  // display date and time of last logon
   Box (22,1) (25,79) "Last logon"
   InputField (23,2) "Date" (23,20) size=10 name="logondate" -readonly
   InputField (24,2) "Time" (24,20) size=5
 name="logontime" -readonly

endif

Components
InputAssistant