Focal Point
[CLOSED] GOTO Not Functioning Properly

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

September 06, 2016, 02:45 PM
RMM
[CLOSED] GOTO Not Functioning Properly
Below is my code that I am having an issue with.
Currently...
CURRENTDAY = 20160906,
TIMESTAMP = 20160906

It works, but backwards. The 2 dates match so it should GOTO STOPPROCESS and end up with no rows, but instead it goes to STARTONE and provides the TIMESTAMP date.
WHat am I doing wrong here? If the dates match it should error out. If they don't match, TIMESTAMP should be provided.


DEFINE FILE FACT_SALES_REBATE_DISCOUNT_COMPANY_DAY_AGG
CURRENTDAY/YYMD = &YYMD;
END

TABLE FILE FACT_SALES_REBATE_DISCOUNT_COMPANY_DAY_AGG
BY CURRENTDAY
BY TOTAL LOWEST COMPUTE TIMESTAMP/YYMD = HDATE(LOAD_TIMESTAMP, 'YYMD');
ON TABLE HOLD AS TEMPONE
END

- IF TEMPONE.TEMPONE.TIMESTAMP NE TEMPONE.TEMPONE.CURRENTDAY THEN GOTO STARTONE;
- ELSE GOTO STOPPROCESS;


-STARTONE

TABLE FILE TEMPONE
PRINT
TIMESTAMP
END


-STOPPROCESS

TABLE FILE TEMPONE
PRINT
TIMESTAMP
WHERE TIMESTAMP EQ 1;
END

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


WebFOCUS 8
Windows, All Outputs
September 06, 2016, 02:55 PM
MartinY
quote:
- IF TEMPONE.TEMPONE.TIMESTAMP NE TEMPONE.TEMPONE.CURRENTDAY THEN GOTO STARTONE;

Semicolon after STARTONE shouldn't be there. Have your ELSE on the same line and you'll see your error.

And you need another GOTO before STOPPROCESS to bypass this step if it's the goal otherwise all code will be processed.
- IF TEMPONE.TEMPONE.TIMESTAMP NE TEMPONE.TEMPONE.CURRENTDAY THEN GOTO STARTONE ELSE GOTO STOPPROCESS;

-STARTONE

TABLE FILE TEMPONE
PRINT
	TIMESTAMP
END

-GOTO XEXIT;

-STOPPROCESS

TABLE FILE TEMPONE
PRINT
	TIMESTAMP
WHERE TIMESTAMP EQ 1;
END

-XEXIT



WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
September 06, 2016, 03:02 PM
Francis Mariani
In Dialogue Manager (scripting language), you cannot reference columns in a table (reporting language).

I don't think this is correct syntax:
BY TOTAL LOWEST COMPUTE TIMESTAMP/YYMD = HDATE(LOAD_TIMESTAMP, 'YYMD');


You need to -READFILE (or -READ) to put data into Dialogue Manager variables to make the GOTO work. Something like this:

DEFINE FILE FACT_SALES_REBATE_DISCOUNT_COMPANY_DAY_AGG
CURRENTDAY/YYMD = &YYMD;
END

TABLE FILE FACT_SALES_REBATE_DISCOUNT_COMPANY_DAY_AGG
PRINT
COMPUTE TIMESTAMP/YYMD = HDATE(LOAD_TIMESTAMP, 'YYMD');

BY CURRENTDAY
BY TOTAL LOWEST 1 TIMESTAMP
ON TABLE HOLD AS TEMPONE
END
-RUN

-READFILE TEMPONE

-IF &TIMESTAMP NE &CURRENTDAY THEN GOTO STARTONE ELSE GOTO STOPPROCESS;


-STARTONE

TABLE FILE TEMPONE
PRINT
TIMESTAMP
END
-RUN

-GOTO FOCENDREP

-STOPPROCESS

TABLE FILE TEMPONE
PRINT
TIMESTAMP
WHERE TIMESTAMP EQ 1;
END
-RUN

-FOCENDREP



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
September 06, 2016, 06:22 PM
Waz
RMM,

This looks like you may need some education.

To extend on what Francis saysm Dialog Manager (lines starting with a dash "-") are a preprocessing script. It runs before the FOCUS code (TABLE FILE etc, not Dialog Manager), and can be used to control program flow, and the FOCUS code its self.


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!

September 07, 2016, 11:14 AM
RMM
Waz,

DO you offer any free training education?

Francis,

Everything seems to work until the -READFILE part. Below is the error I receive. checkprocessed is the name of the script we have been working on. THe first hold works, but the issue arises after that.


09/07/2016 10:26:55 (ICM18015) DEP_3: procedure checkprocessed started.
09/07/2016 10:26:55 0 NUMBER OF RECORDS IN TABLE= 16 LINES= 16
09/07/2016 10:26:55
09/07/2016 10:26:55 (FOC370) THE FIELDNAME USED IN JOIN CANNOT BE FOUND IN THE FILE: TEMPONE.TEMPONE.LLBCMPN
09/07/2016 10:26:55 0 ERROR AT OR NEAR LINE 16 IN PROCEDURE homeapps/modzelewski/checkprocessed
09/07/2016 10:26:55 (FOC2907) ERROR WITH DIALOGUE MANAGER COMMAND: -READFILE TEMPONE


WebFOCUS 8
Windows, All Outputs
September 07, 2016, 02:14 PM
MartinY
quote:
09/07/2016 10:26:55 (FOC370) THE FIELDNAME USED IN JOIN CANNOT BE FOUND IN THE FILE: TEMPONE.TEMPONE.LLBCMPN


Your first error is above one.
The file TEMPONE cannot be read if it doesn't exist due to above error.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
September 07, 2016, 03:07 PM
Tom Flynn
Free Training





Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
September 07, 2016, 04:03 PM
RMM
LOL. Using "Help" contents isn't much in dignified training.


WebFOCUS 8
Windows, All Outputs
September 07, 2016, 04:19 PM
Francis Mariani
But there certainly is a lot of scintillating reading.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
September 07, 2016, 05:51 PM
Waz
RMM,

You your error indicates that there is a JOIN in place, but your code does not show it.

Can you post the code.

My guess is that the JOIN issue is stopping the hold file from being created that is causing the -READFILE to failing.


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!

September 08, 2016, 09:06 AM
RMM
Waz,

Here is the code...

-DEFAULTH &TIMESTAMPS = '';
-DEFAULTH &CURRENTDAY = '';

DEFINE FILE FACT_SALES_REBATE_DISCOUNT_COMPANY_DAY_AGG
CURRENTDAY/YYMD = &YYMD;
END

TABLE FILE FACT_SALES_REBATE_DISCOUNT_COMPANY_DAY_AGG
PRINT
COMPUTE TIMESTAMPS/YYMD = HDATE(LOAD_TIMESTAMP, 'YYMD');
BY CURRENTDAY
ON TABLE HOLD AS TEMPONE
END
-RUN

-READFILE TEMPONE

-IF &TIMESTAMPS NE &CURRENTDAY THEN GOTO STARTONE ELSE GOTO STOPPROCESS;

-STARTONE

TABLE FILE TEMPONE
BY
TIMESTAMPS
END


-STOPPROCESS

TABLE FILE TEMPONE
BY
TIMESTAMPS
WHERE TIMESTAMPS EQ 1;
END


There is no JOIN, in which why I am stumped on this one.

I know that I am not that knowledgeable in my WebFocus, but I am trying in light of not much reading material out there compared to other languages and the fact my boss won't send me to any classes when I have asked. I feel like I am doing everything tied with one arm behind my back.


WebFOCUS 8
Windows, All Outputs
September 08, 2016, 09:07 AM
RMM
Lol! Nice!
quote:
Originally posted by Francis Mariani:
But there certainly is a lot of scintillating reading.



WebFOCUS 8
Windows, All Outputs
September 08, 2016, 10:33 AM
MartinY
Try the following:
1- Process your code and add -EXIT right after
TABLE FILE FACT_SALES_REBATE_DISCOUNT_COMPANY_DAY_AGG
PRINT COMPUTE TIMESTAMPS/YYMD = HDATE(LOAD_TIMESTAMP, 'YYMD');
BY CURRENTDAY
ON TABLE HOLD AS TEMPONE
END
-RUN
-EXIT

You will then confirm that your HOLD file generation works.

2- Remove previous -EXIT, add a -RUN after the READFILE and print variable's value:
-READFILE TEMPONE
-RUN

-TYPE TIMESTAMPS= &TIMESTAMPS, CURRENTDAY= &CURRENTDAY
-EXIT


3- Then if everything goes right, remove the previous -EXIT to process you whole code


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
September 08, 2016, 10:56 AM
RMM
Thanks, Martin.

It turned out that the issue was with the TEMPONE name being used. I changed it and now run into a different issue. Issue stated below...

09/08/2016 10:48:03 (ICM18122) Request - homeapps/RMM/pf_testdayend submitted.
09/08/2016 10:48:03 (ICM18015) DEP_0: procedure checkdayend started.
09/08/2016 10:48:03 0 NUMBER OF RECORDS IN TABLE= 1 LINES= 1
09/08/2016 10:48:03
09/08/2016 10:48:03 0 NUMBER OF RECORDS IN TABLE= 1 LINES= 1
09/08/2016 10:48:03
09/08/2016 10:48:03 0 NUMBER OF RECORDS IN TABLE= 1 LINES= 1
09/08/2016 10:48:03
09/08/2016 10:48:03 0 NUMBER OF RECORDS IN TABLE= 0 LINES= 0
09/08/2016 10:48:03
09/08/2016 10:48:03 0 NUMBER OF RECORDS IN TABLE= 1 LINES= 1
09/08/2016 10:48:03
09/08/2016 10:48:03 0 HOLDING HTML FILE ON PC DISK ...
09/08/2016 10:48:03
09/08/2016 10:48:03
09/08/2016 10:48:03 (ICM18039) DEP_0 checkdayend Return Code = 0

09/08/2016 10:48:03 (ICM18015) DEP_3: procedure checkprocessed started.
09/08/2016 10:48:03 0 NUMBER OF RECORDS IN TABLE= 323 LINES= 323
09/08/2016 10:48:03
09/08/2016 10:48:03 TIMESTAMPS= 20160908, CURRENTDAY= 20160908
09/08/2016 10:48:03 0 NUMBER OF RECORDS IN TABLE= 322 LINES= 1
09/08/2016 10:48:03
09/08/2016 10:48:03 html
09/08/2016 10:48:03 head
09/08/2016 10:48:03 meta name="HandheldFriendly" content="True"
09/08/2016 10:48:03 meta name="PalmComputingPlatform" content="True"
09/08/2016 10:48:03 title WebFOCUS Report /title
09/08/2016 10:48:03 /head
09/08/2016 10:48:03 body
09/08/2016 10:48:03 table border cellpadding=1
09/08/2016 10:48:03 tr
09/08/2016 10:48:03 td
09/08/2016 10:48:03 table cellpadding=0 width="100%" tr
09/08/2016 10:48:03 td
09/08/2016 10:48:03 PAGE 1 /td /tr /table /td
09/08/2016 10:48:03 /tr
09/08/2016 10:48:03 tr
09/08/2016 10:48:03 td valign=BOTTOM
09/08/2016 10:48:03 TIMESTAMPS /td
09/08/2016 10:48:03 /tr
09/08/2016 10:48:03 tr
09/08/2016 10:48:03 td
09/08/2016 10:48:03 2016/09/08 /td
09/08/2016 10:48:03 /tr
09/08/2016 10:48:03 /table
09/08/2016 10:48:03 /body
09/08/2016 10:48:03 /html
09/08/2016 10:48:03 0 HOLDING HTML FILE ON PC DISK ...
09/08/2016 10:48:03
09/08/2016 10:48:03
09/08/2016 10:48:03 (ICM18039) DEP_3 checkprocessed Return Code = 0

It states that there is a record, in which the next procedure should run, but it doesn't. I added a custom condition where &RECORDS EQ 1 as well. You can see the first proc works fine and processes over to the proc in question. Below is the code again...

-DEFAULTH &TIMESTAMPS = '';
-DEFAULTH &CURRENTDAY = '';

DEFINE FILE FACT_SALES_REBATE_DISCOUNT_COMPANY_DAY_AGG
CURRENTDAY/YYMD = &YYMD;
END

TABLE FILE FACT_SALES_REBATE_DISCOUNT_COMPANY_DAY_AGG
PRINT
COMPUTE TIMESTAMPS/YYMD = HDATE(LOAD_TIMESTAMP, 'YYMD');
BY CURRENTDAY
ON TABLE HOLD AS XXXHANSOLO
END
-RUN

-READFILE XXXHANSOLO
-RUN

-TYPE TIMESTAMPS= &TIMESTAMPS, CURRENTDAY= &CURRENTDAY

-IF &TIMESTAMPS EQ &CURRENTDAY THEN GOTO STARTONE ELSE GOTO STOPPROCESS;

-STARTONE

TABLE FILE XXXHANSOLO
BY
TIMESTAMPS
END

-STOPPROCESS

TABLE FILE XXXHANSOLO
BY
TIMESTAMPS
WHERE TIMESTAMPS EQ 1;
END


WebFOCUS 8
Windows, All Outputs
September 08, 2016, 01:41 PM
Tom Flynn
See if this helps...
Also notice the additional code, Bolded

-IF '&TIMESTAMPS.EVAL' EQ '&CURRENTDAY.EVAL' GOTO STARTONE ELSE GOTO STOPPROCESS;

-STARTONE
TABLE FILE XXXHANSOLO
BY
TIMESTAMPS
END
-RUN
-GOTO EOJ

-STOPPROCESS
TABLE FILE XXXHANSOLO
BY
TIMESTAMPS
WHERE TIMESTAMPS EQ 1;
END
-RUN
-EOJ


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
September 08, 2016, 04:55 PM
RMM
Thanks. Unfortunately, that didn't work as well.


WebFOCUS 8
Windows, All Outputs
September 08, 2016, 05:53 PM
j.gross
quote:
09/08/2016 10:48:03 0 NUMBER OF RECORDS IN TABLE= 323 LINES= 323
09/08/2016 10:48:03
09/08/2016 10:48:03 TIMESTAMPS= 20160908, CURRENTDAY= 20160908
09/08/2016 10:48:03 0 NUMBER OF RECORDS IN TABLE= 322 LINES= 1


quote:
It states that there is a record, in which {sic} the next procedure should run, but it doesn't.


RMM: What's your issue?
The values matched, and control passed to -STARTONE;
the TABLE request was run and produced a formatted report with one line (since the value of LOAD_TIMESTAMP, and hence TIMESTAMPS, is uniform throughout the file).

Once you produce formatted output in a ReportCaster job, the music stops -- them's the rules -- so if there is another procedure downstream in your code it cannot be reached.


- Jack Gross
WF through 8.1.05
September 08, 2016, 05:55 PM
RMM
I changed the condition &RECORDS EQ 1 to &RECORDS GE 1 and this fixed it. Thanks you all who helped.


WebFOCUS 8
Windows, All Outputs
September 08, 2016, 06:03 PM
Waz
Hi RMM,

Can you update the title of this thread (Edit your first post) and add [SOLVED] or [CLOSED].


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!