Focal Point
How do you issue a Filedef with maintain

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

February 16, 2005, 04:48 PM
JohnK
How do you issue a Filedef with maintain
I am trying to use fixed format flat file to update the Movies sample focus database using maintain. I created a fixed format flat file called moviesdump and I am now trying to update the movies sample focus database with this data. Here is the code in the maintain file:

=========== start of MoviesUpdt.mnt =============

FILEDEF moviesdump DISK C:\IBI\APPS\JKDEMO\moviesdump.ftm

-RUN
MAINTAIN FILE Movies AND moviesdump
FOR ALL NEXT moviesdump.MovieCode INTO FilmStack;
FOR ALL INCLUDE Movies.MovieCode FROM FilmStack;
END

=============== end of MoviesUpdt.mnt ===========

When I run this code I get the following error message:

(FOC1006) THE DDNAME REQUESTED IS NOT ALLOCATED OR DLBL'ED :
�3�


What is the proper way of allocating the input flat file for the maintain procedure?
February 16, 2005, 08:01 PM
j.gross
[revised]

"I created a fixed format flat file called moviesdump ..."

- but did you also create a matching moviesdump.mas file?

Insert
? FILEDEF
?FF moviesdump

to see what Maintain sees.
February 16, 2005, 09:04 PM
JohnK
Yes I did create a master. The master is as follows:

FILE=MOVIESDUMP ,SUFFIX=FIX
SEGNAME=MOVIESDU,SEGTYPE=S0
FIELDNAME =MOVIECODE ,E01 ,A6 ,A06 ,$
FIELDNAME =TITLE ,E02 ,A39 ,A39 ,$
FIELDNAME =CATEGORY ,E03 ,A8 ,A08 ,$
FIELDNAME =DIRECTOR ,E04 ,A17 ,A17 ,$
FIELDNAME =RATING ,E05 ,A4 ,A04 ,$
FIELDNAME =RELDATE ,E06 ,YMD ,A06 ,$
FIELDNAME =WHOLESALEPR ,E07 ,F6.2 ,A06 ,$
FIELDNAME =LISTPR ,E08 ,F6.2 ,A06 ,$
FIELDNAME =COPIES ,E09 ,I3 ,A03 ,$

I had WebFOCUS create this itself, by first tabling off Movies and including the following statement:
ON TABLE HOLD AS MOVIESDUMP FORMAT ALPHA

I then opened MOVIESDUMP.FTM in an editor, deleted all but one record, and modified the remaining record. Then I attempted to use MOVIESDUMP.FTM as an input file into the maintain procedure, when I got the FILEDEF error message. I added the FILEDEF code to the beginning of the maintain procedure, but WebFOCUS does not seem to be able to understand it. So I don't understand how you can use maintain with a flat file update file.
February 16, 2005, 09:30 PM
j.gross

February 16, 2005, 11:44 PM
JohnK
I had some success, in that I got the maintain update to work through two methods, but I believe either method is clumsy.

The first success was accomplished by including in one fex two steps. In the first step I did a table request with the output being held in a alpha format hold file. This alpha format hold file was then accepted by the second step, which was the maintain step. All this occured within a single fex.

The second method, was to Filedef the input file (for the maintain) in the EDASPROF.PRF file. Then when the maintain procedure was run, it was able to read the input file. In this case, the input file was created though a separate process.

Rather than using these approaches, I would prefer to use a simpler method, where I update a FOCUS file through a simple flat file. This flat file could be coming from another process, which may or may not be FOCUS. I also would like to avoid updating the EDASPROF.PDF everytime I choose to use a flat file as input into maintain.

In the old days, when I used MODIFY, a user could update a FOCUS file using any flat file, by simply FILDEFing the input file and if necessary, describing the file layout of the incoming data.

That method, did not required modifying EDASPROF.PRF, or the creation of a temporary hold file in the same modify fex.

Does the maintain facility have a similar simple feature for updating using a simple flat file?
February 17, 2005, 08:41 AM
j.gross
If the input file is not HUGE (you are slurping the entire file into a stack), I suggest you let TABLE read and HOLD it, and then have Maintain use the HOLD output. That way if there is a problem accessing the data the error messages will come from good-old Table, so they will be more informative, or at least more familiar (and searchable in techsupport).

If large, at least have table read and SAVE some input transactions (under a record-limit) to a throw-away ddname, so you can verify access to the dataset and its mfd before getting into Maintain.

Also - Did you verify whether using short filenames makes a difference, as I suggested earlier? There used to be an 8-char limit in FILEDEF and MAINTAIN (a legacy of VM and MVS), so that's where the instability may lie.
February 17, 2005, 12:22 PM
JohnK
I have determined what the problem has been with reading a flat file into maintain.

I have been using the following code:

FILEDEF SHORTFD DISK C:\IBI\APPS\JKDEMO\FILMDATA.FTM
-RUN
MAINTAIN FILE Movies AND shortfd
FOR ALL NEXT shortfd.MovieCode INTO FilmStack;
FOR ALL INCLUDE Movies.MovieCode FROM FilmStack;
END

Since this is a "Maintain" procedure, I created it with a filetype of ".mnt". Then I would executed in Developer Studio from the maintain folder. Apparently, the "engine" that WebFOCUS runs for a ".mnt" procedure has trouble understanding what a Filedef is, and I get errors.

But if I rename the same procedure, with a suffix of ".FEX", it becomes an ordinary FEX which happens to contain a "Maintain" step. The "engine" that WebFOCUS uses for a "FEX" has no problem understanding the Filedef, and the procedure works properly.

So by including the maintain procedure in a fex, there is no need for either updating the EDASPROF.prf file, or including the TABLE and ON TABLE HOLD AS ALPHA step in the procedure.

I suspect that maintain procedures need to have a filetype of ".mnt" only if it includes a form. For batch processing, where the input is a flat file, then the filetype can be ".fex'.

Jack, thank you for your assistance.
February 22, 2005, 10:49 AM
Maintain Wizard
John
Just to confirm what you already figured out. The true solution to FILEDEF is to place the command in the EDASPROF. The MNT files can ONLY have Maintain commands. Anything that precedes the word Maintain or follows the word END is either ignored or will give an error.

If you just have a FEX, then you can get away with more and have Dialogue Manager and other commands in the same FOCEXEC.

Mark
February 22, 2005, 04:48 PM
<LostinLife>
I was using a different platform � Web Focus 5.2.6 we got the same error. The format was a VSAM file and to resolve I DYNAM ALLOC the VSAM file to my profile. Restarted Developer Studio and it worked. Hope this information helped.

Eeker