Focal Point Banner


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.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     SOLVED - MASKING ALPHA TO NUMERIC

Read-Only Read-Only Topic
Go
Search
Notify
Tools
SOLVED - MASKING ALPHA TO NUMERIC
 Login/Join
 
<Mary3001>
posted
I'm creating a branch hours report based on alpha fields that are formated as follows: MON_OPEN 0900 MON_CLOSE 0530. My goal is to subtract The day's open hours from the day's close hours to get the total number of hours a branch is open each day. My formula (shown below) has been working, when the branch open hours are before noon. However, I've run into a situation where one branch is opened at 1 and closed at 5. The formula below doesn't capture that scenario. Any ideas on how to code for that and where it should go in the formula?

Sample of report with error:
SUN_HOURS SUN_OPEN SUN_CLOSE
4.00 1100 0300 - OKAY
5.00 1200 0500 - OKAY
4.00 1100 0300 - OKAY
16.00 0100 0500 - ERROR



CODE:
IF EDIT(SUN_CLOSE) LE 0 THEN 0

ELSE IF (EDIT(SUN_CLOSE) GT 0 AND
EDIT (SUN_CLOSE) LT 1200) THEN
12 + (EDIT(EDIT(SUN_CLOSE, '99$$')) +
EDIT(EDIT(SUN_CLOSE, '$$99'))/60) -
(EDIT(EDIT(SUN_OPEN, '99$$')) +
EDIT(EDIT(SUN_OPEN, '$$99'))/60)

ELSE (EDIT(EDIT(SUN_CLOSE, '99$$')) +
EDIT(EDIT(SUN_CLOSE, '$$99'))/60) -
(EDIT(EDIT(SUN_OPEN, '99$$')) +
EDIT(EDIT(SUN_OPEN, '$$99'))/60)

This message has been edited. Last edited by: <Mary3001>,
 
Report This Post
Expert
posted Hide Post
Mary,

Here's what looks like a clumsy way to do it, using Date/Time functions and columns. This is a working example using the CAR file. SUN_OPEN and SUN_CLOSE contain the example data you provided. I convert the times to date/time fields with the HINPUT function, using Jan 1 2000 as the date (it could be any date). You have to decide what the normal earliest open hour would be - I decided on 8am: if the time is less than 0800 then it must be after noon, so I add 12 hours to the date/time field using the HADD function. Then I use the HDIFF function to determine the hours open. Then I use the FTOA function to convert back to alpha.

DEFINE FILE CAR
SUN_OPEN/A4         = DECODE COUNTRY ('ENGLAND' '1100', 'FRANCE' '1200', 'ITALY' '1100', 'JAPAN' '0100' ELSE '0000');
SUN_CLOSE/A4        = DECODE COUNTRY ('ENGLAND' '0300', 'FRANCE' '0500', 'ITALY' '0300', 'JAPAN' '0500' ELSE '0000');

SUN_OPENDT/A14      = '20000101' || SUN_OPEN;
SUN_CLOSEDT/A14     = '20000101' || SUN_CLOSE;
SUN_OPEN24/HHI      = HINPUT(14, SUN_OPENDT, 8, 'HYYMDS');
SUN_OPEN24          = IF SUN_OPEN LT '0800' THEN HADD(SUN_OPEN24, 'HOUR', 12, 8, 'HYYMDS') ELSE SUN_OPEN24;
SUN_CLOSE24/HHI     = HINPUT(14, SUN_CLOSEDT, 8, 'HYYMDS');
SUN_CLOSE24         = IF SUN_CLOSE LT '0800' THEN HADD(SUN_CLOSE24, 'HOUR', 12, 8, 'HYYMDS') ELSE SUN_CLOSE24;
SUN_HOURSNUM/D5.2   = HDIFF(SUN_CLOSE24, SUN_OPEN24, 'HOUR', 'D12.2');
SUN_HOURS/A5        = FTOA(SUN_HOURSNUM, '(D5.2L)', 'A5');
END

TABLE FILE CAR
PRINT
SUN_HOURS
SUN_OPEN
SUN_CLOSE

SUN_HOURSNUM
SUN_OPEN24
SUN_CLOSE24
BY COUNTRY
END


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
There's also a TIMETOTS function that easily converts a time to a date time. I think it uses current date for the day. Caveat is that the time must be in acceptable time format - 11:22:33 - but that's easy enough to do with EDIT.

The biggest problem is that your times do not include any sort of 24-hour indicator (either on 24hr time or AM/PM so you have a bunch of extra steps to get them to that point.

Once you've got it in date-time format the rest is easy with HDIFF. This is the best way.

Your approach seems to be more just straight math. The logic would look like

IF (OPEN - CLOSE) GE 0 THEN ABS(OPEN - CLOSE - 1200) ELSE ABS(OPEN - CLOSE)

Always comes up with he correct answer. You would have to add some additional similar logic to calculate minutes to add/subtract from hours.

Still think the conversion to date-time values works best.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
<Mary3001>
posted
Thank you Darin and Francis. I will give both ways a try. I'm a beginner and don't use SQL, just the GUI. Can both ways be written using the GUI?

My work around has been to add a couple more IF Else statements, one which uses OPEN GT 800 and OPEN NE 1 and another that uses OPEN EQ 1. I'm doing my audits by day to see if anything else pops up. My guess is there are some branches (in retirement centers) that have odd hours, like 2 to 4, so I may see more issues.



The final step after getting the hours correct is to do a weekly average hours by branch.

I don't have the am/pm or the information in 24 segments. That may be something to request for future downloads.

Thanks so much for your help.

Mary
 
Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     SOLVED - MASKING ALPHA TO NUMERIC

Copyright © 1996-2020 Information Builders