Skip to Content
avatar image
Former Member

Native SQL

Hi Friends,

Can we access table that is created in native sql by using open sql ?

Regards,

Rushi.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Aug 17, 2007 at 12:42 PM

    No. With Open SQL you access the Data Dictionary layer (SAP side), the runtime links that layer to the real DB. If you create a table using CREATE TABLE from Native SQL, the Data Dictionary definition doesn't exist, so Open SQL cannot "see" that table.

    However, i think you shouldn't use DDL SQL from ABAP (using Native SQL).

    Regards.

    Please reward points if helpful.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 17, 2007 at 12:55 PM

    we can access database using both OPEN SQL and NATIVE SQL but there is problem if use NATIVE SQL because while transporting form one system to another system you have to write some extra coding. For example you are using ORACLE data base in your R/3 system and used NATIVE SQL and in future your management changed made a decision to change the data base to DB2.in these case you have to write extra logic and also you may face some problems using NATIVE SQL you should know the prier knowledge of which database your client using and no F1 help while coding these are the probles you face if you code using NATIVE SQL.It's better to use OPENSQL.

    To use NATIVE SQL write the code in EXEC and ENDEXEC block.

    <b>

    reward points if helpful.</b>

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 17, 2007 at 01:03 PM

    Use Native SQL commands for this purpose, for example:

    TRY.

    EXEC SQL.

    INSERT INTO scarr

    (MANDT, CARRID, CARRNAME, CURRCODE, URL)

    VALUES ('000', 'FF', 'Funny Flyers', 'EUR',

    'http://www.ff.com');

    INSERT INTO scarr

    (MANDT, CARRID, CARRNAME, CURRCODE, URL)

    VALUES ('000', 'EF', 'Easy Flyers', 'EUR',

    'http://www.ef.com');

    ENDEXEC.

    CATCH cx_sy_native_sql_error INTO exc_ref.

    error_text = exc_ref->get_text( ).

    MESSAGE error_text TYPE 'I'.

    ENDTRY.

    Add comment
    10|10000 characters needed characters exceeded