Focal Point
Setting a parm from a file?

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

November 16, 2004, 07:17 PM
<MikeR>
Setting a parm from a file?
The following code:

-* File CARCO.FEX
TABLE FILE CAR
PRINT
COUNTRY
CAR
WHERE ( COUNTRY EQ
'&CNTRY.Please select country.'
);
END

accepts a country and then shows me a report.

I would like to read &CNTRY from columns 11 - 20 in a sequential file, and then run the report.

Is this possible?

Thank you.
November 16, 2004, 07:24 PM
drew billingslea
You might try something like:

FI CFILE DISK E:\data\cntry.dat
-RUN
-READ CFILE &TRSH.A10. &CNTRY.A10.
-* File CARCO.FEX
TABLE FILE CAR
PRINT
COUNTRY
CAR
WHERE ( COUNTRY EQ
'&CNTRY'
);
END

hth,

drew
November 17, 2004, 12:50 PM
<MikeR>
If I run this:

-* File CARCO.FEX
FI CFILE DISK C:\ISMDR\COUNTRY.DAT
-RUN
-READ CFILE &TRSH.A10. &CNTRY.A10.
-*
TABLE FILE CAR
PRINT
COUNTRY
CAR
WHERE ( COUNTRY EQ '&CNTRY' );
END

I get this error:

0 ERROR AT OR NEAR LINE 9 IN PROCEDURE MEMFEX FOCEXEC *
(FOC295) A VALUE IS MISSING FOR: CNTRY

Is there some way to see if I am getting the correct data in &CNTRY?
November 17, 2004, 01:29 PM
reFOCUSing
Try FILEDEF instead of FI CFILE.
November 17, 2004, 02:24 PM
<MikeR>
FILEDEF gives me the same error
November 17, 2004, 02:29 PM
Leah
Regarding the wanting to get the variable from a file. Is the only record in the file the value you want? If so if you filedef the file and then do a selection

filedef cntry .....
Table file car
if country eq (cntry)
....

This is the method I use to find a set of items usually student records in my case, but you would get all of the 'car' entries in the cntry file so if you had japan and england in the file you would get all cars in japan and england.

Of course I may be completely missinterpreting what you want to do here.

Leah C.
November 17, 2004, 02:30 PM
drew billingslea
to see the values of the -READ, put :

-TYPE trash = &TRSH country = &CNTRY
-EXIT

directly after the -READ

this will display the values and cause the focexec to end before producing any output, this will let you see the results of the -TYPE statement.

hth,

drew
November 17, 2004, 02:41 PM
<MikeR>
First, I would like to thank both Drew and Leah for their suggestions and answer both of them at the same time.

Leah, I do only have 1 record with the country in it, but it's not in the first 10 positions of the record. The real file (I am using the CAR file just to see if I can get this to work) is a sequential file on the mainframe with the search criteria in positions 21 - 29.

Drew, if I run this:

-* File CARCO.FEX
FILEDEF CFILE DISK C:\ISMDR\COUNTRY.TXT
-RUN
-READ CFILE &TRSH.A10.,&CNTRY.A10.
-TYPE trash = &TRSH country = &CNTRY
END

I get a message:

(FOC295) A VALUE IS MISSING FOR: TRSH

which would seem to indicate that there is something wrong with my file definition. I do have a sequential file defined on the mainframe which I eventually want to read if that would simplify things.

Mike R
November 17, 2004, 02:56 PM
drew billingslea
Please remove the comma (,) from your read statement.

Is the file C:\ISMDR\COUNTRY.TXT on the (windows) reporting server? or are you doing this from developer? If your webfocus is on the mainframe; then we need to define the file in a different way to webfocus.

I created a file on my (windows) reporting server with the contents :

1234567890abcdefghij###########

and then I ran this program:

FILEDEF CFILE DISK C:\ibi\apps\TESTDATA.TXT
-RUN

-READ CFILE &TRSH.A10. &CNTRY.A10.

-TYPE trash = &TRSH country = &CNTRY
-EXIT

and I got this result:


No HTML Output!

--------------------------------------------------------------------------------


trash = 1234567890 country = abcdefghij


What mainframe environment are you in? Perhaps it would be easier to work on the solution there.

drew
November 17, 2004, 03:16 PM
<MikeR>
Interesting.... This code:
FI CFILE DISK C:\ISMDR\COUNTRY.DAT
-RUN
-READ CFILE &TRSH.A10. &CNTRY.A10.
-TYPE trash = &TRSH
shows:
trash = 1234567890

This code:
FI CFILE DISK C:\ISMDR\COUNTRY.DAT
-RUN
-READ CFILE &TRSH.A10. &CNTRY.A10.
-TYPE country = &CNTRY
shows:
(FOC295) A VALUE IS MISSING FOR: CNTRY

which seems to indicate that I can read the file which is defined on the C: drive of the Test Server, but can't read 2 fields. I changed the type of the file from TXT to DAT to see if that made a difference, but eventually I would like to read a mainframe file that is defined to WebFocus if it's cleaner to skip the distributed file altogether.
November 17, 2004, 03:24 PM
drew billingslea
that looks very much like you are trying to read more bytes than the file contains.

try adding more bytes than you need to the file or changing the -READ to read fewer bytes from the file (i.e. -READ CFILE &TRSH.A10 &CNTRY.A5. )

drew
November 17, 2004, 03:32 PM
<MikeR>
Drew,

Amazingly simple once you know the answer. Since I have FRANCE in my country field, I changed the second definition from A10 to A6 and it runs like a champ. Thank you very much.

Now, can I point this to a mainframe file? (I don't want to get greedy here - you've gotten me a long way down the road).

Thanks again.

Mike R
November 17, 2004, 06:09 PM
drew billingslea
Mike,

You need to have the file you are going to read available to the reporting server. Do you have the reporting server running on your mainframe where the file is? or what is your setup?

regards,

drew
November 19, 2004, 11:29 AM
<MikeR>
Drew,

The reporting server is running on a Windows box, but it does have access to mainframe files. For example:

TABLE FILE SEQT3
PRINT
CNTRY
END

will print FRANCE from the sequential file.

Mike R
November 19, 2004, 03:13 PM
drew billingslea
Then there are a few ways you could go; like using join with ALL=OFF or match file to select only the inner join data (OLD AND NEW). But I would think a simple approach might be:

TABLE FILE SEQT3
PRINT
CNTRY
ON TABLE SAVE
END
-RUN
-IF &LINES EQ 0 GOTO ... ;
TABLE FILE ...
PRINT ...
WHERE COUNTRY IN FILE SAVE
...

Please make sure that the format for the field from the first (mainframe) file CNTRY is identical to the format of COUNTRY; if not, change it to be so with a define.

This would also allow for multiple CNTRY values. (within the FOCUS limits for files to be used with WHERE)

hth,

drew