Focal Point
[SOLVED] Setting an Amper variable from a fex.

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

April 03, 2012, 11:14 AM
paulI
[SOLVED] Setting an Amper variable from a fex.
After much searching, I am stumped. I am trying to run a fex and then take the ouput from that fex to set an amper variable to be used elsewhere in a larger procedure. This would be like a subroutine. My code is as follows:
-TOP
-SET &ECHO=ALL;
-? &
TABLE FILE RORCRHR
SUM
   	 'RORCRHR.RORCRHR.RORCRHR_AIDY_CODE' AS 'AIDY'
BY 'RORCRHR.RORCRHR.RORCRHR_TERM_CODE' AS 'Term' NOPRINT
WHERE RORCRHR.RORCRHR.RORCRHR_TERM_CODE EQ '&TERM';
ON TABLE SET HOLDFORMAT ALPHA
-*ON TABLE PCHOLD FORMAT HTML
ON TABLE HOLD AS HOLDAIDY
END
-RUN
-READ HOLDAIDY &AIDY.A4. CLOSE
-IF &IORETURN NE 0 GOTO ENDIT;
-TYPE &AIDY
-ENDIT;  


If I run just the fex out to HTML, I get a valid value. Useing -TYPE, is gives me zeros.
Is this possible? What am I doing wrong?

This message has been edited. Last edited by: paulI,


Prod: WF 7.7.05, BID, MRE, 7.7.06M Server, Windows 2008, RedHat, Oracle 11gR1, MS Office 2010
Test: I wish we had one!
April 03, 2012, 12:40 PM
Mary Watermann
Try this:

 SET HOLDLIST = PRINTONLY
-SET &IORETURN = 0;

TABLE FILE RORCRHR
SUM
     'RORCRHR.RORCRHR.RORCRHR_AIDY_CODE' AS 'AIDY'
BY 'RORCRHR.RORCRHR.RORCRHR_TERM_CODE' AS 'Term' NOPRINT
WHERE RORCRHR.RORCRHR.RORCRHR_TERM_CODE EQ '&TERM';
ON TABLE HOLD AS HOLDAIDY FORMAT ALPHA
END
-RUN

-REPEAT ENDIT WHILE (&IORETURN EQ 0)
-READ HOLDAIDY NOCLOSE &AIDY.A4.
-TYPE &AIDY
-ENDIT
-CLOSE HOLDAIDY
 



WF 7.6.10, Windows, PDF, Excel
April 03, 2012, 02:28 PM
paulI
Thanks for the reply Mary. I keep getting Error at or Near line 14....
FOC295 A value is missing for &AIDY.

I do get 1 record from the fex which is what is expected.


Prod: WF 7.7.05, BID, MRE, 7.7.06M Server, Windows 2008, RedHat, Oracle 11gR1, MS Office 2010
Test: I wish we had one!
April 03, 2012, 05:42 PM
Waz
Here is another way.

SET HOLDLIST = PRINTONLY

TABLE FILE RORCRHR
SUM
COMPUTE CNTR/I9 = LAST CNTR + 1 ; NOPRINT
COMPUTE CODE/A?? = '-SET &AIDY' || LJUST(FTOA(CNTR,'(F9)','A9'),'A9') || '=''' || 'RORCRHR.RORCRHR.RORCRHR_AIDY_CODE' || ''';' ;
BY 'RORCRHR.RORCRHR.RORCRHR_TERM_CODE' AS 'Term' NOPRINT
WHERE RORCRHR.RORCRHR.RORCRHR_TERM_CODE EQ '&TERM';
ON TABLE HOLD AS HOLDAIDY FORMAT ALPHA
END
-RUN
-SET &AIDYCNT = &LINES ;
-INCLUDE HOLDAIDY
-? &AIDY

-REPEAT AIDYLOOP FOR &CNTR FROM 1 TO &AIDYCNT
-TYPE &AIDY.&CNTR
-AIDYLOOP




Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

April 05, 2012, 10:39 AM
paulI
Thank you Mary and Waz. I used tidbits from both and a little more digging and came up with the following:
-TOP
-*SET &ECHO=ALL;
-*? &
DEFINE FILE RORCRHR
AIDY1/A4V=RORCRHR.RORCRHR.RORCRHR_AIDY_CODE;
END
TABLE FILE RORCRHR
BY 'RORCRHR.RORCRHR.RORCRHR_TERM_CODE' NOPRINT
BY 'RORCRHR.RORCRHR.AIDY1'
WHERE RORCRHR.RORCRHR.RORCRHR_TERM_CODE EQ '&TERM';
ON TABLE HOLD AS HOLDAIDY FORMAT ALPHA
END
-RUN
-READ HOLDAIDY,&AIDY1.A10

-IF &IORETURN NE 0 GOTO ENDIT;

-SET &AIDY = EDIT(&AIDY1,'$$$$$$9999');

-ENDIT;
END  


This -INCLUDE takes the parm &TERM and builds an amper variable &AIDY to be used in logic following.
Thanks again. Your help is always valuable.
Paul


Prod: WF 7.7.05, BID, MRE, 7.7.06M Server, Windows 2008, RedHat, Oracle 11gR1, MS Office 2010
Test: I wish we had one!
April 09, 2012, 05:57 PM
Waz
Be wary of using -READ HOLDAIDY,&AIDY1.A10

Two things.

1. The comma in the line tells FOCUS that you are reading comma delimited line of info.
2. You should always have the ending period (.A10.)


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

April 10, 2012, 09:58 AM
paulI
Thank you Waz. My oversite. I still get confused with punctuation in Focus. Your comments are greatly appreciated.


Prod: WF 7.7.05, BID, MRE, 7.7.06M Server, Windows 2008, RedHat, Oracle 11gR1, MS Office 2010
Test: I wish we had one!
April 10, 2012, 05:46 PM
Waz
If you are unsure, check the manual.

Actually I think checking the manual is always a good idea.

You don't want to start up some nasty habits. From my experience they become "standard code" and then get caught out in later releases with code tightening.

Also if the documnented code does not work, then techsupport will have to listen to you.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!