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.
I am using GETTOK to get the date field from a csv file and print it in another file, the result is not consistent
The code I am using is: DAT1/A20 =GETTOK(LINE1,512,11,'"',19,'A20'); WDDAY/A8 = EDIT(DAT1,'9999$99$99$$$$$$$$');
The date format in the csv file is "yyyy/mm/dd hh:mm:ss" and I am storing it as "YYYYMMSS" in another file, however the out come it "mosty" correct. i.e. if the date is 2014/06/04 I get the following results :
Yes the 11th Token, I am processing the csv file line by line. An example of the line: "Attendo WEWABM";"Kronoby fortsätter med Attendo";"ATTENDOWEWABM130266143";;"Svenska YLE - Yle Fem - Radio Vega";"http://svenska.yle.fi/artikel/2014/06/04/kronoby-fortsatter-med-attendo";"2014/06/04 17:04:00";"Kronoby fortsätter med AttendoPublicerad 04.06.2014 - 16:05.Arkivbild. Dalsbruks hälsostation Bild: YLE/ Tiina GrönroosKronoby hälsocentraler fortsätter med läkare från Attendo.På sikt är tanken att gå över till egna läkare, men ännu klarar man inte det. Därför går social- och..."
In General the token is fetched correctly, in random occasions it's not. I couldn't find any problem in the lines that generated the error.
Thank you for your reply and please bare with me as I am still VERY green with WebFocus.
I am using the the quotation mark as I thought it would be safer in case the file came with a comma instead of the semi colon, and it would make it easier to handle the token without the extra quotation mark to ignore.
I am not sure what you mean with the master file, I am using my code to generate a "master" file that will be processed and added to a database.
All the fields seem to be fetched normally, the only field I am having an issue with is the date.
SET MORE=OFF, MSG=OFF
FILEDEF WWDAT DISK C:\IBI\APPS\ESMERK\WEWADAT.CSV (LRECL 512 -RUN
DEFINE FILE WWDAT APUPROJ/A35 =GETTOK(LINE1,512,1,'"',35,APUPROJ); PROJECT/A35 =GETTOK(APUPROJ,35,1,'_',35,PROJECT); HEADLINE/A80 =GETTOK(LINE1,512,3,'"',80,HEADLINE); WDATID/A35 =GETTOK(LINE1,512,5,'"',35,WDATID); SOURCE/A30 =GETTOK(LINE1,512,7,'"',30,SOURCE); DAT1/A20 =GETTOK(LINE1,512,11,'"',19,'A20'); WDDAY/A8 = EDIT(DAT1,'9999$99$99$$$$$$$$'); END TABLE FILE WWDAT SUM CNT.APUPROJ AS 'CNT' BY WDDAY AS 'DATE'
What I am saying is that it may be esier for you to use the master file to read the csv as a csv.
e.g.
EX -LINES * EDAPUT MASTER,test,CV,FILE
FILENAME=test, SUFFIX=DFIX,$
SEGNAME=test, $
FIELD=FIELD1 ,ALIAS= ,A255 ,A255 ,$
FIELD=FIELD2 ,ALIAS= ,A255 ,A255 ,$
FIELD=FIELD3 ,ALIAS= ,A255 ,A255 ,$
FIELD=FIELD4 ,ALIAS= ,A255 ,A255 ,$
FIELD=FIELD5 ,ALIAS= ,A255 ,A255 ,$
FIELD=FIELD6 ,ALIAS= ,A255 ,A255 ,$
FIELD=FIELD7 ,ALIAS= ,A21,A21 ,$
FIELD=FIELD8 ,ALIAS= ,A500,A500,$
EDAPUT*
EX -LINES * EDAPUT ACCESS,test,CV,FILE
SEGNAME=test, DELIMITER=;, HEADER=NO, $
EDAPUT*
FILEDEF TEST DISK test.ftm
-RUN
-WRITE TEST "Attendo WEWABM";"Kronoby fortsätter med Attendo";"ATTENDOWEWABM130266143";;"Svenska YLE - Yle Fem - Radio Vega";"http://svenska.yle.fi/artikel/2014/06/04/kronoby-fortsatter-med-attendo";"2014/06/04 17:04:00";"Kronoby fortsätter med AttendoPublicerad 04.06.2014 - 16:05.Arkivbild. Dalsbruks hälsostation Bild: YLE/ Tiina GrönroosKronoby hälsocentraler fortsätter med läkare från Attendo.På sikt är tanken att gå över till egna läkare, men ännu klarar man inte det. Därför går social- och..."
-RUN
TABLE FILE TEST
PRINT
FIELD1
FIELD2
FIELD3
FIELD4
FIELD5
FIELD6
COMPUTE DATE/A8 = EDIT(FIELD7,'$9999$99$99') ;
FIELD8
END
the double quotes are fine. just write a master file that says, this is a delimited file and the delimiter is a semicolon. so i've tweaked waz's code above then just pull the field that is supposed to be a date. and work on it alone. Left adjust it, measure its length (ARGLEN function), etc...
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003
fady, not sure what you mean. is 'the report' to be made from this .csv file? or are you just grabbing the date from this .csv file and then using it in some other report? if so, sure. but confirm first before i contine.
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003
I am grabbing the data from the cvs to generate another report. I was having a problem with the GETTOK as in some instances it was getting truncated dates. The master file approach seems to solve the issue, however I lost the variable that had the date inside and I was using in other parts of the report.
TABLE FILE WWDAT SUM CNT.APUPROJ AS 'CNT' BY WDDAY AS 'DATE' HEADING "***** WEWADAT.CSV MATERIAL BY DATE ***** " " END -RUN TABLE FILE WWDAT PRINT PROJECT WDDAY SOURCE HEADLINE BY WDATID BY PROJECT NOPRINT IF WDATID NE ' ' IF WDDAY NE ' ' ON TABLE SAVE END -RUN
So as you see I am using the WDDAY in another file as a sum and then as a field
You can still do something similar to what you are doing now.
EX -LINES * EDAPUT MASTER,WWDAT,CV,FILE
FILENAME=WWDAT, SUFFIX=DFIX,$
SEGNAME=WWDAT, $
FIELD=APUPROJ,ALIAS= ,A35 ,A35 ,$
FIELD=HEADLINE,ALIAS= ,A80 ,A80 ,$
FIELD=WDATID,ALIAS= ,A35 ,A35 ,$
FIELD=SOURCE,ALIAS= ,A30 ,A30 ,$
FIELD=FIELD5 ,ALIAS= ,A255 ,A255 ,$
FIELD=FIELD6 ,ALIAS= ,A255 ,A255 ,$
FIELD=DAT_FROM,ALIAS= ,A21,A21 ,$
FIELD=FIELD8 ,ALIAS= ,A500,A500,$
FIELDNAME=DELIMITER ,ALIAS=';' ,USAGE=A1 ,ACTUAL=A1 ,$
EDAPUT*
FILEDEF WWDAT DISK test.ftm
-RUN
-WRITE WWDAT "Attendo WEWABM";"Kronoby fortsätter med Attendo";"ATTENDOWEWABM130266143";;"Svenska YLE - Yle Fem - Radio Vega";"http://svenska.yle.fi/artikel/2014/06/04/kronoby-fortsatter-med-attendo";"2014/06/04 17:04:00";"Kronoby fortsätter med AttendoPublicerad 04.06.2014 - 16:05.Arkivbild. Dalsbruks hälsostation Bild: YLE/ Tiina GrönroosKronoby hälsocentraler fortsätter med läkare från Attendo.På sikt är tanken att gå över till egna läkare, men ännu klarar man inte det. Därför går social- och..."
-RUN
DEFINE FILE WWDAT
PROJECT/A35 =GETTOK(APUPROJ,35,1,'_',35,PROJECT);
WDDAY/A8 = EDIT(DAT_FROM,'$9999$99$99') ;
END
TABLE FILE WWDAT
SUM CNT.APUPROJ AS 'CNT'
BY WDDAY AS 'DATE'
HEADING
"***** WEWADAT.CSV MATERIAL BY DATE *****
" "
END
-RUN
TABLE FILE WWDAT
PRINT PROJECT WDDAY SOURCE HEADLINE
BY WDATID
BY PROJECT NOPRINT
IF WDATID NE ' '
IF WDDAY NE ' '
ON TABLE SAVE
END
-RUN