sample code for read a 2nd record from last in flatfile how
can do?
Answers were Sorted based on User's Feedback
Answer / nsingh
ADD SEQUENCE NUMBER
SORT FIELDS=COPY
OUTREC FIELDS = (1,80,SEQNUM,ZD,A)
NOW SORT SEQ NUM IN DESCENDING ORDER
SORT FIELDS=(81,4,ZD,D)
INCLUDE ONLY 2ND LAST REC
SORT FILEDS = COPY
INCLUDE COND = (81,4,ZD,EQ,0002')
REMOVE SEQ NUM FROM FILE & THIS REC IS SELECTED
SORT FIELDS =COPY
OUTREC FIELDS = (1,80)
| Is This Answer Correct ? | 1 Yes | 0 No |
Suppose file has 100 Record
1,2,3.........................100
a) Read the file and Count the number of records into a variable
Suppose CNT_VAR = 100
b) Suppose you want to read 2nd record from Last
So Set N = 2
c) Now to find the search variable compute the below
SRC_VAR = CNT_VAR - N i.e (100 - 2)
SRC_VAR = 98
d) Now Read the file to pick 98th record from top
| Is This Answer Correct ? | 1 Yes | 2 No |
Answer / sunilkumar
First open the file in reverse order using OPEN command
OPEN FILE file-name REVERSE
Then read twice to get the 2nd last record.
| Is This Answer Correct ? | 0 Yes | 2 No |
Answer / santhosh vayathuri
for this we need to do fallowing steps
1) read all the records and store into an array and count
value store into an var
2) from that array subtract count var by 1 we will get last
2nd record
ex :: array(count-1) == last 2nd rec
| Is This Answer Correct ? | 1 Yes | 6 No |
88 class is used for
Difference between lrecl, blksize among PS, PDS issues? i.e in jcl at dcb
How many bytes do a s9 (7) comp-3 field occupy?
What is the difference between structured cobol programming and object alternativelyiented cobol?
can we use full outer join with cursors declared in cobol program?
1.Is it possible to move the data from 99.99 to 99v99? 2.What is the CICS-vsam Compilation process? 3.In My GDG 5 generation will be there GDG3 got an abend what will happen? 4.In my GDG first generation is +1 And I want to add the new generation what will happen previous generation? 5.How can you give the PIC clause below conditions A). s9 (reddy), B). s9 (5) occurs 5 times? 6.How override the proc from a particular step? and what is symbolic and override Procs?
01 WS-NAME PIC X(10) OCCURES 2. by this we can get ws-name 2 times. My qustion is how can we access the second name
What are the different forms of EVALUATE statement?
how can i see junk values in dclgen or in hostvariable of comp ?
what is the difference between start and startbr?
what is meaning by design document? who can repared for this?
What the difference is between continue and next sentence?