Select the record based count condition
Hi Experts
I have a table with columns StateDate,State,Name & Type . For the same date there could be 2 or more rows for the same name .
I need to retrieve the data from the table only for the name containing single row in the table and state = 'On'
Please find the Create & Insert Scripts below . Am assuming it needs to be done with a window function and am not yet comfortable with window function .
CREATE TABLE ItemState
(StateDate Date,
State Varchar(3),
Name Varchar(3),
Type int)
INSERT INTO Itemstate (Statedate,State,Name,Type)
Values ('3/11/2014','On','XYZ',1)
INSERT INTO Itemstate (Statedate,State,Name,Type)
Values ('3/11/2014','Off','XYZ',1)
INSERT INTO Itemstate (Statedate,State,Name,Type)
Values ('3/11/2014','On','ABC',1)
INSERT INTO Itemstate (Statedate,State,Name,Type)
Values ('3/12/2014','Off','CBR',1)
INSERT INTO Itemstate (Statedate,State,Name,Type)
Values ('3/12/2014','On','CBR',1)
INSERT INTO Itemstate (Statedate,State,Name,Type)
Values ('3/12/2014','On','XYZ',1)
Expected Result
StateDate
State
Name
Type
3/11/2014
ON
ABC
1
3/12/2014
ON
XYZ
1
Kindly help
Thanks
Priya
INSERT INTO Itemstate (Statedate,State,Name,Type)
Values ('3/11/2014','On','XYZ',1)
INSERT INTO Itemstate (Statedate,State,Name,Type)
Values ('3/11/2014','Off','XYZ',1)
INSERT INTO Itemstate (Statedate,State,Name,Type)
Values ('3/11/2014','On','ABC',1)
INSERT INTO Itemstate (Statedate,State,Name,Type)
Values ('3/12/2014','Off','CBR',1)
INSERT INTO Itemstate (Statedate,State,Name,Type)
Values ('3/12/2014','On','CBR',1)
INSERT INTO Itemstate (Statedate,State,Name,Type)
Values ('3/12/2014','On','XYZ',1)
again adding this 3 rows
INSERT INTO Itemstate (Statedate,State,Name,Type)
Values ('3/11/2014','On','XYZ',1)
INSERT INTO Itemstate (Statedate,State,Name,Type)
Values ('3/11/2014','Off','XYZ',1)
INSERT INTO Itemstate (Statedate,State,Name,Type)
Values ('3/11/2014','On','ABC',1)
SELECT *
FROM itemstate order by statedate, name,state
2014-03-11 On
ABC 1
2014-03-11 On
ABC 1
2014-03-11 Off
XYZ 1
2014-03-11 Off
XYZ 1
2014-03-11 On
XYZ 1
2014-03-11 On
XYZ 1
2014-03-12 Off
CBR 1
2014-03-12 On
CBR 1
2014-03-12 On
XYZ 1
so only xyz on 2014-03-12 will qualify
WITH test
AS (SELECT *,
row_number()
OVER (
partition BY statedate, name
ORDER BY state ASC) rnasc,
count(state)
OVER (
partition BY statedate, name
ORDER BY state desc) rncount
FROM itemstate)
SELECT *
FROM test t1 where rnasc = 1
and state = 'on' and rncount = 1
Amish shah
http://bloq.sqltechie.com
Similar Messages
-
Retrive records based on condition
HI,
Need some clarification on getting the records based on the condition given.
Here is my requirement. I have developed a function module to search the records based on some input given. For suppose i get some around 10000 records for this condition. Now i need the output records in multiples.
Like first i execute the FM based on the some condition and i should get 100 records as output and the second time i execute the FM with the same search condition i need to get the records from 101 to 200 and the third time i execute and so on.
Is there any way of fetching the records in multiles for the same search criteria. If so can anyone let me know hot to do the same.
Thanks in advance.
Regards,
RamHI Ram
Please check this example to get some idea:
tables: vbak.
data: it_vbak type table of vbak,
wa_vbak1 type vbak,
wa_vbak2 type vbak.
data: lin type i.
select-options: s_erdat for vbak-erdat obligatory.
select * into table it_vbak from vbak
package size 10
where erdat in s_erdat.
describe table it_vbak lines lin.
read table it_vbak into wa_vbak1 index 1.
read table it_vbak into wa_vbak2 index lin.
break-point.
endselect.
Check the entries in IT_VBAK whenever the break-point is reached. You will have a fresh set of entries for every collection.
Hope this gives you some idea.
Kind Regards
Eswar -
Spilt the records based on new vendor number
Hi all,
I have a requirement where i must spilt the number of records in my internal table itab .i have to collect new vendor numbers into another internal table itab1.
Based on that,Say if my itab1 has 2000 records ,
i must spilt it taking the first 990 records and doing some posting using Bapi and again take the next 990 records and do the posting and then take the remaining 20 and post it .Can some one help me out.
my code
AT new vendor
v_count = v_count + 1.
if v_count <=950.
append itab1.
describe table itab1 lines v_lines.
v_return = v_lines mod 950.
call bapi.
what abt my last 20 records .
Note : My internal table can have at the maximum 990 records while passing to the Bapi.
Good answers will be rewarded with points.Hai,
Instead of that select the records using the PACKAGE SIZE 990.
so here you can complete 990 records and then proceed for next 990 records, if you have only 20 you will end up with 20 records processing.
SELECT * INTO TABLE itab PACKAGE SIZE 990 FROM scarr.
"process the data here , call the BAPI or what ever
ENDSELECT
Regards
Vijay -
How do I select the items based on their adjacent equality?
In the below table,
DECLARE @t1 TABLE(id INT,NAME VARCHAR(MAX))
INSERT INTO @t1 VALUES(1,'test')
INSERT INTO @t1 VALUES(2,'test')
INSERT INTO @t1 VALUES(3,'best')
INSERT INTO @t1 VALUES(4,'rest')
INSERT INTO @t1 VALUES(5,'rest')
how can I select the records that have equals values coming adjacently? That is I am running an SQL job. It should take the adjacent equal value count for its processing. In the below table, first time the job is running it should take count as 2 the
2nd time job is running it should be 1. Third time it should be 2. What is the query that will fetch the cont of equal records for name column? In case no equal columns it should be 1. Please help
mayooran99Hi
Try the following code.
DECLARE @t1 TABLE(id INT,NAME VARCHAR(MAX))
INSERT INTO @t1 VALUES(1,'test')
INSERT INTO @t1 VALUES(2,'test')
INSERT INTO @t1 VALUES(3,'best')
INSERT INTO @t1 VALUES(4,'rest')
INSERT INTO @t1 VALUES(5,'rest')
INSERT INTO @t1 VALUES(6,'test')
INSERT INTO @t1 VALUES(7,'best')
INSERT INTO @t1 VALUES(8,'best')
INSERT INTO @t1 VALUES(9,'vest')
--ranking adjacent names, running total
SELECT rs.id, rs.NAME, ROW_NUMBER() over (partition by name, nxt_id order by id) RankingCount
FROM (
SELECT nxt.id, nxt.NAME,(SELECT min(s.id)
FROM @t1 s
WHERE s.name <> nxt.name
AND s.id > nxt.id
) as nxt_id
FROM @t1 nxt) rs
ORDER BY rs.id;
--code to just return the totals
with cteTotals
as
SELECT rs.id, rs.NAME, ROW_NUMBER() over (partition by name, nxt_id order by id) RankingCount, nxt_id, ROW_NUMBER() over (partition by name, nxt_id order by id desc) Ranking
FROM (
SELECT nxt.id, nxt.NAME,(SELECT min(s.id)
FROM @t1 s
WHERE s.name <> nxt.name
AND s.id > nxt.id
) as nxt_id
FROM @t1 nxt) rs
select Name, RankingCount
from cteTotals
WHERE Ranking=1
order by id
The first query keeps a running total of adjacent names, the second one just reports the totals -
How can hide the buttons based on condition
Dear all
I have to hide the button based on condition
When I open the third page directly I want to hide that button
When I open the third page via first and second page I need to visible that button
I pass spell parameter from first to second and second to third
In third page I get the value using pagecontext
I write the code in third page co
If I go directly third page it is null
If I go to third page via first the value is Y
If(“Y”.equals(pmode))
OASubmitButtonBean btn =( OASubmitButtonBean )webBean.findChildRecursive(“<id>”);
If(!btn=null)
btn.setrendered(true);
else
btn.setrendered(false);
but the button is not hiding
Regards
SreekanthHi Srikanth,
I have modified ur method:
OASubmitButtonBean btn =( OASubmitButtonBean )webBean.findChildRecursive(“<id>”);
If(btn !=null)
If(“Y”.equals(pmode))
btn.setrendered(true);
else
btn.setrendered(false);
Thanks,
'Kumar
Edited by: Kumar Kovela on Aug 3, 2009 5:53 AM -
Select the table based on 2 months ? Query no working
I have a table TEST1 in schema MESSAGE_REPORT. What i want to do is select the table based on 2 months ( JULY and AUGUST ). The requirement is Whole JULY data should be there and for AUG the data should be till 01 aug . Below is the query i m using but its giving me error . Moreover the Where clause "TRUNC(HIRE,'MONTH') " part is compulsary to be used ,changes have to be made in the ">= timestamp '2010-07-01 00:00:00' and frd.sent_timestamp < timestamp '2010-08-10 00:00:00';" part only . please can anyone help me out
NAME HIRE
SALE 01.07.2010 00:00:00,000000000
cops 15.07.2010 00:00:00,000000000
NAVEED 31.07.2010 00:00:00,000000000
HEN 01.08.2010 00:00:00,000000000
BEN 10.08.2010 00:00:00,000000000
CROSS 15.08.2010 00:00:00,000000000
select * from MESSAGE_REPORT.test1 where
TRUNC(HIRE,'MONTH') >= timestamp '2010-07-01 00:00:00' and frd.sent_timestamp < timestamp '2010-08-10 00:00:00';
ERROR:
ORA-00904: "FRD"."SENT_TIMESTAMP": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 24 Column: 60Edited by: user12633486 on Aug 11, 2010 1:13 PM
Edited by: user12633486 on Aug 11, 2010 1:51 PMThats becuase you are comparing with Month and not the complete date.
Check this:
SQL> ed
Wrote file afiedt.buf
1 with t as (select 'SALE' col1,'01.07.2010 00:00:00' col2 from dual
2 union all select 'cops','15.07.2010 00:00:00' from dual
3 union all select 'NAVEED','31.07.2010 00:00:00' from dual
4 union all select 'HEN','01.08.2010 00:00:00' from dual
5 union all select 'BEN','10.08.2010 00:00:00' from dual
6 union all select 'CROSS','15.08.2010 00:00:00' from dual)
7 select * from t
8 where
9 TO_DATE(col2,'DD.MM.RRRR HH24:MI:SS') >= timestamp '2010-07-01 00:00:00'
10* and TO_DATE(col2,'DD.MM.RRRR HH24:MI:SS') < timestamp '2010-08-10 00:00:00'
SQL> /
COL1 COL2
SALE 01.07.2010 00:00:00
cops 15.07.2010 00:00:00
NAVEED 31.07.2010 00:00:00
HEN 01.08.2010 00:00:00
SQL>
-- For less than equal to
SQL> ed
Wrote file afiedt.buf
1 with t as (select 'SALE' col1,'01.07.2010 00:00:00' col2 from dual
2 union all select 'cops','15.07.2010 00:00:00' from dual
3 union all select 'NAVEED','31.07.2010 00:00:00' from dual
4 union all select 'HEN','01.08.2010 00:00:00' from dual
5 union all select 'BEN','10.08.2010 00:00:00' from dual
6 union all select 'CROSS','15.08.2010 00:00:00' from dual)
7 select * from t
8 where
9 TO_DATE(col2,'DD.MM.RRRR HH24:MI:SS') >= timestamp '2010-07-01 00:00:00'
10* and TO_DATE(col2,'DD.MM.RRRR HH24:MI:SS') <= timestamp '2010-08-10 00:00:00' -- less than equal to includes data for 10th august as well
SQL> /
COL1 COL2
SALE 01.07.2010 00:00:00
cops 15.07.2010 00:00:00
NAVEED 31.07.2010 00:00:00
HEN 01.08.2010 00:00:00
BEN 10.08.2010 00:00:00
SQL> Edited by: AP on Aug 11, 2010 1:31 AM
Edited by: AP on Aug 11, 2010 1:32 AM -
Delete duplicate records based on condition
Hi Friends,
I am scratching my head as how to select one record from a group of duplicate records based upon column condition.
Let's say I have a table with following data :
ID START_DATE END_DATE ITEM_ID MULT RETAIL | RETAIL / MULT
1 10/17/2008 1/1/2009 83 3 7 | 2.3333
2 10/17/2008 1/1/2009 83 2 4 | 2
3 10/17/2008 1/1/2009 83 2 4 | 2
4 10/31/2008 1/1/2009 89 3 6 | 2
5 10/31/2008 1/1/2009 89 4 10 | 2.5
6 10/31/2008 1/1/2009 89 4 10 | 2.5
7 10/31/2008 1/1/2009 89 6 6 | 1
8 10/17/2008 10/23/2008 124 3 6 | 2From the above records the rule to identify duplicates is based on START_DATE,+END_DATE+,+ITEM_ID+.
Hence the duplicate sets are {1,2,3} and {4,5,6,7}.
Now I want to keep one record from each duplicate set which has lowest value for retail/mult(retail divided by mult) and delete rest.
So from the above table data, for duplicate set {1,2,3}, the min(retail/mult) is 2. But records 2 & 3 have same value i.e. 2
In that case pick either of those records and delete the records 1,2 (or 3).
All this while it was pretty straight forward for which I was using the below delete statement.
DELETE FROM table_x a
WHERE ROWID >
(SELECT MIN (ROWID)
FROM table_x b
WHERE a.ID = b.ID
AND a.start_date = b.start_date
AND a.end_date = b.end_date
AND a.item_id = b.item_id);Due to sudden requirement changes I need to change my SQL.
So, experts please throw some light on how to get away from this hurdle.
Thanks,
Raj.Well, it was my mistake that I forgot to mention one more point in my earlier post.
Sentinel,
Your UPDATE perfectly works if I am updating only NEW_ID column.
But I have to update the STATUS_ID as well for these duplicate records.
ID START_DATE END_DATE ITEM_ID MULT RETAIL NEW_ID STATUS_ID | RETAIL / MULT
1 10/17/2008 1/1/2009 83 3 7 2 1 | 2.3333
2 10/17/2008 1/1/2009 83 2 4 | 2
3 10/17/2008 1/1/2009 83 2 4 2 1 | 2
4 10/31/2008 1/1/2009 89 3 6 7 1 | 2
5 10/31/2008 1/1/2009 89 4 10 7 1 | 2.5
6 10/31/2008 1/1/2009 89 4 10 7 1 | 2.5
7 10/31/2008 1/1/2009 89 6 6 | 1
8 10/17/2008 10/23/2008 124 3 6 | 2So if I have to update the status_id then there must be a where clause in the update statement.
WHERE ROW_NUM = 1
AND t2.id != t1.id
AND t2.START_DATE = t1.START_DATE
AND t2.END_DATE = t1.END_DATE
AND t2.ITEM_ID = t1.ITEM_IDInfact the entire where_ clause in the inner select statement must be in the update where clause, which makes it totally impossible as T2 is persistent only with in the first select statement.
Any thoughts please ?
I appreciate your efforts.
Definitely this is a very good learning curve. In all my experience I was always writing straight forward Update statements but not like this one. Very interesting.
Thanks,
Raj. -
Retrieve records based on condition from xml using XPATH
Hi all,
I have a table form_content where there are two columns - form_content_id (numeric) and xml_content (clob). The structure of xml_content is
<RAF xmlns="http://www.abnamro.com/WCS/GCEG/KRT">
<XBorderRAF>
<ClientProfile isBranch="1" isBusinessAddressDifferent="1" isSubsidiary="0" regDate="2009-09-01">
<RegisteredAddress city="test" country="GB" nameOfContactPerson="3454545" street1="test" telephoneNumber="34534545"/>
</ClientProfile>
</XBorderRAF>
</RAF>
I want to retrive all form_contant_id from form_content table where country is 'GB' inside RegisteredAddress tag.
I am able to retrive all form_content_id with country value using below query,
SELECT form_content_id,
extractValue(xmltype(xml_content),'/RAF/XBorderRAF/ClientProfile/RegisteredAddress/@country', 'xmlns="http://www.abnamro.com/WCS/GCEG/KRT"')
as registerAddress
from
form_content
but I am finding it difficult to reterive records based on any condition..
SELECT form_content_id,
extractValue(xmltype(xml_content),'/RAF/XBorderRAF/ClientProfile/RegisteredAddress/@country', 'xmlns="http://www.abnamro.com/WCS/GCEG/KRT"')
as registerAddress
from
form_content
where
(extractValue(xmltype(xml_content),'/RAF/XBorderRAF/ClientProfile/RegisteredAddress/@country', 'xmlns="http://www.abnamro.com/WCS/GCEG/KRT"')='GB'
Please help me to resolve this problem. ....
ThanksOk, thaks to all who looked this query, I found the answer
select form_content_id
from xmltest
where existsnode(xmltype(xml_content), '/RAF/XBorderRAF/ClientProfile/RegisteredAddress[@country="GB"]','xmlns="http://www.abnamro.com/WCS/GCEG/KRT"') = 1; -
Fetch the records based on number
Hi experts,
I have a req like if user give input as 5..it should fetch 5 records from database.
for example database values are
SERNR MATNR
101 A
102 A
103 A
104 A
105 A
106 A
107 A
If user gives the input as 5 it should fetch 5 records like 101 to 105....Can any body plz help me how to write select query for this..
Thanks in advance,
Veena.
Edited by: s veena on Jan 18, 2011 5:52 AMHi Veena,
You can use UPTO in your select query. For example
SELECT MATNR FROM MARA INTO TABLE IT_MATNR UPTO P_NUMBER ROWS.
"Here P_NUMBER is the Selection Screen Parameter
It will fetch records based on the number in the parameter.
Thanks & Regards,
Faheem. -
Want to sort the records based on non-base table item
I have a multi-record block and I am trying to sort the data based on nbt item
I have a table called X which has x_type,x_code fields.
The table on which the block is created is Y. the table Y has x_type and y_desc as its fields
form layout is like below .the x_type is key field on which I have to query the records
and x_code is a non-base item in the form.I want to sort the records by X_code.
x_code y_desc
A xyz
c par
B lmn
my pre-query has this code
select x_type from y
where
x_type := x_type;
post-query has this code
select x_code from x
where x_type = :x_type;
It works fine in Enter-Queryand execute query mode. but when I am sorting the records on
nbt item x_code by SET-BLOCK-PROPERTY it doesn't do any thingHi Tony ,
I have created a function and in Pre-Query & have add this
SET_BLOCK_PROPERTY('b1', ORDER_BY, 'fn_get_code(x_type)');
and the function created is as below
Function fn_get_code (p_x_type in varchar2) return varchar2 is
v_code varchar2(40);
begin
select x_code into v_code
from X, Y
where X.x_type = Y.x_type
and y.x_type = p_x_type
return v_code;
end;
when I run the form and execute query it comes up with the error message
FRM-40505 and when I pressed display error it shows
SQL Statement error:
SELECT ROWID,X_TYPE,X_CODE
FROM Y order by fn_get_code(x_type)
Error:
"ORA-00904: "FN_GET_code": invalid identifier"
Is it that I need to create a function on the database?. As I have created function
in program unit section -
Selection of records based on minimum date actioned
Post Author: jrdoyle
CA Forum: Data Connectivity and SQL
Hi!
I've been building a report that displays records, grouped by the Service Department to which they have been assigned; however I need to constrain the report to only show the Service Department to which the record was first assigned. I had tried to group the report by incident reference #, and had in the details the actions taken agains the record, the date of the action, the SVD to which it was assigned, etc. In the Select Expert, I have the following:
{INC_DATA.EVENT_TYPE} = "i" and{SERV_DEPT.SERV_DEPT_SC} = "DISPATCH" and{INCIDENT.DATE_LOGGED} in DateTime (2007, 05, 01, 00, 00, 00) to DateTime (2007, 05, 30, 00, 00, 00) and{SERV_DEPT_1.SERV_DEPT_SC} in ["CUSTHOME", "CUSTWEST", "HARDWARE"]
The SERV_DEPT_1 table will displays the information about the Service Department to which the records are assigned. I need to be able to count only the minimum date of assignment. I've tried using the Minimum function, but it appears that I then can't summarize (count records) higher up in the report groups, as it gets evaluated after (?) the groups are made.
Is anyone able to offer suggestions as to how I might go about this? I have tried to somehow flag records in the details which meet the criteria, but haven't been able to come up with anything yet.
Thanks!Post Author: Jagan
CA Forum: Data Connectivity and SQL
I'm not quite sure how/where you tried to use the Minimum function - sounds like you used it in the record selection formula? Anyway, if you want the report to have only the earliest record per service department group then you can use the group selection expert, e.g.{incident.date_logged} = minimum({incident.date_logged}, {serv_dept_1.serv_dept_sc})If you want to display the earliest record but still have the other records there for processing then sort on {incident.date_logged} ascending, suppress the details, and print in the {serv_dept_1.serv_dept_sc} group header. i.e the record you're "looking" at in the group header is the first one for the group.The difference between the two is that the former will only have one record per service department group (assuming the date_logged is unique per incident per department) while the latter will have all records but only display one. This makes a difference when using the built-in summary functions. -
Need to delete the record based on the checkbox xselected
I am displaying the data from tables vbrk and vbrp.along with that data i am displaying the checkbox also.
here my requirement is when ever the user checks the checkboxes and click on delete button the checkbox selected items should deleted and need to display the remaining.
please any send me the example how to process it.
thanks and regards
vamsi
[email protected]Hi,
Herewith i am sending the sample coding for checkbox alv report. Kindly go through it. U can get some idea for your requirement.
REPORT YMS_CHECKBOXALV.
TYPE-POOLS: slis.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
DATA: s_layout TYPE slis_layout_alv.
DATA: BEGIN OF itab OCCURS 0,
icon TYPE icon-id,
vbeln TYPE vbeln,
kunnr TYPE kunnr,
erdat TYPE erdat,
box TYPE c,
END OF itab.
DATA: v_repid TYPE syrepid.
START-OF-SELECTION.
Get the data.
SELECT vbeln kunnr erdat UP TO 100 ROWS
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE itab.
IF sy-subrc <> 0.
MESSAGE s208(00) WITH 'No data found'.
LEAVE LIST-PROCESSING.
ENDIF.
Modify the record with red light.
itab-icon = '@0A@'.
MODIFY itab TRANSPORTING icon WHERE NOT vbeln IS initial.
v_repid = sy-repid.
Get the field catalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'ICON'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-seltext_l = 'Status'.
s_fieldcatalog-icon = 'X'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'VBELN'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'KUNNR'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'KUNNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'ERDAT'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'ERDAT'.
APPEND s_fieldcatalog TO t_fieldcatalog.
Set the layout.
s_layout-box_fieldname = 'BOX'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = s_layout
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = t_fieldcatalog[]
TABLES
t_outtab = itab.
FORM SET_PF_STATUS *
--> EXTAB *
FORM set_pf_status USING extab TYPE slis_t_extab.
SET PF-STATUS 'TEST2'.
ENDFORM.
FORM user_command *
--> UCOMM *
--> SELFIELD *
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
Check the ucomm.
IF ucomm = 'DETAIL'.
LOOP AT itab WHERE box = 'X'.
itab-icon = '@08@'.
MODIFY itab TRANSPORTING icon.
ENDLOOP.
ENDIF.
selfield-refresh = 'X'.
ENDFORM.
Thanks,
Shankar -
Dynamic selection of records based on checkbox checked
Hello,
I want to select a list of records from a multirecord block by
using the checkbox checked values as the criterion and use the
records selected in the where clause for querying in another
forms. The data from the multirecord block is from a query
result and hence is dynamic.
I went about doing this:
I created a multirecord block. In the multirecord block, I
created a checkbox which was a non-database item.
In the when_button_pressed trigger I wrote the following code:
declare
temp varchar2(1000);
start_rec number;
stop_rec number;
item_id item;
block_id block;
item_value varchar2(1000);
pl_id paramlist;
item_name varchar2(10);
patient_list varchar2(1000);
begin
go_block('patient_list');
block_id:=find_block('patient_list');
start_rec:=1;
stop_rec:=get_block_property(block_id,query_hits);
for i in start_rec..stop_rec loop
if :selection='Y' then --selection is the checkbox
if item_value is null then
/*item_value holds the value of the data shown in the forms &
for which the checkbox is checked*/
item_value:=name_in(':patient_list.patient_id');
/*patient_id is the item name as well as field name in the
table*/
else
item_value:=item_value||','||name_in(':patient_list.patient_id');
end if;
end if;
end loop;
patient_list:='('||item_value||')';
pl_id:=create_parameter_list('list_of_patients');
add_parameter(pl_id,'querypatients',text_parameter,patient_list);
message(patientlist);
run_product
(forms,'patient_history',synchronous,runtime,filesystem,pl_id,nul
l);
end;
When I run this form, patient_list comes as
(111,111,111,111,111,111,111) where
111 is the value of the patient_id.
The only value that gets into the patient_list is the patient_id
for the last checkbox I have
checked in the forms and the same patient_id appears so many
times.
Can anyone tell me where I am doing the mistake? Why is the same
value appearing so many times and only the last record selected
appears in the patient_list.
Thank you for your suggestions.Thank You.
I added go_record(start_rec) and next_record and everything
worked fine.
Here I have the working code:
declare
temp varchar2(1000);
start_rec number;
stop_rec number;
item_id item;
block_id block;
item_value varchar2(1000);
pl_id paramlist;
item_name varchar2(10);
patient_list varchar2(1000);
begin
go_block('patient_list');
block_id:=find_block('patient_list');
start_rec:=1;
stop_rec:=get_block_property(block_id,query_hits);
go_record(start_rec);-- I added it
for i in start_rec..stop_rec loop
if :selection='Y' then --selection is the checkbox in
the patient_list block.
if item_value is null then
-- item_value holds the value of the data shown in the forms and
for which the checkbox is checked
item_value:=name_in(':patient_list.patient_id');
-- patient_id is the item name as well as field name in the table
else
item_value:=item_value||','||name_in
(':patient_list.patient_id');
end if;
end if;
next_record;-- I added it
end loop;
patient_list:='('||item_value||')';
pl_id:=create_parameter_list('list_of_patients');
add_parameter(pl_id,'querypatients',text_parameter,patient_list);
message(patientlist);
run_product
(forms,'patient_history',synchronous,runtime,filesystem,pl_id,nul
l);
end; -
I cannot select the 'Recorded Timing' when I choose to export to Quicktime - is this normal?
Just installed Keynote but find that the 'Recorded Timing' option is not available in the Playback Uses dropdown. My presentation has animation and transitions for fully automated presentation. I am doing something wrong?
Did you record the slideshow? You must record it before you can use the recorded timing. Go to Play Menu and select Record Slideshow. Then let it play through and you will then be able to use the Recorded timing to export.
-
Fetching Records Based on Condition
hi all,
i am having some problem in getting the records from three tables.could anybody there to help me out of this.....
there are three tables SUB,TICKETS and INDTICKETS.
In the first table SUB(master table)which contains the masters.
In the second table TICKET(detail table) which contains the tickets belongs to the subscriber in the master(SUB)table.
So if we want to see the tickets(2 each) of one subscriber belongs to which routeid we can combine the 2 tables and get it since routeid is in the SUB master table.
Sometimes all tickets wouldnt belongs to the same routeid whatever specified in the SUB master.So i created the another INDTICKET table which will save the routeid ticketid wise.So the INDTICKET Table will contains tickets which are only having routeid is been changed.
DESC SUB
SUBNO SUBNAME ROUTEID
1 SMITH 01
2 SCOTT 02
DESC TICKETS
SUBNO TICKETID AMOUNT
1 01 1000
1 02 2000
2 09 4000
2 10 7000
DESC INDTICKET
SUBNO TICKETID ROUTEID
1 02 02
2 10 01
Now i need a query which will fetch only the tickets
1 . belongs to 01 routeid in the SUB master table and not in the INDTICKET table of other routeid
2 . and the ticketid belongs to the 01 routeid in the INDTICKET table.
So from the above example the query should fetch like this
=== Tickets in routeid '01' ===
SUBNO SUBNAME TICKETID AMOUNT
1 SMITH 01 1000
2 SCOTT 10 7000
thanks in advance
regrds,
punithIn the future, it would be much more helpful if you could post the DDL to create and populate these tables instead of DESC and query output. It would greatly increase the chances of having your question answered.
I would probably have put the routeid override as an additional column in the tickets table instead of creating a new table just for the override, but with your current layout:
sql>select * from sub;
SUBNO SUBNAME ROUTEID
1 Smith 1
2 Scott 2
2 rows selected.
sql>select * from tickets;
SUBNO TICKETID AMOUNT
1 1 1000
1 2 2000
2 9 4000
2 10 7000
4 rows selected.
sql>select * from indticket;
SUBNO TICKETID ROUTEID
1 2 2
2 10 1
2 rows selected.
sql>select s.subno, s.subname, t.ticketid, t.amount
2 from sub s, tickets t
3 where s.routeid = 1
4 and t.subno = s.subno
5 and not exists (select null
6 from indticket it
7 where it.subno = s.subno
8 and it.ticketid = t.ticketid)
9 union all
10 select s.subno, s.subname, it.ticketid, t.amount
11 from indticket it, sub s, tickets t
12 where it.routeid = 1
13 and s.subno = it.subno
14 and t.subno = s.subno
15 and t.ticketid = it.ticketid;
SUBNO SUBNAME TICKETID AMOUNT
1 Smith 1 1000
2 Scott 10 7000
2 rows selected.
Maybe you are looking for
-
External screen in vertical mode - how to do it ?
I have a 20" Dell external screen which can rotate 90 degrees, I need to use it in vertical mode but I don't know how, neither if it's possible with the ATI Mobility Radeon 9000 card which is in my Powerbook. Is it possible with Tiger ? Thanks if any
-
Can we have a static ref file for XML
I have a report XML that displays the action status which is numeric. e.g. PayOrder PayStatus 1 1 2 23 Here 1=Active, 23= Pending and so on .... While displaying, I want to display the status description on screen. I do not want to hit the database f
-
Hello and thank you in advance for your help. I am building a website for a small business and following various tutorials etc to help me along the way. I have created a menu bar within the banner with hover formatting etc. but in IE it fails to sh
-
DDL is not working on table!
Hi all' I have a problem in one of my db schema. All of a sudden all views and triggers vanished and one of the tables is not allowing any ddl showing that resources are busy so lock could not be acquired . Instant help is needed. Thanks in advance
-
JVM takes more RAM than defined in -Xmx param on solaris
Hi all, We have a problem on production installation of our product on Solaris paltfroms: jvm takes more (much more) RAM than defined in -Xmx param and without any OutOfMemory exceptions. (how itt possible at all ?) The only JNI call in application i