Focal Point
[SOLVED] MAINTAIN file name question

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

March 10, 2009, 07:59 AM
Ron R
[SOLVED] MAINTAIN file name question
We have files that we create monthly. Every month the file name changes depending on the month and the year. e.g. ybmart0901, ybmart0902, ect. We are trying to build a maintain app that will allow a user to update the current month file. Is there some way to dynamically enter the maintain file name?

Thanks,
Ron

This message has been edited. Last edited by: Kerry,
March 10, 2009, 08:18 AM
Laure
Might be simplistic, but can't you populate an amper variable with the file name before the MAINTAIN statement?

-* strip the month and year from the system date and append to the static text.
-SET &FILENAME = 'ybmart' | 'yr_mth' ;
MAINTAIN FILE &FILENAME
.....


Laure


Prod: WebFOCUS 7.7.03 - MRE, BID, - WindowsXP - Oracle 9i, SQLServer, DevStudio 7.7.3 - Apache Tomcat , Output: HTML, Excel 2013 and PDF
March 10, 2009, 09:27 AM
Ron R
It looks like your idea might work for us. I was told by tech support that there was no way to make a MAINTAIN procedure dynamic. Maybe I asked the question wrong.

Thanks,
Ron
March 10, 2009, 09:39 AM
Maintain Wizard
Morning Ron -
You DID ask the right question. When you are creating a Maintain application with forms, it is not possible to do: MAINTAIN FILE &FILE. The reason for this is, every control that is placed on the form is tagged as: Master.Segment.Field. If your Maintain does not have forms, and the field names ARE the same, then you could probably use Amper Variables and run the procedure as a FEX instead of an MNT.

Now, having said that, there is another thing you can do. Since Maintain DOES store all of the names in the MNT file for both the code and the Winforms you could open the Maintain procedure in Wordpad and do a global replace and change the name of the Master File monthly with the new name. It's more than just changing the file name on the Maintain line. The global replace would change the form objects as well. Again, this assumes that the segment and field names are the same. There may even be a way to do this with a macro.

I hope this helps.

Mark
March 10, 2009, 10:04 AM
Ron R
Mark,
Thanks for clearing this up. I wasn't making the correct distinction between a fex and a mnt. I didn't know there was that big of a difference.

Unfortuantely we use this monthly file naming technique in a number of different instances, which makes using MAINTAIN a tough sell.

Ron

Ron
March 10, 2009, 10:28 AM
Maintain Wizard
Ron
Please let me know if I can be of any assistence in any way. You can e-mail me directly at:
Mark_Derwin@IBI.Com

Mark
March 11, 2009, 11:46 AM
Dave Ayers
Ron,

If the databases are Focus files you could:

-SET &DBNAME = 'YBMART' || &MONTH || '.foc';

USE &DBNAME AS YBMART
END

So you would have one Master for the maintain, and a sliding datasource name. I'm not sure if this will work, but it is another approach.

Or, maybe you could change the DATASET attribute in a common Master, but only for Focus, VSAM, or flat file types.


Regards,
Dave

http://www.daveayers.com

WebFocus/Maintain 7.6.4-8
on Win2000 and 2003 Server
March 12, 2009, 04:57 AM
GamP
Ron,

The following will only work if the master/access files are always 100% the same across all the months (except for the naming of the file), and if it works, it will work for all database types.

You could create an html form that lists all the available months. Then you could create a fex that pick up the user's selection, transforms that to the correct name of the master and access file, and copies that master/access file to the current temp directory as master/access file without the month part. Within that copied master/access file references are still being made to the correct month file. Then you could possibly start the maintain, that uses only the master without month extension.

Just my 2ct's, hope it helps ...


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
March 12, 2009, 05:07 AM
Rafael
Ron:

Try these
DYNAM ALLOC FILE [master name] DA [file included server path] SHR REU


WebFOCUS 7.6.5
Windows
March 18, 2009, 01:56 PM
Ron R
Thanks for all of your suggestions. We’ve come up with a kind of hybrid solution to our multi-month file name issue. What we’ve done is for all queries we use the EXEC command to call a focus procedure. By using this technique, the user can select the file name and we can then pass the filename to the procedure as an argument and get the data back into a MAINTAIN stack.

For all "update" type functionality, we use the CALL command to call a maintain procedure. In the maintain procedure we have an if statement based on the filename selected. We plan on changing the file names at the beginning of each year. By using the EXEC and CALL functionality, we have minimized and compartmentalized the code that will need to be changed each year.

Here is an som example code

Exec ybmartQuery from databasestack().filename sQueryString sRecordLimit into gridstack;

ybmartquery.fex code:

TABLE FILE &1
PRINT *
&2
&3
ON TABLE PCHOLD
END


CALL UPDATEPROC from gridstack selectperiodstack;

Here is an example of the UPDATEPROC maintain procedure:

MAINTAIN FILES YBMART0901
AND YBMART0902
AND YBMART0903
AND YBMART0904
AND YBMART0905
AND YBMART0906
AND YBMART0907
AND YBMART0908
AND YBMART0909
AND YBMART0910
AND YBMART0911
AND YBMART0912
FROM gridstack selectperiodstack

Infer YBMART0901.SEG01.YBPORT YBMART0901.SEG02.AS_OF_DATE into gridstack;
Compute selectperiodstack.filename / A20;

IF selectperiodstack(selectperiodstack.focindex).filename EQ 'ybmart0901' THEN BEGIN
For all update YBMART0901.SEG01.ISSUE_NAM YBMART0901.SEG01.TICKER from gridstack(1) ;
TYPE "YBMART0901 has been updated";
ENDBEGIN
ELSE IF selectperiodstack(selectperiodstack.focindex).filename EQ 'ybmart0902' THEN BEGIN
For all update YBMART0902.SEG01.ISSUE_NAM YBMART0902.SEG01.TICKER from gridstack(1) ;
TYPE "YBMART0902 has been updated";
ENDBEGIN
.
.
.
END

Thanks,
Ron