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 have read the many posts and have used them to get this far, but for some reason I am having trouble with how my flat file is being printed out.
My first question is, how does the master file know what delimeter you have?
I looked at a previous post where Susanne was listing step by step the process and I noticed she created a fill field for when there was a space in her flat file... do I have to do that?
My flat file is reading the fields well but when there is no data for a certain "field" then it populates it with the next fields data... help?
FILEDEF my_logfile DISK /server/app/ibi/apps/appfolder/my_file.txt -RUN
TABLE FILE MY_LOGFILE PRINT * END
If anyone can give me any help, that would be great... even if it is just telling me that this has been answered and maybe giving me the link... I think I've looked though
Thank you
Dev, SIT, UAT, Production:7.6.6 Dev Sandbox:7.6.11
SUFFIX=FIX assumes that you have a file with no delimeter and they are most often fixed length. Most often, these files contain data whose columns always start in the same position. When you create the master, you must account for every character on a line.
There are other formats like COM, COMT, TAB, TABT which are more specific formats for fixed files. You can look these up on the web site for more detail.
Now, in your case you have one column that seems to be of a fixed size and the rest of the line is keyword driven with the columns of varying sizes. If that is true, your effort will be a bit more complex.
Assuming tht is true, create a master for the way you want your flat file to look after you are done with what I'm going to tell you next. The one in your post should work fine.
Then, and here is where it gets a bit complicated if you don't have too much experience, you will have to use Dialogue Manager to -READ the original file, use subroutines to create variables representing the fields in the result master, then -WRITE them to the file that is filedef'd to the result master.
I will give you more detail in a later post if this is what you want to do and your input data is not in neat columns.
If your data is in neat columns, then just add fillers for the stuff you don't want to print. Just remember, you have to account for all the character in a row.
I figured there was an easy way to identify the delimeter but I didn't know and I tried searching everywhere (not good enough I guess)!
I am a pretty experienced developer so feel free to get into details on the next step. Yes each column can have varying sizes and will not always be fixed.
Could I just add a comma delimeter to the file and edit the master file to COM? So I would need to read my_logfile and trim the date/time so that I can get rid of the ",435" ending and then go in and put in commas...
I am up for suggestions though
S
Dev, SIT, UAT, Production:7.6.6 Dev Sandbox:7.6.11
if you are able to change the format of the txt file you can make it to a TAB delimited or an COM delimited file. The last on would have problems with your time, unless you change that comma to a point. With the comma delimited (and tab) you don't have to think about the actual format, but in a comma delimited file you need a special end of line: a ",$" In the master file you also can set a pointer to the location, if the location is not fixed than your filedef is better. In the master you also might need to set the ACTUAL format. PE the first field could be ACTUAL=HYYMD. If some fields are sometimes empty you can add the line "MISSING=ON".
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, 2006
How would I change the format of the text file? Just by placeing TAB or COM in the suffix spot in the master file?
I think the problem is that I get the text file as is. I don't think it's really delimeted or has any sort of format. I guess I could create a 1 field master file and then parse everything out using defines and keywords in the file ... is that a long way of doing it? S
Dev, SIT, UAT, Production:7.6.6 Dev Sandbox:7.6.11
If you want to avoid changing the file before you process it, this is what I would do. I'm only going to do a couple of fields and you can do the rest.
APP FI INPTTXT DISK appdir/inpttxt.txt
APP FI MYLOGFILE DISK appdir/my_logfile.txt
-READLOOP
-READ INPTTXT NOCLOSE INPTLINE.A80. <== or whatever the max length of the line is
-IF &IORETURN NE 0 GOTO ENDLOOP;
-SET &LOG_DATE=SUBSTR(80,&INPTLINE,1,23,23,'A23');
-SET &UPOS=POSIT(&INPTLINE,80,'U=',2,'I2');
-SET &EPOS=POSIT(&INPTLINE,80,'E=',2,'I2');
-SET &ULEN=&EPOS-&UPOS-3; <== You might have to play with this
-SET &UFLD=SUBSTR(80,&INPTLINE,&UPOS+2,&EPOS-2,&ULEN,'A11');
... <== Extract rest of fields here
-WRITE MYLOGFILE &LOG_DATE.A23. &UFLD.A11. &EFLD.A5. ...
-GOTO READLOOP
-ENDLOOP
... Rest of Code
I just was having a hard time when there was no data in the field... but I see in your post.. you minus the positions to get the lenghts for the substring (-SET &ULEN=&EPOS-&UPOS-3; <== You might have to play with this)... makes sense!
I will try both ways... but I had a question about your way: Is &IORETURN a reserved variable... or where/when would I set it if not? Is the input text file an empty text file that I need to create or where does that come from... is it auto created?
Other than that... that looks great!
Thank you I will try this.
S
Dev, SIT, UAT, Production:7.6.6 Dev Sandbox:7.6.11
&IORETURN is a system variable that is used to check the results of a -READ to see if you are at end of file.
The input text file is your original file with the U=, etc. The output will be a file to match the master that you put in your original post that won't have all that stuff in it and you will have fixed column widths and it will be easier to report on.
You are correct about the empty field. You would probably want to check the results of the length calculation to make sure that it wasn't zero. If zero, set to spaces else do the substring.
If you don't mind to have the E= and U+ and such in your datafields, there is an even simpler solution. You only need to change your master file. I've taken your data from this post and created the follwing example for you:
Wonderful Solution! I'd never heard of or used file type DFIX. I cracked open my 'Describing Data' manual, consulted the Index a few times, and learned a lot!
It's neat, too, how you created a *.mas dynamically with WRITE's. Knew it was possible but never saw it used before. I can just image the possibilities when this is combined with DM and some &vars and loops in the WRITE statements. Such a script would illustrate the remarkable power of the FOCUS scripting language to 'boot strap' itself into a dynamically described process.
Chris Burtt
WIN/2K running WF 7.6.4 Development via DevStudio 7.6.4, MRE, TextEditor. Data is Oracle, MS-SQL.
Posts: 154 | Location: NY | Registered: October 27, 2005
Have you run the code he provided as is? That works.
Is your logfile really only 1 space between the time and u data, more spaces could cause this.
The code you have, and copying the data from the forum, seems to work okay, and I cannot see another reason other than the data in the file for it not to run properly.
Alan. WF 7.705/8.007
Posts: 1451 | Location: Portugal | Registered: February 07, 2007
i agree w/ Alan... my next step would be to read 1 record and take a look at the BITVAL of that blank after the 653. It might have a funky nonascii character in it that isn't a 32 (blank) but is something else goofy, like a carriage-return-line-feed, which i've encountered reading whacky flat files. look up BITVAL and HEXBYT in your Using Functions manual. If that turns out to be revealing, then use the CTRAN function to clean out all those whacky values and change them to , say, blanks (32). Do a complete read and write of your file using a master that is just 1 field per record. Then readback your cleaned output under the nice DFIX master you just made. That's what i would try , anyway.
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003