Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Alternative for EXEC command(Native SQL)

Former Member
0 Likes
1,425

Hi Friends,

While Using the EXEC command in native sql it is showing the obselete Error , Can any one help with giving the alternative for the commands for native SQl.

Immediate

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
850

In a Native SQL statement, data is passed between the ABAP program and the database using host variables. A host variable is an ABAP variable that is identified as such in the Native SQL statement by a preceding colon (:).

Example

Displaying an extract from the table AVERI_CLNT:

DATA: F1(3), F2(3), F3(3).

F3 = ' 1 '.

EXEC SQL.

SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT

WHERE ARG2 = :F3

ENDEXEC.

WRITE: / F1, F2.

To simplify the form of the INTO lists in the SELECT statement, you can, as in Open SQL, specify a single structure as the target area.

Example

Displaying an Extract from the Table AVERI_CLNT:

DATA: BEGIN OF WA,

CLIENT(3), ARG1(3), ARG2(3),

END OF WA.

DATA F3(3).

F3 = ' 1 '.

EXEC SQL.

SELECT CLIENT, ARG1 INTO :WA FROM AVERI_CLNT

WHERE ARG2 = :F3

ENDEXEC.

WRITE: / WA-CLIENT, WA-ARG1.

Native SQL supports the directly-executable commands of your underlying database system. There are other special commands that you can use after the EXEC SQL statement for cursor handling, stored procedures (procedures stored in the database), and connections to other databases.

Cursor Processing

4 REPLIES 4
Read only

Former Member
0 Likes
850

Hi Geetha,

In ABAP Objects a clean-up of the ABAP language has been carried out. As part of this language clean-up, stricter syntax checks are performed for constructs that were previously allowed, or obsolete statements are no longer allowed at all. The stricter syntax checks usually result in a syntax which should also be used outside of ABAP Objects but where the old versions cannot be forbidden for compatibility reasons.

One more Scenario where there is a chance of getting an error is during :-

Using the PERFORMING addition in the EXEC SQL statement to use a subroutine to process data line by line that you have read using Native SQL is not allowed in ABAP Objects. The EXIT FROM SQL statement, previously used within such subroutines, is also forbidden.

Regards,

Sai

Read only

Former Member
0 Likes
850

In ABAP Objects, an error message occurs on:

EXEC SQL PERFORMING form.

select ... into :wa from dbtab where ...

ENDEXEC.

FORM form.

...

EXIT FROM SQL.

...

ENDFORM.

Correct syntax:

EXEC SQL.

open c1 for

select ... from dbtab where ...

ENDEXEC.

DO.

EXEC SQL.

fetch next c1 into :wa

ENDEXEC.

IF sy-subrc <> 0.

EXIT.

ENDIF.

...

ENDDO.

EXEC SQL.

close c1

ENDEXEC.

Reason:

You should not call subroutines from local classes, and cannot call them from global classes. The called subroutine has no interface, working instead with the global data of the main program. The EXIT FROM SQL statement ends the SQL processing without reference to the actual SQL statement

Read only

Former Member
0 Likes
850

hi

good

i dont think there is any alternative to the EXEC statement in Native SQL.

thanks

mrutyun^

Read only

Former Member
0 Likes
851

In a Native SQL statement, data is passed between the ABAP program and the database using host variables. A host variable is an ABAP variable that is identified as such in the Native SQL statement by a preceding colon (:).

Example

Displaying an extract from the table AVERI_CLNT:

DATA: F1(3), F2(3), F3(3).

F3 = ' 1 '.

EXEC SQL.

SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT

WHERE ARG2 = :F3

ENDEXEC.

WRITE: / F1, F2.

To simplify the form of the INTO lists in the SELECT statement, you can, as in Open SQL, specify a single structure as the target area.

Example

Displaying an Extract from the Table AVERI_CLNT:

DATA: BEGIN OF WA,

CLIENT(3), ARG1(3), ARG2(3),

END OF WA.

DATA F3(3).

F3 = ' 1 '.

EXEC SQL.

SELECT CLIENT, ARG1 INTO :WA FROM AVERI_CLNT

WHERE ARG2 = :F3

ENDEXEC.

WRITE: / WA-CLIENT, WA-ARG1.

Native SQL supports the directly-executable commands of your underlying database system. There are other special commands that you can use after the EXEC SQL statement for cursor handling, stored procedures (procedures stored in the database), and connections to other databases.

Cursor Processing