Focal Point
[CLOSED]Run Procedure Multiple Times with Single Input Parameter

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

November 30, 2011, 01:41 PM
dburton
[CLOSED]Run Procedure Multiple Times with Single Input Parameter
I have my HTML Launch page that asks the user for a TO and FROM date. I would like these parameters to run the same report, multiple times. The first time through it would run with the dates entered in the field.

The second run of the same report would be the same report subtract one year.

The third time would be the same report subtract 2 years.

I am not sure how to change the parameter and run the other two instances of the report. Any help would be appreciated.

Thanks,

Dave

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


WebFOCUS 7.7.03
Windows Web Server 2008
MS SQL Server 2000
Excel,CSV,PDF,HTML
November 30, 2011, 03:25 PM
Dan Satchell
You could use a -REPEAT loop. Let's assume the variables coming from your launch page are named &DATE_FROM and &DATE_TO, in mmddyyyy format.

-SET &YEAR_FROM = EDIT(&DATE_FROM,'$$$$9999');
-SET &YEAR_TO   = EDIT(&DATE_TO,'$$$$9999');
-*
-REPEAT :ENDREPEAT1 FOR &I FROM 0 TO 2
-SET &BEG_YEAR = &YEAR_FROM - &I ;
-SET &END_YEAR = &YEAR_TO - &I ;
-SET &BEG_DATE = EDIT(&DATE_FROM,'9999$$$$') | &BEG_YEAR ;
-SET &END_DATE = EDIT(&DATE_TO,'9999$$$$')   | &END_YEAR ;
-*
TABLE FILE xxxx
 PRINT/SUM etc.
 BY etc.
 WHERE <xxxx.date_field> FROM '&BEG_DATE' TO '&END_DATE';
 ON TABLE HOLD/PCHOLD AS REPORT&I
END
-*
-:ENDREPEAT1

This message has been edited. Last edited by: Dan Satchell,


WebFOCUS 7.7.05
November 30, 2011, 03:39 PM
dburton
This would work. However, I don't think I explained my self properly.

I would have 3 different report frames on the HTML page with the same procedure referenced in each frame. For example, I select a date in YYMD format of '20110101' and that is assigned to the variable &DATE_FROM. The first report would run with that value in the first report frame. The second report would run with the value '20100101' in the second report frame and the third report would run with the value '20090101'. All by only clicking the Run button once.

I hope that helps explain things.

Thanks.


WebFOCUS 7.7.03
Windows Web Server 2008
MS SQL Server 2000
Excel,CSV,PDF,HTML
July 06, 2012, 05:03 PM
Kevin Patterson
I'm looking to do the exact same thing. Did you get anywhere this since since last November?


Kevin Patterson
Appalachian State University
WebFOCUS 7.7.03
Windows, All Outputs
July 06, 2012, 06:50 PM
Dan Satchell
I believe in the HTML Composter Hyperlink properties for a button, you can specify multiple actions. Each action allows you to specify a different target frame. If you have a separate focexec for each of the three reports, you could specify all three as actions for your RUN button. Your date value (&INPUT_DATE in the example below) would be passed as a parameter to all three focexecs. Each focexec would subtract the appropriate number of years from the input date before proceeding. To avoid having three different copies of the same report, each focexec could simply have a -INCLUDE for the report focexec and pass the appropriate date value. For example:

runexec1.fex:
-SET &REPORT_DATE = &INPUT_DATE ;
-*
-INCLUDE REPORT
-RUN

runexec2.fex:
-SET &INPUT_YEAR   = EDIT(&INPUT_DATE,'9999$$$$');
-SET &INPUT_MTHDAY = EDIT(&INPUT_DATE,'$$$$9999');
-SET &REPORT_YEAR  = &INPUT_YEAR - 1 ;
-SET &REPORT_DATE  = &REPORT_YEAR || &INPUT_MTHDAY ;
-*
-INCLUDE REPORT
-RUN

runexec3.fex:
-SET &INPUT_YEAR   = EDIT(&INPUT_DATE,'9999$$$$');
-SET &INPUT_MTHDAY = EDIT(&INPUT_DATE,'$$$$9999');
-SET &REPORT_YEAR  = &INPUT_YEAR - 2 ;
-SET &REPORT_DATE  = &REPORT_YEAR || &INPUT_MTHDAY ;
-*
-INCLUDE REPORT
-RUN


EDIT: I've never actually tried the above and I suppose it's possible running the three focexecs at the same time might have them stepping on each other. (Does WF initiate three agents or one?) So it might be necessary to chain the three frames so they run sequentially instead of concurrently. Just a thought...

This message has been edited. Last edited by: Dan Satchell,


WebFOCUS 7.7.05
July 10, 2012, 08:19 AM
dburton
quote:
Originally posted by Kevin Patterson:
I'm looking to do the exact same thing. Did you get anywhere this since since last November?


Dan is right, it is easier to use 3 different procedures and use the same button and two input parameters to control all 3 outputs on the HTML page. So, that's exactly what I did. I took the same report and created 3 copies of it and then just modified the parameters for the dates to subtract a year or two depending on what I needed. The code i used is below.


 
first procedure: 
-SET &DATEFROM = IF &DATEFROM EQ '' THEN 'FOC_NONE' ELSE '20'||STRIP(&DATEFROM.LENGTH,&DATEFROM,'/',&DATEFROM);
-SET &DATETO = IF &DATETO EQ '' THEN 'FOC_NONE' ELSE '20'||STRIP(&DATETO.LENGTH,&DATETO,'/',&DATETO);
-SET &FROMDATE = IF &DATEFROM NE 'FOC_NONE' THEN EDIT(&DATEFROM,'9999$$$$')|'-'|EDIT(&DATEFROM,'$$$$99$$')|'-'|EDIT(&DATEFROM,'$$$$$$99') ELSE 'FOC_NONE';
-SET &TODATE = IF &DATETO NE 'FOC_NONE' THEN EDIT(&DATETO,'9999$$$$')|'-'|EDIT(&DATETO,'$$$$99$$')|'-'|EDIT(&DATETO,'$$$$$$99') ELSE 'FOC_NONE';

second procedure:
-SET &PDATEFROM = IF &PDATEFROM EQ '' THEN 'FOC_NONE' ELSE '20'||STRIP(&PDATEFROM.LENGTH,&PDATEFROM,'/',&PDATEFROM);
-SET &PNDATEFROM = IF &PDATEFROM NE 'FOC_NONE' THEN EDIT(&PDATEFROM,'9999$$$$') ELSE 'FOC_NONE';
-SET &PNDATEFROM2 = IF &PNDATEFROM NE 'FOC_NONE' THEN &PNDATEFROM -1 ELSE 'FOC_NONE';
-SET &PDATEF = IF &PDATEFROM NE 'FOC_NONE' THEN &PNDATEFROM2||EDIT(&PDATEFROM,'$$$$9999') ELSE 'FOC_NONE';
-SET &PDATEFROM = &PDATEF;
-SET &PDATETO = IF &PDATETO EQ '' THEN 'FOC_NONE' ELSE '20'||STRIP(&PDATETO.LENGTH,&PDATETO,'/',&PDATETO);
-SET &PNDATETO = IF &PDATETO NE 'FOC_NONE' THEN EDIT(&PDATETO,'9999$$$$') ELSE 'FOC_NONE';
-SET &PNDATETO2 = IF &PNDATETO NE 'FOC_NONE' THEN &PNDATETO -1 ELSE 'FOC_NONE';
-SET &PDATET = IF &PDATETO NE 'FOC_NONE' THEN &PNDATETO2||EDIT(&PDATETO,'$$$$9999') ELSE 'FOC_NONE';
-SET &PDATETO = &PDATET;
-SET &FROMDATE = IF &PDATEFROM NE 'FOC_NONE' THEN EDIT(&PDATEFROM,'9999$$$$')|'-'|EDIT(&PDATEFROM,'$$$$99$$')|'-'|EDIT(&PDATEFROM,'$$$$$$99') ELSE 'FOC_NONE';
-SET &TODATE = IF &PDATETO NE 'FOC_NONE' THEN EDIT(&PDATETO,'9999$$$$')|'-'|EDIT(&PDATETO,'$$$$99$$')|'-'|EDIT(&PDATETO,'$$$$$$99') ELSE 'FOC_NONE';

Third procedure:
-SET &P2DATEFROM = IF &P2DATEFROM EQ '' THEN 'FOC_NONE' ELSE '20'||STRIP(&P2DATEFROM.LENGTH,&P2DATEFROM,'/',&P2DATEFROM);
-SET &PN2DATEFROM = IF &P2DATEFROM NE 'FOC_NONE' THEN EDIT(&P2DATEFROM,'9999$$$$') ELSE 'FOC_NONE';
-SET &PN2DATEFROM2 = IF &PN2DATEFROM NE 'FOC_NONE' THEN &PN2DATEFROM -2 ELSE 'FOC_NONE';
-SET &P2DATEF = IF &P2DATEFROM NE 'FOC_NONE' THEN &PN2DATEFROM2||EDIT(&P2DATEFROM,'$$$$9999') ELSE 'FOC_NONE';
-SET &P2DATEFROM = &P2DATEF;
-SET &P2DATETO = IF &P2DATETO EQ '' THEN 'FOC_NONE' ELSE '20'||STRIP(&P2DATETO.LENGTH,&P2DATETO,'/',&P2DATETO);
-SET &PN2DATETO = IF &P2DATETO NE 'FOC_NONE' THEN EDIT(&P2DATETO,'9999$$$$') ELSE 'FOC_NONE';
-SET &PN2DATETO2 = IF &PN2DATETO NE 'FOC_NONE' THEN &PN2DATETO -2 ELSE 'FOC_NONE';
-SET &P2DATET = IF &P2DATETO NE 'FOC_NONE' THEN &PN2DATETO2||EDIT(&P2DATETO,'$$$$9999') ELSE 'FOC_NONE';
-SET &P2DATETO = &P2DATET;
-SET &FROMDATE = IF &P2DATEFROM NE 'FOC_NONE' THEN EDIT(&P2DATEFROM,'9999$$$$')|'-'|EDIT(&P2DATEFROM,'$$$$99$$')|'-'|EDIT(&P2DATEFROM,'$$$$$$99') ELSE 'FOC_NONE';
-SET &TODATE = IF &P2DATETO NE 'FOC_NONE' THEN EDIT(&P2DATETO,'9999$$$$')|'-'|EDIT(&P2DATETO,'$$$$99$$')|'-'|EDIT(&P2DATETO,'$$$$$$99') ELSE 'FOC_NONE';


It might not be pretty but it works.


WebFOCUS 7.7.03
Windows Web Server 2008
MS SQL Server 2000
Excel,CSV,PDF,HTML