As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
Hi, I tried to determine the number of hours to add to a time variable in HH.MM.SS format, I then add the number of hours to the time variable. I use this 'total' time variable to determine whether the job should proceed or goes throught the loop. My code is as below.
-********** -STARTTIME -********** -* -SET &SLEEP = DECODE &&A_CODE ('04' 1, '09' 3600, '12' 7200, '08' 10800, ELSE 14400); -*convert the time variable (&A_LOCKTM) to second -SET LOCKTM/D6 = HTIME(8, &A_LOCKTM, LOCKTM); -*add them together -SET &AGENTST = LOCKTM + &SLEEP; -* -SET &STARTTM/HYYMDm = &DATEDMYY || &AGENTST; -*get the current date and time -SET &CURDT = HGETC(8, 'HYYMDm); -* -IF &CURDT GE &STARTTM GOTO ENDPROC; -* !sleep &STARTTM -RUN -GOTO ENDPROC
It is not working. Any suggestion is much appreciated.
Thanks
WebFOCUS 5.2 upgrading to the latest version at the moment. UNIX HTML
First thing is the use of formats on the amper variables. Amper variables only have alpha or number, and number depends on the DMPRECISION setting.
What is the format of &A_LOCKTM ?
I think you can do this , but with a bit of a rework of the functions used.
Its been mentioned many times in the forum and the documentation that the datetime functions do not lend them selves to dialog manager calculations, you have to be very careful whet you create and store in a varable.
-SET &SLEEP = DECODE &&A_CODE ('04' 1, '09' 3600, '12' 7200, '08' 10800, ELSE 14400); -*convert the time variable (&A_LOCKTM) to second -SET LOCKTM/D6 = HTIME(8, &A_LOCKTM, LOCKTM); -*add them together -SET &AGENTST = LOCKTM + &SLEEP; -* -SET &STARTTM/HYYMDm = &DATEDMYY || &AGENTST; -*get the current date and time -SET &CURDT = HGETC(8, 'HYYMDm); -* -IF &CURDT GE &STARTTM GOTO ENDPROC; -* !sleep &STARTTM -RUN -GOTO ENDPROC
I'm afraid you are mixing up Dialog Manager code with DEFINE code. For example:
-SET LOCKTM/D6 = HTIME(8, &A_LOCKTM, LOCKTM);
-SET must have a &variable after. The &variable does not have a format. Then &A_LOCKTM being an &variable probably does not contain a datetime value but an alpha. So, could you please tell what are the contents of your variables?
Daniel In Focus since 1982 wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006
The problem is that I tried to add the number of hours (which is currently decoded in 'second' for the &SLEEP variable) to the &A_LOCKTM variable (with format HH.MM.SS) and I am not sure what is the best way to do this?
Thanks
WebFOCUS 5.2 upgrading to the latest version at the moment. UNIX HTML
Let's take this backward: You want to run the "sleep" program with a value which is the date and time until when to sleep. What is supposed to be the format of this parameter? A date followed by a time? Spaces in between? Slashes? Colons? Or is it in binary? Once you know this, then you can go about putting it together.
Daniel In Focus since 1982 wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006
The job is to go to 'sleep' if the 'time calculated' variable is GE to the current time. The format for the 'time calculated' is DDMMYYY HH:MM:SS so that it can compare with the current date and time.
I have changed my code as below. My question is how do I convert the &SLEEP in 'second' format to 'hour'?
-SET &SLEEP = DECODE &&VWA_A_CODE ('04' 1, '09' 3600, '12' 7200, '08' 10800, ELSE 14400); -* -*convert the second to hours -SET &LOCKTM = (&SLEEP*60)*60; -* -*Add hours to the &A_LOCKTM (which is in HH.MM.SS format) -SET &AGENTST = HADD(&A_LOCKTM, 'HOUR', &LOCKTM, 8, &AGENTST); -* -*Get the date and time to start &STARTTM (format DD/MM/YYYY HH:MM:SS) -SET &STARTTM = &DATEDMYY || &AGENTST; -* -*Get the current date and time -SET &CURDT = HGETC(8, 'HYYMDm'); -* -IF &CURDT GE &STARTTM GOTO ENDPROC; -* !sleep &STARTTM -RUN -GOTO ENDPROC
Thanks
WebFOCUS 5.2 upgrading to the latest version at the moment. UNIX HTML
I have tried to run your suggestion and it prompted me the following message.
Task error:ibi.jlink.EdaPcb: Pcb2.: ibi.ngxxj.NGException: local error
It doesn't seem to relate to any syntax error. I did some research on this error message but could not find any information from internet. Do you know what cause this? Thanks
WebFOCUS 5.2 upgrading to the latest version at the moment. UNIX HTML
-*extract hours from seconds (there are 3600 sec/hr)
-SET &HH=&SEC_WAKETM / 3600;
-*prefix a 0 if the hour is only 1 digit
-SET &HH=IF &HH LT 10 THEN '0' | &HH ELSE &HH;
-*calculate number of minutes: seconds less number of hours * 3600 divided by 60
-SET &MM=(&SEC_WAKETM - &HH * 3600) / 60;
-*prfix a 0 if minutes has only 1 digit
-SET &MM=IF &MM LT 10 THEN '0' | &MM ELSE &MM;
-*calculate number of seconds: remainder of all seconds divided by 60
-SET &SS=IMOD(&SEC_WAKETM, 60, 'I2');
-*prefix a 0 if seconds has only 1 digit
-SET &SS=IF &SS LT 10 THEN '0' | &SS ELSE &SS;
I hope this makes it clearer.
Daniel In Focus since 1982 wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006
I believe the Unix SLEEP command takes seconds as the default parameter and stops current processing for the specified number of seconds starting from the current date-time. So couldn't you simply SLEEP your process based on the number of seconds from your DECODE?
Yes Dan, however, this will force the job to wait according to the seconds set regardless of when it is being executed.
The reason for the wait is for the dependency job to complete before it can start. For example, if the dependency job is finished on Sunday at 10am and the job is set to wait for 3600 sec, it should be started any time after Sunday 11am. Therefore, if the job is executed on Monday, it should start straight away without having to wait, etc.
Hope this explain why we need to do all these time calculation.
At the moment, when I incoporated Danny's suggested code, I get the error message below:
Task error:ibi.jlink.EdaPcb: Pcb2.: ibi.ngxxj.NGException: local error
Any suggestion of what cause this error would be very much appreciated.
Thanks
WebFOCUS 5.2 upgrading to the latest version at the moment. UNIX HTML
Hi, I am getting there to resolve the error message by doing 'process elimination'.
I am trying to convert a date with the format dd/mm/yyyy to I8yymd. I have tried the following functions CHGDAT, EDIT, DATECVT and HINPUT and I couldn't get it working.
What is the best way to convert this? Thanks
WebFOCUS 5.2 upgrading to the latest version at the moment. UNIX HTML
-* Set-up a date to mimic Sophie's requirement
-SET &S_Date = EDIT(&DMYY,'99/99/9999');
-* Now manipulate it in dialogue manager
-SET &I8YYMD = DATECVT(EDIT(&S_Date,'99$99$9999'), 'A8DMYY', 'I8YYMD');
-* Now in a define
DEFINE FILE CAR
X_DATE/A8 WITH COUNTRY = &DMYY.QUOTEDSTRING;
S_DATE/A10 WITH COUNTRY = EDIT(X_DATE,'99/99/9999');
I_DATE/I8YYMD WITH COUNTRY = DATECVT(EDIT(S_DATE,'99$99$9999'), 'A8DMYY', 'I8YYMD');
END
TABLE FILE CAR
SUM S_DATE
I_DATE
BY HIGHEST 1 COUNTRY NOPRINT
END
TThis message has been edited. Last edited by: Tony A,
In FOCUS since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2
WebFOCUS App Studio 8.2.06 standalone on Windows 10
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004
-* Set-up a date to mimic Sophie's requirement -SET &S_Date = EDIT(&DMYY,'99/99/9999');
-* Now manipulate it in dialogue manager -SET &I8YYMD = DATECVT(EDIT(&S_Date,'99$99$9999'), 'A8DMYY', 'I8YYMD');
Thank you Tony. It works!
As I am new to programming, I understand that you use the EDIT function to convert the date from alphanumeric to numeric format before using DATECVT. Why do you need to use the EDIT function again within the DATECVT function?
Thanks
WebFOCUS 5.2 upgrading to the latest version at the moment. UNIX HTML
The first -SET command is only to set up a variable with a value that has slashes in it - just like the one you need to convert. (The slash in this EDIT function call places the slash or any other character of your choice: the system variable &DMYY has no slashes, so, to replicate a variable like yours the EDIT function adds the slashes in the appropriate positions).
Tony could have used this instead (&DATEMDYY being a system variable not normally visible):
-SET &S_Date = &DATEMDYY;
The second -SET command is to remove the slashes (or whatever other separator character there is) - the $ is an EDIT mask to exclude a character.
"WebFOCUS 5.2" - I certainly hope your company upgrades soon!
Cheers,This message has been edited. Last edited by: Francis Mariani,
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