Search on this Website

Wednesday, June 13, 2007

SQL STATEMENTS: OPEN SQL vs NATIVE SQL

OPEN SQL:
Subset of standard SQL statements.
To avoid conflicts between database tables and to keep ABAP programs independent from the database system used, SAP has generated its own set of SQL statements known as Open SQL.


Using Open SQL allows you to access all database tables available in the R/3 System, regardless of the manufacturer.
Database language that allows you to include database-specific SQL statements in an ABAP program.

NATIVE SQL
To enable the execution of ABAP Native SQL statements in ABAP programs, you use the statement EXEC.
Most ABAP programs containing database-specific SQL statements do not run with different databases. If programs are meant to run against variosu databases, you should use ABAP Open SQL.

EXERCISE:

TABLES: ZKA_CENTER.

DATA: ITAB LIKE ZKA_CENTER OCCURS 0 WITH HEADER LINE.

SELECT * FROM ZKA_CENTER.
WRITE:/ ZKA_CENTER-CENTERNO,ZKA_CENTER-CENTERNAME,ZKA_CENTER-CENTERPHONE,ZKA_CENTER-CENTERID,ZKA_CENTER-CENTERMAN.
ENDSELECT.


SELECT SINGLE * FROM ZKA_CENTER WHERE CENTERNAME = 'INEST'.
WRITE:/ ZKA_CENTER-CENTERNO,ZKA_CENTER-CENTERNAME,ZKA_CENTER-CENTERPHONE,ZKA_CENTER-CENTERID,ZKA_CENTER-CENTERMAN.


SELECT * FROM ZKA_CENTER INTO TABLE ITAB.
LOOP AT ITAB.
WRITE:/ ITAB-CENTERNO,ITAB-CENTERNAME,ITAB-CENTERPHONE,ITAB-CENTERID,ITAB-CENTERMAN.
ENDLOOP.


SELECT CENTERNAME CENTERMAN FROM ZKA_CENTER INTO CORRESPONDING FIELDS OF TABLE ITAB.
LOOP AT ITAB.
WRITE:/ ITAB-CENTERNO,ITAB-CENTERNAME,ITAB-CENTERPHONE,ITAB-CENTERID,ITAB-CENTERMAN.
ENDLOOP.


No comments: