Focal Point
retrieve data from a previous record...(RESOLVED)

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7717030006

March 10, 2011, 11:30 AM
ERINP
retrieve data from a previous record...(RESOLVED)
I am having coders block. I have a scenario that I can not seem to figure out what I need to do: I have 4 records, each have a transaction#, sorted by highest (4, 3, 2, 1), if trans#2 has a specific DEFINEd value in it, then I need to retrieve a date value from trans#3 and return that date to the row that contains trans#2, this is Excel or html output. Any ideas or suggestions?

This message has been edited. Last edited by: ERINP,


WebFOCUS 7.6.9

Reporting client Windows 2003 Service pack 2 using IIS and TomCat 5.5
Reporting Server OS/400 V5R4M0
Outputs: HTML, Excel, PDF, CSV, and Flat Files
March 10, 2011, 12:21 PM
RSquared
You can use the "LAST" function.
Example
DEFINE CARRY_OVER/HMDYY=
IF LAST DEFINED_FIELD EQ 'I NEED THEN LAST DATE_NEEDED;


WF 7.6.11
Oracle
WebSphere
Windows NT-5.2 x86 32bit
March 10, 2011, 12:58 PM
ERINP
RSquared I will give it a try...seems to make sense and hopefully that works
thanks,
Erin


WebFOCUS 7.6.9

Reporting client Windows 2003 Service pack 2 using IIS and TomCat 5.5
Reporting Server OS/400 V5R4M0
Outputs: HTML, Excel, PDF, CSV, and Flat Files
March 10, 2011, 01:57 PM
ERINP
RSquared..I attempted your approach to resolve my issue but when I use the 'LAST' in the DEFINE it does not return any data. I tried the following:
1) CARRY_OVER/MDYY = IF LAST DEFINED_FIELD EQ 'Y' THEN LAST DATE_NEEDED; returns no data to CARRY_OVER.
2) CARRY_OVER/MDYY = IF DEFINED_FIELD EQ 'Y' THEN LAST DATE_NEEDED; returns no data to CARRY_OVER
3) CARRY_OVER/MDYY = IF LAST DEFINED_FIELD EQ 'Y' THEN DATE_NEEDED; returns no data to CARRY_OVER
4) CARRY_OVER/MDYY = IF DEFINED_FIELD EQ 'Y' THEN DATE_NEEDED; returns the date but it is for the record that contains the 'Y'.
I'm not sure why the LAST funvtion does not work for any of the 3 attepts that I tried...??...


WebFOCUS 7.6.9

Reporting client Windows 2003 Service pack 2 using IIS and TomCat 5.5
Reporting Server OS/400 V5R4M0
Outputs: HTML, Excel, PDF, CSV, and Flat Files
March 10, 2011, 02:02 PM
Francis Mariani
Don't you need an ELSE in those IF statements, and the data must be previously sorted in the correct order.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
March 10, 2011, 02:15 PM
ERINP
Francis,
those are four seperate attempts to retrieve data from a previous record not four consecutive lines of code therefore the ELSE would not be required. Unless you mean to make them a blank if the conditionis not true like ELSE ''; at the end?
the data is sorted by highest transaction number (4, 3, 2, 1). in my report trans#2 has a DEFINEd value EQ 'Y' if this value EQ 'Y' then I need to retrieve a date value from trans#3 to display it in the row of data for trans#2. But when I apply RSquared logic to my program the LAST function does not return any data. What am I missing here??
Thanks,
Erin


WebFOCUS 7.6.9

Reporting client Windows 2003 Service pack 2 using IIS and TomCat 5.5
Reporting Server OS/400 V5R4M0
Outputs: HTML, Excel, PDF, CSV, and Flat Files
March 10, 2011, 02:33 PM
ERINP
Francis and RSquared,
Upon further attempts and adding the ELSE '' logic to my code I was able to retrieve the proper data. I used the following code to retrieve data from another record:
CARRY_OVER/MDYY = IF DEFINED_FIELD EQ 'Y' THEN LAST DATE_NEEDED ELSE '';
In my example above this returns a date value from trans#3 to the data for trans#2 when the DEFINEd field has a value EQ 'Y'.
I believe the lack of the ELSE logic was the reason the LAST function was not working previously. Thank you for helping me with my coders block.

Erin


WebFOCUS 7.6.9

Reporting client Windows 2003 Service pack 2 using IIS and TomCat 5.5
Reporting Server OS/400 V5R4M0
Outputs: HTML, Excel, PDF, CSV, and Flat Files
March 10, 2011, 03:17 PM
Waz
With an IF THEN ELSE, you MUST always code the ELSE.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!