Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] LAST command

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] LAST command
 Login/Join
 
Member
posted
Hi,

we are new to webfocus . please help me on the below problem.

SET LINES=99999

TABLE FILE EMP
PRINT
IID
-*COMPUTE RNR=RNR+1;
ON TABLE HOLD
END

TABLE FILE HOLD
PRINT
IID
COMPUTE RF/I1 = IF IID EQ 34082 THEN 1 ELSE IF IID EQ 34154 THEN 1 ELSE IF IID EQ 34158 THEN 1 ELSE IF IID EQ 34169 THEN 1 ELSE 0;
ON TABLE HOLD
END

DEFINE FILE HOLD
RF1/I1=IF RF NE 0 THEN RF ELSE LAST RF1;
END

TABLE FILE HOLD
PRINT
IID
RF
RF1
WHERE RECORDLIMIT EQ 30
END
-EXIT
RESULT:
-************
IID RF RF1
34074 0 0
34075 0 0
34078 0 0
34082 1 1
34083 0 1
34093 0 1
34096 0 1
34101 0 1
34102 0 1
34103 0 1
34107 0 1
34125 0 1
34126 0 1
34127 0 1
34151 0 1
34152 0 1
34153 0 1
34154 1 1
34155 0 1
34156 0 1
34157 0 1
34158 1 1
34159 0 1
34166 0 1
34167 0 1
34169 1 1
34181 0 1
34182 0 1
34183 0 1
34184 0 1


i NEED THE RESULT LIKE BELOW FORMAT

IID RF RF1
34074 0 0
34075 0 0
34078 0 0
34082 1 1
34083 0 1
34093 0 1
34096 0 1
34101 0 1
34102 0 1
34103 0 1
34107 0 1
34125 0 1
34126 0 1
34127 0 1
34151 0 1
34152 0 1
34153 0 1
34154 1 1
34155 0 0
34156 0 0
34157 0 0
34158 1 1
34159 0 1
34166 0 1
34167 0 1
34169 1 1
34181 0 0
34182 0 0
34183 0 0
34184 0 0

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


7.6.11, Windows
Excel,html,pdf,xml
 
Posts: 6 | Registered: February 18, 2011Report This Post
Expert
posted Hide Post
Dunno. Please see LAST COMMAND

This message has been edited. Last edited by: Francis Mariani,


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Member
posted Hide Post
Hi Francis,
I have checked given link but posted problem is different . Can you please check posted result format and expetec format .


7.6.11, Windows
Excel,html,pdf,xml
 
Posts: 6 | Registered: February 18, 2011Report This Post
Expert
posted Hide Post
I pointed you to that link because, for LAST to work, the input data file has to be in the correct order,
TABLE FILE EMP
PRINT
IID
-*COMPUTE RNR=RNR+1;
ON TABLE HOLD
END 
This does not guarantee the file is in the correct order.

What you're looking for should be very easy to do.


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
Also, it sometimes is a little boring to read somebody else's code, it would be a lot better if you could post code that uses one of the IBI supplied data tables (CAR, GGORDER, CENTCRED, etc) - in that way, we could run the code and resolve the issue much faster.


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
Here is example code anyone can run:

-*-- Create the master for EMP
APP FI DATAMAST DISK EMP.MAS
-RUN

-WRITE DATAMAST FILE=EMP, SUFFIX=FIX, $
-WRITE DATAMAST SEGNAME=SEG1, SEGTYPE=S0, $
-WRITE DATAMAST FIELD=IID, ALIAS=IID, USAGE=I05, ACTUAL=A05, $

-*-- Create the data file for EMP
APP FI EMP DISK EMP.FTM
-RUN

-WRITE EMP 34074
-WRITE EMP 34075
-WRITE EMP 34078
-WRITE EMP 34082
-WRITE EMP 34083
-WRITE EMP 34093
-WRITE EMP 34096
-WRITE EMP 34101
-WRITE EMP 34102
-WRITE EMP 34103
-WRITE EMP 34107
-WRITE EMP 34125
-WRITE EMP 34126
-WRITE EMP 34127
-WRITE EMP 34151
-WRITE EMP 34152
-WRITE EMP 34153
-WRITE EMP 34154
-WRITE EMP 34155
-WRITE EMP 34156
-WRITE EMP 34157
-WRITE EMP 34158
-WRITE EMP 34159
-WRITE EMP 34166
-WRITE EMP 34167
-WRITE EMP 34169
-WRITE EMP 34181
-WRITE EMP 34182
-WRITE EMP 34183
-WRITE EMP 34184

TABLE FILE EMP
PRINT *
BY IID
ON TABLE HOLD
END
-RUN

TABLE FILE HOLD
PRINT
IID
COMPUTE RF/I1 = IF IID IN (34082, 34154, 34158, 34169) THEN 1 ELSE 0;
BY IID
ON TABLE HOLD
END
-RUN

DEFINE FILE HOLD
RF1/I1 = IF RF NE 0 THEN RF ELSE LAST RF1;
END
-RUN

TABLE FILE HOLD
PRINT
IID
RF
RF1
BY IID
END
-RUN


34169 1 1
34181 0 1
34182 0 1
34183 0 1
34184 0 1 

For 34181, RF is equal to zero, so
 RF1/I1=IF RF NE 0 THEN RF ELSE LAST RF1; 
RF1 will evaluate to 34169's value (1), which it does, so where's the problem?


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
Hi Raoja,

Here is some suggestion from our expert, expanding on Francis’ example: (many thanks for Francis' input Smiler)

remove:

DEFINE FILE HOLD
RF1/I1 = IF RF NE 0 THEN RF ELSE LAST RF1;
END
-RUN

TABLE FILE HOLD
PRINT
IID
RF
RF1
BY IID
END
-RUN

and change it to :

TABLE FILE HOLD
PRINT
IID
RF
COMPUTE RFA/I1=IF RF EQ 1 THEN
(IF RFA EQ 0 THEN 1 ELSE 0) ELSE LAST RFA;
COMPUTE RF1/I1=IF RF EQ 1 THEN 1 ELSE RFA;
BY IID
END
-RUN

Also, please note that when using LAST in a DEFINE, the data must be in the expected sort order, but when using it in a COMPUTE the order is determined by the BY phrases in the TABLE request.

Cheers,

Kerry


Kerry Zhan
Focal Point Moderator
Information Builders, Inc.
 
Posts: 1948 | Location: New York | Registered: November 16, 2004Report This Post
Member
posted Hide Post
Thanks Kerry . Its work fine. Smiler


7.6.11, Windows
Excel,html,pdf,xml
 
Posts: 6 | Registered: February 18, 2011Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] LAST command

Copyright © 1996-2020 Information Builders