Formatting Output Based on Data in TVARVC
Hi Guys
In the below program I need to highlight lines of output where the plant complies to the rules green and those that do not in red in a variant called check plant.
Here are the values.
S 0000 I EQ 1000
S 0001 I EQ 3000
S 0002 I BT 2000 2500
S 0003 I BT 6100 6150
S 0004 E EQ 2300
S 0005 E EQ 6101
I have tried to achieve this in the code below but it doesn't work properly some plants are highlighted green when they should be red and vice versa. Please could you help me with the correct logic.
REPORT ZTREVOR_CHECK_VARIANT message-id ZTREVOR_MSG_CLASS1.
data: it_makt type standard table of makt,
wa_makt type makt,
it_mard type standard table of mard,
wa_mard type mard,
it_t001w type standard table of t001w,
wa_t001w type t001w.
Data: it_mard_distinct type standard table of mard,
v_werks type werks,
v_matnr type matnr.
data: it_tvarvc type standard table of tvarvc,
wa_tvarvc type tvarvc.
CONSTANTS : C_VARNAME TYPE rvari_vnam value 'CHECK_PLANT'.
select-options : s_matnr for v_matnr no intervals no-extension,
s_spras for wa_makt-spras no intervals no-extension.
AT SELECTION-SCREEN.
SELECT single matnr from mara into v_matnr WHERE matnr in s_matnr.
IF sy-subrc IS NOT INITIAL.
MESSAGE w000 with s_matnr-low display like 'I'.
ENDIF.
start-of-selection.
select * from makt into table it_makt where matnr in s_matnr and spras in s_spras.
select * from mard into table it_mard where matnr in s_matnr.
select * from tvarvc into table it_tvarvc where name = C_VARNAME.
end-of-selection.
IF it_mard is not initial.
sort it_mard by werks.
LOOP AT it_mard INTO wa_mard.
IF wa_mard-werks NE v_werks.
APPEND wa_mard TO it_mard_distinct.
ENDIF.
v_werks = wa_mard-werks.
ENDLOOP.
select * from t001w into table it_t001w for all entries in it_mard_distinct where werks = it_mard_distinct-werks.
endif.
write : at / 'Material' color col_positive,
10 'Description' color col_positive,
30 'Plant' color col_positive,
60 'Plant Name' color col_positive.
LOOP AT it_mard_distinct into wa_mard.
READ table it_makt into wa_makt with key matnr = wa_mard-matnr binary search.
READ table it_t001w into wa_t001w with key werks = wa_mard-werks.
READ TABLE it_tvarvc into wa_tvarvc with key low = wa_mard-werks.
if wa_tvarvc is not initial.
FORMAT color = 5.
else.
FORMAT color = 6.
endif.
write : at / wa_makt-matnr,
10 wa_makt-maktx,
30 wa_mard-werks,
60 wa_t001w-name1.
endloop.
you are crosschecking with TVARVC the wrong way.
At least you cant check for equality.
See in tvarvc there are not only single variables (parameters), but also ranges (select-options).
I assume the small list in the top of your post is an excerpt of your TVARVC entries for plant checks.
As you can see there are select option using option BT (between)
when you select on tvarvc with LOW field you will never get those which are between the customized entries.
what you need to do is select your TVARVC entries, make a range out of it and check your plant like following:
loop at it_mard_distinct into wa_mard.
If wa_mard-werks IN range_plants.
colour green.
else.
colour red.
endif.
endloop.
hope you could follow me.
Similar Messages
-
Query output based on date - Oracle 8i
I am trying to write a very simple query to output data based
on date ranges, but I keep encountering an error.
When I do this statement:
select * from my.table
where startdate > '2008-01-01'
I get this error:
[ODBC][Ora]ORA-01861: literal does not match format string
When I format the select statement this way:
select * from my.table
where startdate > #2008-01-01#
i get this error:
[ODBC][Ora]ORA-00932: inconsistent datatypes: expected DATE
got NUMBER
Currently using CF8, and what I believe is Oracle 8i. I have
tried formatting this data in many other ways, but can't get it to
work. I know that when I query the database via access, it has no
problem returning results with the SQL date formatted like
#01/01/2008#You can use the Oracle to_date() function to convert your
string to a date/time object:
select * from my.table
where startdate > to_date('2008-01-01', 'YYYY-MM-DD')
Or, since you are using an ODBC connection to Oracle, you can
try using the ColdFusion CreateODBCDate() function:
select * from my.table
where startdate > #CreateODBCDate("2008-01-01")#
Or, as already suggested, use cfqueryparam with the
appropriate CFSQLType, such as
CF_SQL_TIMESTAMP instead of CF_SQL_INTEGER like you are
attempting to do.
You can't use a "string" date value against a date/time
column in an Oracle query, as it won't perform an implicit type
conversion.
Phil -
Want to write formatted search based on date
Hi,
I want to write formatted search where one date is lesser than other date.But it is giving error stating like date comparision not possible
Pls adviseHi Sanjay,
SQL DateDifferent Function.
for example.
DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate = $[ODLN.DocDate]
SET @EndDate = $[ODLN.TaxDate]
SELECT DATEDIFF(Year, @StartDate, @EndDate) AS NewDate
Check the thread, You will be get more details of SQL Date Different Function.
http://sqltutorials.blogspot.com/2007/06/sql-datediff-function.html
Regards,
Madhan. -
Formatting output so that data repeated between rows is not shown
Hi Everyone,
Here is a snippet of some sample data from a report that I have just written -
Notice above that the 'Item Code', 'Item Description', and 'Order Qty' all repeat for rows 2 and 3.
I would like to remove the repeated data (and ideally replace it with 'empty' cells), similar to the snippet below -
I am connecting to an MS SQL Server 2008 R2 database, and therefore I have come to believe I cannot use the IIF(...) function, as detailed in
this link.
How can I go about formatting the data as indicated above?
Any help will be greatly appreciated.
Kind Regards,
DavidHere is my initial attempt where only the Seq column is shown.
select *
from
select ROW_NUMBER()
over
partition by td.ItemCode , td.Dscription, td.Quantity, titm.OnOrder, th.CardCode, th.CardName, th.DocNum, tsp.SlpName, twhs.WhsCode
order by td.ItemCode
as 'Sequence No.'
from AU.dbo.RDR1 td
left outer join AU.dbo.ORDR th on th.DocEntry = td.DocEntry
left outer join AU.dbo.OITM titm on titm.ItemCode = td.ItemCode
left outer join AU.dbo.OITW twhs on twhs.ItemCode = td.ItemCode
left outer join AU.dbo.OSLP tsp on tsp.SlpCode = td.SlpCode
left outer join A1Warehouse.dbo.BINLOCAT tbloc on tbloc.PRODUCT = td.ItemCode collate SQL_Latin1_General_CP850_CI_AS
where
td.LineStatus = 'O' and td.ItemCode = 'DR1124' and twhs.WhsCode like @whCode
) as ResultsGroup
And then I attempted to 'refine' it further...
select
case when Seq = 1 then td.ItemCode else '' end as 'Item Code',
case when Seq = 1 then td.Dscription else '' end as 'Item Description',
case when Seq = 1 then td.Quantity else '' end as 'Order Qty',
case when Seq = 1 then titm.OnOrder else '' end as 'PO Qty',
case when Seq = 1 then th.CardCode else '' end as 'BP Code',
case when Seq = 1 then th.CardName else '' end as 'BP Name',
case when Seq = 1 then th.DocNum else '' end as 'Sales Order Number',
case when Seq = 1 then tsp.SlpName else '' end as 'Sales Person',
case when Seq = 1 then twhs.WhsCode else '' end as 'Whs Code',
isnull(tbloc.BINLABEL, '') as 'BIN Label',
isnull(cast(tbloc.QUANTITY as nvarchar(20)), '') as 'BIN Qty'
from
select ROW_NUMBER()
over
partition by td.ItemCode , td.Dscription, td.Quantity, titm.OnOrder, th.CardCode, th.CardName, th.DocNum, tsp.SlpName, twhs.WhsCode
order by td.ItemCode
as Seq
from AU.dbo.RDR1 td
left outer join AU.dbo.ORDR th on th.DocEntry = td.DocEntry
left outer join AU.dbo.OITM titm on titm.ItemCode = td.ItemCode
left outer join AU.dbo.OITW twhs on twhs.ItemCode = td.ItemCode
left outer join AU.dbo.OSLP tsp on tsp.SlpCode = td.SlpCode
left outer join A1Warehouse.dbo.BINLOCAT tbloc on tbloc.PRODUCT = td.ItemCode collate SQL_Latin1_General_CP850_CI_AS
where
td.LineStatus = 'O' and td.ItemCode = 'DR1124' and twhs.WhsCode like @whCode
) as ResultsGroup
Here are the error messages that I get from running the above code snippet.
The multi-part identifier error message
I am sure that I have made several errors, however I am new to MS SQL programming so please be patient with me.
try like below
select
case when Seq = 1 then ItemCode else '' end as 'Item Code',
case when Seq = 1 then Dscription else '' end as 'Item Description',
case when Seq = 1 then Quantity else '' end as 'Order Qty',
case when Seq = 1 then OnOrder else '' end as 'PO Qty',
case when Seq = 1 then CardCode else '' end as 'BP Code',
case when Seq = 1 then CardName else '' end as 'BP Name',
case when Seq = 1 then DocNum else '' end as 'Sales Order Number',
case when Seq = 1 then SlpName else '' end as 'Sales Person',
case when Seq = 1 then WhsCode else '' end as 'Whs Code',
isnull(BINLABEL, '') as 'BIN Label',
isnull(cast(QUANTITY as nvarchar(20)), '') as 'BIN Qty'
from
select ROW_NUMBER()
over
partition by td.ItemCode , td.Dscription, td.Quantity, titm.OnOrder, th.CardCode, th.CardName, th.DocNum, tsp.SlpName, twhs.WhsCode
order by td.ItemCode
as Seq,
td.ItemCode,
td.Dscription ,
td.Quantity ,
titm.OnOrder ,
th.CardCode ,
th.CardName,
th.DocNum,
tsp.SlpName,
twhs.WhsCode,
tbloc.BINLABEL,
tbloc.QUANTITY
from AU.dbo.RDR1 td
left outer join AU.dbo.ORDR th on th.DocEntry = td.DocEntry
left outer join AU.dbo.OITM titm on titm.ItemCode = td.ItemCode
left outer join AU.dbo.OITW twhs on twhs.ItemCode = td.ItemCode
left outer join AU.dbo.OSLP tsp on tsp.SlpCode = td.SlpCode
left outer join A1Warehouse.dbo.BINLOCAT tbloc on tbloc.PRODUCT = td.ItemCode collate SQL_Latin1_General_CP850_CI_AS
where
td.LineStatus = 'O' and td.ItemCode = 'DR1124' and twhs.WhsCode like @whCode
) as ResultsGroup
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Adding new records in output based on extracted data
Hi Experts,
Good day!
I'm still having a problem with my material hitorical data project. I have a requirements in our historical data of material price which adding data that are not existing based on data extracted from standard tables such as A004 and KONP.
Now, i need to use the VALIDFROM (DATAB) as well as VALIDTO(DATBI) value as basis for the latest price.
To make it more clear, see the example below:
Extracted data:
Material Number Valid From Valid to Price
100101 01/01/2008 02/01/2008 100.00
100101 02/02/2008 04/02/2008 100.00
100101 04/03/2008 08/01/2008 200.00
100101 08/02/2008 01/31/2009 300.00
100102 05/02/2008 07/01/2008 10.00
100102 07/02/2008 10/31/2008 15.00
100102 11/01/2008 01/31/2009 20.00
Output:
Material Number Calmonth Price
100101 01/2008 100.00
100101 02/2008 100.00
100101 03/2008 100.00
100101 04/2008 200.00
100101 05/2008 200.00
100101 06/2008 200.00
100101 07/2008 200.00
100101 08/2008 300.00
100101 09/2008 300.00
100101 10/2008 300.00
100101 11/2008 300.00
100101 12/2008 300.00
100101 01/2009 300.00
100102 05/2008 10.00
100102 06/2008 10.00
100102 07/2008 15.00
100102 08/2008 15.00
100102 09/2008 15.00
100102 10/2008 15.00
100102 11/2008 20.00
100102 12/2008 20.00
100102 01/2009 20.00
Text that are in bold are the added data. What is the best code to do with this?
How can i come up with this output? Help me please guys....
Thanks and Godbless,
nips
Edited by: Nips on Jan 18, 2009 4:23 AMhi,
I havenot created such program before but i think the logic shud work.
I have refined the logic take a look at it.
DATA: d1 like sy-datum VALUE '11012008', "dates in internal format
d2 LIKE sy-datum VALUE '01012008', "dates in internal format
mon TYPE i,
v_mon TYPE i,
v_year TYPE char4
v_date type char6.
CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = d1
i_datum_von = d2
I_KZ_INCL_BIS = ' '
IMPORTING
E_MONATE = mon
IF mon > 0.
v_mon = wa1-validfrom+0(2).
v_year = wa1-validfrom+4(4).
ENDIF.
do mon times.
CONCATENATE v_mon '/' v_year INTO v_date.
wa2-matnr = wa1-matnr.
wa2-calmonth = v_date.
wa2-price = wa1-price.
append wa2 to itab2.
v_mon = v_mon + 1.
enddo.
endloop.
кu03B1ятu03B9к -
Display output based on oldest date
I am developing picking list report. I have fetched the data into final internal table consisting of the fields material number, batchno, shelf life expr date, pick qty, actual qty and bin number based on some conditions from different tables. Now, my requirement is to display the data based on following condition
Using the Material Code, locate the Material master record on SAP. Determine if the material is stored by shelf life. If it is, find the batch with the oldest shelf life with available stock for the material and get the bin number in which it is stored. Write the bin number, shelf life, batch and quantity picked details to the record and write the record. If there is insufficient stock in the batch to satisfy the requirement in full, find the next batch with the next oldest shelf life and write those details to a second record and so on until the requirement is met in full.
Can anyone pls help me to write the logic ?
Geetahi,
tell me first that japanese data is coming from table in japanese text ?
or u just needed to hardcode japanese text ?
if so u can write a format trigger .
Take taht particular column in a seperate frame and on that frame write a format trigger based on the user input for language selection.
try with this.
is it ok?r give me ur requirement clearly once.
--Basava.S -
Conditional format based on date
Hi,
I want to keep track of reports that my students need to turn in. The due date is set, but should turn red 10 days before the actual due date, so I can double check with the student if he started work on his report. Once the report was turned in, the due date should become grey or black. Here's an example:
Report
Topic
Due date
Finished
A
XX
Jan 26, 2012
Jan 25, 2012
B
YY
Feb 5, 2012
C
ZZ
Mrz 11, 2012
C3 is read, because its due date is less than 10 days away. C2 is black, because it has been finished on time. C4 is black, because its due date is more than 10 days away (from the perspective of today, Jan. 27th)
While conditional formats can be set based on dates and relative dates, it doesen't allow to compare actual date to a date calculated from a cell, as far as I can see.
Any help with this is very appreciated!
Thank you!Maybe this sample may fit your needs :
One more case where Numbers User Guide is helpful.
Yvan KOENIG (VALLAURIS, France) vendredi 27 janvier 2012
iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
My Box account is : http://www.box.com/s/00qnssoyeq2xvc22ra4k -
Newbie: Trying to write PL/SQL that is dynamic based on data
Hi everyone,
I was wondering how I would go about writing a report that outer joins based on data from the main table? Here is what I wanna do in pseudo-sql:
SELECT
b.po_number,
a.ht_code,
b.figure_no,
b.order_number,
a.supplier_no,
b.cert_date,
b.plant
FROM header b, part_spec a
where ...
begin:
project = '' /* initialize project */
/* The table to get the project value for the report is named ORDER01 or ORDER02 or ... */
/* It is the word ORDER concatenated with the plant value above. */
select project from 'ORDER' || :PLANT;
END;
How would I do this with APEX 2.0?
I've successfully used APEX to generate SQL Query reports (REGION) but never PL/SQL.
Your help is appreciated,
FerrisWheel
Edited by: FerrisWheel on Dec 15, 2009 10:13 AM
Edited by: FerrisWheel on Dec 15, 2009 10:14 AM
Edited by: FerrisWheel on Dec 15, 2009 10:14 AMOK, Thanks for the quick feedback. Here is a quick generic SQL I wrote up to show my goal using your suggestion. Notice the ERP_ORDERHDR and plant values in each of the SQLs below.
SELECT b.cust_po_no,
a.ht_code,
b.item_no,
b.ERP_ORDER_NO,
a.supplier_code,
b.cert_date,
c.prj
FROM CERT_HDR b, PART_DETL a, ERP_ORDERHDR011 c
WHERE plant = 1
AND a.cert_no = b.cert_no
AND a.cert_no like '%%%' || UPPER(:p1_cert_no) || '%%%'
AND b.cust_po_no like '%%%' || UPPER(:p1_cust_po_no) || '%%%'
AND a.ht_code like '%%%' || UPPER(:p1_ht_code) || '%%%'
AND b.item_no like '%%%' || UPPER(:p1_item_no) || '%%%'
AND b.ERP_ORDER_NO like '%%%' || UPPER(:p1_sales_order) || '%%%'
AND (b.cert_date BETWEEN :P1_DATE_FROM AND :P1_DATE_TO)
AND c.orno (+) = b.ERP_ORDER_NO
AND c.prj like '%%%' || UPPER(:p1_project) || '%%%'
UNION ALL
SELECT b.cust_po_no,
a.ht_code,
b.item_no,
b.ERP_ORDER_NO,
a.supplier_code,
b.cert_date,
c.prj
FROM CERT_HDR b, PART_DETL a, ERP_ORDERHDR012 c
WHERE plant = 2
AND a.cert_no = b.cert_no
AND a.cert_no like '%%%' || UPPER(:p1_cert_no) || '%%%'
AND b.cust_po_no like '%%%' || UPPER(:p1_cust_po_no) || '%%%'
AND a.ht_code like '%%%' || UPPER(:p1_ht_code) || '%%%'
AND b.item_no like '%%%' || UPPER(:p1_item_no) || '%%%'
AND b.ERP_ORDER_NO like '%%%' || UPPER(:p1_sales_order) || '%%%'
AND (b.cert_date BETWEEN :P1_DATE_FROM AND :P1_DATE_TO)
AND c.orno (+) = b.ERP_ORDER_NO
AND c.prj like '%%%' || UPPER(:p1_project) || '%%%'
UNION ALL
SELECT b.cust_po_no,
a.ht_code,
b.item_no,
b.ERP_ORDER_NO,
a.supplier_code,
b.cert_date,
c.prj
FROM CERT_HDR b, PART_DETL a, ERP_ORDERHDR014 c
WHERE (plant = 4 or plant = 5 or plant = 8)
AND a.cert_no = b.cert_no
AND a.cert_no like '%%%' || UPPER(:p1_cert_no) || '%%%'
AND b.cust_po_no like '%%%' || UPPER(:p1_cust_po_no) || '%%%'
AND a.ht_code like '%%%' || UPPER(:p1_ht_code) || '%%%'
AND b.item_no like '%%%' || UPPER(:p1_item_no) || '%%%'
AND b.ERP_ORDER_NO like '%%%' || UPPER(:p1_sales_order) || '%%%'
AND (b.cert_date BETWEEN :P1_DATE_FROM AND :P1_DATE_TO)
AND c.orno (+) = b.ERP_ORDER_NO
AND c.prj like '%%%' || UPPER(:p1_project) || '%%%'
and this would go on for up to 4 more unions. Is there a way to use PL/SQL to make it more clean? Another issue I have with the above is that the c.orno field that I try to outer join is not numeric whereas the b.ERP_ORDER_NO is numeric. I can to_char(c.orno) but how do I do that and still have an outer join? If I can use PL/SQL, I hope to be able to better control the output and eliminate the unions.
I hope this is enough information.
Thanks,
FerrisWheel -
Hide Repeating Frames based on data value
Hello,
Wonderful forum. Hope someone out there can give us input on this one. We have a report where we would like to show a different layout depending on the data value from the master query. One layout occupies a full 8X11 page and the second layout occupies 1/3rd of a page. Is it possible to hide one reapeating frame and show the other based on data value? This would be a multiple page report and each page will have to take the correct payout depending on the value of the data in the row.
I appreciate any input on this. Thanks
RaviThanks for you input. I appreciate it.
I am having a problem doing this. Let us say i have 2 differnt paper layouts. I want to show or hide one of the layouts based on a data value.
The problem i am facing is that the 2nd instance of true value for showing the 1st layout is over lapping the 1st instance of the 2nd layout thus showing 2 layouts overlapping each other on the same page. I know this is confusing but i will attempt to give an example:
page 1 shows - layout #1 only is showing based on result of data value. This is good.
page 2 shows - layout #2 shows based on data value, but also the 2nd instace of layout #1 (what ever data record satisfies layout #1 rule) is also showing over layout #2. So both the layouts are jumbled up on 1 page.
Essentially conditional formatting on layout #1 is not able to recognize that there is a 2nd layout taking its place and thus showing the layout #1 whenever it finds data which satisfies the condition on the 2nd page and so on..
Any help is greatly appreciated.
Thanks.. -
Hi,
I've been really struggling to get this working for a few days and near the point of giving up!!
I'm using output designer 5.4 and I'm trying to change jfmain for the whole document based on data in the file, so if the field type is A, then set it to JFMAIN_A and if it's B, set it to JFMAIN_B. I've nearly got it working by at the top of JFPREAMBLE (just below ^FILE DOCVAR:JFPREAMBLE_1 DICTIONARY) putting the following two lines.
^page JFMAIN_A
^define group:SWITCHPAGE @_$_.@(IF("@TYPE."=="A","\pageJFMAIN_A\field$POSITION\subformHEADER.","\pageJFMAIN_B\fiel d$POSITION\subformHEADER.")).
The only problem with this is that it always prints a page with just the elements (two graphics logos) of JFMAIN_A then prints the report with the correct JFMAIN, either A or B.
If I don't do the
^page JFMAIN_A
It never changes the JFMAIN.
I've tried loads and loads of different permutations of this but nothing works.
Any help would be massively appreciated.
MikeHi there,
Not sure if this will help.
Keep the two foundation pages as JFMain and JFMain_B. By default the central server looks for JFMain for the first page. -
Calculation based on date key figures in BEx
Hi Friends,
Hi Friends,
I need to creat report for sales order data, which involved the calculation based on dates.
In my cune iam having the data at the granual level with the dates as key figures. the calculation that i need to do is VTW = Actual PGI date - Customer want date.
1) whn i run the report at the granual level my VTW is working correctly. No issues.
2) when i run the report at higher levels the date fields are updated with X, as the system is unable to aggrigate the dates. The dates are at the material level in a sales order. I need to show the VTW at the sales order level (each one of the two dates are same for all the materials). So, when i run the report with out mataril at the sales order level...i wanto sea the bothe date fields in a single line and also the VTW calculated as the different between throse two dates.
3) Once we get the VTW correctly at the sales orde level. if i drill down the report for material, i want to sea both the dates in every record againest the matarial, but the VTW only aginest the first record...that is againest the sales order. I dont waht the VTW value repeated/duplicated for all the records againest the sales order,as VTW makes sence only at the Sales Order level.
Please suggest me hwo i can achive the resulsts by meeting both Point 2 and 3.
Thanks for ur help...in advance.
Thanks,
RenuHi..
I have the data from the extractore and in the cube as below.
SALES ORDER ITEM MATERIAL DATE1 DATE2
101 Item1 Mat1 01/01/2010 15/01/2010
101 Item2 Mat2 01/01/2010 15/01/2010
101 Item3 Mat3 01/01/2010 15/01/2010
I need the reports as below...
Report1:
SALES ORDER DATE1 DATE2 VTW (DATE2 - DATE1)
101 01/01/2010 15/01/2010 14
currently iam getting this Report1 output as below...
SALES ORDER DATE1 DATE2 VTW (DATE2 - DATE1)
101 X X 42
Report2: Out put required as below
SALES ORDER ITEM MATERIAL DATE1 DATE2 VTW (DATE2 - DATE1)
101 Item1 Mat1 01/01/2010 15/01/2010 14
101 Item2 Mat2 01/01/2010 15/01/2010
101 I tem3 Mat3 01/01/2010 15/01/2010
currently iam getting this Report2 output as below...
SALES ORDER ITEM MATERIAL DATE1 DATE2 VTW (DATE2 - DATE1)
101 Item1 Mat1 01/01/2010 15/01/2010 14
101 Item2 Mat2 01/01/2010 15/01/2010 14
101 I tem3 Mat3 01/01/2010 15/01/2010 14
As VTW is need to be measued at the sales order level and we always have the DATE1 & DATE2 as same for all the itesm, it should be shon as only 14 in the first record. It mean once iget the required output from Report one in a single line with VTW as 14, it should not repeat with every line , when i dril down the report for Items or materials.
Even if i can generate oly report2 as required in a single sheet ...that will be enough.
Plas kindly provide some solution as how we can achieve this,
Thanks,
Renu -
Hi,
I am trying to output only a successful job during the past 24 hrs of each day. If there is job that has an outcome of a success and a failure within the last
24 hrs for each day, I want to only output the successful one. If there are no success for the same job, I will output the last attempted failed job.
Here are my columns:
current output:
JOB_ID JOBDATE GROUP PATH OUTCOME FAILED LEVEL ASSET
3400908 7/27/2012 10:01:18 AM polA target1 Success 0 incr clone1
3400907 7/27/2012 10:01:09 AM polA target1 Failed 0 incr clone1
3389180 7/23/2012 10:01:14 AM polA target1 Failed 1 incr clone1
3374713 7/23/2012 10:01:03 AM polA target1 Success 0 incr clone1
3374712 7/22/2012 11:24:32 AM polA target1 Success 0 Full clone1
3367074 7/22/2012 11:24:00 AM polA target1 Failed 1 Full clone1
3167074 7/21/2012 10:01:13 AM polA target1 Success 0 incr clone1
336074 7/21/2012 10:01:08 AM polA target1 Success 0 incr clone1
desired output:
JOB_ID JOBDATE GROUP PATH OUTCOME FAILED LEVEL ASSET
3400908 7/27/2012 10:01:18 AM polA target1 Success 0 incr clone1
3374713 7/23/2012 10:01:03 AM polA target1 Success 0 incr clone1
3374712 7/22/2012 11:24:32 AM polA target1 Success 0 Full clone1
3167074 7/21/2012 10:01:13 AM polA target1 Success 0 incr clone1
Here is a code I am trying to use without success:
select *
from
(selectjob_id, jobdate, group, path, outcome, Failed, level, asset,
ROW_NUMBER() OVER(PARTITION BY group, path, asset ORDER BY jobdate desc) as rn
from job_table where jobdate between trunc(jobdate) and trunc(jobdate) -1 )
where rn = 1
order by jobdate desc;Thanks,
-AbeHi, Abe,
You're on the right track, using ROW_NUMBER to assign numbers, and picking only #1 in the main query. The main thing you're missing is the PARTITION BY clause.
You want to assign a #1 for each distinct combination of group_id, path, asset and calendar day , right?
Then you need to PARTITION BY group_id, path, asset and calendar day . I think you realized that when you named this thread "Query Based *on date partition* ".
The next thing is the analytic ORDER BY clause. To see which row in each partition gets assigned #1, you need to order the rows by outcome ('Success' first, then 'Failed'), and after that, by jobdate (latest jobdate first, which is DESCending order).
If so, this is what you want:
WITH got_r_num AS
SELECT j.* -- or list columns wanted
, ROW_NUMBER () OVER ( PARTITION BY group_id -- GROUP is not a good column name
, path
, asset
, TRUNC (jobdate)
ORDER BY CASE outcome
WHEN 'Succcess'
THEN 1
ELSE 2
END
, jobdate DESC
) AS r_num
FROM job_table j
WHERE outcome IN ('Success', 'Failed')
-- AND ... -- Any other filtering, if needed
SELECT * -- or list all columns except r_num
FROM got_r_num
WHERE r_num = 1
;If you'd care to post CREATE TABLE and INSERT statements for the sample data, then I could test it.
It looks like you posted multiple copies of this thread. I'll bet that's not your fault; this site can cause that. Even though it's not your fault, please mark all the duplicate versions of this thread as "Answered" right away, and continue in this thread if necessary.
Edited by: Frank Kulash on Jul 28, 2012 11:47 PM
This site is flakier than I thought! I did see at least 3 copies of this same thread earlier, but I don't see them now. -
Date Format (Need result in date format)
Dear ,
i have worked on this query which produce result in error, infact i need result in date format and this format 'MON-YY'. :
select to_date( EFFECTIVE_DATE,'MON-YY' ) as MON_YY FROM GL_JE_LINES
but now EFFECTIVE_DATE is like this format '12/31/2008'I tell again: a date has no internal format.
There is only a default output-format for date-objects wich is used as default output format and for implicit date conversions.
If you want to know the actual nls_date_format for your session you can use:
select * from nls_session_parameters where parameter='NLS_DATE_FORMAT';You can change it for your session with:
alter session set nls_date_format='<your_new_date_format>';Please take a look at:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/initparams122.htm
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements004.htm#sthref405
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements003.htm#BABGIGCJ
The internal storage of a date-object does not depend on the actual value of NLS_DATE_FORMAT.
This will only used for output and for implicit conversions e.g. with to_date or to_char without explicit format.
To select a date from a table is also an implicit conversion to character, because you want to see characters on your screen.
Edited by: hm on 29.12.2010 04:20 -
How to get XML format output from Hyperion Financial Reporting
Dears,
We are using Hyperion Financial Reporting to replace FSG in fusion. I found that Hyperion FR report can be exported to html/excel/pdf format. However, I would like the report to export to xml format.It means I only need the xml data source.
Anyone who knows how to get the xml format output from Hyperion FR, is there any avaiable API?I think if you export the report, you will be able to open the .des file in Notepad/Wordpad and see xml content.
-
EJB Query Language where condtion based on date
Hi,
I am using EJB3 query language. In the table I have a column called requestdate which is in date time format. I have created an entity class.
I need to select few records using query language(named queries) based on this requestdate matching to the current date. I want to compare only based on Date value (truncating the time). Something like this
select max(o.req_id) from requests o where o.requestdate = :currentdate
currentdate is java.sql.Date value formatted to yyyymmdd only.
How can I do this using query language?
Please help to me get this done.
thanka
AnuradhaHi Anuradha ,
I'm afraid the query language does not support retrieving the date portion (i.e. truncating the time) from a date field.
I propose you turn you named into a BETWEEN query taking two parameters one for the beginning of the day and another for the end of the day. Then your named query could look like:
SELECT max(o.req_id) FROM requests o WHERE o.requestdate BETWEEN :start AND :end
The following code creates two calendar instances for the current day, one for 00:00:00 and another for 23:59:59:
Calendar start = Calendar.getInstance();
start.set(Calendar.HOUR_OF_DAY, 0);
start.set(Calendar.MINUTE, 0);
start.set(Calendar.SECOND, 0);
start.set(Calendar.MILLISECOND, 0);
Calendar end = Calendar.getInstance();
end.set(Calendar.HOUR_OF_DAY, 23);
end.set(Calendar.MINUTE, 59);
end.set(Calendar.SECOND, 59);
end.set(Calendar.MILLISECOND, 999);
Here is some sample code that creates a query instance for a named query called findMaxRequestPerDay and passes the Date of the above Calendar instance as actual parameter values. It assumes the named query is called findMaxRequestPerDay and the req_id field is a long:
Query query = em.createNamedQuery("findMaxRequestPerDay");
query.setParameter("start", start.getTime());
query.setParameter("end", end.getTime());
Long max = (Long)query.getSingleResult();
I hope this helps.
Regards Michael
Maybe you are looking for
-
Assigning multiple values from a List of Values at detail (table) level
Hi, I have a master detail entry screen. I want to assign multiple values when end user selects an item from the list. The field is at detail level (Table type). I can do it using the "Select one choice" type component (ADF Faces Core) but it doesnt
-
How do I set my mg2520 printer to print on transfer sheetd
trying to print on t shirt transfer paper. cant set to mirror image
-
I can not update my iphone 4 to ios5?
I can not update my iphone 4 to ios5? I get a error message saying that "the iphone could not be resotred, this device isn't elgiable for the requested build. If anyone ran into this problem please advise if you were able to fix this errror. Thanks
-
Problem with Aperture not syncing iPhoto albums to iPad
Want to sync a few choice old photo albums created in iPhoto to my iPad. Since I am now running that old iPhoto library in Aperture I should be able to sync selected albums via iTunes, Aperture and USB. I looked at iTune's photo sync screen and
-
When I call someone, an unusual number shows up on...
I have a problem with my Skype service. When I call people, the number: 661-380-3000 appears to them as the number I am calling from. I have no idea what this number is. It's no where close to my skype number. Please help. I'm paying for an online n