SAP Open SQL, ABAP Open SQL,In SAP R/3 System data is stored in data base tables. SAP has created a set of SQL statements called Open
SQL statements to perform operations on databases. SAP Open SQL contains a
subset of Standard SQL statements, with some enhancements, which are specific
to SAP ABAP. Here we are providing a article which gives a clear idea about Open SQL Statements in SAP ABAP/4. Click on read more to read this article.
SAP-R/3-ABAP/4-Open-SQL-Statements-and-it's-Usage
In SAP R/3 System data is stored in Data base Tables. SAP has created a set of SQL statements called Open SQL statements to perform operations on databases. Open SQL contains a subset of Standard SQL statements, with some enhancements, which are specific to SAP. Here we are providing a article which gives a clear idea about Open SQL Statements in SAP ABAP/4.
With Open SQL, you can
access any database table with in the SAP system, regardless of manufacturer of
database table e.g., Oracle, Informix etc.,
In case of Open SQL, an
interface translates Open SQL commands specific to database in use.
In case of Native SQL,
Native SQL statements access the database directly.(No interface)
Key words with Open SQL
°Select
°Insert
°Update
°Modify
°Delete
Simple Select Query
------------------------
1) Select * from <table>.
Write:/ <table>.
Clear <table>.
Endselect.
(You can also use Where clauses in select)
Select upto 1 rows Query
----------------------------
2) Select * from <table> upto 1 rows.
Write:/ <table>.
Clear <table>.
Endselect.
(You can use Where clauses)
Select Single * Query
------------------------
3) Select single * from sflight where carrid = ‘LH’ and connid =
‘0400’ and fldate = ‘19950228’.
Write:/ sflight-carrid, sflight- connid,sflight-fldate, sflight- seatsocc.
4) Select carrid connid from sflight in to (v_carrid,v_connid).
Write:/ v_carrid,v_connid.
Clear : v_carrid,v_connid,sflight.
Endselect.
5) Select * from sflight.
Select
* from sbook where carrid = sflight-carrid.
Wright : / sflight-carrid,sflight-connid, sbook-bookid.
Clear sbook.
Endselect.
Clear sflight.
Endselect.
6)Select f~carrid f~connid f~fldate into
(carrid,connid,date) from sflight as f
inner join spfli as p on f~carrid = p~carrid and f~connid = p~connid
write:/ carrid,connid,date.
Endselect.
7) select scustom~name scustom~city sbook~carrid sbook~bookid into (scustom-name, scustom-city,sbook-bookid, sbook-carrid) from scustom left outer join sbook on scustom~id = sbook~customid and sbook~fldate = '19971015’.
write: / scustom-name, scustom-city,sbook-carrid, sbook-bookid.
endselect.
SY-SUBRC is a system
variable.
•Returns
zero after every successful operation.
•Returns
non zero, if the operation is not successful.
•Never use
SY-SUBRC with in the Select - End
select statement.
Select * from sflight where carrid = ‘MN’.
Wright:/ sflight-carrid,sflight-connid.
Clear sflight.
Endselect.
If sy-subrc <> 0.
Write:/ ‘No data found’.
Endif.
ztable-fname = ‘BILL’.
ztable-lname = ‘CLINTON’.
ztable-add1 = ‘USA’.
ztable-add2 = ‘WASHINGTON’.
Insert ztable.
update ztable set add1 = ‘AMERICA’
where fname = ‘BILL’.
ztable-fname = ‘ATAL BIHARI’.
ztable-lname = ‘VAJPAI’.
ztable-add1 = ‘INDIA’.
ztable-add2 = ‘NEW DELHI’.
Modify ztable.
(above record will be inserted if not existing, else modified)
Delete from ztable where fname = ‘BILL’.
This all about Open SQL Statements in SAP-ABAP/4, dear ABAPers if you want to extend this post please write your views on below comments box.
"You found the information helpful and want to say thanks? Your donation is enough to inspire us to do more. Thanks a bunch!"
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.