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] decode database data

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] decode database data
 Login/Join
 
Virtuoso
posted
I have a database that hold several fields like this:

C018: '[21000..23000],34567,56555,[57000..58000]'
C401: '01.02'

I have to translate this field as follows into a conditional where clause.

DEFINE FILE XXX
VER_C018/A10=IF C018 FROM '21000' TO '23000' OR  C018 EQ '34567' OR C018 EQ '56555' OR 
C018 FROM '57000' TO '58000' THEN '01.02' ;
END


It looks rather easy, but the real challange is even a bit more complex.
The database holds about 200 records and may also chane so coding this by hand is not an option.

I was thinking of first read the string and do something with a replace characters.
The "[" needs to be "FROM " and so on.

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




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Virtuoso
posted Hide Post
Your best best is probably to read the record, create an alpha hold file, and then read the file line by line as an &var.

First, EDIT out the characters to the left of the first : - that's the field namWith careful use of a few iterations using the STRREP you shoule be able to replace the necessary strings:

: '[ = FROM
,[ = OR (|columname|' FROM '
.. = TO
], = ) OR
, = OR
]' = space

You'll also need some logic (probably including a sum and a LAST) to combing the first record with the second record which becomes the THEN. And don't forget the ; at the end.


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
Expert
posted Hide Post
Whats the relationship between C018 and C401 ?

I think this could be done with a couple of TABLE FILE's, which would produce a WHERE clause.


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Virtuoso
posted Hide Post
there is no real relation between the two fileds Waz
it is just a condition to code a general ledger datafield, to report to the banking authorities

and yes I am thinking in that direction too
creating some define rules




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
<JG>
posted
Give this a spin

 
DEFINE FILE CAR
C018/A100 WITH COUNTRY='[21000..23000],34567,56555,[57000..58000]';
C401/A5= '01.02';
WHERE0/A400V=STRREP (100, C018, 2, ',[', 14,' OR C018 FROM ', 400, WHERE0);
WHERE1/A400V=STRREP (400, WHERE0, 1, '[', 10,'C018 FROM ', 400, WHERE1);
WHERE2/A400V=STRREP (400, WHERE1, 2, '..', 4,' TO ', 400, WHERE2);
WHERE3/A400V=STRREP (400, WHERE2, 1, ',', 12,' OR C018 EQ ', 400, WHERE2);
WHERE4/A400V=STRIP(400, WHERE3, ']', WHERE4);
MYDEFINE/A500V= 'IF '| WHERE4 | ' THEN C401 ELSE '| ''' '''|';';
END
TABLE FILE CAR
SUM COUNTRY NOPRINT
C018 OVER
WHERE0 OVER
WHERE1 OVER
WHERE2 OVER
WHERE3 OVER
MYDEFINE
END
 
 
Report This Post
Expert
posted Hide Post
Thanks Frank, just wondering if there is more the to values than the two lines.

Here is my suggestion, a bit long winded, but relatively dynamic.
EX -LINES 5 EDAPUT MASTER,tmp_gl,CV,FILE
FILENAME=tmp_gl, SUFFIX=FIX,$
SEGNAME=tmp_gl, $
  FIELD=GL_CODE ,ALIAS=  ,A4 ,A5 ,$
  FIELD=GL_DATA ,ALIAS=  ,A250 ,A250 ,$

EX -LINES 3 EDAPUT FOCTEMP,tmp_gl,CV,FILE
C018 [21000..23000],34567,56555,[57000..58000]
C401 01.02

-RUN
FILEDEF TMP_GL DISK tmp_gl.ftm

-RUN

TABLE   FILE TMP_GL
 PRINT  
        COMPUTE
        SET_CMD/A266 = '-SET &|C401 = ''' || GL_DATA || ''';' ;
 WHERE  GL_CODE EQ 'C401'
 ON     TABLE SET HOLDLIST PRINTONLY
 ON     TABLE HOLD AS TMP_C401 FORMAT ALPHA
END

-RUN

-INCLUDE TMP_C401

-RUN

DEFINE  FILE TMP_GL
-* change the ' ' | HEXBYT(10,'A1') to match the EOL for the OS.
 CR_LINE/A300 = STRREP(250,GL_DATA,1,',',2,' ' | HEXBYT(10,'A1'),300,'A300') ;
END

TABLE   FILE TMP_GL
 PRINT  
        CR_LINE
 WHERE  GL_CODE EQ 'C018'
 ON     TABLE HOLD AS TMP_C018 FORMAT ALPHA
END

TABLE   FILE TMP_C018
 PRINT  
        COMPUTE
        CNTR/I9     = LAST CNTR + 1 ; NOPRINT
        COMPUTE
        VALUES/A250 = STRREP(250,CTRAN(250,CTRAN(250,CR_LINE,91,39,'A250'),93,39,'A250'),2,'..',6,''' TO ''',250,'A250') ;
                                      NOPRINT
        COMPUTE
        TEST/A262   = IF VALUES CONTAINS ' TO '
                     THEN '(C018 FROM ' | VALUES || ')'
                     ELSE '(C018 EQ ' | VALUES || ')' ;
                                      NOPRINT
        COMPUTE
        FEX_LINE/A278 = IF CNTR EQ 1
                       THEN 'VER_C018/A10=IF ' | TEST
                       ELSE 'OR ' | TEST ;
 ON     TABLE SET HOLDLIST PRINTONLY
 ON     TABLE HOLD AS FEX_C018 FORMAT ALPHA
END

-RUN

DEFINE FILE XXX
-INCLUDE FEX_C018
THEN '&C401' ELSE ' ' ;
END


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Virtuoso
posted Hide Post
Thanks all for your suggestions.
I think the solution as presented by JG is the most transparant one (for me) so I have build this in my report already and it works.
The real world is even more complex, but also that will work




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report 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] decode database data

Copyright © 1996-2020 Information Builders