Focal Point
Writing Records in Reverse Order

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

May 08, 2006, 02:04 AM
Shrivatsa
Writing Records in Reverse Order
I have a Physical sequential file with 10 records.

I want to copy all these records into another ps fille in the reverse order (last record should be first record in the new file).

IS IT POSSIBLE ? HOW ????


Thanks
Shri
Mainframe FOCUS 7.2.6
WEBFOCUS 5.2
May 08, 2006, 04:22 AM
<Special-K>
If this is a one-off for this file only you could do 10 -READs followed by 10 -WRITEs in the reverse order like this:

FILEDEF file1 DISK location1
FILEDEF file2 DISK location2
-RUN

-READ file1 &VAR1.A40
-READ file1 &VAR2.A40
-READ file1 &VAR3.A40
-READ file1 &VAR4.A40
-READ file1 &VAR5.A40
-READ file1 &VAR6.A40
-READ file1 &VAR7.A40
-READ file1 &VAR8.A40
-READ file1 &VAR9.A40
-READ file1 &VAR10.A40
-WRITE file2 &VAR10
-WRITE file2 &VAR9
-WRITE file2 &VAR8
-WRITE file2 &VAR7
-WRITE file2 &VAR6
-WRITE file2 &VAR5
-WRITE file2 &VAR4
-WRITE file2 &VAR3
-WRITE file2 &VAR2
-WRITE file2 &VAR1

If this procedure is to be used many times with an unknown number of records in the file you'll have to try something else
May 08, 2006, 04:47 AM
Shrivatsa
I have tried your code on Mainframe FOCUS
But I am getting only the first Record only in my Output.

FILEDEF P7
FILEDEF B7
-RUN

-READ P7 &VAR1.A40
-READ P7 &VAR2.A40
-READ P7 &VAR3.A40
-READ P7 &VAR4.A40
-READ P7 &VAR5.A40
-READ P7 &VAR6.A40
-READ P7 &VAR7.A40
-READ P7 &VAR8.A40
-READ P7 &VAR9.A40
-READ P7 &VAR10.A40
-WRITE B7 &VAR10
-WRITE B7 &VAR9
-WRITE B7 &VAR8
-WRITE B7 &VAR7
-WRITE B7 &VAR6
-WRITE B7 &VAR5
-WRITE B7 &VAR4
-WRITE B7 &VAR3
-WRITE B7 &VAR2
-WRITE B7 &VAR1

The location of the file P7 and B7 are given in JCL.

Could you please help me


Thanks
Shri
Mainframe FOCUS 7.2.6
WEBFOCUS 5.2
May 08, 2006, 05:05 AM
<Special-K>
It might be the A40 you'll need to change this to the length of the record in your file. Try -TYPEing the values to the screen first as it's only 10 records see what that produces
May 08, 2006, 07:12 AM
Shrivatsa
FILEDEF P7
UNKNOWN FOCUS COMMAND FILEDEF
BYPASSING TO END OF COMMAND
FILEDEF B7
JAUGAR 130150
ERROR AT OR NEAR LINE 114 IN PROCEDURE TEST FOCEXEC
(FOC295) A VALUE IS MISSING FOR: VAR9

I am getting this error

As my file layout is
FILENAME=P7,SUFFIX=FIX
SEGNAME=MAIN
FIELD=NAME, , A10,A10, $ 001-010
FIELD=ID, , I3,A3, $ 011-013
FIELD=BATCH, , I3,A3, $ 014-017
FIELD=FILLER, , A63,A63, $ 018-080


And also its reading the first record

Thanks
Shri


Thanks
Shri
Mainframe FOCUS 7.2.6
WEBFOCUS 5.2
May 08, 2006, 07:24 AM
<Special-K>
Should your VAR9 be &VAR9?
No matter, ignore that and try this

TABLE FILE P7
LIST NAME ID BATCH FILLER
ON TABLE HOLD AS HOLD1
END

TABLE FILE HOLD1
PRINT E02 E03 E04 E05
BY HIGHEST E01 NOPRINT
ON TABLE HOLD AS HOLD2
END

If you then TABLE out HOLD2 it should be in reverse order of the original file
May 08, 2006, 07:48 AM
ET
Here is another way without using a hold file.
DEFINE FILE P7
CNTR/I9= LAST CNTR +1;
END
TABLE FILE P7
PRINT * BY HIGHEST CNTR NOPRINT
ON TABLE HOLD AS HOLD1 FORMAT INTERNAL
END

Good luck.


FOCUS 7.6 MVS PDF,HTML,EXCEL
May 08, 2006, 07:58 AM
Shrivatsa
Thanks for all your help

I have tried the logic of ET

It worked


Thanks
Shri
Mainframe FOCUS 7.2.6
WEBFOCUS 5.2
May 08, 2006, 09:55 AM
susannah
on your result of getting only the first record,
you might want to use the NOCLOSE modifier to your -READ statement to keep the file open and reading successsive records.
-READ MYFILE NOCLOSE &MYVAR.A40




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
May 08, 2006, 05:18 PM
j.gross
Without dialog manager:

TABLEF FILE FIRST
LIST [the fields]
ON TABLE HOLD
END
TABLE FILE HOLD
PRINT [the fields]
BY HIGHEST LIST NOPRINT
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE HOLD AS SECOND
END

You may need to use an alternate MFD that describes the source as a single (format A) field.
May 18, 2006, 09:53 AM
<Mabel>
Hi Shrivasta,

Has this issue been resolved?

As always, you may contact Information Builders’ Customer Support Services for assistance at any time. The phone number is 1-800-736-6130, or you may access the online system InfoResponse at http://techsupport.ibi.com. Here is a list of information to be ready when you call: http://techsupport.ibi.com/before_you_call.jsp.

Hope this helps.
May 18, 2006, 07:26 PM
Shrivatsa
Thanks for your help.

This problem has been resolved


Thanks
Shri
Mainframe FOCUS 7.2.6
WEBFOCUS 5.2