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
3
votes
2 answers

GROUP by aggregation does not calculate SUM

I have to aggregate in my query SUM of AMUNT field according to WERKS, DATUM and UZEIT I try to make a group by without any success I have an error like that: What is the problem in my code? That is my ABAP code: DATA: gt_compr TYPE TABLE OF…
shmoolki
  • 1,551
  • 8
  • 34
  • 57
3
votes
2 answers

And + Or in one Select-Statement

In my select statement I chain different conditions with AND. Now I need for one condition an OR. How can I add this for just this one Attribute without affecting the other AND-statements before? That's my coding: SELECT pernr reinr pdatv pdatb…
Dyrdek
  • 411
  • 4
  • 12
  • 33
3
votes
1 answer

The fastest way to SELECT MAX( ) from table

What would be the most efficient and elegant way to select MAX value from transparent table? For example, let's try to select such simple table as T100, Messages. Let us imagine we should select maximum message number within some application…
Suncatcher
  • 10,355
  • 10
  • 52
  • 90
3
votes
1 answer

How to access the data in the table used for the FOR ALL ENTRIES statement?

I need some data from the tables BKPF and BSEG compressed in one table. For example let's say the final table has to look something like this: | BKPF-BUKRS | BKPF-GJAHR | BKPF-MONAT | BSEG-DMBTR…
cheeZer
  • 460
  • 1
  • 8
  • 15
3
votes
2 answers

Open SQL equivalent for ROW_NUMBER()

Is there an equivalent for the ROW_NUMBER() function for ABAP programs? This function is used as follows in SQL: SELECT ROW_NUMBER() OVER (ORDER BY SomeField) AS Row, * FROM SomeTable Where it should return the line number as the first column in…
Lilienthal
  • 4,327
  • 13
  • 52
  • 88
3
votes
1 answer

Storing a Deep/Nested Structure

SAP rather sensibly prohibits you from including deep structures in database tables. For a new project however I have a deeply nested structure that I want to store persistently. This structure includes another dozen structures with each of those…
Lilienthal
  • 4,327
  • 13
  • 52
  • 88
3
votes
1 answer

Pragma to Hide Warning: the field used in the where condition may contain null values

I'm looking for a pragma I can use to hide the compiler warning generated when a field used in the WHERE condition of a select may contain NULL values in the database. Having read SAP note 1088403, I am aware of the possible issues here but I cannot…
Lilienthal
  • 4,327
  • 13
  • 52
  • 88
3
votes
2 answers

Performance when using wildcard % in Select LIKE

I have the following, horribly slow and inefficient statement where I want to select all the entries in e071 where the obj_name field CONTAINS the value of the obj_name field in tadir followed by wildcard. LOOP AT tadir ASSIGNING . …
baarkerlounger
  • 1,217
  • 8
  • 40
  • 57
3
votes
2 answers

SELECT FOR ALL ENTRIES vs LOOP SELECT SINGLE in ABAP

I am comparing the SELECT FOR ALL ENTRIES vs LOOP SELECT SINGLE and I am having a big difference between results. Somebody can help me with this? What is the difference? SELECT ekko~ebeln ekpo~ebelp ekko~bstyp ekko~bsart ekko~lifnr …
Ailin Albertoni
  • 83
  • 1
  • 2
  • 7
3
votes
1 answer

Subquery throws error: "Wrong table name or table alias"

In SAP the following request works well, but has result I obtain #5000000 lines for 3000 materials (MATNR): SELECT k~bldat a~matnr k~bldat e~maktx a~mtart a~brgew a~ntgew a~gewei a~volum a~laeda mseg~bwart k~budat INTO CORRESPONDING FIELDS OF…
FredM
  • 175
  • 2
  • 9
3
votes
1 answer

First column's data is missing

I am a newbie to ABAP. I am trying this program with open sql, and when I execute the program, the first column's data is always missing. I have looked up and the syntax appears to be correct. I am using kna1 table, the query is pretty simple too.…
macha
  • 7,337
  • 19
  • 62
  • 84
3
votes
2 answers

How to include multiple conditions in a SELECT?

I am using 5 Parameters to fetch the details from DB table (mara, makt, marc, mard). PARAMETERS :number TYPE matnr MATCHCODE OBJECT MAT1 , type TYPE MTART MATCHCODE OBJECT H_T134 , sector TYPE MBRSH MATCHCODE OBJECT H_T137…
Dhivya
  • 518
  • 2
  • 8
  • 17
2
votes
1 answer

Object of class doesn't exist error after SELECT

This is the Open Sales Order Report im working on. im trying to read data from table VBUK and the VBELN field im trying to get the data from table 'VAPMA' where the error occurred. I get the following error after the second select statement. object…
Abap newbie
  • 173
  • 1
  • 5
  • 11
2
votes
1 answer

Specifying a DB table dynamically? Is it possible?

I am writing a BSP and based on user-input I need to select data from different DB tables. These tables are in different packages. Is it possible to specify the table I want to use, based on its path, like this: data: path1 type string value…
B. Bowles
  • 764
  • 4
  • 9
  • 21
2
votes
2 answers

How to get row count of database table

I am just new in abap language and I am trying to practice an inner join statement but I don't know how whether I will be able to get the number of rows of my select statement before output. Here's what I want to…
Kid
  • 100
  • 1
  • 3
  • 16
1 2
3
19 20