Native SQL Statement help!
Hi guys,
I need some help here.
I have a requirement to select from Microsoft SQL database
Question
How do I select with RANGE internal tables? As you can see, I have 4 range tables for this.
BElow are my codes
EXEC SQL.
CONNECT TO 'CONNECTION_NAME'
ENDEXEC.
IF sy-subrc <> 0.
MESSAGE 'Unable to connect to CONNECTION_NAME' TYPE 'E' DISPLAY LIKE 'I'.
RETURN.
ENDIF.
* Define database cursor
EXEC SQL.
OPEN dbcur FOR
SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,
qty, zopcd, bstnk, wekunnr
FROM <TABLE_NAME>
WHERE month IN i_month
AND yyear IN i_year
AND kunnr IN i_kunnr
AND bstnk IN i_bstnk
ENDEXEC.
* Fill itab
DO.
EXEC SQL.
FETCH NEXT dbcur INTO :l_dest-name1,
:l_dest-zvctk,
:l_dest-kunnr,
:l_dest-yyear,
:l_dest-mmonth,
:l_dest-matnr,
:l_dest-qty,
:l_dest-zopcd,
:l_dest-bstnk,
:l_dest-wekunnr
ENDEXEC.
IF sy-subrc <> 0.
EXIT.
ELSE.
APPEND l_dest TO it_dest.
ENDIF.
ENDDO.
its giving me a shortdump
>>>>> OPEN dbcur FOR
35 SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,
36 qty, zopcd, bstnk, wekunnr
37 FROM v_promise_sa
38 WHERE month IN i_month[]
39 AND yyear IN i_year[]
40 AND kunnr IN i_kunnr[]
41 AND bstnk IN i_bstnk[]
Error message:
Database error text........: "[Microsoft][SQL Server Native Client 10.0][SQL
Server]Incorrect syntax near 'i_month'."
Database error code........: 102
Triggering SQL statement...: "SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,
qty, zopcd, bstnk, wekunnr FROM <TABLE_NAME> WHERE month IN i_month[] AND
yyear IN i_year[] AND kunnr IN i_kunnr[] AND bstnk IN i_bstnk[]"
Internal call code.........: "[DBDS/NEW DSQL]"
Please check the entries in the system log (Transaction SM21).
Can anyone guide me? If I do not enter the where clause, it is selecting fine.
Appreciate it guys! Thanks in advance!
lol, Come guys, don't judge me by just my forum nick man. It was just something random during registration a few years back...was indeed new in ABAP language :P
But anyway, the table v_promimse_sa is not in the DDIC, its some microsoft MYSQL database or something.
anyway what I did now:
EXEC SQL.
CONNECT TO 'MSSQL_PROMISE'
ENDEXEC.
IF sy-subrc <> 0.
MESSAGE 'Unable to connect to MSSQL_PROMISE' TYPE 'E' DISPLAY LIKE 'I'.
RETURN.
ENDIF.
* Define database cursor
EXEC SQL.
OPEN dbcur FOR
SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,
qty, zopcd, bstnk, wekunnr
FROM v_promise_sa
WHERE mmonth = :i_month
AND yyear = :i_year
* AND ( kunnr BETWEEN :i_kunnr-low AND :i_kunnr-high )
* AND ( bstnk BETWEEN :i_bstnk-low AND :i_bstnk-high )
ENDEXEC.
* Fill itab
DO.
EXEC SQL.
FETCH NEXT dbcur INTO :l_dest-name1,
:l_dest-zvctk,
:l_dest-kunnr,
:l_dest-yyear,
:l_dest-mmonth,
:l_dest-matnr,
:l_dest-qty,
:l_dest-zopcd,
:l_dest-bstnk,
:l_dest-wekunnr
ENDEXEC.
IF sy-subrc <> 0.
EXIT.
ELSE.
APPEND l_dest TO it_dest.
ENDIF.
ENDDO.
* EXEC SQL.
* CLOSE dbcur
* ENDEXEC.
DELETE it_dest WHERE kunnr NOT IN i_kunnr
AND bstnk NOT IN i_bstnk.
Well, after checking with the functional person, there are only 3 records so I guess the selection + filtering is working.
Similar Messages
-
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 -
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 -
Is there a way to excute a Native SQL statements simply?
I heard that there is a standard transaction code to test a Native SQL statement.
Please let me know if you are know that.
Thank you!hi,
Try this in SE38.
data: itab type mara-matnr.
exec sql performing a1.
select matnr from mara into :itab
endexec.
form a1.
write:/ itab.
endform.
Note: The sql stmt with in exec sql and endexec
'll not be checked.
Thanks.
Arunprasad.P -
Oracle Spatial operator SQL statement help
I have a 3D elevation point feature class (elev) and a polygon feature class (Building) loaded in Oracle Spatial. I am trying to update the "HEIGHT" attribute of the "Building" Feature class using the average elevation of "elev" feature class. Here below is the SQL statement I used, which generated the same value for all buildings. The avg(elevation) returns the average elevation of all points within all building polygons, not all points within ONE polygon.
Please help and thanks.
update building
set height = (select avg(elevation)
from elev e, building b
where sdo_anyinteract(e.shape, b.shape) = 'TRUE');Hi,
try this
update building b
set height = (select avg(elevation)
from elev e where sdo_anyinteract(e.shape, b.shape) = 'TRUE');
Udo -
If someone would be so kind, I need help in formulating a SQL statement.
Table A - employees(empoyee_id, employee_name, status)
This table contains all employees
employee status can be one of three values (A=active, T=temporary, I=inactive)
Table B - savings_program(employee_id, plan_type)
This table only has employee_id's of those that participate in a savings program (subset of all employees).
plan_type can be one of three numeric values (30,35,40)
I need SQL to report a.employee_id,a.employee_name,b.plan_type (return plan_type 30,35, or none)of all active employees in Table A that don't participate in Table B plan_type 40.
Working with version 9iR2. Thanks!
Edited by: fosterk on Nov 21, 2008 12:59 PMThe tables and columns above were for demo purposes but actual code I'm trying is below. Please excuse me I'm more of an SA type so SQL is not my thing.
As you can see from the first SQL statement below I know that I have exactly
3,000 employees that meet this criteria. The second SQL statement is my attempt to return the rows I want (I'm just nesting it in a count(*) until the numbers look right)
The last statement is what was given to me by someone else (seeking my help haha) trying to resolve it and it only returns 3 rows. This SQL shows the actual columns that we're trying to return from both tables.
HR> select count(*) from ps_All_employees where empl_status != 'T'
2 and emplid not in
3 (select emplid from ps_savings_pt_vw where plan_type = 40)
4 /
COUNT(*)
3000
HR> select count(*) from (
2 (select * from ps_all_employees where empl_status != 'T') a left outer join
3 (select emplid from ps_savings_pt_vw where plan_type != 40) s
4 on a.emplid = s.emplid
5 )
6 /
COUNT(*)
4587
select count(*) from (
select a.location, a.ssn, a.first_name, a.last_name, a.birthdate, a.orig_hire_dt, a.hire_dt, a.location, a.street1,
a.street2, a.city, a.state, a.zip, s.plan_type
from ps_all_employees a, ps_savings_pt_vw s
where a.empl_status != 'T' and
a.emplid = s.emplid and
a.emplid not in (select s.emplid from ps_savings_pt_vw s where s.plan_type = 40)
COUNT(*)
3 -
EarlyWatch - Expensive SQL Statements help
Hi all,
i need to analyze an EWA report and i don't know how exactly can i identify an "expensive SQL statement".
The report says:
During this session, the following expensive SQL statements were identified as causing a database load of at least 1%.
The corresponding stored procedure names are referenced in the table below.
And in the table with stored procedure names, a row looks like this:
ID Stored Procedure Name
1 ##Y4DCWWES7EHY100000053960000254832042037
What does it mean and how can i identify the name of program and the exact statement (probably select) that is causing this problem?
Thank you,
OndrejHi Ondrej,
you're running on SQL Server. SAP creates stored procedures for each and every statement run against the database. The name you get seems to be a temporary stored procedure which (if I'm not wrong) is marked by the two # characters at the beginning. You may be still find it in the stored procedures of your system.
Open the Enterprise Manager and open your database, then the stored procedure link (you should run the Enterprise Manager on the server or on a PC with enough RAM). The search for the procedure and double click on it. I think that should show you the SQL statement. There should also the report name is a comment.
Regards
Ralph -
here is a sample code of my application....
int initialDelay = 10000; // start after 10 second
int period = 10000*60*60*24*30; // repeat every month
Timer timer = new Timer();
TimerTask task = new TimerTask() {
public void run() {
try {
MyDBConnection jdbc = new MyDBConnection();
jdbc.init();
Connection conn = jdbc.getMyConnection();
Statement stmt = conn.createStatement();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String[] tbl = {"emticket","emattachment","emhistory","emtracker"};
progTxt.setText("");
Logs l = new Logs();
l.append("Auto Archive");
date.getTime();
//Archive data
progTxt.append("\n\n");
progTxt.append(" Archiving Data...\n ");
stmt.execute("select * into outfile 'c:/emticket " + dateFormat.format(date) + ".csv' fields terminated by ',' enclosed by '\"' lines terminated by '\\n' from emticket where RcvDateTime between date_sub(curdate(),interval 90 day) and curdate()");
stmt.execute("select * into outfile 'c:/emattachment " + dateFormat.format(date) + ".csv' fields terminated by ',' enclosed by '\"' lines terminated by '\\n' from emattachment where EmID in (select EmID from emticket where RcvDateTime between date_sub(curdate(),interval 90 day) and curdate())");
stmt.execute("select * into outfile 'c:/emhistory " + dateFormat.format(date) + ".csv' fields terminated by ',' enclosed by '\"' lines terminated by '\\n' from emhistory where TicketID in (select TicketID from emticket where RcvDateTime between date_sub(curdate(),interval 90 day) and curdate())");
stmt.execute("select * into outfile 'c:/emtracker " + dateFormat.format(date) + ".csv' fields terminated by ',' enclosed by '\"' lines terminated by '\\n' from emtracker where TicketID in (select TicketID from emticket where RcvDateTime between date_sub(curdate(),interval 90 day) and curdate())");
progTxt.append("Done.\n\n");
//Delete data
progTxt.append(" Deleting Data... ");
stmt.execute("delete emticket, emattachment, emhistory, emtracker from emticket, emattachment, emhistory, emtracker where emattachment.EmID=emticket.EmID and emhistory.TicketID=emticket.TicketID and emtracker.TicketID=emtracker.TicketID and where RcvDateTime
"_______"DATE_SUB(CURDATE(),INTERVAL 90 DAY) and CURDATE())");
System.out.println(stmt.getUpdateCount());
progTxt.append("Done.\n\n");
Here's what i want to do....I want to backup file for the current date back to 3 mos...e.g 2007-05-23 down to 2007-02-23...then delete the remaining records...before"02-23-2007 to 05-23-2007"....this is where the query part i that doesn't work....
Delete data
progTxt.append(" Deleting Data... ");
stmt.execute("delete emticket, emattachment, emhistory, emtracker from emticket, emattachment, emhistory, emtracker where emattachment.EmID=emticket.EmID and emhistory.TicketID=emticket.TicketID and emtracker.TicketID=emtracker.TicketID and where RcvDateTime
"_______"DATE_SUB(CURDATE(),INTERVAL 90 DAY) and CURDATE())");
System.out.println(stmt.getUpdateCount());
progTxt.append("Done.\n\n")
I tried putting <>=which means not equal in the "_____"but it fails to work..can somebody help me to work out with this query.I don't know MySQL, but shouldn't you just use <= ? I also don't understand what the final part 'and CURDATE()' is for...
-
Dynamic table name in FROM clause of an abap native sql statement
Hi Frenz,
Kindly help me with the solution. Thank you.
data: tabname type string.
tabname = 'CRMD_ORDERADM_H'.
EXEC SQL.
SELECT count( * )
FROM tabname into :count
ENDEXEC.
This piece of the code is giving me a dump. Kindly let me know how can i use tabname in this context. It is a parameter on the selection screen.
Thank you,
Kamal
Edited by: Rob Burbank on May 20, 2009 10:02 AMHi
try using ( )
EXEC SQL.
SELECT count( * )
FROM ( tabname ) into :count
ENDEXEC.
hope this helps!
haven't tested it in from section but it worked for me in where section
regards jacko
Edited by: Jacko1986 on May 20, 2009 3:55 PM -
I am sure some of you will laugh lol, but I am drawing a blank and need some assistance if anyone is willing to help:
I have this query:
SELECT DISTINCT ID
FROM (SELECT productcode
FROM sforce_product2
WHERE productcode NOT LIKE 'DSXXX%'
AND productcode NOT LIKE 'DO NOT USE%'
AND productcode NOT LIKE 'MAXXXX%'
AND isactive = 'true'
MINUS
SELECT productcode
FROM vew_product_export) a,
sforce_product2
WHERE a.productcode = sforce_product2.productcode
which returns 112 ID's (which is wrong)
The inner SELECT statement:
SELECT productcode
FROM sforce_product2
WHERE productcode NOT LIKE 'DSXXX%'
AND productcode NOT LIKE 'DO NOT USE%'
AND productcode NOT LIKE 'MAXXXX%'
AND isactive = 'true'
MINUS
SELECT productcode
FROM vew_product_export
returns 106.
Am I doing something simple wrong or is my query just mangled!
TIA,
MikeSELECT DISTINCT ID
FROM (SELECT productcode
FROM sforce_product2
WHERE productcode NOT LIKE 'DSXXX%'
AND productcode NOT LIKE 'DO NOT USE%'
AND productcode NOT LIKE 'MAXXXX%'
AND isactive = 'true'
MINUS
SELECT productcode
FROM vew_product_export) a,
sforce_product2
WHERE a.productcode = sforce_product2.productcodethe above code is returning an ID column which i think most probable from the sforce_product2 table
while this query below returns the 106 value that is coming from the column productcode.
SELECT productcode
FROM sforce_product2
WHERE productcode NOT LIKE 'DSXXX%'
AND productcode NOT LIKE 'DO NOT USE%'
AND productcode NOT LIKE 'MAXXXX%'
AND isactive = 'true'
MINUS
SELECT productcode
FROM vew_product_exportso i think there is nothing wrong because if you will review the 112 is from the column ID while the 106 is from the column productcode. -
Simple SQl statement help needed!!!
New to SQL..Please can you advice where is the problem..
select file_id, a.file_name, a.sum(bytes/1024/1024) Used_space, b.sum(bytes/1024
/1024) Free_space from dba_data_files a, dba_free_space b where tablespace_name
='DATA_TS' OR tablespace_name='INDEX_TS' OR tablespace_name='LOB_TS' group by fi
le_id
ERROR at line 1:
ORA-00918: column ambiguously defined
Thanks!Hi,
Should you chose to format your SQL the problem is easily seen:
SQL>select file_id
2 ,a.file_name
3 ,a.sum(bytes / 1024 / 1024) used_space
4 ,b.sum(bytes / 1024 / 1024) free_space
5 from dba_data_files a, dba_free_space b
6 where tablespace_name = 'DATA_TS'
7 or tablespace_name = 'INDEX_TS'
8 or tablespace_name = 'LOB_TS'
9 group by file_id;
group by file_id
ERROR at line 9:
ORA-00918: column ambiguously defined
SQL>So, which file_id do you want - a or b?
Regards
Peter -
Native sql DBCO, CONNECT statement short dump
Hi ALL ,
I am facing the problem here. please help me out in this.
i am trying to connce to the external database MSS, i made all the entries in the DBCO t-code and writing the follwoing native sql statement.
EXEC SQL.
CONNECT TO 'AAJ' AS 'V'
ENDEXEC.
EXEC SQL.
SET CONNECTION 'V'
ENDEXEC.
The above statement is not giving any error when i activate it but when i execute it is giving me shortdump error .
I already maintan entries in DBCON table or DBCO t-code
And also tel me once it is connect how can i access the data from MSS (Microsoft sql server)i mean what kind of statement.
helpfull answer will be rewarded.
Anees
9886358645
Message was edited by:
anees jawadNative SQL
Open SQL allows you to access database tables declared in the ABAP Dictionary regardless of the database platform that you R/3 System is 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 administered by the ABAP Dictionary, and therefore integrate data that is not part of the R/3 System.
As a rule, an ABAP program containing database-specific SQL statements will not run under different database systems. If your program will be used on more than one database platform, only use Open SQL statements.
Native SQL Statements in ABAP Programs
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 )
The parameters are separated by commas. You must also specify whether the parameter is for input (IN), output (OUT) or input and output (INOUT). For further information, refer to SAP Note 44977.
EXEC SQL
EXECUTE PROCEDURE proc1 ( IN , OUT :y )
ENDEXEC.
Cursor Processing
Cursor processing in Native SQL is similar to that in Open SQL:
OPEN
ENDIF.
ENDDO.
EXEC SQL.
CLOSE c1
ENDEXEC.
This example opens a cursor, reads data line by line, and closes the cursor again. As in Open SQL, SY-SUBRC indicates whether a line could be read.
Data Types and Conversions
Using Native SQL, you can
Transfer values from ABAP fields to the database
Read data from the database and process it in ABAP programs.
Native SQL works without the administrative data about database tables stored in the ABAP Dictionary. Consequently, it cannot perform all of the consistency checks used in Open SQL. This places a larger degree of responsibility on application developers to work with ABAP fields of the correct type. You should always ensure that the ABAP data type and the type of the database column are identical.
If the database table is not defined in the ABAP Dictionary, you cannot refer directly to its data type. In this case, you should create a uniform type description in the ABAP Dictionary, which can then be used by all application programs.
If the table is defined in the ABAP Dictionary, you should remember that the sequence of fields in the ABAP Dictionary definition may not be the same as the actual sequence of fields in the database. Using the asterisk (*) in the SELECT clause to read all columns into a corresponding work area would lead to meaningless results. In the worst case, it would cause an error.
The Native SQL module of the database interface passes a description of the type, size, and memory location of the ABAP fields used to the database system. The relevant database system operations are usually used to access and convert the data. You can find details of these operations in the manuals for the programming interface of the relevant database system. In some cases, Native SQL also performs other compatibility checks.
The documentation from the various database manufacturers provides detailed lists of combinations of ABAP data types and database column types, both for storing ABAP field values in database tables (INSERT, UPDATE) and for reading database contents into ABAP fields (SELECT). You can also apply these descriptions for the input and output parameters of database procedures. Any combinations not listed there are undefined, and should not be used.
The following sections provide details of the data types and conversions for individual databases. Although they are database-specific, there are also some common features.
Recommended type combinations are underlined. Only for these combinations is behavior guaranteed from release to release. For any other combinations, you should assume that the description only applies to the specified release.
The results of conversions are listed in a results column:
"OK": The conversion can be performed without loss of data.
Operations that fail are indicated by their SQL error code. Errors of this kind always lead to program termination and an ABAP short dump.
In some cases, data is transferred without an SQL error occurring. However, the data is truncated, rounded, or otherwise unusable:
Right truncation.
"Left" or "right" applies to the normal way of writing a value. So, for example, if a number is truncated, its decimal places are affected.
: Left truncation
: Number is rounded up or down during conversion
: A number that was "too small" is rounded to 0 (underflow)
: The conversion result is undefined.
There are several possible results. The concrete result is either not known at all, or can only be described using a set of rules that is too complicated for practical use.
: The conversion returns the SQL value NULL.
: The conversion is performed without fields and unchecked.
The original data is converted, but without its format being checked. The result may therefore be a value invalid for the result type, which cannot be processed further. An example of this is a date field containing the value "99999999" or "abcdefgh" after conversion.
Combinations of ABAP data type and database column type can be divided into finer subcategories. Here, for example, using the transfer direction ABAP ® database (INSERT, UPDATE):
If the width of the ABAP field is greater than that of the database column, the ABAP field may contain values for which there is not enough space in the database column. This can produce other cases: The concrete data value in ABAP finds space in the database column, or not.
If the ABAP field is at most as long as the database column, there is always space for the ABAP value in the database column.
Some types, such as numeric columns, expect values in a particular format. This is particularly important in connection with character types, for example, when you want to write an ABAP character field (type C) into an integer column.
Native SQL for Oracle
Native SQL for Informix
Native SQL for DB2 Common Server
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/content.htm -
ABAP Standards for a SQL statement
Hi,
I have a Native SQL statement in my ABAP user exit, pls. edit into a Open SQL,
SELECT v1~tknum v1~tsnum
INTO TABLE t_vtts
FROM vtts AS v1
FOR ALL ENTRIES IN t_shipment_del
WHERE v1~tknum = t_shipment_del-tknum AND
v1~vstel = rv_shppt AND
v1~kunnz = rv_shipto AND
v1~tsrfo = c_one AND
EXISTS ( SELECT addrnumber
FROM adrc CLIENT SPECIFIED
WHERE client = v1~mandt AND
addrnumber = v1~adrnz AND
date_from <= sy-datum AND
date_to >= sy-datum AND
post_code1 = rv_post_code1 ).
Thank youHhmm, for proper performance analysis we'd need some further details. Looking at your query I doubt that the following alternative helps, but you can give it a try, because subqueries are not always optimal:
SELECT tknum tsnum INTO TABLE t_vtts
FROM vtts INNER JOIN adrc ON
vtts~adrnz = adrc~addrnumber
FOR ALL entries IN t_shipment_del
WHERE tknum = t_shipment_del-tknum AND
vstel = rv_shppt AND
kunnz = rv_shipto AND
tsrfo = c_one AND
post_code1 = rv_post_code1.
You might need to add the condition on the address dates, but in any system I've checked so far, the ADRC-FROM date was always 00010101 and there was only one entry per address number (so if required, add it back).
For performance tuning requests you should try to provide some background information, like:
<ol>
<li>How many entries are you your table T_SHIPMENT_DEL</li>
<li>How many entries match your conditions on VTTS</li>
<li>How many entries get dropped because of the condition on postal code</li>
<li>Do a SQL trace and provide information about the execution plan chosen by the database</li>
</ol>
Also, you might want to consider moving your question to the forum.
Cheers, harald -
Alternative for EXEC command(Native SQL)
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.
ImmediateIn 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 -
Error in Native SQL..
Hello,
I am getting the below error while executing Native SQL statements.
Runtime Errors DBIF_DSQL2_SQL_ERROR
Except. CX_SY_NATIVE_SQL_ERROR
Short text
An SQL error occurred when executing Native SQL.
What happened?
The error 903 occurred in the current database connection "XXXXX".
Below is the code which we are working on..
EXEC SQL.
connect to :'XXXXX'----
>>Logical Connection name.
ENDEXEC.
EXEC SQL.
OPEN s_cursor FOR SELECT (S_S_IF-T_FIELDS)
FROM SAP_BW_FP_EXTRACT_VIEW.----
>>Oracle table/view name
ENDEXEC.
EXEC SQL.
FETCH NEXT s_cursor----
>>Getting Error at this line.
INTO :wa_et_data-FACT_TYPE_CODE,
:wa_et_data-FISCAL_YEAR_PERI,
:wa_et_data-PROD_FPC_ID,
:wa_et_data-GEO_ID,
:wa_et_data-LEGAL_ENT_ID,
:wa_et_data-PROFT_CTR_ID,
:wa_et_data-COMP_VOL_STAT_UN
ENDEXEC.
EXEC SQL.
CLOSE S_CURSOR.
ENDEXEC.
Any ideas where I am making a mistake, is it a syntax issue, or is it a Authorization issue, or something else..Please help..
Your Inputs will be appreciated....Ishdeep,
Firstly, you should paste the code straight from your program without modifying it. That way, we can see what exactly the syntax error is. Also, use code tags and help us.
I think the problem is in your code at this line:
FROM SAP_BW_FP_EXTRACT_VIEW.
You should not use period (full stop) after the SQL statement when using native SQL.
Secondly, you should ALWAYS check the return code (using IF SY-SUBRC NE 0); you would have caught the problem yourself.
EXEC SQL.
OPEN s_cursor FOR SELECT (S_S_IF-T_FIELDS)
FROM SAP_BW_FP_EXTRACT_VIEW.
ENDEXEC.
IF sy-subrc NE 0.
WRITE: / 'Something is wrong.'.
EXIT.
ENDIF.
Finally, I don't think you can supply a list of fields dynamically in native SQL. Double check that.
OPEN s_cursor FOR SELECT (S_S_IF-T_FIELDS)
Edited by: Sudhi Karkada on Feb 25, 2011 9:51 PM
Maybe you are looking for
-
Concatenation error - when i use text column value in where condition.
Hi, i am creating Materialized view using few columns from two tables and as per requirement i need to prepare select statement with where condition in another column.(new column) i tried like below.... create materialized view MAIN refresh force on
-
Same as in title.
-
Question about modify statement
Hi, when i try to use modify i have this error the type of the database table and workarea (or internal table) are not unicode convertible. modify /BIC/AZARDS05800 from table resultado_mod. thanks. <b><REMOVED BY MODERATOR></b> Message was edited by:
-
Moving iPhone to new apple ID.
We have a son going to college, and we want to put his iphone on his own apple ID. It is currently connected with my apple ID and iCloud account. How can we transfer it?
-
How to convert Oracle Queries into SQLite Queries
Hi.. Is it possible to convert Oracle Sql queries into SQLite queries using java ? Regards, Ajay