Multiple condition check using if statement.
Hi
i NEED to check two conditions using if statment. I was wondering whether it is possible.
say fields zx and zy in an internal table itab. if one of those is intiial i have to display a message.
i tried this way
if itab-zx or itab-zy is initial.
error message.
endif.
It gives me error in syntax check.
I think i can check for first field using if and second one with elseif but for that matter of fact i have like 10 fields .out of which even one is initial i have to throw a message saying 'DATA CANNOT BE SAVED'.
Please suggest me how to go about this.
Thanks in advance.
Hi Swathi,
You have to loop your internal table and then check.
Try this code.
LOOP AT itab.
IF itab-z1 IS INITIAL OR
itab-z2 IS INITIAL OR
itab-z3 IS INITIAL OR
itab-z4 IS INITIAL OR
itab-z5 IS INITIAL OR
itab-z6 IS INITIAL OR
itab-z7 IS INITIAL OR
itab-z8 IS INITIAL OR
itab-z9 IS INITIAL OR
itab-z10 IS INITIAL.
MESSAGE 'DATA CANNOT BE SAVED' TYPE 'E'.
ELSE.
" Processing if none of the fields are Initial
ENDIF.
ENDLOOP.
Regards,
Arun Sambargi.
Similar Messages
-
Multiple condition check using decode
HI All,
I have a new requirement and need your help .
need to check the follwing condidtions in a sql statement.
a) we have a status coulmn which has values like 1,2,3,4,5,6,7 based on some other coulmns . this status will keep on repeat based on values in other coulmns.
each status will update one by one. ( ie, update of status1 to status2 takes 3 min of time ) and status4 to status5 takes 10 min of time.
i need to select the rows which exceeds the above time limit.
ie )
if Time taken for (status1 to status2) change is > 3min then select that row.
and if Time taken for (status14 to status5) change is > 10min then select that row.the query will run on every 10 min,and if any of the status not changed ,
ie )
for eg), trunc( (sysdate-modifieddate)*24*60 ) > 15, we need to select those rows.
Below shows example of the data . , if you see the record3 ( which in status2)
if modidifeddate <sysdate by 15 min , that record need to be selected.
its applicable for other status also . Plz help me
paytrxkey Groupid Payref status Modifieddate
15198595 GHK02793 Q0003119 1 12/6/2006 8:49
15198673 GHK02793 Q0003120 1 12/6/2006 8:49
15275420 GSG00764 Q0007162 2 12/6/2006 8:49
15275421 GSG00764 Q0007163 1 12/6/2006 8:49
15275425 GSG00764 Q0007167 2 12/6/2006 8:49
15275427 GSG00764 Q0007169 1 12/6/2006 8:49
15310160 GHK04571 Q0000138 3 12/6/2006 9:00
15275426 GSG00764 Q0007168 1 12/6/2006 9:02
15275424 GSG00764 Q0007166 4 12/6/2006 9:02
15275423 GSG00764 Q0007165 1 12/6/2006 9:02
15275422 GSG00764 Q0007164 4 12/6/2006 9:02
15404354 GAE00099 Q0014834 1 12/6/2006 9:06 -
Conditional Filters using case statements
Hello,
I have a table view which displays Total Quota and Theatre Quota. Against the Total Quota, there are 2 values - Rollover Revenue and Theatre Revenue. Against the Theatre Quota, there is only Theatre Revenue.
What I want to accomplish is to display only the Rollover Revenue Aggregated Quarterly number whenever there is a Total Quota number and not display the Theatre Revenue number
In the table view,
Year Name Quarter Name Quarter Name Sort Person Region Quota Name Quarterly Quota Credit Amount QTD Attainment Credit Type Name
YEAR-2012 QTR-1-2012 QTR-1-2012 750 Total Quota 6,128,500 5,492,081 89.62% Rollover Revenue Aggregated Quarterly
750 6,128,500 5,344,000 87.20% Theatre Revenue
QTR-2-2012 QTR-2-2012 750 Total Quota 5,922,500 5,890,264 99.46% Rollover Revenue Aggregated Quarterly
750 5,922,500 6,120,000 103.33% Theatre Revenue
QTR-3-2012 QTR-3-2012 750 Total Quota 5,716,500 0 0.00%
QTR-4-2012 QTR-4-2012 750 Total Quota 5,510,500 0 0.00%
I used an example in the following link:
http://oraclebizint.wordpress.com/2008/02/06/oracle-bi-ee-101332-conditional-filters-using-case-statements-in-filters/
and applied the example in my scenario:
CASE WHEN Quota."Quota Name" = 'Total Quota' THEN "Credit Type"."Credit Type Name" ELSE 'Dummy' END != 'Theatre Revenue'
I still get duplicate rows.
Thanks.Could you suggest any solutions for this problem where I can conditionally hide the number only for a certain type of data and not for all type of data?
Thanks. -
Checking for the condition types using case statement
hi folks,
I have a lot of condition types that I have to check for and I am using case statement to do that. The code goes like this.
case wac-kschl.
when 'ZRAT' OR 'ZAGR' OR 'ZRCR' OR
'Y098' OR 'Y007' OR 'ZREW' OR 'Y106' OR 'ZTSR' OR 'Y127' OR 'Y125' OR 'Y126' OR 'Y124' OR 'Y157' OR 'Y092' OR 'Y085' OR 'Y090' OR 'ZMZD'
OR 'Y215' OR 'Y214' OR 'Y111' OR 'ZC$D' OR 'ZAUD'.
up till here it is working on errors and when I add few more condition types to the case statement it is throwing the error.
I have to check for all the condition types out here.
How can I correct it? Is there a better way to do it?
thanks
SanthoshHi Santhosh,
I think that your CASE statement has a flaw. The line length of one of the lines is too large. You need to insert a carriage-return to shorten it (or press the button 'Pretty Printer').
The code would look nicer like this:[code] CASE wac-kschl.
WHEN 'ZRAT' OR 'ZAGR' OR 'ZRCR' OR 'Y098' OR 'Y007' OR 'ZREW'
OR 'Y106' OR 'ZTSR' OR 'Y127' OR 'Y125' OR 'Y126' OR 'Y124'
OR 'Y157' OR 'Y092' OR 'Y085' OR 'Y090' OR 'ZMZD' OR 'Y215'
OR 'Y214' OR 'Y111' OR 'ZC$D' OR 'ZAUD' OR 'Z001' OR 'Z002'
OR 'Z003' OR 'Z004' OR 'Z005' OR 'Z006' OR 'Z007' OR 'Z008'
OR 'Z009' OR 'Z010' OR 'Z011' OR 'Z012' OR 'Z013' OR 'Z014'.
Do your thing here
WRITE: / 'OK'.
WHEN OTHERS.
WRITE: / 'NOT OK'.
ENDCASE.[/code]If this will not work for you, you could try a different approach:[code]* Local definition
DATA:
var_list(1024).
Build variable string for checking
CONCATENATE 'ZRAT ZAGR ZRCR Y098'
'Y007 ZREW Y106 ZTSR'
'Y127 Y125 Y126 Y124'
'Y157 Y092 Y085 Y090'
'ZMZD Y215 Y214 Y111'
'ZC$D ZAUD'
INTO var_list
SEPARATED BY space.
Check if the correct value is supplied
IF var_list CS wac-kschl.
Do your thing here
WRITE: / 'OK'.
ENDIF.[/code]Hope this helps you a bit.
Regards,
Rob. -
Negative Condition checking in read statement
Hi,
i have table, which i have to read, key on which i am going to read that will be determined dynamically. now i have to check the value for the key field is initial or not. i can't use a loop here as it doesn't allow me to mention where condition field dynamically.
thanks & regards,
prabhuHi use this:
DATA: BEGIN OF it OCCURS 0, "your dynamic table
field1 TYPE c,
field2 TYPE c,
END OF it.
it-field1 = '1'.
it-field2 = 'A'.
APPEND it.
it-field1 = ''.
it-field2 = 'B'.
APPEND it.
it-field1 = '2'.
it-field2 = 'C'.
APPEND it.
FIELD-SYMBOLS: <struct> TYPE ANY,
<comp> TYPE ANY.
LOOP AT it ASSIGNING <struct>. "loop at your dynamic table
ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <struct> TO <comp>. "FIELD1 is determined dynamically
IF sy-subrc = 0 AND <comp> is not initial.
WRITE <comp>. "will write out <comp> for each entry which has non initial value in <comp> (here FIELD1)
ENDIF.
ENDLOOP.
Please note that your <lfs> must hold name 'FIELD1' inside, than you can replace it with below code
ASSIGN COMPONENT <lfs> OF STRUCTURE <struct> TO <comp>.
Regards
Marcin
One thing to be added here:
You can't read table comparing its key field with negative condition NE , only comparison EQ are allowed in READ TABLE statement, that's why I chose above approach.
Edited by: Marcin Pciak on May 26, 2009 4:51 PM -
Condition Checking with " IF " statement....
Hi All,
In one of my requirement ,the existing scenario is like this: IF currency is USD, then call subroutine X
ELSE call subroutine Y. i.e if po_headers-waers = 'USD'
Perform fill_bdc_table using ' ' 'RV61A-KOEIN(01)' 'US4'.
else.
Perform fill_bdc_table using ' ' 'RV61A-KOEIN(01)' po_headers-waers .
endif.
(The above code first check if po_header currency value is 'USD' then it calls subroutine to convert the currency to US4,else it calls other subroutine to convert currency as per po_header currency value.)
Now my new requirement is : if po_header currency value is USD and po item value(po_items-netpr) is greater than '10000000.00', then call subroutine to convert it into USD, else for po_header currency value USD and po item value(po_items-netpr) is lesser than '10000000.00', call subroutine to convert into US4(as written above US4 code line).
I have inserted code for the condition like this:
if po_headers-waers = 'USD'
and po_items-netpr GE '10000000.00'.
Perform fill_bdc_table using ' ' 'RV61A-KOEIN(01)' po_headers-waers.
else.
Perform fill_bdc_table using ' ' 'RV61A-KOEIN(01)' 'US4'.
endif.
But it only satisfies one condition i.e for po_items-netpr >= '10000000.00' with currency as USD , it is converting to USD,but for po_items-netpr < '10000000.00' with currency as USD, it is not converting to US4.where i am missing the steps? can you all through some light.
Thanx.
Debhi,
Modify the code as following.
if po_headers-waers = 'USD' .
if po_items-netpr GE '10000000.00'.
Perform fill_bdc_table using ' ' 'RV61A-KOEIN(01)' po_headers-waers.
else.
Perform fill_bdc_table using ' ' 'RV61A-KOEIN(01)' 'US4'.
endif.
endif.
Regards
Sharath -
Multiple condition checking question
Hi I have a newbie question -
if ((temp == null) && (!temp.text.equals(""))) {
statement;
If temp really is null, would this give a compiler error? or would it simply break after the first condition?
Thanks,
Mikewhatsupdoc wrote:
Hi I have a newbie question -
if ((temp == null) && (!temp.text.equals(""))) {
statement;
If temp really is null, would this give a compiler error?Compile it and see.
I'm curious though what you're trying to accomplish. You seem to be confused about the meaning of &&.
or would it simply break after the first condition?&& and || are "short-circuit" operators. They stop evaluating once the truth of the operation is known. So if the first operand to && is false, it stops there and does not evaluate the second, since the result of the && must be false, regardless of what the second operand is. Likewise, if the first operand to || is true, then it doesn't evaluate the second one, because the result is true regardless. -
SCCM 2012 multiple search terms using OR statement
I have a collection of 100s of machines in SCCM 2012
I have a short list of machines that I need to add to another collection, is there any way using the search bar at the top of the collection display view to have multiple terms? I've tried commas and semi colons. These are machine names, and I cannot create
a new query or collection as the machines have no information that seperates them in SCCM, they are seperated by which building they are in, which SCCM is not aware of.To add-on, if you really want to add a list of devices the search is not really going to help you. In these case PowerShell is your friend. Have a look at this for example:
http://miketerrill.net/2013/11/03/how-to-add-computers-listed-in-a-text-file-to-a-collection/v
My Blog: http://www.petervanderwoude.nl/
Follow me on twitter: pvanderwoude -
Condition checking using the user input
hi all,
i am taking input from the user and the input is the employeeid,starttime and endtime with in the report. then i want to display the columns of some table based on these inputs. my require ment is the data realted to that employeeid and the information of that columns between the starttime and endtime must be extracted.
SELECT ALL TASK_ENTRY.TDATE,
TASK_ENTRY.T_TASK, TASK_ENTRY.SUB_TASK, TASK_ENTRY.TASK_STATUS
FROM TASK_ENTRY WHERE TASK_ENTRY.EMPID LIKE :EMPLOYEEID AND
TASK_ENTRY.START_TIME<= :STARTTIME AND TASK_ENTRY.END_TIME >= :ENDTIME
can any body clarify whether the query is right or not. if not please give me the right query.
i have written the code for bringing the data of that particular employee but i am unable to bring the data between those dates. the query what i have written is as above. can any body rectify my query.ANDTASK_ENTRY.START_TIME>= :STARTTIME AND TASK_ENTRY.END_TIME >= :ENDTIME
I think here is problem.
You must reverse it. as
AND
TASK_ENTRY.START_TIME >= :STARTTIME
AND
TASK_ENTRY.END_TIME <= :ENDTIME
Capri... -
If Statement Multiple Conditions
Using LiveCycle, FormCalc or JavaScript.
I am trying to create an if statement with multiple conditions.
a Sum field calculates a series of numeric input fields. I want the result in the Sum field to determine the expression in a final field.
If the Sum is <30MM then "50000" also if the Sum is >30MM but <60MM then "125000" also if the Sum is >60MM but <100MM then "250000" also if the Sum is >100MM but <300MM then "375000" also if the Sum is >300MM then "500000"
I have only been able to figure out a single if then for the first condition but not able to include the whole set of conditions and the multiple results.
Help would be much Appreciated!
Thank you in advance.Tried a few variations of this and still seem not
to be able to find a solution to this issue. I'm surprised my google searches are bringing up better examples because there seems to be an example of everything else.
Any more detailed advive? -
Need Help on using xdoxslt:ifelse multiple conditions
Hi Experts
I have a requirement with multiple conditions and not able to get this working e.g. if possible how to get the variable if condition then get_variable
<?xdofx: if Group='X' and Price!=0 and ItemId='' then (xdoxslt:get_variable($_XDOCTX,'Price'), ' ')
else if Group='Y' and ItemId!='' then 'Included'
else if Group='Z' and ItemId!='' then 'Included' else '' end if?>
Also I tried using xdoxslt:ifelse
<?xdoxslt:ifelse((Group='X' and (Price)!=0 and ItemId=''),
(xdoxslt:ifelse((Group='Y' and ItemId=''),Include,' ')),(xdoxslt:get_variable($_XDOCTX, 'Price'))?>
Please help it is very critical
ThanksCan you please explain a bit as to what you are trying to achieve?
for example: if Group = X and Price <>0 and ItemID is null then what are you trying to do?
You can use choose statements for your scenario.
Example:
<?choose:?>
<?when:ReportStatus='Approved' ?>
<?'Approved'?> <?end when?>
<?when:ReportStatus = 'Closed'?>
<?....?>
<?otherwise:?>
<?....?>
<?end otherwise?>
<?end choose?>
Thanks,
Bipuser -
Using Select statement in IF condition?
hi all,
Can i use select statement in IF COndition in pl sql ?
eg like- if( select 1 from ASD) then
end if;There is no way to do any kind of select statement inside if conditions.
Why don't test simple cases like this first?
An example to show it.
SQL> begin
2 if exists (select 1 from dual) then
3 dbms_output.put_line('ok');
4 end if;
5 end;
6 /
if exists (select 1 from dual) then
ERRORE alla riga 2:
ORA-06550: line 2, column 5:
PLS-00204: function or pseudo-column 'EXISTS' may be used inside a SQL
statement only
ORA-06550: line 2, column 2:
PL/SQL: Statement ignored
SQL> begin
2 if ( (select count(*) from dual) > 0 ) then
3 dbms_output.put_line('ok');
4 end if;
5 end;
6 /
if ( (select count(*) from dual) > 0 ) then
ERRORE alla riga 2:
ORA-06550: line 2, column 8:
PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( - + case mod new not null others <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall merge time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
<an alternatively-quoted string literal with character set specification>
<an alternativ
ORA-06550: line 2, column 33:
PLS-00103: Encountered the symbol ")" when expecting one of the following:
. , @ ; for <an identifier>
<a double-quoted delimited-identifier> group having intersect
minus order partition start subpartition union where connect
SQL> begin
2 if ( 0 in (select count(*) from dual) ) then
3 dbms_output.put_line('ok');
4 end if;
5 end;
6 /
if ( 0 in (select count(*) from dual) ) then
ERRORE alla riga 2:
ORA-06550: line 2, column 12:
PLS-00405: subquery not allowed in this context
ORA-06550: line 2, column 2:
PL/SQL: Statement ignoredBye Alessandro -
How can i use multiple row subquery in update statement
Hai All
I using group function in my update statement.. and i need to update more rows so i need to use multiple row
subquery pls tell me how to use multiple row subquery in update statement
For example
while i am using this like this i got an error
update dail_att set outtime in (select max(r2.ptime) from temp_att where empcode=r2.enpno and
barcode=r2.cardn and attend_date=r2.pdate group by enpno,pdate,cardn);
Pls tell me how to use with example
Thanks & regards
Srikkanth.MHai Man
Thanks for ur response Let me clear what i need
First step Fetch the records as text file and stores into table T1
and the next step is i have seperated the text using substring and stores in different columns of a table
There are two shifts 0815 to 1645 and 1200 and 2000
Here I rep IN and O rep OUT
Empno date time inout
001 01-01-10 0815 I
002 01-01-10 0815 I
003 01-01-10 0818 I
001 01-01-10 1100 0
001 01-01-10 1130 I
002 01-01-10 1145 0
002 01-01-10 1215 I
004 01-01-10 1200 I
005 01-01-10 1215 I
004 01-01-10 1315 O
004 01-01-10 1345 I
001 01-01-10 1645 0
002 01-01-10 1715 0
003 01-01-10 1718 0
004 01-01-10 2010 0
005 01-01-10 2015 0
This is my T1 table i have taken data from text file and stored in this table from this table i need to move data to another table T2
T2 contains like this
Empno Intime Intrin Introut Outtime Date
001 0815 1100 1130 1645 01-01-10
002 0815 1145 1215 1715 01-01-10
003 0818 1718 01-01-10
004 1200 1315 1345 2010 01-01-10
005 1215 2015 01-01-10
This what i am trying to do man but i have little bit problems Pls give some solution with good example
And my coding is
declare
emp_code varchar2(25);
in_time varchar2(25);
out_time varchar2(25);
Cursor P1 is
Select REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
From temp_att
group by REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
ORDER BY enpno,pdate,ptime;
begin
for r2 in p1 loop
declare
bar_code varchar2(25);
begin
select barcode into bar_code from dail_att where empcode=r2.enpno and attend_date=r2.pdate;
For r3 in (select empcode,empname,barcode,intime,intrin,introut,addin,addout,outtime,attend_date from dail_att)loop
if r2.inout ='O' then
update dail_att set outtime =(select max(r2.ptime) from temp_att where empcode=r2.enpno and barcode=r2.cardn and attend_date=r2.pdate group by r2.cardn,r2.enpno,r2.pdate );
end if;
end loop;
exception
when no_data_found then
if r2.inout ='I' then
insert into dail_att(barcode,empcode,intime,attend_date)(select r2.cardn,r2.enpno,min(r2.ptime),r2.pdate from temp_att group by r2.cardn,r2.enpno,r2.pdate );
end if;
end;
end loop;
commit;
end;
Pls tell me what correction i need to do i the update statement i have used a subquery with group function but when i used it will return only one row but my need is to return many rows and i need to use multiple row subquery
and how can i use it in the update statement
Thanks In Advance
Srikkanth.M -
Using Check in alter statement
Hi
I am using the statement like this:
alter table dept
modify (deptno check deptno in (10,20,30,40,50));
ERROR at line 2:
ORA-02253: constraint specification not allowed here
Any suggestions?
ThanksSQL> alter table dept modify (deptno check (deptno in (10,20,30,40,50))) ;
Table altered.
SQL>if you wanted a name for the constraint, you could do:
SQL> alter table dept modify (deptno constraint deptno_ck check (deptno in (10,20,30,40,50))) ;
Table altered.
SQL> disconnect
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.7.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.7.0 - Production
SQL>Added database version. sometimes, that is important.
Message was edited by:
Kamal Kishore -
While attempting to check out, ERROR states "Account registered for different country. Please sign out and sign in using an existing account for this country." I started my account in India. Then changed it to the US when I moved here, then tried to change it back to india when this issue arose, however, the error still occurs. How can I fix this??
I think a new account may be the easiest way if you don't have an existing subscription or cloud files for which to keep continuity.
Maybe you are looking for
-
Playing wmv files crashes windows 7
playing wmv files crashes windows 7. same happens when online streaming video
-
I had 23 Microsoft updates and 12 did not update. I am 73 and not very computer literate. I finally (accidentally) discovered that, at least part of the problem, was that I must have installed Explorer 9. It told me to update to a new driver/software
-
LabVIEW: Resource not found. when running executable
Hi, I've made a fully functional vi with LabVIEW 2009 (developer suite) and need to be able to run it on another PC without it. I have downloaded LV Run-Time 2009, but when I try to run the executable I built, I recieve an error which reads: LabVIEW
-
IPhone App Key Performance Indicators
Hi, Is there a way to access the iPhone App Key Performance Indictors to change it or add something to it? For Example: AR Balance?
-
When trying to access itunes store all I get is white with word itunes. This is recent issue. Is my computer blocking access?