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     [TECHNIQUE] Converting To Alpha

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[TECHNIQUE] Converting To Alpha
 Login/Join
 
Expert
posted
Converting To Alpha
by Art Greenhaus

The FOCUS and WebFOCUS language supports a multitude of data formats: alpha, integer, single precision floating point (F), double precision floating point (D), packed (P), smart date, date-time and text. The numeric formats all have different uses, and it is fairly easy to convert them to other formats.

One conversion that is frequently needed is conversion to alpha. Why? Well, if you want to do any character manipulation with a field (stripping out or altering characters, appending to other strings or breaking into components for re-arrangement, to name a few), alpha strings are easier to manipulate.

Traditionally, users have used routines such as EDIT to convert a number to a character string. Unfortunately, EDIT poses certain limitations. For one, it only works with INTEGERS (How would it know how many decimal places to create?). It also adds leading zeros, so the resultant string is always the output length desired (an I6 field containing 123 would become '000123'). In addition, on some platforms you're limited to INTEGER magnitude (how much can be stored in an I4 internal format).

Click here to read more, and subscribe today to receive the WebFOCUS Newsletter in email.
 
Posts: 1948 | Location: New York | Registered: November 16, 2004Report This Post
Expert
posted Hide Post
This one of the best things to come aling in a long time.

The other is -READFILE.


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
Guru
posted Hide Post
Looks like this is a 7.7.x new feature. http://documentation.informati.../source/topic113.htm. I appears to be working fine in my 7.6.10 localhost. Interesting.


WebFOCUS 8.1.05M Unix Self-Service/MRE/Report Caster - Outputs Excel, PDF, HTML, Flat Files
 
Posts: 320 | Location: Memphis, TN | Registered: February 12, 2008Report This Post
Platinum Member
posted Hide Post
Agreed Francis. Will be so great to use FPRINT instead of whipping out my subroutine manual everytime I need to convert a value.

Max, you're right! FPRINT works in our 7.6.11 environment. Here is another take on Art's code that hilights replacing 5 separate numeric to alpha conversion routines with FPRINT.

DEFINE FILE CAR
-*
-* Set initial values
-*
  IVAL                /I6     = 99.99;
  FVAL                /F6.2   = 99.99;
  PVAL                /P5.2   = 99.99;
  YYMD_DM             /YYMD   = &YYMD;
  HYYMDS_HGETC        /HYYMDS = HGETC(8,'HYYMDS');
-*
-* Use OLD conversion routines to convert numberic values defined above to alpha
-* 
  IVAL_EDIT           /A6     = EDIT(IVAL);
  FVAL_FTOA           /A6     = FTOA(FVAL, '(F6.2)', 'A6');
  PVAL_PTOA           /A5     = PTOA(PVAL, '(P5.2)', 'A5');
  YYMD_DM_DATECVT     /A10    = EDIT(DATECVT(&YYMD,'I8YYMD','A8YYMD'),'9999/99/99');
  HYYMDS_HGETC_HCNVRT /A19    = HCNVRT(HGETC(8,'HYYMDS'),'(HYYMDS)',19,'A19');
-*
-* Use FPRINT function to convert numeric values defined above to alpha
-*
  IVAL_FPRINT         /A6     = FPRINT(IVAL,'I6','A6');
  FVAL_FPRINT         /A6     = FPRINT(FVAL,'F6.2','A6');
  PVAL_FPRINT         /A5     = FPRINT(PVAL,'P5.2','A5');
  YYMD_DM_FPRINT      /A10    = FPRINT(&YYMD,'I8YYMD','A10');
  HYYMDS_HGETC_FPRINT /A19    = FPRINT(HGETC(8,'HYYMDS'),'HYYMDS','A19');
END

TABLE FILE CAR
HEADING
"Numeric Value <+0> Old Conversion <+0> FPRINT Conversion"
PRINT IVAL         IVAL_EDIT           AS EDIT    IVAL_FPRINT         AS FPRINT OVER
      FVAL         FVAL_FTOA           AS FTOA    FVAL_FPRINT         AS FPRINT OVER
      PVAL         PVAL_PTOA           AS PTOA    PVAL_FPRINT         AS FPRINT OVER
      YYMD_DM      YYMD_DM_DATECVT     AS DATECVT YYMD_DM_FPRINT      AS FPRINT OVER
      HYYMDS_HGETC HYYMDS_HGETC_HCNVRT AS HCNVRT  HYYMDS_HGETC_FPRINT AS FPRINT     
WHERE COUNTRY EQ 'ENGLAND'
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLE *
FONT='ARIAL', SIZE=9,$
TYPE=HEADING,HEADALIGN=BODY,STYLE=BOLD,SIZE=10,$
TYPE=HEADING,ITEM=1,COLSPAN=2,JUSTIFY=CENTER,BACKCOLOR='Pale Green',$
TYPE=HEADING,ITEM=2,COLSPAN=2,JUSTIFY=CENTER,BACKCOLOR='Yellow',$
TYPE=HEADING,ITEM=3,COLSPAN=2,JUSTIFY=CENTER,BACKCOLOR='Light Blue',$
END


Thanks Kerry.



In FOCUS since 1985 - WF 8.009/8.104 Win 8 Outputs: ALL of 'em! Adapters: Sql Server Teradata Oracle
 
Posts: 161 | Location: Dallas, TX | Registered: February 20, 2009Report 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     [TECHNIQUE] Converting To Alpha

Copyright © 1996-2020 Information Builders