How to compare dates in a select query in open sql
Hi
How can I retrieve data pertaining to a specified date using a select query.
I have inserted date using the following code:
String dateString = "2009-03-11";
java.sql.Date date = java.sql.Date.valueOf(dateString);
PreparedStatement stmt =con.prepareStatement("insert into DATEACCESS"
+ "(DATETEST)"
+ "values (?)");
stmt.setDate(1,date);
stmt.executeUpdate();
How can I pass this in a select query,the below mentioned query did not fetch me any results.
Select * from DATEACCESS where DATETEST='2009-03-11'
Hi
Has ur date problem resolved ?
If not resolved u can do the following
As u already have sql date today declared . You want to get the data depending on that date
As ur query is
if( today != null)
String query2 = select * from DATEACCESS where DATETEST<= ?
PreparedStatement ps = conn.prepareStatement(query2);
ps.setDate(1,today)
ResultSet rs = ps.executeQuery();
While(rs.next)
////// Here u will get data from query u needed ///
If this also does not work just print the date and check in which format is it returning u .
Regards
Anuradha Rao
Edited by: Anuradha Rao on Mar 20, 2009 10:16 AM
Similar Messages
-
How to compare date which is greatest date
iam new to sql
how to compare date which date is greatest date with example
can i use to_char to compare date
SELECT eno, ename, GREATEST (TBLE.MAX1, TBLE.MAX2) recent_date "
FROM (SELECT TBLA.eno, TBLA.ename, "
MAX (TO_CHAR (TBL.date1, 'MM/DD/YYYY HH24:MI') "
) MAX1, "
MAX (TO_CHAR (TBL.date2, 'MM/DD/YYYY HH24:MI') "
) MAX2 "
FROM dual TBL, dual2 TBLA
in above query if any one of the date having null value then recent_date is showing 'null'
and also it showing wrong value
example
date1='08-22-2009' and date2='01-23-2010' then it showing wrong recent_datel ike='08-22-2009'
as according my knowledge it is comparing with month it sholud not be like this wat i have to do pls explain with example my o/p should come for recent_date like =''01-23-2010''
Edited by: user9112274 on Aug 27, 2010 5:31 AMHi,
there are numerous ways to compare dates, i give you some examples:
with data_Sample as
(select to_date('01-jan-2001','dd-mon-yyyy') d1, to_date('01-mar-2002','dd-mon-yyyy') d2, to_date('03-feb-2002','dd-mon-yyyy') d3 from dual)
select greatest(d1,d2,d3) from data_Sample
GREATEST(D1,D2,D3)
3/1/2002
with data_Sample as
(select to_date('01-jan-2001','dd-mon-yyyy') d1 from dual union all
select to_date('01-mar-2002','dd-mon-yyyy') from dual union all
select to_date('03-feb-2002','dd-mon-yyyy') from dual)
select max(d1) from data_Sample
MAX(D1)
3/1/2002
declare
d1 date :=to_date('01-jan-2001','dd-mon-yyyy');
d2 date :=to_date('01-jan-2001','dd-mon-yyyy');
begin
if d1>d2 then
dbms_output.PUT_LINE('d1 greater than d2');
else
dbms_output.PUT_LINE('d1 less or equql than d2');
end if;
end;
output:
d1 less or equal than d2now concerning your question:
>
can i use to_char to compare date
>
If you have date data types : don't convert them.
if you have no choice, use something like:
if to_char(d1,'YYYYMMDD') > to_char(d2,'YYYYMMDD') then
else
end if;Take care when you convert a date into a char format it becomes string comparison (with all it implies) (It's the reason why i've use an explicit mask format). -
How describe model data and get select in DB throw topLink.
Hello,
I have table from code
create table t_tree
id int primary key,
parent_id int,
value varchar2(255)
Alter table t_tree
add constraint constr_id_parent foreign key (parent_id) references t_tree (id)
I must get query
select level as lv,lpad('-@-', (level-1)*2)||value as MMM, t.* from t_tree t
connect by prior id=parent_id
start with T.PARENT_ID is null
How describe model data and get select in DB throw topLink.
Dema.So you'll probably have to write a function which uses dynamic SQL to retrieve the desired message text, like this untested one:
CREATE OR REPLACE FUNCTION get_msg(p_db IN VARCHAR2,
p_id IN NUMBER)
RETURN VARCHAR2
IS
msg_txt VARCHAR2(4000);
BEGIN
-- make sure p_db is a valid database link ...
EXECUTE IMMEDIATE 'SELECT d_msg FROM msg@' || p_db || ' WHERE t_id = :id' INTO msg_txt USING p_id;
RETURN msg_txt;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN NULL;
END get_msg;
/The you can update likeUPDATE mex
SET t_msg = get_msg(db_id, t_id);Hth, Urs -
How to compare date and time together
Hi,
How to compare Date and Time together?
For example in a database table there are two fields rundate and runtime. I want to compare these two with perticular date and time in the program. Like, I want to pull all the records where the records's date and time are less than a perticular date and time in the program.
Hope the question is clear...
Thanks.
KavitaHi Kavita
There is no as such Date and Time Comparision FM in Standard SAP But You can define your own like this
<b>FUNCTION ZAV4_COMPAREDATETIME.
""Lokale Schnittstelle:
*" IMPORTING
*" REFERENCE(DATE1) TYPE DATS
*" REFERENCE(TIME1) TYPE TIMS
*" REFERENCE(DATE2) TYPE DATS
*" REFERENCE(TIME2) TYPE TIMS
*" EXPORTING
*" VALUE(TWOISMORETOPICAL) TYPE C
twoismoretopical = ''.
if date2 > date1.
twoismoretopical = 'X'.
else.
if date2 = date1 and time2 > time1.
twoismoretopical = 'X'.
endif.
endif.
ENDFUNCTION.</b>
Regards
Mithlesh -
How to change date format in select-option (mm.yyyy).
Hi,
Plz, How to change date format in select-option (mm.yyyy).
in my selection screen date type selection-option is there ,when i am enter date it's taken dd.mm.yyyy format,but i want mm.yyyy format.
how to set that .
Regards,
Kk.sorry
parameters : pmonyr type spmon or
select-options : sspmon for PGPL-spmon .
or what table ccontains spmon.
regards
shiba dutta -
How to load data into html:select using Struts ?
How to load data into <html:select> using Struts ?
I can not load an array or collection (static or dynamic data) into drop down list control by <html:select /> Struts.
please use:
<html:select >
<html:options />
</html:select >
Please help me. please detail it. thanks a lot.
Message was edited by:
tranminhmanIn order to load a collection or array of data you can use <html:select> with <html: options collection="" name=""/>
here collection attribute refers to the Arraylist or Array of data and name is the name of the Form bean.
Hope this helps...
Chaitanya V -
How to Compare Data length of staging table with base table definition
Hi,
I've two tables :staging table and base table.
I'm getting data from flatfiles into staging table, as per requirement structure of staging table and base table(length of each and every column in staging table is 25% more to dump data without any errors) are different for ex :if we've city column with varchar length 40 in staging table it has 25 in base table.Once data is dumped into staging table I want to compare actual data length of each and every column in staging table with definition of base table(data_length for each and every column from all_tab_columns) and if any column differs length I need to update the corresponding row in staging table which also has a flag called err_length.
so for this I'm using cursor c1 is select length(a.id),length(a.name)... from staging_table;
cursor c2(name varchar2) is select data_length from all_tab_columns where table_name='BASE_TABLE' and column_name=name;
But we're getting data atonce in first query whereas in second cursor I need to get each and every column and then compare with first ?
Can anyone tell me how to get desired results?
Thanks,
Mahender.This is a shot in the dark but, take a look at this example below:
SQL> DROP TABLE STAGING;
Table dropped.
SQL> DROP TABLE BASE;
Table dropped.
SQL> CREATE TABLE STAGING
2 (
3 ID NUMBER
4 , A VARCHAR2(40)
5 , B VARCHAR2(40)
6 , ERR_LENGTH VARCHAR2(1)
7 );
Table created.
SQL> CREATE TABLE BASE
2 (
3 ID NUMBER
4 , A VARCHAR2(25)
5 , B VARCHAR2(25)
6 );
Table created.
SQL> INSERT INTO STAGING VALUES (1,RPAD('X',26,'X'),RPAD('X',25,'X'),NULL);
1 row created.
SQL> INSERT INTO STAGING VALUES (2,RPAD('X',25,'X'),RPAD('X',26,'X'),NULL);
1 row created.
SQL> INSERT INTO STAGING VALUES (3,RPAD('X',25,'X'),RPAD('X',25,'X'),NULL);
1 row created.
SQL> COMMIT;
Commit complete.
SQL> SELECT * FROM STAGING;
ID A B E
1 XXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXX
2 XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX
3 XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXX
SQL> UPDATE STAGING ST
2 SET ERR_LENGTH = 'Y'
3 WHERE EXISTS
4 (
5 WITH columns_in_staging AS
6 (
7 /* Retrieve all the columns names for the staging table with the exception of the primary key column
8 * and order them alphabetically.
9 */
10 SELECT COLUMN_NAME
11 , ROW_NUMBER() OVER (ORDER BY COLUMN_NAME) RN
12 FROM ALL_TAB_COLUMNS
13 WHERE TABLE_NAME='STAGING'
14 AND COLUMN_NAME != 'ID'
15 ORDER BY 1
16 ), staging_unpivot AS
17 (
18 /* Using the columns_in_staging above UNPIVOT the result set so you get a record for each COLUMN value
19 * for each record. The DECODE performs the unpivot and it works if the decode specifies the columns
20 * in the same order as the ROW_NUMBER() function in columns_in_staging
21 */
22 SELECT ID
23 , COLUMN_NAME
24 , DECODE
25 (
26 RN
27 , 1,A
28 , 2,B
29 ) AS VAL
30 FROM STAGING
31 CROSS JOIN COLUMNS_IN_STAGING
32 )
33 /* Only return IDs for records that have at least one column value that exceeds the length. */
34 SELECT ID
35 FROM
36 (
37 /* Join the unpivoted staging table to the ALL_TAB_COLUMNS table on the column names. Here we perform
38 * the check to see if there are any differences in the length if so set a flag.
39 */
40 SELECT STAGING_UNPIVOT.ID
41 , (CASE WHEN ATC.DATA_LENGTH < LENGTH(STAGING_UNPIVOT.VAL) THEN 'Y' END) AS ERR_LENGTH_A
42 , (CASE WHEN ATC.DATA_LENGTH < LENGTH(STAGING_UNPIVOT.VAL) THEN 'Y' END) AS ERR_LENGTH_B
43 FROM STAGING_UNPIVOT
44 JOIN ALL_TAB_COLUMNS ATC ON ATC.COLUMN_NAME = STAGING_UNPIVOT.COLUMN_NAME
45 WHERE ATC.TABLE_NAME='BASE'
46 ) A
47 WHERE COALESCE(ERR_LENGTH_A,ERR_LENGTH_B) IS NOT NULL
48 AND ST.ID = A.ID
49 )
50 /
2 rows updated.
SQL> SELECT * FROM STAGING;
ID A B E
1 XXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXX Y
2 XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX Y
3 XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXHopefully the comments make sense. If you have any questions please let me know.
This assumes the column names are the same between the staging and base tables. In addition as you add more columns to this table you'll have to add more CASE statements to check the length and update the COALESCE check as necessary.
Thanks! -
How to re-write this big SELECT Query with INNER JOINs?
Hi Experts
I have a performance killer SELECT query with an inner join of 3 tables u2013 VBAP, VBAK and VBEP together, which populates records to an internal table INT_COLL_ORD. Based on these records selected, in another SELECT query, records are fetched from VBUK table to the internal table INT_VBUK.
SELECT A~VBELN A~POSNR A~MATNR A~KWMENG A~KBMENG A~ERDAT A~ERZET A~PSTYV D~AUART E~ETTYP E~EDATU
INTO TABLE INT_TAB_RES
FROM VBAP AS A INNER JOIN VBAK AS D
ON D~VBELN EQ A~VBELN AND D~MANDT EQ A~MANDT
INNER JOIN VBEP AS E
ON E~VBELN EQ A~VBELN AND E~POSNR EQ A~POSNR AND E~MANDT EQ A~MANDT
WHERE A~VBELN IN s_VBELN AND
D~auart in s_auart AND
D~vkorg in s_vkorg AND
D~vbtyp eq 'C' AND
( ( matnr LIKE c_prefix_sp AND zz_msposnr NE 0 AND kbmeng EQ 0 )
OR ( matnr LIKE c_prefix_fp AND kwmeng NE A~kbmeng ) ) AND
A~ABGRU EQ SPACE AND
A~MTVFP IN R_MTVFP AND
A~PRCTR IN R_PRCT AND
E~ETENR EQ '1'.
SORT INT_COLL_ORD BY VBELN POSNR ETTYP.
DELETE ADJACENT DUPLICATES FROM INT_TAB_RES COMPARING VBELN POSNR.
CHECK NOT INT_TAB_RES [] IS INITIAL.
SELECT VBELN UVALL CMGST INTO TABLE INT_VBUK
FROM VBUK FOR ALL ENTRIES IN INT_TAB_RES
WHERE VBELN = INT_TAB_RES-VBELN AND UVALL NE 'A'.
Now, the requirement is:
I want to split this query. Like, first join VBAK and VBUK first. With this selection, go to the inner join of VBAP and VBEP (on key VBELN) to get the results. How can I re-write this Query?
Please help.
Thx n RgdsHi Nagraj
As of your suggestion, I have re-written the query as below:
* Declarations
TYPES: BEGIN OF TYP_COLL_ORD,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBUP-POSNR,
MATNR LIKE VBAP-MATNR,
KWMENG LIKE VBAP-KWMENG,
KBMENG LIKE VBAP-KBMENG,
ERDAT LIKE VBAK-ERDAT,
ERZET LIKE VBAK-ERZET,
PSTYV LIKE VBAP-PSTYV,
AUART LIKE VBAK-AUART, u201Calready exists in type
ETTYP LIKE VBEP-ETTYP,
EDATU LIKE VBEP-EDATU.
TYPES: END OF TYP_COLL_ORD.
DATA: INT_COLL_ORD TYPE TABLE OF TYP_COLL_ORD WITH HEADER LINE.
TYPES: BEGIN OF TYP_VBUK,
AUART LIKE VBAK-AUART, u201Chave added this field
VBELN LIKE VBUK-VBELN,
UVALL LIKE VBUK-UVALL,
CMGST LIKE VBUK-CMGST.
TYPES: END OF TYP_VBUK.
DATA: INT_VBUK TYPE TABLE OF TYP_VBUK WITH HEADER LINE.
*QUERY#1 u2013 for VBAK & VBUK Join
SELECT A~AUART B~VBELN B~UVALL B~CMGST
INTO TABLE INT_VBUK
FROM VBAK AS A INNER JOIN VBUK AS B
ON A~VBELN EQ B~VBELN
WHERE A~VBELN IN s_VBELN AND
A~auart in s_auart AND
A~vkorg in s_vkorg AND
A~vbtyp eq 'C' AND
B~UVALL NE 'A'.
IF NOT INT_VBUK[] IS INITIAL.
SORT INT_VBUK BY VBELN.
DELETE ADJACENT DUPLICATES FROM INT_VBUK COMPARING VBELN.
*QUERY#2 u2013 for VBAP & VBEP Join
SELECT A~VBELN A~POSNR A~MATNR A~KWMENG A~KBMENG A~ERDAT A~ERZET A~PSTYV B~ETTYP B~EDATU
INTO TABLE INT_COLL_ORD
FROM VBAP AS A INNER JOIN VBEP AS B
ON B~VBELN EQ A~VBELN AND B~POSNR EQ A~POSNR AND B~MANDT EQ A~MANDT
FOR ALL ENTRIES IN INT_VBUK
WHERE A~VBELN = INT_VBUK-VBELN AND
( ( matnr LIKE c_prefix_sp AND zz_msposnr NE 0 AND kbmeng EQ 0 )
OR ( matnr LIKE c_prefix_fp AND kwmeng NE A~kbmeng ) ) AND
A~ABGRU EQ SPACE AND
A~MTVFP IN R_MTVFP AND
A~PRCTR IN R_PRCT AND
B~ETENR EQ '1'.
ENDIF.
SORT INT_COLL_ORD BY VBELN POSNR ETTYP.
DELETE ADJACENT DUPLICATES FROM INT_COLL_ORD
COMPARING VBELN POSNR.
CHECK NOT INT_COLL_ORD[] IS INITIAL.
LOOP AT INT_COLL_ORD.
CLEAR: L_MTART,L_ATPPR,L_ETTYP.
IF L_PREVIOUS_ETTYP NE INT_COLL_ORD-ETTYP OR
L_PREVIOUS_AUART NE INT_COLL_ORD-AUART.
READ TABLE INT_OVRCTL WITH KEY AUART = INT_COLL_ORD-AUART ETTYP = INT_COLL_ORD-ETTYP.
CHECK SY-SUBRC NE 0.
Now, the issue is:
Please note that declaration for INT_COLL_ORD has a field AUART, which is used in further parts of program (see the statement just above)
But, since neither VBAP nor VBEP contains AUART field, it cannot be fetched through the QUERY#2. So this value is not populated into INT_COLL_ORD through SELECT Query.
Since this field is used in later part of program & that the internal table has no value for this field, it dumps!!
How to include this value into the INT_COLL_ORD?
Plz suggest.... -
How can i use index in select query.. facing problem with the select query.
Hi Friends,
I am facing a serious problem in one of the select query. It is taking a lot of time to fetch data in Production Scenario.
Here is the query:
SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
FROM ztftelat LEFT JOIN ztfzberep
ON ztfzberep~gjahr = st_input-gjahr
AND ztfzberep~poper = st_input-poper
AND ztfzberepcntr = ztftelatrprctr
WHERE rldnr = c_telstra_accounting
AND rrcty = c_actual
AND rvers = c_ver_001
AND rbukrs = st_input-bukrs
AND racct = st_input-saknr
AND ryear = st_input-gjahr
And rzzlstar in r_lstar
AND rpmax = c_max_period.
There are 5 indices present for Table ZTFTELAT.
Indices of ZTFTELAT:
Name Description
0 Primary key( RCLNT,RLDNR,RRCTY,RVERS,RYEAR,ROBJNR,SOBJNR,RTCUR,RUNIT,DRCRK,RPMAX)
005 Profit (RCLNT,RPRCTR)
1 Ledger, company code, account (RLDNR,RBUKRS, RACCT)
2 Ledger, company code, cost center (RLDNR, RBUKRS,RCNTR)
3 Account, cost center (RACCT,RCNTR)
4 RCLNT/RLDNR/RRCTY/RVERS/RYEAR/RZZAUFNR
Z01 Activity Type, Account (RZZLSTAR,RACCT)
Z02 RYEAR-RBUKRS- RZZZBER-RLDNR
Can anyone help me out why it is taking so much time and how we can reduce it ? and also tell me if I want to use index number 1 then how can I use?
Thanks in advance.Hi Shiva,
I am using two more select queries with the same manner ....
here are the other two select query :
***************1************************
SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
FROM ztftelpt LEFT JOIN ztfzberep
ON ztfzberep~gjahr = st_input-gjahr
AND ztfzberep~poper = st_input-poper
AND ztfzberepcntr = ztftelptrprctr
WHERE rldnr = c_telstra_projects
AND rrcty = c_actual
AND rvers = c_ver_001
AND rbukrs = st_input-bukrs
AND racct = st_input-saknr
AND ryear = st_input-gjahr
and rzzlstar in r_lstar
AND rpmax = c_max_period.
and the second one is
*************************2************************
SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
FROM ztftelnt LEFT JOIN ztfzberep
ON ztfzberep~gjahr = st_input-gjahr
AND ztfzberep~poper = st_input-poper
AND ztfzberepcntr = ztftelntrprctr
WHERE rldnr = c_telstra_networks
AND rrcty = c_actual
AND rvers = c_ver_001
AND rbukrs = st_input-bukrs
AND racct = st_input-saknr
AND ryear = st_input-gjahr
and rzzlstar in r_lstar
AND rpmax = c_max_period.
for both the above table program is taking very less time .... although both the table used in above queries have similar amount of data. And i can not remove the APPENDING CORRESPONDING. because i have to append the data after fetching from the tables. if i will not use it will delete all the data fetched earlier.
Thanks on advanced......
Sourabh -
Table_comparison - how to compare data at a high level
Hi,
I have to do data validation at a high level between two tables that I am loading.
I am trying to use table_comparion transform but the problem is that my target table is at a much lower level than at which I want to compare data. So it has many more columns (both key and data fields) than what I want to compare.
Does the output of query transform ( which I am using as input into table_comparion) be in the exact same format as comparion table? If not, then can somebody suggest me something else.
Or how can I compare output of two query transforms ?
Thanks,
Saurabh BansalDear Saurabh,
Not sure if you have already got the solution to this. If yes please close the thread.
If not, i would suggest you can use the validation rule to compare the two tables and then based on the PASS or FAIL result can check what needs to be done on the output.
Do post back if you have got the solution or you need any furthur help or else close the question.
regards,
Den -
How to compare Date in the TextField or DateTime with Date/Time field?
Hi All,
I am facing an issue with respect Date comparinson. I tried to look into entire discussions but failed to get the answer.
My issue is: I wanted to comparet Date/time field value with Date value which is in TextField.
The functionality of my form is:
I have dropdown list which lists the registered customer ids binded to XML Datasource. On selection of the customer id from the dropdown I am displaying customer registration date in the TextField or say Date/Time field as below code in dropdown change event.
RegistrationDetails.PurchaseEntry.txtRegDate.rawValue = regDataNode.CREATION_DATE.value; (this is TextField control)
In form I have an Date/Time field in which use will select the date of item purchase. In the validation part I want to make sure that, the purchase date selected in Date/Time field must be greater than the Customer Registraiton Date. I able to compare if the customer selects the date from two different Date/Time fields. But how to compare the dates which one is in Date/Time field and Date is in TextField?
I have tried using Num2Date and Date2Num with "YYYY-MM-DD" format to compare but not succeed!
Can you guys help me in this? Thanks in advance
Regards.Hi,
Yes, I am able to display the date which I have assigned to the text box. In the message box it show the value as '31/05/2009', since in this format i am assigining the date in the text box.
Here is the code which I am assigning the value:
RegistrationDetails.PurchaseEntry.txtRegDate.rawValue = regDataNode.CREATION_DATE.value;
Do I need to change the format while assigning value in text box?
You have told that, you have attached your test form, nothing is the reply. Can you repost the file?
Regards. -
How to assign table name for select query in loop.
Hi friends my requirement is count the no of records of all the database table which comes into an internal table ."Check the below coding". Iam fetching the tables from dd03l table into an internal table .plz give me a sujjesion how to assign a table name in select query in a loop.
SELECT tabname FROM dd09l
INTO TABLE i_dd09l
WHERE protokoll = 'X'.
IF sy-subrc = 0.
SORT i_dd09l BY tabname.
ENDIF.
LOOP AT i_dd09l.
SELECT COUNT(*) INTO val FROM i_dd09l-tabname.
IF sy-subrc = 0.
i_dd09l-count = val.
ENDIF.
MODIFY i_dd09l INDEX sy-index.
CLEAR val.
ENDLOOP.
error : 'I_DD09L-TABNAME' is not defined in the abap dictionary as a table.data: dy_table type ref to data,
dy_line type ref to data,
xfc type lvc_s_fcat,
ifc type lvc_t_fcat,
dy_field type ref to data.
LOOP AT i_dd09l.
perform get_structure using i_dd09l-tabname .
CREATE DATA dy_table TYPE TABLE OF (_dd09l-tab_name).
UNASSIGN <dyn_table>.
ASSIGN dy_table->* TO <dyn_table>.
SELECT COUNT(*) INTO val FROM <dyn_table>.
IF sy-subrc = 0.
i_dd09l-count = val.
ENDIF.
MODIFY i_dd09l INDEX sy-index.
CLEAR val.
ENDLOOP.
form get_structure using p_table.
data : idetails type abap_compdescr_tab,
xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails = ref_table_des->components.
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
endform. "get_structure
Try like this hope it will work.
Regards,
madan. -
How to compare dates between two items
Hello all,
I am trying to compare dates in two items.
The first item is a computation P45_PAGE_LOADED_TIME
select sysdate from dual;
This essentially keeps track of when the user opened the form. They are accessing data that may become obsolete while they are in the form.
So we have a dynamic action that finds the last_update date from a table. This field is of type date. It is placed in a text field called P45_STATUS.
We then have a notification which we want to fire when P45_PAGE_LOADED_TIME is before P45_STATUS. We tried the following condition
declare
least_date date;
begin
SELECT LEAST(TO_DATE(:P45_STATUS),TO_DATE(:P45_PAGE_LOADED_TIME)) into least_date
from dual;
if least_date = to_date(:P45_STATUS) then
return false;
else
return true;
end if;
end;
Any guidance would be most appreciated.
ThanksMaybe your better off putting your anonymous block into a plsql function.
A function that you can test. If it works in plsql then you must call it in APEX.
I kinda get a headache when I see that least, to_date, to_date query (although I've seen worse :p)
Make it like:
create or replace function fun_least_date(in_status in varchar2,
in_page_loaded_time varchar2) return boolean
is
l_status date;
l_page_loaded_time date;
least_date date;
l_return boolean;
begin
l_status := to_date(in_status, 'FORMAT MASK!!!');
l_page_loaded_time := to_date(in_page_loaded_time, 'FORMAT MASK!!!!');
least_date := least(l_status, l_page_loaded_time);
if least_date = l_status then
l_return := false;
else
l_return := true;
end if;
return l_return
end fun_least_date;If your sure that your function is correct then use it as a condition for your dynamic action.
Regards
Nico
ps: I haven't tested that function. Be aware that you most correctly enter the format mask you use in APEX. Also before APEX may know about these variables you should set a dynamic action on your items to always submit their value to the server when they change!!! -
How to formulate where clause in select query at runtime..??
I am facing a problem..
I have to generate a select query during runtime..For Ex: when user selects a row in an alv report, particular date field is to be read and another report is to be opened for that data..
I know how to make drill down report but my problem is concatenating date field...
Plz tell a solution....Hi,
Try like this....
refresh : gt_tvarvc_temp[].
gt_tvarvc_temp[] = lt_tvarvc[].
loop at gt_tvarvc_temp into gs_tvarvc_temp
where name = 'CREDIT_MEMO_DOC_TYPE'.
r_blart-sign = gs_tvarvc_temp-sign.
r_blart-option = gs_tvarvc_temp-opti.
r_blart-low = gs_tvarvc_temp-low.
append r_blart.
clear r_blart.
endloop.
concatenate 'BLART IN ' 'r_blart' into lv_condition
separated by space.
if not lv_customer_cond is initial.
if lv_condition is initial.
concatenate lv_customer_cond lv_condition
into lv_condition separated by space.
else.
concatenate lv_condition 'AND' lv_customer_cond
into lv_condition separated by space.
endif.
endif.
select bukrs belnr gjahr appending corresponding fields
of table lt_potential_credits
from bsid
where (lv_condition).
Hope its helps -
How to compare Date/time string
I read from datalog file including Date/time string ,and want to query the special Date/time string span ,how to compare the data/time string ?
Hello Joshua,
To compare date/time you have to extract the different components (day, month, year, hour, minute, second) anyway. Why not "convert to seconds"? I think it's easier to compare one number (where you also can do other math, like calc the difference and so on) than to compare seven (?) parameters with some exceptions... If the dates are read from excel (there was a similar thread some days ago), why not convert to seconds in excel (just a format change)?
Best regards,
GerdW
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome
Maybe you are looking for
-
Hello All, While doing a interim invoice, the system is generating an error "G/L account does not exist". All the G/L are maintained. Can anyone guide what the issue could be. thanx.
-
Page process throwing No data found error when deleting tabular form item
Hi guys, I am trying to run a page process just before the Tabular form's MRU process and it's throwing a no data found error. Here is my code: BEGIN for i in 1..apex_application.g_f02.count LOOP IF apex_application.g_f01(i) is no
-
Error code 6 when updating to iOS 7
Hi, I have a fairly new iPhone 4S which had behaved impeccably, bur when I came to update the iOS to 7.0, through iTunes, error code 6 was returned. I had to restore to factory settings, which gave me the new iOS and then I had to restore all apps e
-
Hi, I am using Report Generation Tool kit for my Excel Report, I want to give the Print Option to User, before printing the documents the user likes to see the Preview of the document(as option in Excel and Other Application), Is there a possibility
-
Resizing graphics frames that have stroke/keylines
When I resize a graphic frame (with a placed image in it) that has a stroke/keyline, the stroke changes weight and I have to reapply the Object Style which sets the weight. How can I keep the same weight when I resize? Also is there a way of changing