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.
am trying to merge two hold files using loop unfortunately it is not taking the MORE and FILE command. the file name I get from a filename
here is the dummy code I tired. Please let me know if there is anyway to get this.
TABLE FILE GETFILES
PRINT FILENAME
ON TABLE SAVE AS FLNAME
END
-RUN
-SET &CNT=1;
-READ FLNAME &FN.&CNT.A10.
-SET &CNT=&CNT+1;
TABLE FILE &FN.&CNT
PRINT *
ON TABLE HOLD AS FINALHLD
-REPEATE LO WHILE &CNT LE &LINES
MORE
FILE &FN.&CNT
END
-LO
END
if I do it normal way it would be as below for example. The below is the normal way of merging the hold file I wanted to have a loop to do that. Please let me know if there is a way to bring this.
TABLE FILE FEBFILE
PRINT *
ON TABLE HOLD AS FINALHLD
MORE
FILE MARFILE
MORE
FILE APRFILE
END
This message has been edited. Last edited by: <Kathryn Henning>,
That APPEND on the end of the command allows you to add records to the end of the existing ftm file (hold file) instead of overwriting. At that point your loop would simply go through each of your filenames, writing to the same ddname.
J.
Posts: 1012 | Location: At the Mast | Registered: May 17, 2007
Am not an expert on loops (as I have one way I always structure them and stick with it!) - am I right in thinking you are not varying the value of &cnt within your loop - so you will enter the loop with one value of &cnt and stay in it without any way out? Am sure you are wanting to start with &cnt at a value of 1 and work up to the value held in &lines and I don't think you are doing that..
7.7.05 Windows.
Posts: 39 | Location: UK | Registered: July 11, 2012
please try below code, May be this can solve your problem. But for this code, you have to maintain the same structure of hold files. ------------------------- -***************************************************************************** -* SET VARIABLE APP HOLD ibisamp -SET &ECHO = ALL; -*----------------------------------------------------------------------------- -***************Creating hold file which contains the table name*************** -****************************************************************************** TABLE FILE GETFILES PRINT TABLE_NAME ON TABLE HOLD AS FLNAME FORMAT ALPHA END -*----------------------------------------------------------------------------- -********Reading The Table Names and Dyanamic Holdfile Creation**************** -****************************************************************************** -TYPE &LINES -SET &COUNTER=&LINES; -SET &A_CNT=1; -REPEAT LOOPING &COUNTER TIMES -READ FLNAME &TABLE_NAME.A25 -SET &TABLE_NAME=EDIT(&TABLE_NAME,'$$$$$$999999999'); -TYPE &TABLE_NAME -SET &FILENAM=HOLDFILE||&A_CNT TABLE FILE &TABLE_NAME.EVAL PRINT DIV DEPT ON TABLE HOLD AS &FILENAM END -SET &A_CNT = &A_CNT + 1; -LOOPING
-*----------------------------------------------------------------------------- -********Adding Hold File Using More Command*********************************** -******************************************************************************
-TYPE &A_CNT 'COUNTER' -*-SET &F_CNT=CSAHOLD||&A_CNT; -SET &COL_CNT=&A_CNT-2; -SET &A_CNT=2; TABLE FILE HOLDFILE1 PRINT * ON TABLE HOLD AS FINALHOLD -REPEAT LOOPING1 &COL_CNT TIMES -SET &FIL_NAME=HOLDFILE||&A_CNT; MORE FILE &FIL_NAME -SET &A_CNT = &A_CNT + 1; -LOOPING1 END
Where do we start? When you are building code using DM, try using -SET &ECHO=ON; to trap the code that you are creating. You should then see why your code doesn't work!!
Next, your code is not structured correctly.
You increment the counter before you issue the first table request.
You do not have a subsequent -READ to get the next value for filename.
When using subscripts, you need to use the .EVAL extension.
You have an incorrectly placed END statement rendering the subsequent MORE offerings outside of the request structure.
Although you do not have a -RUN within your loop, it can be good practice to use NOCLOSE with -READ.
-SET &CNT=1; -READ FLNAME &FN.&CNT.A10. -SET &CNT=&CNT+1; -* This needs to be within the loop to be effective
TABLE FILE &FN.&CNT -* The first point is not needed. Better to code it as &FN&CNT.EVAL PRINT * ON TABLE HOLD AS FINALHLD -REPEATE LO WHILE &CNT LE &LINES; MORE FILE &FN.&CNT.EVAL -* You need to repeat the -READ statement here to get the next filename END-* This causes incorrect syntax to be issued -LO END
My tuppence worth? I would be inclined to use the newer -READFILE syntax.
There is no substitute for using standard debug options such as -SET &ECHO and checking that your syntax is correct. You knew what you needed from hand coding it, so why do you not check the syntax created?
TThis message has been edited. Last edited by: Tony A,
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, 2004
Example using -READFILE without the unnecessary &CNT!
FILEDEF FINALHLD DISK FINALHLD.FTM (APPEND
-RUN
-READFILE GETFILES
TABLE FILE &FILENAME
PRINT *
ON TABLE HOLD AS FINALHLD
-REPEAT :Loop2 WHILE &IORETURN EQ 0;
-READFILE GETFILES
-IF &IORETURN NE 0 THEN GOTO :Loop2;
MORE
FILE &FILENAME
-:Loop2
END
TABLE FILE FINALHLD
PRINT *
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, 2004
Thanks Tony for your feedback. your code is very nice. But as per Subbu's query what i understand, Subbu has a list of table names in an other table and need to read the table name value in that table for creating the hold file dynamically.
Please suggest me if im wrong.
Thanks! @vi
WebFOCUS 8105, Dev Studio 8105, Windows 7, ALL Outputs
If you want a fuller example using a sample database (GGSALES), then try this -
-DEFAULTH &FILENAME = '', &MNTHYEAR = ''
DEFINE FILE GGSALES
YEAR/YY = DATE;
MNTH/MT = DATE;
MNTHYEAR/MTYY = DATE;
FILENAME/A10 = EDIT(FPRINT(MNTHYEAR, 'MTYY', 'A10'), '999FILE');
END
TABLE FILE GGSALES
SUM MNTHYEAR
BY MNTHYEAR NOPRINT
BY FILENAME
WHERE YEAR EQ 1996;
WHERE MNTH FROM 2 TO 6;
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE HOLD AS GETFILES
END
-RUN
-READFILE GETFILES
-REPEAT :Loop WHILE &IORETURN EQ 0;
-TYPE &|FILENAME IS &FILENAME
TABLE FILE GGSALES
SUM DOLLARS
FILENAME
BY REGION
BY ST
BY CITY
WHERE MNTHYEAR EQ &MNTHYEAR
ON TABLE HOLD AS &FILENAME
END
-RUN
-READFILE GETFILES
-:Loop
FILEDEF FINALHLD DISK FINALHLD.FTM (APPEND
-RUN
-READFILE GETFILES
TABLE FILE &FILENAME
PRINT *
ON TABLE HOLD AS FINALHLD
-REPEAT :Loop2 WHILE &IORETURN EQ 0;
-READFILE GETFILES
-IF &IORETURN NE 0 THEN GOTO :Loop2;
MORE
FILE &FILENAME
-:Loop2
END
TABLE FILE FINALHLD
PRINT *
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, 2004
When using subscripts, you need to use the .EVAL extension.
I think you mean "... you should not use .EVAL"
Consider, for &CNT = 2:
-READ FLNAME &FN.&CNT.A10. /* reads a filename value into &FN2
TABLE FILE &FN.&CNT /* equivalent to &FN2, which evaluates to the second filename
FILE &FN.&CNT.EVAL /* equivalent to &FN.2 which probably generates an error, since plain &FN is unassigned
Then again, unless there is need to preserve the series of values for later re-use, why not just use (and re-euse) plain &FN to hold the successive filenames?
- Jack Gross WF through 8.1.05
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005
Thanks for all(John, Tony,Avinash) your solutions given. I have completed my task with Filedef however I learnt new things.
Tony - Thanks for pointing the unstructured code, like I said it is dummy code i.e.. I just put for anyone just reference what I'm looking for. Thank you for all your comments or suggestions.