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

About Native SQL Insert statement

Former Member
0 Likes
669

INSERT INTO ZPO_BULKOR_ORDER

(ORDER_NUMBER, SEQUENCE_NUMBER)

VALUES ('45679012', '12345987')

COMMIT

why is this not working and giving a dump ?

Can anyone please explain this.

Regards,

Manoj

3 REPLIES 3
Read only

Former Member
0 Likes
503

hi,

Could you post your entire code?

Have you given the stmt inside EXEC SQL....and ENDEXEC?

Regards

Subramanian

Read only

Former Member
0 Likes
503

Native SQL statement is to be included between EXEC SQL and ENDEXEC.

EXEC SQL.

<Native SQL statement>

ENDEXEC.

Also in the INSERT statement you need not mention the field names.

~Kiran

Read only

Former Member
0 Likes
503

Hi,

Open SQL allows you to access database tables declared in the ABAP Dictionary, regardless of the database platform you are using. Native SQL allows you to use database-specific SQL statements in an ABAP program. This means that you can use database tables that are not managed by the ABAP Dictionary, and therefore integrate data that is not part of the SAP Web AS ABAP System.

To use a Native SQL statement, you must precede it with the EXEC SQL statement, and follow it with the ENDEXEC statement as follows:

EXEC SQL [PERFORMING form].

Native SQL statement

ENDEXEC.

There is no period (.) after Native SQL statements. Furthermore, using inverted commas (“) in a Native SQL statement or an asterisk (*) at the beginning of a line does not introduce a comment as it would in normal ABAP syntax.

In Native SQL statements, the data is transported between the database table and the ABAP program using host variables. These variables are declared in the ABAP program, and preceded in the Native SQL statement by a colon (:).

Example:

REPORT demo_native_sql.

DATA: BEGIN OF wa,

connid TYPE spfli-connid,

cityfrom TYPE spfli-cityfrom,

cityto TYPE spfli-cityto,

END OF wa.

DATA c1 TYPE spfli-carrid VALUE 'LH'.

EXEC SQL PERFORMING loop_output.

SELECT connid, cityfrom, cityto

INTO :wa

FROM spfli

WHERE carrid = :c1

ENDEXEC.

FORM loop_output.

WRITE: / wa-connid, wa-cityfrom, wa-cityto.

ENDFORM.

The work area wa and the field c1 Native SQL statement SELECT are used. wa is the target area into which the selected data is written. As a structure, wa is handled in the INTO clause as if all subfields were listed individually: [..] INTO :wa-connid, :wa-cityfrom, :wa-cityto. c1 is used in the WHERE clause. The subroutine loop_output writes the data from wa to the list.

Hope this helps

Regards,

Sruthi.