Focal Point
[SOLVED] Issue with LAST function.

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

April 12, 2010, 07:17 AM
lalita
[SOLVED] Issue with LAST function.
Hi,

We have a requirement in the report to display a concatenated stirng of PERSON_IDs(say P_ID).
This I am generating in DEFINE. P_ID is based on ISSUE_ID(say I_ID) and AUTHER_ID(A_ID).

The data is something like : --

P_ID I_ID A_ID
---- ----- -----
P1 800 1
P2 800 1
P2 800 3

The code I've return is

DEFINE HOLD_DUMMY
P_ID_STRING/A1000V = IF (I_ID EQ LAST I_ID) AND (P_ID NE LAST P_ID) THEN LAST P_ID_STRING|(P_ID||'@ ; ') ELSE P_ID||'@ ; ';
END

The result I am getting is : P2@;

Expected result : P1@;P2@;

Please let me know if you have any solution.

Thanks.

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


764
Windows
PDF,EXL2K,HTML
April 12, 2010, 07:33 AM
Dan Satchell
Try:

P_ID_STRING/A1000V = IF (I_ID NE LAST I_ID) OR (P_ID NE LAST P_ID) THEN P_ID||'@ ; ' ELSE LAST P_ID_STRING|(P_ID||'@ ; ');



WebFOCUS 7.7.05
April 12, 2010, 08:44 AM
Danny-SRL
Using the CAR file:
  
-* File lalita01.fex
TABLE FILE CAR
PRINT CAR SEATS
BY COUNTRY
ON TABLE HOLD
END
DEFINE FILE HOLD
C_STRING/A1000V = IF (COUNTRY NE LAST COUNTRY) THEN CAR || '@;'
                  ELSE IF (CAR NE LAST CAR) THEN LAST C_STRING | (CAR || '@;') ELSE LAST C_STRING;
END
TABLE FILE HOLD
PRINT CAR COUNTRY SEATS C_STRING
END



Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

April 12, 2010, 10:15 AM
lalita
Hi Danny -- you logic worked perfectly. Thanks a lot !!


764
Windows
PDF,EXL2K,HTML
April 13, 2010, 02:31 AM
Tony A
Using LAST within a define requires that the input file is in the exact sort order that your code logic requires. If this is not the case then you would be better served doing the new field via a COMPUTE within you code.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
April 14, 2010, 06:40 AM
Danny-SRL
Tony,

Very true! Wink


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

April 14, 2010, 08:14 AM
Tony A
quote:
Very true!

Thanks Danny, that's why I mentioned it Razzer

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
April 14, 2010, 11:48 AM
njsden
quote:
Using LAST within a define requires that the input file is in the exact sort order that your code logic requires. If this is not the case then you would be better served doing the new field via a COMPUTE within you code.


Very true indeed! Lalita, just keep in mind that, if you use the COMPUTE approach, you'll be using a PRINT verb and *not* a SUM, otherwise it won't work as you might expect.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.