Explain Open Sql?

Answer

Open SQL consists of a set of ABAP statements that perform operations on the central database in the R/3 system. The results of the operations and any error messages are independent of the database system in use. Open SQL thus provides a uniform syntax and semantics for all of the database systems supported by SAP. ABAP programs that only use Open SQL statements will work in any R/3 system, regardless of the database system in use. Open SQL statements can only work with database tables that have been been created in the ABAP dictionary.

Basic Open SQL Commands

  • SELECT
  • INSERT
  • UPDATE
  • MODIFY
  • DELETE
  • OPEN CURSOR, FETCH, CLOSE CURSOR

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
TABLES SBOOK.
 
DATA C TYPE CURSOR,
 
WA LIKE SBOOK.
 
OPEN CURSOR C FOR SELECT * FROM SBOOK WHERE CARRID = 'LH '
 
AND CONNID = '0400'
 
AND FLDATE = '19950228'
 
ORDER BY PRIMARY KEY.
 
DO.
 
FETCH NEXT CURSOR C INTO WA.
 
IF SY-SUBRC <> 0.
 
CLOSE CURSOR C.
 
EXIT.
 
ENDIF.
 
WRITE: / WA-BOOKID, WA-CUSTOMID, WA-CUSTTYPE,
 
WA-SMOKER, WA-LUGGWEIGHT, WA-WUNIT,
 
WA-INVOICE.
 
ENDDO.

 

Output the passenger list for the Lufthansa flight 0400 on 28-02.1995:

 

Open SQL Return Codes

All Open SQL statements fill the following two system fields with return codes.

SY-SUBRC

After every Open SQL statement, the system field SY-SUBRC contains the value 0 if the operation was successful, a value other than 0 if not.

All SAP ABAP Questions

Ask your interview questions on sap-abap

Write Your comment or Questions if you want the answers on sap-abap from sap-abap Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---