Focal Point
[CLOSED] Update flatfile using MODIFY

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/364107972

October 29, 2009, 01:49 PM
dev532
[CLOSED] Update flatfile using MODIFY
I have a flat file in fixed format that has these columns fld1~fld2~fld3~fld4
(In my master I have used FILL1 for ~ delimiter)

I am trying to update a row in the flat file(FLAT1) using the MODIFY command, to retain the original record on NO MATCH and to do an update on a MATCH.

Not sure why this isn't working.


FLAT1
-----
fld1~fld2~fld3~fld4
line1~aaaaaa~bbbbbb~cccccc
line2~dddddd~eeeeee~ffffff


-SET &fld1 = 'line2' ;

TABLE FILE FLAT1
PRINT
FLD1
COMPUTE FLD2/A6 = 'XXXXXX' ;
COMPUTE FLD3/A6 = 'YYYYYY' ;
COMPUTE FLD4/A6 = 'ZZZZZZ' ;
WHERE FLD1 EQ '&fld1'
ON TABLE HOLD AS FLAT2
END

MODIFY FILE FLAT1
FIXFORM FROM FLAT2
MATCH FLD1
ON NOMATCH OLD
ON MATCH INCLUDE FLD2 FLD3 FLD4
DATA ON FLAT2
END

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


WF 7.1.1, WF Developer studio 7.1.1, Windows & Mainframe, HTML
October 29, 2009, 01:58 PM
Francis Mariani
You cannot use MODIFY to update flat files, it can only be used for FOCUS databases and DBMS tables.

HOLD file FLAT2 as format FOCUS, update using MODIFY, then read it again and HOLD as alpha.


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
October 29, 2009, 02:02 PM
Francis Mariani
MODIFY FILE FLAT1
FIXFORM FROM FLAT2
MATCH FLD1
ON NOMATCH OLD
ON MATCH INCLUDE FLD2 FLD3 FLD4
DATA ON FLAT2
END

I'm not debugging it, but I'm not sure if this code is valid:

- ON NOMATCH OLD?
- ON MATCH INCLUDE?


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
October 29, 2009, 02:12 PM
dev532
Hi Francis,

ON MATCH OLD is a typo. I actually had ON MATCH INCLUDE

So,
1. HOLD file FLAT2 as format FOCUS
2. update using MODIFY - update FLAT1 you mean?
3. read FLAT2? and HOLD as alpha - but this would ceate a hold file. how would it update the flat file?

Sorry, didn't quite understand what you meant. could you elaborate a little?


WF 7.1.1, WF Developer studio 7.1.1, Windows & Mainframe, HTML
October 29, 2009, 02:19 PM
Francis Mariani
Well, you're creating an alpha hold file called FLAT2 - make it a FOCUS db instead so you can modify it.

Modify it.

Then create an alpha hold file from the modified FOCUS db for whatever next you need to do.


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
October 29, 2009, 02:29 PM
dev532
I need to update the original flat file not the hold file.


WF 7.1.1, WF Developer studio 7.1.1, Windows & Mainframe, HTML
October 29, 2009, 02:46 PM
Francis Mariani
Sheesh!

Then make a FOCUS DB from FLAT1.


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
October 29, 2009, 03:03 PM
GinnyJakes
Or you might try Universal Concatenation, i.e. MORE.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
October 29, 2009, 04:34 PM
dev532
If a file is in use and if another user is trying to update it, what would be the focerrnum or focerror code?

Thanks.


WF 7.1.1, WF Developer studio 7.1.1, Windows & Mainframe, HTML
October 29, 2009, 04:35 PM
Francis Mariani
Try it see it.


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
October 29, 2009, 04:36 PM
Waz
I would suggest using TABLE FILE, perhaps

TABLE FILE FLAT1
PRINT
FLD1
COMPUTE NFLD2/A6 = IF FLD1 EQ '&fld1' THEN 'XXXXXX' ELSE FLD2 ;
COMPUTE NFLD3/A6 = IF FLD1 EQ '&fld1' THEN 'YYYYYY' ELSE FLD3 ;
COMPUTE NFLD4/A6 = IF FLD1 EQ '&fld1' THEN 'ZZZZZZ' ELSE FLD4 ; 
WHERE FLD1 EQ '&fld1'
ON TABLE SAVE AS FLAT2
END


This all depends on your actual requirements


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!

October 30, 2009, 09:13 AM
Danny-SRL
Here is a solution, a bit longish, maybe:

  
The FLAT1 file:
111BBBBCCDDDDD
222GGGGFFEEEEE
333BBBBCCDDDDD
444HHHHFFEEEEE

The FLAT1.mas
FILENAME=FLAT1, SUFFIX=FIX
SEGNAME=FLAT1, SEGTYPE=S0
FIELDNAME=F1, FORMAT=A3, ACTUAL=A3,$
FIELDNAME=F2, FORMAT=A4, ACTUAL=A4,$
FIELDNAME=F3, FORMAT=A2, ACTUAL=A2,$
FIELDNAME=F4, FORMAT=A5, ACTUAL=A5,$

The FLAT2 file:
111B1B1C2DD3DD
333BB3BC2D4DDD

The FLAT2.mas
FILENAME=FLAT2, SUFFIX=FIX
SEGNAME=FLAT2, SEGTYPE=S0
FIELDNAME=F1, FORMAT=A3, ACTUAL=A3,$
FIELDNAME=F2, FORMAT=A4, ACTUAL=A4,$
FIELDNAME=F3, FORMAT=A2, ACTUAL=A2,$
FIELDNAME=F4, FORMAT=A5, ACTUAL=A5,$

The FLAT.mas file:
FILENAME=FLAT, SUFFIX=FOC
SEGNAME=FLAT, SEGTYPE=S1
FIELDNAME=F1, FORMAT=A3, ACTUAL=A3,$
FIELDNAME=F2, FORMAT=A4, ACTUAL=A4,$
FIELDNAME=F3, FORMAT=A2, ACTUAL=A2,$
FIELDNAME=F4, FORMAT=A5, ACTUAL=A5,$

The focexec:
-* File dev3.fex
FILEDEF FLAT1 DISK C:\ibi\apps\focalpoint\FLAT1.TXT
FILEDEF FLAT2 DISK C:\ibi\apps\focalpoint\FLAT2.TXT
SET HOLDLIST=PRINTONLY
MODIFY FILE FLAT
FIXFORM FROM FLAT1
MATCH F1
ON MATCH REJECT
ON NOMATCH INCLUDE
DATA ON FLAT1
END
MODIFY FILE FLAT
FIXFORM FROM FLAT2
MATCH F1
ON MATCH UPDATE *
ON NOMATCH REJECT
DATA ON FLAT2
END
TABLE FILE FLAT 
PRINT *
ON TABLE SAVE 
END
!copy SAVE.FTM C:\ibi\apps\focalpoint\FLAT1.TXT




Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

November 03, 2009, 06:16 AM
<JG>
quote:
If a file is in use and if another user is trying to update it,

I wouldn't worry about the error codes.
You've got a serious problem if you are using flat files even staged to a FOCUS DB.

If you want multiple access to data for read / write then you either need to use a relational table
or a FOCUS DB on a sync machine
November 03, 2009, 08:06 AM
Gary Gerstung
You're obviously new to focus since MODIFY does not work against flat files (Non-indexed) You can, however, accomplish what you want to do with Dialogue Manager code.
November 03, 2009, 10:02 AM
Francis Mariani
Are we not flogging this poor, dead pony just a tad too much? dev532 has lost interest, shouldn't we?


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
November 03, 2009, 03:34 PM
Waz
There are certainly more than enough suggestions for dev532 to try out.


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!