1

I am trying to create an SAP data query using SQVI (or SQ01) to display all entries that meet certain criteria. I can use the 'Selection Fields' tab to have a user specify any of these parameters, but I want to be able to query the data with more complex conditions such as a nested 'AND'/'OR'. I have researched the question for a couple hours and have yet to find a solution that works. Here is an example simplified query that I would like to do, written in SQL form:

SELECT t0.name, t0.birthYear, t1.grade, t1.county
FROM t0 
INNER JOIN t1 on t0.personID = t1.personID
WHERE t0.name = 'Bob'
AND t0.birthyear = 2000
AND (t1.grade = 12
     OR t1.county <> 'Cook');

Now the tricky part is figuring out how to do a nested 'AND' and 'OR' in SQVI. At first, I pulled all the data without these conditions, exported it to Excel, and then performed this logic to get the correct entries that meet these criteria. However, I do not want to do this every time, as it is highly repetitive and there HAS TO be some solution within the SAP environment. Ideally, I would be able to create a query that I can share with co-workers to execute once a week, where they don't need to enter any values to test against 'name', 'birthyear', 'grade', or 'county'. They should be able to type in the code for this query and hit execute, and it should spit out all of the entries that meet all the criteria. I want to be able to hard-code the testing parameters in this instance.

Let me know if this is even possible! If it's not possible using SQVI, what would I need access to in order to do a complex conditional query like this? I do not have write-access on the data, so I am not authorized to use 'DBACOCKPIT' to write the query as SQL (which would be so much simpler).

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • 1
    If you don't have a Developer Key, it's a problem. If you want to use SAPQuery only, the only possibility is to create an Infoset with "integrated reading program" (or an "external reading program" if you have a Developer Key). But you also need to create a DDIC structure to define the query output fields, which also needs a Developer Key. – Sandra Rossi Jun 23 '22 at 07:19
  • Agree with Sandra, you are required dev permissions for this, technically two non-related conditions in a single clause `t1.grade = 12 OR t1.county <> 'Cook'` are a UNION on the same table, so it indeed requires **integrated reading program** type of infoset, which is impossible without dev-key – Suncatcher Jun 23 '22 at 10:20

0 Answers0