Using Native SQL in ABAP for DB2 database

Dear Friends,
       I have 500K records in ITAB(Internal table) which needs to insert in 'Z' transparent table. Currently it is taking hours of time for insertion and commit. 
Does using Native SQL helps in performance or any suggestions? If so please send the code. Our database is DB2.
Your immediate reply is appreciated. Thanks in advance.

Hi Rama,
Using array inserts and commit after each Insert, set up your array size as a parameter and try  different array sizes.
I would start with 2000 and increment by 1000 or 2000 and see what the optimal array size is.
I would think more commits are desirable, as the array gets bigger it takes longer for the system to prepare in the event of a rollback.
Just remember to commit after each insert. And are you enqueueing the table first?
Hope this helps.
Filler

Similar Messages

  • Are there any risks to use native sql in ABAP to access external DB

    here is a requirement to use native sql in abap program to access external DB to load some data into sap. Are there any risks and effects which SAP not recommend ?
    Can anybody show some official document to me because I want to know some risks and dangerous to report to my manager..thanks very much.

    hi Anversha s 
    thank you for your reply
    I means what's the risk when to use native sql to access external DB..
    can you show me some examples about open sql which is used to access external DB...
    Now I am investigating the technique about the connection
    between SAP (by abap program) and external DB...the supporter suggestion is to use native sql to access external DBs.but my manager is afraid of the risks when to use native sql,So I have to report the effective document (example: SAP official document) to explain  to my manager.
    thanks very much

  • Accessinng Table using Native SQL in ABAP Program

    Hi Experts,
    I need to access a table that is created in Oracle.
    But while writing a select query as below:
      EXEC sql.
       SELECT MAX(ID_EVENTO)
         INTO :LV_ID_EVENTO
         FROM ZTAB.
      ENDEXEC.
    I am getting a dump saying "ZTAB doesnot exist" or IF I use ZTAB@ifsap then it dumps saying "Database name is missing a component".
    Do I need to add some suffix to the table name like @ifsap to ZTAB?
    Also, can I use SY-SUBRC to check to the success and failure for SELECTION OR INSERTION Operation?
    Thanks
    Depesh

    Hello,
    Try using SAP<SID>.ZTAB in your query.
    For example SAPC05.ZTAB
    Regards,
    Yoganand.V

  • Performance issue using Native SQL

    Hi
        I am getting the data from Oracle database using Native SQL in ABAP. I am facing performance problem when i am using Native SQL to get data from Oracle database.Its been very slow and getting timed out.
    This is the code i am using for this.
    EXEC SQL PERFORMING BUILD_TAB.
    Get the territory id
        SELECT TERR_ID
          FROM DWPROD.VW_ARDETAIL_PRD1@DWP
          INTO :IT_TERR-TERR_ID
               :DG_TERR_ID
         WHERE COMPANY     = :dt_output-bukrs
           AND PAY_ADDR_ID = :dt_output-kunnr
           AND DOC_NO      = :dt_output-belnr
           AND DOC_ITEM_NO = :dt_output-buzei
      ENDEXEC.
      IF sy-dbcnt >= 1.
        READ TABLE it_terr INDEX 1.
        dg_terr_id = it_terr-terr_id.
        EXEC SQL.
    Get the Saled rep id, name
          SELECT MR_USER_ID,
                 MR_NAME
            FROM DWPROD.VW_TERR@DWP
            INTO :dt_output-srep_id,
                 :dt_output-srep_name
           WHERE TERR_ID = :DG_TERR_ID
        ENDEXEC.
    *Get sales manager id and sales manager name
        EXEC SQL.
          SELECT SALES_GRP_ID
            FROM DWPROD.VW_TERRRPT@DWP
            INTO :DG_SGRPID
           WHERE TERR_ID = :DG_TERR_ID
        ENDEXEC.
        IF sy-dbcnt >= 1.
          EXEC SQL.
            SELECT MGR_USER_ID,
                   MGR_NAME
              FROM DWPROD.VW_SGRP@DWP
              INTO :dt_output-sman_id,
                   :dt_output-sman_name
             WHERE SALES_GRP_ID = :DG_SGRPID
          ENDEXEC.
        ENDIF.
      ENDIF.
    Can any one suggest a solution to improve the performance.
    Thnaks
    Vianney

    Hi John!
    Looks like you need just one entry out of the tables, but you select 'into table'.
    Try to add a 'up to 1 rows' restriction, then Oracle will be much faster with the execution.
    To get an idea, who this parameter looks like in native SQL for Oracle, write a simple test program with an open SQL statement (including this parameter / select single) and run a SQL-trace (ST05). Here you can see in 'explain' how native translation looks like, can also maintain some small tests with 'enter SQL statement'.
    Regards,
    Christian

  • Who to use Native SQL statements in ABAP

    hi all,
    who to use native sql staements in abap bypassing Application server.
    with regards,
    suresh babu aluri.

    Hi
    Native SQL statements define an area in an ABAP program in which one or more Native SQL statements are to be carried out. The area between EXEC and ENDEXEC is not completely checked by the syntax check. The statements entered there are passed to the Native SQL interface and processed there as follows:
    Almost all SQL statements that are valid for the addressed database system can be included between EXEC and ENDEXEC, in particular the DDL statements. These SQL statements are passed from the Native SQL interface to the database system largely unchanged. The syntax rules are specified by the database system, in particular the case sensitivity rules for database objects. If the syntax allows a separator character between individual statements, you can include several Native SQL statements between EXEC and ENDEXEC. Generally, the semicolon ( is used as the separator character.
    You can also include SAP-specific Native SQL language elements between EXEC and ENDEXEC. These statements are not passed directly from the Native SQL interface to the database, but are converted appropriately.
    All Native SQL statements bypass SAP buffering.
    The ENDEXEC statement sets sy-dbcnt to the number of table rows processed in the last Native SQL statement. After implicit cursor processing with PERFORMING, sy-dbcnt contains the total number of lines read.
    Programs with Native SQL statements are generally dependent on the database system used, so that they cannot be executed in all ABAP systems. This is especially true for the examples in this section, which was written for Informix database systems.
    Example
    Inserting two rows in the database table SCARR. If neither of these rows exists, sy-subrc is set to 0 by ENDEXEC and sy-dbcnt to 1. Otherwise, an exception is raised and handled.
    DATA: exc_ref    TYPE REF TO cx_sy_native_sql_error,
          error_text TYPE string.
    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.
    Reward points if useful
    Regards
    Anji

  • Using native sql for update

    Hello ,
    I have a reqaust to update a db table declared "outside" our R3 db.
    I mennage to select the data using native sql with a connection to the db.
    Now i need to modify the data on the db.
    Is there a similliar command like "fetch next" ' for update?
    Mybe i need to build a procedure in th "host" db and use its own commands to update?
    Thanks,
    koby

    Hello Kobi,
    Which release of SAP are you woking on?
    If you're on ECC6.0, instead you using Native SQL to call the stored procs of external DBs you can use the [ADBC APIs |http://help.sap.com/abapdocu_702/en/abenadbc_procedure.htm](CL_SQL* classes).
    BR,
    Suhas

  • Error while installing NW7.3 ABAP for DB2 on z/OS Install DB CLI driver

    Dear Experts,
    i'm installing for the first time NW7.3 ABAP for DB2 on z/OS with AIX application server. Central Services was installed succesfull but next step Install Database on AIX stoped with error (establishConn.log):
    db2radm (release: "720", patch level: "000", version: "Jan 14 2012") begin:28.02.2012 10:54:39
    This is db2radm release: "720", patch level: "120", version: "Jan 14 2012".
    This is db2radm setting up DB2 Connect.
    Message file is /sapmnt/tmp/sapinst_instdir/NW73/INSTALL/NW73/DB2/HA/PI/DB/establishConn.log.
    db2radm called as: /usr/sap/DW8/SYS/exe/uc/rs6000_64/db2radm -m db2i -P 456 -L DW8DDF -S DW88 -H s10d1 -u SAPADM -p ******** -W primary_only -l /sapmnt/tmp/sapinst_instdir/NW73/INSTALL/NW73/DB2/HA/PI/DB/establishConn.log
    Adjusting environment
      dbs_db2_ssid=DW88
      SAPDBHOST=s10d1
      dbs_db2_user=SAPADM
      dbs_db2_schema=SAPADM
      dbs_db2_schema8=1
      dbs_db2_pw=********
    Checking environment
      DB host    = s10d1
      SSID       = DW88
      SAPSYSTEMNAME = DW8
    DB2Trc:    000000 CLI_ALLOC_ENV 1
    connect.ini file used: 'connect.ini.for.db2radm'
    Fail over connection list of this application server:
    NAME       = DW88_on_s10d1             
    USER       = SAPADM                    
    PASSWORD   = <***>                     
    SCHEMA     = SAPADM                    
    PS         = SAP0907U                  
    LOCATION   = DW8DDF                    
    SSID       = DW88                      
    HOST       = s10d1                     
    PORT       = 456                       
    RETRY_CNT  = 3                         
    SLEEP_TIME = 0                         
    DB2Trc: trace level of dbdb2cli set to 1
    COLLECTION ID used is "SAP0907U"
    DB2 Call 'SQLDriverConnectW' Warning: SQLCODE = 8007 : [IBM][CLI Driver][DB2] SQL8007W  There are "90" day(s) left in the evaluation period for the product "DB2 Connect". For evaluation license terms and conditions, refer to the License Agreement document located in the license directory in the installation path of this product. If you have licensed this product, ensure the license key is properly registered. You can register the license via the License Center or db2licm command line utility. The license key can be obtained from your licensed product CD.  SQL
    use lib_dbsl for DB2 version V9.
    Callback functions for dynamic profile parameter registered
    DbSl library successfully loaded.
    WARNING: schema with 8 bytes length allowed; shadow upgrate will not work
    dbs/db2/use_accounting != 1 -> DB2 accounting is switched off
    dbs/db2/use_drda_lob_handling != 1 -> SAP LOB handling is used
    dbs/db2/chaining = 20 -> CLI CHAIN optimization is switched on
    dbs/db2/opt2_hint = 1 -> implicit 'optimize for 1 rows' hint is switched off
    SQL DRIVER VERSION is "09.07.0003"
    DB2Connect driver identified as THIN CLIENT
    Now I'm connected to DW88_on_s10d1
    DB2 DBMS version 09.01.0005
    DB2 LOCATION name DW8DDF
    (HYB): Info: Using OLD dbsl support.
    DB2 connect shared library loaded successfully.
    09.07.0003DB2Connect driver identified as THIN CLIENT
    WARNING: schema with 8 bytes length allowed; shadow upgrate will not work
    dbs/db2/use_accounting != 1 -> DB2 accounting is switched off
    dbs/db2/use_drda_lob_handling != 1 -> SAP LOB handling is used
    dbs/db2/chaining = 20 -> CLI CHAIN optimization is switched on
    dbs/db2/opt2_hint = 1 -> implicit 'optimize for 1 rows' hint is switched off
    DBSLHA: Got Failover profile /usr/sap/DW8/SYS/global/connect.ini
    DBSLHA: Using new Failover Support
    DBSLHA: Using user(  SAPADM) and password(<pwd>) from profile.
    DBSLHA:
    DBSLHA:Connection List
    DBSLHA:
    DBSLHA:NAME      |HOST      |SSID|COLLECTION  |PLAN    |PORT             |SCHEMA  |OWNER   |LOCATION  |RETRY|SLEEP|                                                                               
    DBSLHA:--|||||||||-|---|                                                                               
    DBSLHA:DW88_on_s1|s10d1     |DW88|SAP<DB2Conne|        |                 |SAPADM  |SAPADM  |DW8DDF    |00003|00000|                                                                               
    DBSLHA:--|||||||||-|---|                                                                               
    GetHaProfile: GetHaProfile: found 1 connections in connection profile.
    GetHaProfile: found section DW88_on_s10d1, ssid DW88, port 456, location DW8DDF, host s10d1  in connection profile
    connection profile /usr/sap/DW8/SYS/global/connect.ini opened.
    >>>>>> dump of connection profile
    ADDED 20120228 103331 by DB2RADM RELEASE 720 PATHLEVEL 000
      [DEFAULT_GROUP]
      CON1=DW88_on_s10d1
      [DW88_on_s10d1]
      SSID=DW88
      HOST=s10d1
      PORT=456
      LOCATION=DW8DDF
    <<<<<< end of dump of connection profile
    ssid DW88 found in connection profile, section DW88_on_s10d1.
    >>> analyse line:  * ADDED 20120228 103331 by DB2RADM RELEASE 720 PATHLEVEL 000
    >>> analyse line:  [DEFAULT_GROUP]
    >>> analyse line:  CON1=DW88_on_s10d1
    >>> analyse line: 
    >>> analyse line:  [DW88_on_s10d1]
    section DW88_on_s10d1 found.
    >>> analyse line:  SSID=DW88
    >>> analyse line:  HOST=s10d1
    >>> analyse line:  PORT=456
    >>> analyse line:  LOCATION=DW8DDF
    >>> analyse line:  section DW88_on_s10d1 found and data matches.
    backup connection profile /usr/sap/DW8/SYS/global/connect.ini .
    switch connection profile /usr/sap/DW8/SYS/global/connect.ini .
    check for adapted connection profile.
    WARNING: schema with 8 bytes length allowed; shadow upgrate will not work
    dbs/db2/use_accounting != 1 -> DB2 accounting is switched off
    dbs/db2/use_drda_lob_handling != 1 -> SAP LOB handling is used
    dbs/db2/chaining = 20 -> CLI CHAIN optimization is switched on
    dbs/db2/opt2_hint = 1 -> implicit 'optimize for 1 rows' hint is switched off
    DBSLHA: Got Failover profile /usr/sap/DW8/SYS/global/connect.ini
    DBSLHA: Using new Failover Support
    DBSLHA: Using user(  SAPADM) and password(<pwd>) from profile.
    DBSLHA:
    DBSLHA:Connection List
    DBSLHA:
    DBSLHA:NAME      |HOST      |SSID|COLLECTION  |PLAN    |PORT             |SCHEMA  |OWNER   |LOCATION  |RETRY|SLEEP|                                                                               
    DBSLHA:--|||||||||-|---|                                                                               
    DBSLHA:DW88_on_s1|s10d1     |DW88|SAP<DB2Conne|        |                 |SAPADM  |SAPADM  |DW8DDF    |00003|00000|                                                                               
    DBSLHA:--|||||||||-|---|                                                                               
    GetHaProfile: GetHaProfile: found 1 connections in connection profile.
    GetHaProfile: found section DW88_on_s10d1, ssid DW88, port 456, location DW8DDF, host s10d1  in connection profile
    ssid DW88 found in connection profile, section DW88_on_s10d1.
    check for adapted connection profile passed.
    WARNING: schema with 8 bytes length allowed; shadow upgrate will not work
    dbs/db2/use_accounting != 1 -> DB2 accounting is switched off
    dbs/db2/use_drda_lob_handling != 1 -> SAP LOB handling is used
    dbs/db2/chaining = 20 -> CLI CHAIN optimization is switched on
    dbs/db2/opt2_hint = 1 -> implicit 'optimize for 1 rows' hint is switched off
    DBSLHA: Got Failover profile /usr/sap/DW8/SYS/global/connect.ini
    DBSLHA: Using new Failover Support
    DBSLHA: Using user(  SAPADM) and password(<pwd>) from profile.
    DBSLHA:
    DBSLHA:Connection List
    DBSLHA:
    DBSLHA:NAME      |HOST      |SSID|COLLECTION  |PLAN    |PORT             |SCHEMA  |OWNER   |LOCATION  |RETRY|SLEEP|                                                                               
    DBSLHA:--|||||||||-|---|                                                                               
    DBSLHA:DW88_on_s1|s10d1     |DW88|SAP<DB2Conne|        |                 |SAPADM  |SAPADM  |DW8DDF    |00003|00000|                                                                               
    DBSLHA:--|||||||||-|---|                                                                               
    GetHaProfile: GetHaProfile: found 1 connections in connection profile.
    GetHaProfile: found section DW88_on_s10d1, ssid DW88, port 456, location DW8DDF, host s10d1  in connection profile
    WARNING: schema with 8 bytes length allowed; shadow upgrate will not work
    dbs/db2/use_accounting != 1 -> DB2 accounting is switched off
    dbs/db2/use_drda_lob_handling != 1 -> SAP LOB handling is used
    dbs/db2/chaining = 20 -> CLI CHAIN optimization is switched on
    dbs/db2/opt2_hint = 1 -> implicit 'optimize for 1 rows' hint is switched off
    DBSLHA: Got Failover profile /usr/sap/DW8/SYS/global/connect.ini
    DBSLHA: Using new Failover Support
    DBSLHA: Using user(  SAPADM) and password(<pwd>) from profile.
    DBSLHA:
    DBSLHA:Connection List
    DBSLHA:
    DBSLHA:NAME      |HOST      |SSID|COLLECTION  |PLAN    |PORT             |SCHEMA  |OWNER   |LOCATION  |RETRY|SLEEP|                                                                               
    DBSLHA:--|||||||||-|---|                                                                               
    DBSLHA:DW88_on_s1|s10d1     |DW88|SAP<DB2Conne|        |                 |SAPADM  |SAPADM  |DW8DDF    |00003|00000|                                                                               
    DBSLHA:--|||||||||-|---|                                                                               
    SQL DRIVER VERSION is "09.07.0003"
    DB2Connect driver identified as THIN CLIENT
    DB2Trc: 00 000000 cli_get_cli_driver_bld_level 1 s101006
    SQL DRIVER NAME is "libdb2.a"
    SQL DBMS NAME is "DB2"
    SQL DBMS VERSION is "09.01.0005"
    DATABASE NAME(DB2 Connect DCS database name) is "DW8DDF"
    The bind is skipped since collection for ssid DW88 is already bound.
    To force the bind, use option "-B force".
    DB2TRC: 0000000000 00      000000   CLI_DISCONNECT
    DB2TRC: 0000000000 00      000000   CLI_FREE_DBC 1
    DB2TRC: 0000000000 00      000000   CLI_FREE_ENV 1
    DB VERSION is 09.01.0005.
    Starting Grants .
    DB2Trc:    000000 CLI_ALLOC_ENV 1
    COLLECTION ID used is "SAP0907U"
    DB2 Call 'SQLDriverConnectW' Warning: SQLCODE = 8007 : [IBM][CLI Driver][DB2] SQL8007W  There are "90" day(s) left in the evaluation period for the product "DB2 Connect". For evaluation license terms and conditions, refer to the License Agreement document located in the license directory in the installation path of this product. If you have licensed this product, ensure the license key is properly registered. You can register the license via the License Center or db2licm command line utility. The license key can be obtained from your licensed product CD.  SQL
    Connecting to <DW88_on_s10d1> on connection 0 ...
    Now I'm connected to DB2 (09.01.5)
    SQL DRIVER NAME is "libdb2.a"
    SQL DBMS NAME is "DB2"
    SQL DBMS VERSION is "09.01.0005"
    DATABASE NAME(DB2 Connect DCS database name) is "DW8DDF"
    New functions of DB2 V9 are switched on
    Profile parameter dbs/db2/cli_trace_dir is not set
    dbdb2dic.c 1709 INFO    Profile: SDB2_DEBUG=<UNSET>                                                                           
    dbdb2dic.c 1733 INFO    Envrmnt: sdb2_debug=<UNSET>                                                                           
    dbdb2dic.c 1733 INFO    Envrmnt: SDB2_DEBUG=<UNSET>                                                                           
    DB2 Call 'CLI_EXECUTE' Error: sqlcode = -204 : [IBM][CLI Driver][DB2] SQL0204N  "SAPADM.#LOBU" is an undefined name.  SQLSTATE=42704
    dbdb2dic.c 2251 INFO    rc=103,sqlcode=-204: ExeRead                                                                          
    dbdb2dic.c 1709 INFO    Profile: dbs/db2/max_retry=<UNSET>                                                                    
    dbdb2dic.c 1733 INFO    Envrmnt: DB2_MAX_RETRY=<UNSET>                                                                        
    dbdb2dic.c 1709 INFO    Profile: dbs/db2/retry_on_924=<UNSET>                                                                 
    dbdb2dic.c 1733 INFO    Envrmnt: DB2_RETRY_ON_924=<UNSET>                                                                     
    dbdb2dic.c 1709 INFO    Profile: dbs/db2/no_retry_on_10=<UNSET>                                                               
    dbdb2dic.c 1733 INFO    Envrmnt: dbs_db2_no_retry_on_10=<UNSET>                                                               
    dbdb2dic.c 1733 INFO    Envrmnt: DBS_DB2_NO_RETRY_ON_10=<UNSET>                                                               
    DB2 Call 'SQLEndTran' Error: sqlstate = 08003 : [IBM][CLI Driver] CLI0106E  Connection is closed. SQLSTATE=08003
    [dbdb2dic.c  1873:rc=99: COMMIT WORK failed]
    dbdb2dic.c 1873 ERROR   rc=99: COMMIT WORK failed                                                                             
    [dbdb2dic.c  2019:rc=99,sqlcode=268435455: ExecDDL failed (DB error)]
    dbdb2dic.c 2019 ERROR   rc=99,sqlcode=268435455: ExecDDL failed (DB error)                                                    
    DB2 Call 'SQLEndTran' Error: SQLCODE = -99999 : [IBM][CLI Driver] CLI0106E  Connection is closed. SQLSTATE=08003
    ROLLBACK failed with SQL error '-99999'
    ERROR: couldn't connect to DB
    rc = 99
    error message returned by DbSl:
    rc=99,sqlcode=268435455: ExecDDL failed (DB error)
    DB2RADM EXITCODE: 12
    db2radm finished (0012)
    db2radm stop:28.02.2012 10:54:39
    i've patched db2radm and sapinst to the latest version.
    May be i should manually create "SAPADM.#LOBU"?
    Please help to solve these issue.
    Best regards,
    Alexander V

    Hi ,
    Please check if Note 1581637 - Installing a System with DB2CODEPAGE other than the default is useful.
    Award points if useful.
    Thanks,
    Ravi

  • Reading BLOB in Native SQL from ABAP program

    Hello,
    I'm trying to read content of a BLOB field from a table with Native SQL in ABAP like this:
    DATA: l_bytes type xstring.
    EXEC SQL.
      SELECT bytes INTO :l_bytes FROM tablename
    ENDEXEC.
    But when I'm using xstring it returns only 32768 bytes. When using type x length 65000 for l_bytes it returns 65000 bytes, but x is limited to 65535 bytes only. So why it returns only 32768 bytes in direct sql? For DB2 I found note 610342 where you need to add \lob to the statement, I tried with Oracle but doesn't work.
    DATA: CLOB_VAR TYPE STRING.
    DATA: BLOB_VAR TYPE XSTRING.
    EXEC SQL.     
      SELECT FCLOB, FBLOB FROM ZZTAB        INTO :CLOB_VAR\lob, :BLOB_VAR\lob
    ENDEXEC.
    Regards
    Markus

    Hi Markus,
    you have to read it in chunks (remember a blob could be up to 4 Gbyte!).
    I assume you store the byte stream in the field (no bfile pointer to a file ).
    Give you a pseudocode that you get the picture.
    Would recommend that you read the Oracle manual (db Version?)
    9i
    http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_lob2.htm#1008611
    10g
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#ARPLS600
    chunksize = 32768 .  " or use 65000 . This is the amount of the blob part you want to read
    offset = 1.
    *get the row of interest and retrieve blob's length
    Exec sql.
    select  dbms_lob.getlength(your_blob)  :blob_length from blob_table where my_primary_key = 1
    end exec.
    *calculate times to read from blob  until the end (well, leave the adjustment to you
    * in case of an uneven  fraction)
    ntimes = blob_length / chunksize .
    Do ntimes
    *loop and get the chunks into your variable:
    * start reading from offset chunksize of bytes
    exec sql.
    select dbms_lob.substr(your_blob, :chunksize,:offset) into  :xblobvar  from blob_table
    where my_primary_key = 1
    endexec.
    *don't know what you want to do with the blob chunk...
    *process  :xblobvar
    offset = chunksize * ntimes .
    enddo.
    bye
    yk

  • How to use Native SQL statement in JDBC receiver interface

    Dear All,
    Can any one please help us in using Native SQL statement in a JDBC receiver channel. The reason why I need to use Native SQL statement instead of standard XML structure is that I need to execute a dynamic SQL query in third party database system lke:-
    Select Field1 Field2 from TABLE Where Field3 like "%Name'
    I expect the the response in the form of XML file which I can pick up using synchornous interface as mentioned on help.sap.com:-
    http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
    The value for %Name can change dynamically according to the transaction and hence cannot be inluded as a KEY element in standard XLM structure,
    Hence I need to know:-
    1. What message mapping I should use in case if I have to use Native SQL statement.
    2.What operation mapping I should use in case if I have to use Native SQL statement.
    If guess correclty I may have to use Java mapping to do the above activities. Hence I want to know
    3 .How do to go about it to do the Java mapping.
    Thanks
    Ameet

    >
    Ameet Deshpande wrote:
    > Dear All,
    >
    > Can any one please help us in using Native SQL statement in a JDBC receiver channel. The reason why I need to use Native SQL statement instead of standard XML structure is that I need to execute a dynamic SQL query in third party database system lke:-
    >
    > "
    > Select Field1 Field2 from TABLE Where Field3 like "%Name'
    > "
    > I expect the the response in the form of XML file which I can pick up using synchornous interface as mentioned on help.sap.com:-
    >
    > http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
    > http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
    >
    > The value for %Name can change dynamically according to the transaction and hence cannot be inluded as a KEY element in standard XLM structure,
    >
    > Hence I need to know:-
    >
    > 1. What message mapping I should use in case if I have to use Native SQL statement.
    > 2.What operation mapping I should use in case if I have to use Native SQL statement.
    > If guess correclty I may have to use Java mapping to do the above activities. Hence I want to know
    > 3 .How do to go about it to do the Java mapping.
    >
    > Thanks
    > Ameet
    You can use a stored procedure, and call it from jdbc receiver adapter.
    I also solve this issue, with a DBLookup in message mapping. You can refer to my blog, and this usefull 3d:
    http://simonlesflex.wordpress.com/2010/12/07/pi-oracle-dblookup/
    /people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer
    /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler

  • How to use Native SQL String

    Hi all,
    How do i use Native SQL String in the Reciver JDBC Adapter.
    Do i need to change the message format could u suggest me some blogs on the same.
    Also please can anyone let me knw if i can use this for stored procedure.

    hi aditya,
    there shud be no format as such. for sql xml format there are specific structure. but for native sql there shudnt be any specific structure.
    as pointed in sap documentaion:
    Instead of an XML document format, a text is expected that represents any valid SQL statement.
    When inserting a line into a table the corresponding document looks as follows:
    INSERT INTO tableName  (column-name1, column-name2, column-name3) VALUES(‘column-value1’, ‘column-value2’, ‘column-value3’)
    so jus make sure that u give a valid sql statement becoz if will be passed as it is to the database and try ur scenario.
    regards,
    latika.

  • # coming when I select data from oracle table using Native SQL

    Hi Gurus,
    I am selecting 'First name' from oracle table directly using native sql. I am fetching 65000 records but 10+ records having '#' at the end of firstname. For eg: John#.
    But oracle team couldn't find '#' in their table for those records. What could be problem?
    or what could be the character in oracle which comes as '#' in abap?
    Pls help...
    Saj

    Thanks for replies.
    My DB NLS_PARAMETER is AL32UTF8. I am able to pullout data with older version of ojdbc jar file. So I think there is no issue regarding NLS setting.
    So please guide me with proper solution as soon as possible.

  • How to get oracle 9i blob column into an itab  in sap using Native SQL

    Hi ,
    We are using SAP ECC 5.0  and we need to coonect to an oracle database ver 9i rel2.
    We need to get the data stored in a blob(pdf/jpeg) into an itab and later
    use it for futher processing.
    I am familiar with using native SQL and I wrote a stored procedure in the non sap oracle database to send the blob info into an internal table in sap.
    But the information is in hex format and the long raw of SAP does not handle this very well.
    Plz see my code below.
    data: itab_insp_drawing like zpicture_cluster(which is of type lraw - 7902 )
          occurs 100 with header line.
    EXEC SQL.
        EXECUTE PROCEDURE
           proc_get_insp_drawings  (
                   IN  :itab-aq_id,
                   IN  :itab-section_id,
                   IN  :t_in_position,
                   out :itab_insp_drawing-picture,
                   OUT :t_blob_length,
                   out :t_out_position,
                   OUT :t_status  )
       ENDEXEC.
      append itab_insp_drawing.
      while t_out_position < t_blob_length.
       EXEC SQL.
        EXECUTE PROCEDURE
           proc_get_insp_drawings  (
                   IN  :itab-aq_id,
                   IN  :itab-section_id,
                   IN  :t_in_position,
                   out :itab_insp_drawing-picture,
                   OUT :t_blob_length,
                   out :t_out_position,
                   OUT :t_status  )
       ENDEXEC.
       append itab_insp_drawing.
       endwhile.
    Any ideas of how to handle blobs from non sap oracle table. I need this blob into an itab in sap.
    Help appreciated.
    Thanks
    Mala

    Please refer the example in this link which deals with Oracle date format.
    You can finnd a command DECODE which is used for date formats. If you have a look at whole theory then you will get an idea.
    Link:[Bulk insert SQL command to transfer data from SAP to Oracle|http://sap.ittoolbox.com/groups/technical-functional/sap-dev/bulk-insert-sql-command-to-transfer-data-from-sap-to-oracle-cl_sql_connection-3780804]

  • Native SQL from ABAP - ORA 02396 max idle time exceeded

    Hello,
      I am trying to read a table outside of the R/3 environment using native SQL statements. I'm getting the data just fine. But every other time (depending on elapsed time), I get the ORA-02396 exceeded maximum idle time, connect again. Here's the SQL code I'm using and I'm obviously not getting disconnected but I'm not sure why. Any help?
    Open a native SQL connection.
      EXEC SQL.
        connect to 'ONECD'
      ENDEXEC.
    Retrieve information from the BVER tables.
      EXEC SQL PERFORMING read_dental.
        select emp_ssn_num, emp_fname, emp_lname,
               to_char(start_date, 'YYYYMMDD') as start_date,
               rec_type,
               to_char(eff_date, 'YYYYMMDD') as eff_date,
               vendor_plan_id
            into :dental
            from opr$8oc.BVER_CURR_DENTAL_MASTER
      ENDEXEC.
      EXEC SQL PERFORMING read_medical.
        select emp_ssn_num, emp_fname, emp_lname, rec_type,
               to_char(start_date, 'YYYYMMDD') as start_date,
               to_char(eff_date, 'YYYYMMDD') as eff_date,
               network_code, pcp_number, patient_flag,
               vendor_plan_id,
               to_char(network_eff_date, 'YYYYMMDD') as
                       network_eff_date,
               to_char(pha_eff_date, 'YYYYMMDD') as
                       pha_eff_date
             into :medical
             from opr$8oc.BVER_CURR_MEDICAL_MASTER
      ENDEXEC.
    Disconnect from the native SQL connection.
      EXEC SQL.
        DISCONNECT 'ONECD'
      ENDEXEC.
    The system log has messages like 'Work process is in reconnect status' and 'Work process has left reconnect status' after the ORA-02396 message. And I specifically do a disconnect at the end and a connect at the beginning, but it looks like it is trying to do a reconnect?
    Thanks,
    Diane

    Hi Daine,
    Oracle Parameter IDLE_TIME set by the administrator.
    1. Since you are using Secondary database
       connection, the connection must
       have been made with the help of BASIS Team.
    2. This secondary database ORACLE
       has some settings/parameters
       which have been set to say 10 minutes, 60 minutes etc.
       , so what happens,
       if there is NO ACTIVITY / NO SQL / NO INTERACTION
       with the database ,
       the connection is IDLE
       and hence ORACLE then disconnects by itself.
    3. Contact your basis team / oracle administarotr
      team to INCREASE this setting.
      (they do it for some security purpose, firewall etc)
    I hope it helps.  
    Regards,
    Amit M.
    Message was edited by: Amit Mittal

  • Insertion / Update of field of type "TIME" using Native SQL

    Hi ABAP gurus,
    We are trying to perform inserts and updates within an ORACLE table where a TIME field exists without suscess. We are trying to code it using Native SQL.
    EXEC SQL.
    INSERT INTO table (field1[name], field2[age], field3[birthday], field4[hour])
    VALUES (:name, :age, TO_DATE(:date_birth), ¿:hour?)
    ENDEXEC.
    EXEC SQL.
    UPDATE table SET field3[birthday] = TO_DATE(:date_birth), field4[hour] = ¿:hour?
    WHERE field1[name] = :name AND field2[age] = :age
    ENDEXEC.
    Which is the right coding sentence in order to achieve our goal?
    Many thanks in advance. Best regards,
       Imanol

    >
    Imanol Beguiristain wrote:
    > Hi all,
    >
    > I am sorry for being unclear.
    >
    > I do want to code both INSERT and UPDATE. That is clear.
    >
    > The problem we are having is that we don't know how to code (using Native SQL) such instructions using in the SQL sentence a field of TIME type.
    >
    > Any helps?
    >
    > Thanks in advance.
    >
    >   Imanol
    I've not heard of an Oracle TIME datatype; we used to use the timestamp which is stored as part of the date or we set up a separate column to hold the time defined as CHAR.  Still, it is possible that they have created such a thing since I last did SQL.  In which case, there would have to be a function like TO_DATE which you would use to convert your time to its time format.
    If you mean TIMESTAMP you can use something like the following to do the data conversion.
    TO_TIMESTAMP(LOCALTIMESTAMP, 'DD-MON-RR HH.MI.SSXFF')

  • Insert / Update of a TIME field using Native SQL

    Hi Oracle gurus,
    We are trying to perform inserts and updates within an ORACLE table where a TIME field exists without suscess. We are trying to code it using Native SQL.
    EXEC SQL.
    INSERT INTO table (field1[name], field2[age], field3[birthday], field4[hour])
    VALUES (:name, :age, TO_DATE(:date_birth), ¿:hour?)
    ENDEXEC.
    EXEC SQL.
    UPDATE table SET field3[birthday] = TO_DATE(:date_birth), field4[hour] = ¿:hour?
    WHERE field1[name] = :name AND field2[age] = :age
    ENDEXEC.
    Which is the right coding sentence in order to achieve our goal?
    Many thanks in advance. Best regards,
       Imanol

    Hi
    There is no TIME datatype in oracle. There is only a TIMESTAMP or DATE type or the field is VARCHAR2 as most date fields in a SAP database are. To help you we would need the real field type. If possible you please do a desc <owner>.<table> in a sqlplus session and give us the field type.
    If possible also supply the error you get.
    Regards, Michael

Maybe you are looking for

  • Slow boot time after upgrading to Mavericks

    I use MBP mid 2010 it came with Snow Leopard 10.6.8. About 2 months ago I upgraded to 10.9.2 and ever since I'm experiencing slower boot time - in previous OS it started within less than 30sec and right now it starts around ~1min untill I see the des

  • AWT co-ordinate system

    Hello. I still can't figure out. I'm plotting graph co-ordinates on an AWT Canvas component. i.e (x,y) values However, due to the AWT co-ordinate system, the origin (0,0) is at the top left hand corner of the screen. What trick can I do to plot my po

  • Looking for appropriate TV-Out cable

    Hey guys... I lost my tv-out cables in a recent move.  Looked all over for them, but they're gone.  The card that these fit is an XFX 7900GT. I really have two options.  The first, preferred option is to get a new 7-pin tv-out cable.  I have found on

  • Transfer email to ipad from old computer

    old computer email and accounts to transfer my ipad

  • Imported images clip in Preview mode

    When I preview a layout several of the images either disappear or are cropped. I have an example of the cropping in these screenshots. This is happening in multiple files.