Questions tagged [opensql]

Open SQL is used for SAP database access in the ABAP programming language.

Presentation

ABAP SQL (named Open SQL before version 7.53), is a set of ABAP statements that performs operations like reads, modifies or deletes data in the SAP database. ABAP SQL is independent of the database system, so the syntax of the ABAP SQL is uniform for all the databases supported by SAP.

All ABAP SQL statements are passed to the database interface. The DB interface converts the ABAP SQL into native SQL and passes it on to the database.

ABAP SQL Description

  • SELECT : Reads data from database
  • INSERT : Inserts lines to database
  • UPDATE : Changes the contents of lines in database
  • MODIFY : Inserts lines into database or changes the contents of existing lines
  • DELETE : Deletes lines from database

Links

ABAP SQL (ABAP documentation)

A complete guide to OpenSQL statements (SAP Community Blog Post)

Related Tags

288 questions
4
votes
3 answers

WHERE variable = ( subquery ) in OpenSQL

I'm trying to retrieve rows from a table where a subquery matches an variable. However, it seems as if the WHERE clause only lets me compare fields of the selected tables against a constant, variable or subquery. I would expect to write something…
Lilienthal
  • 4,327
  • 13
  • 52
  • 88
4
votes
1 answer

Open SQL condition in RFC_READ_TABLE call via PyRFC

How do I specify the Open SQL WHERE clause in an RFC_READ_TABLE query using PyRFC? I'm trying to get started with PyRFC to have python do table extractions from SAP (in the absence of a supportive/cooperative basis team). In this example from…
cowbert
  • 3,212
  • 2
  • 25
  • 34
4
votes
2 answers

Make a SELECT by field is empty?

I need to know how to make a comparison in a SELECT for a field that has to be empty. I'm trying to select some fields from bkpf, with the field stblg as empty. I've done it in this way: SELECT c~kunnr a~belnr d~spart c~bldat c~waers a~hwaer…
Eva Dias
  • 1,709
  • 9
  • 36
  • 67
3
votes
1 answer

How to add trailing spaces when concatenating two columns?

I am trying to find a way to preserve a space within SQL concatenation. For context: A table I am selecting from a table with a single concatenated key column. Concatenated keys respect spaces. Example: BUKRS(4) = 'XYZ ', WERKS(4) = 'ABCD' is…
Zero
  • 1,562
  • 1
  • 13
  • 29
3
votes
1 answer

HanaDB - Complexity of: SELECT COUNT( * ) FROM dbtab

This question is the same as MySQL - Complexity of: SELECT COUNT(*) FROM MyTable;. The difference is that instead MySQL i want to know the answer for HDB. I Googled it, and looked for it in SAP Knowledge Base without finding an answer. To clarify:…
Dorad
  • 3,413
  • 2
  • 44
  • 71
3
votes
2 answers

Call a class method from ABAP CDS View?

I would like to call a method from a class in an existing CDS view to get certain data, which can only be called by this method. So I want to call a method from a CDS View. What is the easiest way to do this? I would be very happy about an example…
Tangodo
  • 35
  • 1
  • 5
3
votes
2 answers

Aggregated field to use SUM/MIN based on a condition?

I would like to know if it's possible to SUM if a field has a specific value otherwise take only the MIN (just one value of the aggregated records) I tried something like that but it's syntactically not correct, so I'm looking for an alternative to…
RaTiO
  • 979
  • 2
  • 17
  • 33
3
votes
1 answer

Select 5 most recent notifications with inactive status within single SELECT?

I need to SELECT the 5 most recent notifications linked to an equipment but I also need to check that status DLFL (I0076 - deletion flag) is not active OR doesn't exist. I think it should be pretty simple but I'm a bit confused with the fact that…
RaTiO
  • 979
  • 2
  • 17
  • 33
3
votes
3 answers

Use second condition instead if rows are not found

I have the following select: SELECT name, text, lang FROM texts WHERE name IN @r_names AND lang IN ( @lv_lang, 'E' ) INTO TABLE @DATA(lt_texts). It will select texts multiple lines of texts for a given name. How do I say that I want texts…
kdobrev
  • 270
  • 1
  • 3
  • 11
3
votes
1 answer

How can I use table names containing slashes in SQL performance trace transaction st05 ("Explain SQL")?

How can I select table names that do contain slashes in the inline SQL performance analysis (aka "Explain SQL") of transaction ST05? I tried escaping them with '/table/name' or "/table/name" or "\/table\/name". None of them worked. Works for tables…
koks der drache
  • 1,398
  • 1
  • 16
  • 33
3
votes
2 answers

Slow SELECT FOR ALL ENTRIES

The below SELECT runs with the internal table GIT_KUNNR_TAB containing 2.291.000 lines with unique clients (kunnr) and takes 16 minutes to complete. select kunnr umsks umskz gjahr belnr buzei bschl shkzg dmbtr bldat zfbdt zbd1t zbd2t…
ekekakos
  • 563
  • 3
  • 20
  • 39
3
votes
2 answers

Return dynamically-typed table rows via RFC?

I need to return the rows of some tables via RFC, and the names of these tables are not known before the execution. I have this statement which gets executed in a loop: SELECT * up to iv_max_count rows into table FROM…
guettli
  • 25,042
  • 81
  • 346
  • 663
3
votes
3 answers

Proper type for OpenSQL IN operand

I have function module which imports my_values my_values is an custom internal table type of string. This "my_values" variable contains for example: ["foo", "bar"] I want to select all values from table Z_MYTAB where the column my_col is in…
guettli
  • 25,042
  • 81
  • 346
  • 663
3
votes
4 answers

Very slow itab loop with nested SELECTs

I have declare an internal table like: DATA: wa_collectoraction TYPE zcollectoraction, it_collectoraction LIKE STANDARD TABLE OF zcollectoraction. Then I fill the table with: SELECT bukrs kunnr yearmonth MAX( dat ) AS dat FROM zcollectoraction …
ekekakos
  • 563
  • 3
  • 20
  • 39
3
votes
3 answers

How to shorten DELETE statement for DB tables?

Hello is there a way to put this in one statement? DELETE e_worklist where wbs_element = '00000000000000000054TTO'. DELETE e_worklist where wbs_element = '00000000000000000056TTO'. DELETE e_worklist where wbs_element =…
1
2
3
19 20