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

Abap: Select the same field from two db tables into one column of the internal table with one select

I'm new in using SQL in ABAP, so it must be a silly question, but is this somehow possible?: as I'm new, I cannot add images directly. Thanks a lot in advance, kind regards
user20601717
-1
votes
1 answer

OPEN-SQL query doesn't work at abap 4 EXEC SQL

I'm new in ABAP (i'm working with ABAP4 on R/3) and there is something about my code that i don't understand. My code is used to show the prices that are different between the tickets that enter through an external database, and the prices of the…
marcdecline
  • 186
  • 4
  • 22
-1
votes
3 answers

Query and Pivot Column for the last last 3 Years SQL

My need is to retrieve sell data from and pivot the last three years and sum the quantities. See example below. I wonder how to do it. I read that SQL pivot is the way to go, but I can't figure out how to deal with pivoting "automatically" N number…
-1
votes
2 answers

Selecting rows within last 30 days

I've got a select statement to get the orders of a reference, but now I need to restrict the results into a range od the last 30 days but i don't know how to do it. SELECT * FROM AFKO WHERE AFKO~PLNBEZ = @reference AND DATEDIFF( DAY, AFKO~GLTRP,…
usr1990
  • 21
  • 2
  • 7
-1
votes
2 answers

SQL query does not return data

I am developing a SAP program to obtain information about a reference from the material table (MARA). First I take certain references and then using a loop I need to make other query for every iteration: SELECT MARA~BISMT FROM mara WHERE…
usr1990
  • 21
  • 2
  • 7
-1
votes
4 answers

Load whole database table then filter in memory, or load only filtered entries?

I need to program a customer-search from the database. I know databases are for managing huge amounts of data. But my "mentor" told me to interact with the db as little as possible. Is it better to read the whole database table into an internal…
Aramus
  • 47
  • 8
-1
votes
4 answers

How to join the following 3 tables with exactly one ABAP SQL statement

I have the following 3 tables with data: ZMYTABLE with columns: ZUSER & ZTCODE and 2 records elias VA01 elias VF01 AGR_1251 with the records SD_role VA01 SD2_role VA01 SD3_role VA01 SD_role VA02 FI_role VF01 FI_role …
ekekakos
  • 563
  • 3
  • 20
  • 39
-1
votes
4 answers

How can I use SUBSELECT with JOIN?

I want to build an OpenSQL query to return only the max stat value for all objnr. This works: SELECT O.OBJNR FROM JCDS AS O WHERE O.OBJNR = 'Obj12345' AND STAT = ( SELECT MAX(STAT) FROM JCDS AS I WHERE…
András
  • 1,326
  • 4
  • 16
  • 26
-1
votes
1 answer

'N' type variable is not saving into 'NUMC' type table field

My variable is of type N ie., COMP_ID(8) TYPE n I have created a Transparent Table. In my table, COMPLAINT_ID field is of type 'NUMC'. while I'm saving COMP_ID into my table's COMPLAINT_ID, it is not fetching the value.
BalajiB
  • 326
  • 6
  • 29
-1
votes
2 answers

How to check if a field is present in a particular view or table using ABAP

I have list of 100 views for which I need to check if those views have fields A and B. If any of those 100 views uses those two fields, I need to display a message. Any existing function module will help.
Sujeet325
  • 21
  • 1
  • 1
-1
votes
1 answer

how to populate internal table with multiple database tables?

I have declared an internal table. DATA ITAB_DEPT TYPE TABLE OF ZCLOUD9_DEPT WITH HEADER LINE. SELECT A~DEPT_ID A~DEPT_NAME A~DEPT_NO A~EMP_ID B~FIRST_NAME B~LAST_NAME INTO TABLE ITAB_DEPT FROM ZCLOUD9_DEPT AS A INNER JOIN ZCLOUD9_EMP AS B ON…
Pu3
  • 11
  • 1
  • 5
-1
votes
1 answer

Performance for validating data against various database tables

My Problem: I "loop" over a table into a local structure named ls_eban.. and with those information I must follow these instructions: ls_eban-matnr MUST BE in table zmd_scmi_st01 ( 1. control Table (global) ) ls_eban-werks MUST BE in table…
-2
votes
1 answer

Using BETWEEN operator in a WHERE clause with dates from an internal table

I have an internal table populated with start and end dates for each type of period. I want to use this internal table in a WHERE clause of an SQL query to select items whose start and end dates are within the open period of their respective…
Cutter
  • 1,673
  • 7
  • 27
  • 43
-2
votes
1 answer

Flatten/Unify Table Rows where criteria matches array with ABAP or SQL

I am trying to achieve flattening a table into an array (or structure). My implementation is in SAP ABAP; however, I believe the question is code agnostic. I am wondering if there is an algorithm I'm not aware of or simple solution for what I'm…
Jim22150
  • 511
  • 2
  • 8
  • 22
-2
votes
1 answer

Join returns unexpected empty result

I hope you can help me. Ι have 2 tables ( eg. T1, T2 ): T1: ID (key), maktx, ... T2: ID (key), tabname (key), fieldname (key), fieldvalue, ... T1 and T2 contain respectively 2 and 3 rows: T1: T2: ID MAKTX ID TABNAME FIELDNAME…
Silver Paw
  • 11
  • 1
1 2 3
19
20