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.
My expertise with Focus is basically limited to using table commands in a Batch environment. What I need to do is manually read a record from an external file and write if out to a new file. In addition, if a given field in that record has a certain value I need to modify that field and write the record out a second time. I need to do this for every record in the file I'm reading (about 10k records)
Can someone help?
I've reviewed all the documentaion available to be, and can't find what I need.
Thanks
TomThis message has been edited. Last edited by: <Kathryn Henning>,
first you need to say what kind of file you're writing out to. Is every record so different that it can't be fixed with just a DEFINE FILE ... ?? DEFINE FILE CAR newvalue/I8 = IF RCOST GT 100 THEN 200 ELSE RCOST ; END ...kind of a thing
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003
The file I am reading from is a 1200 byte sequential file. The file I want to create is the exact same format. I know how to read a file with a table command... what I can't figure out is how to read, modify, and write out individual records manually to a new file.
Initially create an MFD for the sequential file, and then print all fields into a SAVE file. This should be the first step.
Next create DEFINE fields for the fields that you need to change, with the logic for the changes required, and use the PUTDDREC function to write out the changed data to the scone file.
That is the basic approach I would initially take.
Alan. WF 7.705/8.007
Posts: 1451 | Location: Portugal | Registered: February 07, 2007
I have the Master of the input file, but how do I read only 1 record at a time in a batch procedure so that I can make modifications and then rewrite the record?
Using DEFINE FILE fn handles data one record at a time. Therefore you can change one or more fields one record at a time.
Using the PRINT verb in TABLE FILE fn also handles data one record at a time, so the COMPUTE verb can also be used to change one or more fields one record at a time.
The example in the documentation for PUTDDREC gives a good example for what you need to achieve if you use ON TABLE SAVE within the request.
Alan. WF 7.705/8.007
Posts: 1451 | Location: Portugal | Registered: February 07, 2007
Ok, I got that... but how would I write out the same record twice? For example, if my input file contains the following records...
A1234 A5678 B1234 B5678
What I need to do is read the input file and write each record to a new file... in additon, for any record that has an 'A' in position 1, I need to change the 'A' to an 'X' and write the record to the new file. So using the above input, my output file needs to look like this...
A1234 A5678 B1234 B5678 X1234 X5678
What I can't figure out is how to read any given record and write that record out multiple times if needed.
Ah, OK. Examples are always better, particularly over the weekend...
Just run a TABLE request over the incoming file twice in the same focexec. FILEDEF or ALLOC the file with APPEND or MOD.
The first request will just create the vanilla output file with a simple ON TABLE SAVE AS filename, the second run modifies the records as required, limiting the records that are needed to be changed with a WHERE clause, and output to the same SAVE file.
Alan. WF 7.705/8.007
Posts: 1451 | Location: Portugal | Registered: February 07, 2007
Tom, If your input file is not very large, then do what Alan suggests. You will read your input file twice, but it is not too heavy. However, if you have a large file, then I would suggest using MacGuyver. You can duplicate records and thus for each input you can get more than one output.
Daniel In Focus since 1982 wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006
For the number of records here, and the relative simplicity of what you require, I would expect MacGuyver to be over kill.
These are the 2 approaches I think are effective:
-* Create input file for example
TABLE FILE CAR
PRINT COUNTRY CAR MODEL BODYTYPE RETAIL_COST DEALER_COST SALES
ON TABLE HOLD AS INPUT FORMAT ALPHA
END
-RUN
-* Use PUTDDREC and SAVE to same output file
FILEDEF OUTPUT1 DISK BASEAPP/OUTPUT1.DAT (LRECL 82 RECFM V
DEFINE FILE INPUT
NEW_COUNTRY/A10 = IF COUNTRY EQ 'W GERMANY' THEN 'GERMANY' ELSE ' ';
NEW_RECORD/A82 = NEW_COUNTRY | CAR | MODEL | BODYTYPE | FPRINT(RETAIL_COST, 'D7c', 'A7') | FPRINT(DEALER_COST, 'D7c', 'A7') |FPRINT(SALES, 'I6', 'A6');
END
TABLE FILE INPUT
PRINT COUNTRY CAR MODEL BODYTYPE RETAIL_COST DEALER_COST SALES
COMPUTE NEW_OUTPUT/I4 = IF COUNTRY EQ 'W GERMANY' THEN PUTDDREC('OUTPUT1',82, NEW_RECORD,82,'I4') ; NOPRINT
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SAVE AS OUTPUT1
END
-* Use 2 SAVEs to same output file
FILEDEF OUTPUT2 DISK BASEAPP/OUTPUT2.DAT (LRECL 82 RECFM V
DEFINE FILE INPUT
NEW_COUNTRY/A10 = IF COUNTRY EQ 'W GERMANY' THEN 'GERMANY' ELSE ' ';
END
TABLE FILE INPUT
PRINT COUNTRY CAR MODEL BODYTYPE RETAIL_COST DEALER_COST SALES
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SAVE AS OUTPUT2
END
FILEDEF OUTPUT2 DISK BASEAPP/OUTPUT2.DAT (LRECL 82 RECFM V APPEND
TABLE FILE INPUT
PRINT NEW_COUNTRY CAR MODEL BODYTYPE RETAIL_COST DEALER_COST SALES
WHERE NEW_COUNTRY NE ' '
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SAVE AS OUTPUT2
END
Alan. WF 7.705/8.007
Posts: 1451 | Location: Portugal | Registered: February 07, 2007