Purpose
You want to use SAP Query (transaction SQ01) for data retrieval.

SAP Query provides us with a convenient way to display data from various sources without programming. Connecting multiple tables, simple testing options, predefined info sets are supported, and much more as well. The origin of the tool goes back to SAP R/2 and is available in the latest S/4HANA systems. The output is mostly displayed in the ALV list viewer.

Solution Use the function module /guixt/submitreport and specify the query name and the user group as defined in SQ01.

Please note:

  • Always pass a selection variant or at least one selection parameter; otherwise no data will be returned.
  • A default layout variant in the selection variant does not take effect because the data is copied without applying the layout rules. That is, you get all the columns specified in the query definition, and if you pass a column selection, it refers to the query definition, not the layout variant.

1. Example with variant

// process query
Call "/guixt/submitreport"   _
  in.query="DISPUTECASES" _
  in.usergroup="GUIXT" _
  in.variant="V1" _
  table.csvdata="csvdata"

// copy query data into own table
CreateTable V[disputes] id date reason paid currency processor
CopyText fromText="csvdata"  toTable="V[disputes]" delimiter=";"

2. Example with variant, using the GuiXT Open Call interface

// Set parameters for SAP Query call
Set V[query] "DISPUTECASES"
Set V[usergroup] "
GUIXT"
Set
V[variant]  "V1"

//
create output table 
CreateTable V[csvdata] feld
 
// process query

Call
"/guixt/submitreport"  _
  export.query="query" _
  export.usergroup="usergroup" _
 
export.
variant="variant" _
  import.csvdata="csvdata"

// copy query data into own table
CreateTable V[disputes] id date reason paid currency processor

CopyText fromTable="V[csvdata]" toText=temp
CopyText fromText="temp" toTable="V[disputes]" delimiter=";"

3. Example with selection parameters, using the GuiXT Open Call interface

// Set parameters for SAP Query call
Set V[query] "DISPUTECASES"
Set V[usergroup] "
GUIXT"

// fill parameter table
CreateStructure V[paraminfo] selname kind sign option low high
CreateTable V[params] include=V[paraminfo]
   
Set V[paraminfo.selname] "FIN_BUKR"
Set V[paraminfo.kind] "S"
Set V[paraminfo.sign] "I"
Set V[paraminfo.option] "EQ"
Set V[paraminfo.low] "&F[Company Code]"
AppendRow V[paraminfo] table=V[params]

Set V[paraminfo.selname] "FIN_KUNN"
Set V[paraminfo.kind] "S"
Set V[paraminfo.sign] "I"
Set V[paraminfo.option] "EQ"
Set V[paraminfo.low] "&F[Customer]"
AppendRow V[paraminfo] table=V[params]


CreateTable V[csvdata] feld
 
Call "/guixt/submitreport"  _
  export.query="query" _
  export.usergroup="usergroup" _
 
export.
params="params" _
  import.csvdata="csvdata"

// copy query data into own table
CreateTable V[disputes] id date reason paid currency processor

CopyText fromTable="V[csvdata]" toText=temp
CopyText fromText="temp" toTable="V[disputes]" delimiter=";"

4. Performance aspect: create your own query with a minimum of columns

It can be unnecessarily slow to run a query with, say, 60 columns, possibly from different database tables, when you only need a few columns. Copy the query in SQ01 and remove unneeded columns.

It probably also makes sense to create your own SQ01 user group, e.g. "GUIXT", and to copy all "data access" queries into this user group.


Components
InputAssistant