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     [CLOSED] Create 1 amper variable for every row in a hold file?

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Create 1 amper variable for every row in a hold file?
 Login/Join
 
Member
posted
I have a hold file that will have 2 columns. It will be small, less than 10 rows.

The data looks like this:

  
COSTCENTER      DESCRIPTION
12345           COST CENTER A
23456           COST CENTER B
34567           COST CENTER C


So looking at that hold file, in this instance there's 3 cost centers each with a description... but the number of cost centers may vary when the report is ran each time.

I would like to use those cost centers in a DEFINE statement.... each cost center getting its own entry. The example below is STATIC but would like to make it dynamic.

  
DEFINE FILE PREP
METRIC1/D15.2 = IF COSTCENTER = &COSTCENTER1 THEN AMOUNT ELSE 0;
METRIC2/D15.2 = IF COSTCENTER = &COSTCENTER2 THEN AMOUNT ELSE 0;
METRIC3/D15.2 = IF COSTCENTER = &COSTCENTER3 THEN AMOUNT ELSE 0;
-*this needs to loop for as many cost centers as there are in the hold file
END



and then later, in a PRINT step, each of those cost centers would get its own entry (the metrics from the define step) with the description of the cost center pulled in.

TABLE FILE PREP
SUM
METRIC1 AS '&COSTCENTER1DESC' -* THIS WOULD BE THE DESCRIPTION OF COST CENTER 1
METRIC2 AS '&COSTCENTER2DESC' -* THIS WOULD BE THE DESCRIPTION OF COST CENTER 2
METRIC3 AS '&COSTCENTER3DESC' -* THIS WOULD BE THE DESCRIPTION OF COST CENTER 3
-*this needs to loop for as many cost centers as there are in the hold file
END


What would be the best way to approach this?

I've done some reading on -READ loops but it isn't entirely clear to me how to do that or what the best approach would be. Any help or direction would be very much appreciated.
Thanks,
Jason

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8009
 
Posts: 14 | Registered: March 27, 2017Report This Post
Silver Member
posted Hide Post
Hello Jason,
I can help you with looping part, probably you can figure it out from there.

1. Use -READFILE and REPEAT to iterate for no. of records in the HOLD file

Example:

-REPEAT LOOPTEMP FOR &A FROM 1 TO &LINES
-READFILE "YOUR TEMP FILE"
-* you can access hold file data using &FILED_NAME1, &FIEL_NAME2 etc. (in your case &COSTCENTER etc.)
...
...
Write your code here of whatever looping is required. For each iteration, each row's data in your hold file can be accessed.
...

-LOOPTEMP

Hope this helps and works out for you.


WebFOCUS 8
Windows, All Outputs
 
Posts: 38 | Registered: July 25, 2016Report This Post
Virtuoso
posted Hide Post
Another approach is to TABLE your costcenters as an ALPHA file containing the DEFINE lines. Next you can simply -INCLUDE that ALPHA file in your DEFINE.

Or better yet, -INCLUDE it directly as COMPUTES in your final TABLE request. In that case you can generate the appropriate descriptions at the same time.

TABLE FILE COSTCENTER
SUM
    COMPUTE LINENR/I1 = LAST LINENR +1; NOPRINT
    COMPUTE LINE/A512 = 'COMPUTE METRIC' || FPRINT(LINENR, 'I1', 'A1') || '/D15.2 = IF COSTCENTER EQ ''' ||
        COSTCENTER || ''' THEN AMOUNT ELSE 0; AS ''' || DESCRIPTION || ''';
BY COSTCENTER NOPRINT
ON TABLE HOLD AS LINES FORMAT ALPHA
END
-RUN

TABLE FILE PREP
SUM
-INCLUDE LINES
END


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Expert
posted Hide Post
Have you thought about doing something like this?

TABLE FILE PREP
SUM AMOUNT
ACROSS COSTCENTER NOPRINT
ACROSS DESCRIPTION
....


As in this example

TABLE FILE GGSALES
SUM DOLLARS
ACROSS ST NOPRINT
ACROSS STCD AS ''
BY REGION
END


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 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Member
posted Hide Post
quote:
Originally posted by Wep5622:
Another approach is to TABLE your costcenters as an ALPHA file containing the DEFINE lines. Next you can simply -INCLUDE that ALPHA file in your DEFINE.

Or better yet, -INCLUDE it directly as COMPUTES in your final TABLE request. In that case you can generate the appropriate descriptions at the same time.

TABLE FILE COSTCENTER
SUM
    COMPUTE LINENR/I1 = LAST LINENR +1; NOPRINT
    COMPUTE LINE/A512 = 'COMPUTE METRIC' || FPRINT(LINENR, 'I1', 'A1') || '/D15.2 = IF COSTCENTER EQ ''' ||
        COSTCENTER || ''' THEN AMOUNT ELSE 0; AS ''' || DESCRIPTION || ''';
BY COSTCENTER NOPRINT
ON TABLE HOLD AS LINES FORMAT ALPHA
END
-RUN

TABLE FILE PREP
SUM
-INCLUDE LINES
END


This approach intrigued me...I tried, but the include step is what threw it off. I got an error saying cannot include the specified resource. Can you include a hold file that is generated within the same fex?


WebFOCUS 8009
 
Posts: 14 | Registered: March 27, 2017Report This Post
Virtuoso
posted Hide Post
It may have unbalanced apostrophes in Wep Code

The following do work:
TABLE FILE CAR
SUM
    COMPUTE LINENR/I1 = LAST LINENR +1; NOPRINT
    COMPUTE LINE/A512 = 'COMPUTE METRIC' || FPRINT(LINENR, 'I1', 'A1') || '/D15.2 = IF COUNTRY EQ ''FRANCE'' THEN RETAIL_COST ELSE 0; AS ''DESCRIPTION''';
BY CAR NOPRINT
ON TABLE HOLD AS LINES FORMAT ALPHA
END
-RUN

TABLE FILE CAR
SUM
-INCLUDE LINES
END

To find out where is the error run only the first TABLE FILE without holding the data and have trace on to see generated code.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Virtuoso
posted Hide Post
2 suggestions:
1. add ON TABLE SET HOLDLIST PRINTONLY
2. use FILEDEF LINES DISK LINES.FEX before the TABLE command.


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

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report 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     [CLOSED] Create 1 amper variable for every row in a hold file?

Copyright © 1996-2020 Information Builders