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
2
votes
1 answer

Performance of AMDP vs HANA DB procedure?

As far as I know there is very little difference between the two except syntax. You have to use: CALL METHOD for AMDP CALL DATABASE PROCEDURE for HANA Procedure Is the AMDP performance affected by the fact it is run at ABAP Application Server? Can…
2
votes
2 answers

Ignore leading zeros in JOIN condition?

I want to compare the field bseg~zuonr with aufk~aufnr in an inner join SQL select. SELECT bseg~hkont, bseg~zuonr, bseg~belnr, bseg~gjahr, aufk~prctr FROM bseg INNER JOIN aufk ON bseg~zuonr = aufk~aufnr "<-- WHERE bseg~hkont IN @s_hkont INTO…
schmelto
  • 427
  • 5
  • 18
2
votes
1 answer

Asterisk in variable not considered like % in SQL

I created these three radio buttons to define values to the variable TEST. The first two work just fine: if I click in p_r1 it assigns B and if I click p_r2 it assigns A. I wanted the third to assign * to get all status i.e A, B, C. Why doesn't it…
SALTZZZZ
  • 49
  • 5
2
votes
3 answers

Checking whether a record from a structure exist in a cluster table

I am trying to validate if a record in a structure is in a cluster table. The code that I thought of using is the following: REPORT zzz. DATA: BEGIN OF gs_zfi, number TYPE bseg-belnr, END OF gs_zfi. START-OF-SELECTION. SELECT…
Frank
  • 153
  • 3
  • 17
2
votes
2 answers

Why is a full TADIR select with ORDER BY PRIMARY KEY much slower than INTO sorted table?

Having the following statements: SELECT * FROM tadir ORDER BY PRIMARY KEY INTO TABLE @DATA(lt_tadir). DATA lt_tadir TYPE SORTED TABLE OF tadir WITH UNIQUE KEY pgmid object obj_name.` SELECT * FROM tadir INTO TABLE @lt_tadir. Why is the first one…
Regyn
  • 585
  • 3
  • 17
2
votes
1 answer

Field "REF" is unknown in ADBC statement

I'm having trouble using ABDC. This is the code I am trying to run: DATA: gr_sql_result_set TYPE REF TO cl_sql_result_set, gr_sql_statement TYPE REF TO cl_sql_statement. START-OF-SELECTION. CREATE OBJECT gr_sql_statement. …
Diego
  • 133
  • 1
  • 12
2
votes
1 answer

Notify user about not allowed results via ASPECT pfcg_auth?

In "classic" ABAP authority checks, you would sometimes loop over a result list. If for at least one item the check fails, you'd notify the user about this and show only the items he's entitled to. My question is: How would you do this in CDS using…
Matthias
  • 21
  • 4
2
votes
2 answers

FOR ALL ENTRIES through empty itab selects all records from DB

I have a query in which I am using FOR ALL ENTRIES. The internal table lt_customer has no records. SELECT * FROM bsid INTO CORRESPONDING FIELDS OF TABLE lt_customer2 FOR ALL ENTRIES IN lt_customer WHERE bukrs EQ p_bukrs AND…
Kjarlvi
  • 126
  • 1
  • 13
2
votes
2 answers

Problem with where clause while updating database record

I have a screen in ABAP that makes it possible to update a database row. It's sort of working: I can update the 'row' but the problem is, that it's updating EVERY row in the table and not the one specified in the where clause. This is the code I'm…
user393964
2
votes
2 answers

Generic way of handling concatenated table key

If I have a tabkey value, e.g., DATA(lv_tabkey) = '1000041508773180000013000'., which is the concatenated value of all table keys for an entry and I know the name of the corresponding table: How I can get the table entry for it without splitting…
Cold_Class
  • 3,214
  • 4
  • 39
  • 82
2
votes
3 answers

Wildcards in GROUP BY clause in OpenSQL?

I have a select similar to the one below: SELECT DISTINCT SCARR~CARRID, SCARR~CARRNAME, MIN( SPFLI~DISTANCE ) AS MIN_DISTANCE FROM SCARR JOIN SPFLI ON SPFLI~CARRid = SCARR~CARRid GROUP BY SCARR~CARRID, SCARR~CARRNAME INTO TABLE…
RaTiO
  • 979
  • 2
  • 17
  • 33
2
votes
2 answers

Conditional field by selected column in JOIN query

At the moment my query looks like this SELECT CSKS~KOSTL CSKS~DATBI CSKS~NAME1 CSKS~KOSAR CSKS~VERAK CEPC~PRCTR CEPC~NAME3 CEPC~NAME4 UP TO X ROWS FROM CSKS INNER JOIN CEPC ON ( CSKS~PRCTR = CEPC~PRCTR AND CSKS~KOKRS = CEPC~KOKRS ) INTO…
2
votes
3 answers

Select date field by year?

I wanna get all elements of table EKKO by year , but I don't know how. This is my query: SELECT * FROM EKKO INTO TABLE @data(RESULT) WHERE BUKRS = @CO_Code AND WAERS = 'USD'. I tried extract() and year(), like this : SELECT * FROM EKKO INTO TABLE…
Hien Phan
  • 23
  • 1
  • 5
2
votes
2 answers

SELECT into structured object with ABAP CDS associations

I have a CDS View with multiple associations: define view ZORDER as select from ZORDERHDR as orderHdr association [0..1] to ZORDER_LOCATION as _location on _location.orderID = orderHdr.orderID association [0..*] to ZORDER_ITEM as _items on…
RaTiO
  • 979
  • 2
  • 17
  • 33
2
votes
1 answer

JOIN of 4 tables, how to restrict SELECT columns to one table only?

I am working on ABAP program - user input is to query column ANLAGE and output is to get all records from table EADZ (and only fields of EADZ) based on ANLAGE. Statement and joins should work like this: Input ANLAGE, find in table EASTL, gets…
PeterP
  • 23
  • 4