Just wanted to know if there is any sort option available to edit a record based on the line number.
For eg. I have a file with approx 5 million records and i want to edit 500th record with the value of X'0000892C' in Col. 56 , I don't have a key in the file and the line number can change from situation to situation. Like today i want to edit 500th record some other time i could be 89th record.
A one way of doing it would be to identify the LRECL of the file and then have a seq number at the end to locate the line number and then using OVERLAY to edit the value. Just want to explore if there is any other better alternative to this approach.
I know Subset can be used to directly point to the specified line number which is used for KEEP or REMOVE the records.. can we also edit the record in similar way based on the line number, by using OVERLAY with SUBSET ??
Is the "edit" you want always in a fixed-position, and is the value to be changed fixed as well?
All the three parameters are dynamic in nature since they need to be passed via CLIST panel to build a JCL step to edit a value in the file based on the line number,column position of the field user wants to edit and the new field value.
You can generate the sequence number through INREC
and edit the nth record using IFTHEN in INREC
OP already knows this solution and he wants to know if there is a better solution than this.
Quote:
A one way of doing it would be to identify the LRECL of the file and then have a seq number at the end to locate the line number and then using OVERLAY to edit the value. Just want to explore if there is any other better alternative to this approach
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
Rajatbagga,
I agree with Bill Woodger suggestion of generating dynamic symbols.
1. LISTDS on the dataset you want to edit
2. Get the RECFM, LRECL ,DSORG from the output of step1
3. Validate DSORG and set a RC=4 when it is not a PS.
4. If DSORG=Fx, generate symbols with seqnum at the end by taking the LRECL+1 as startpos for the seqnum
5. If DSORG =Vx generate generate symbols with seqnum after the RDW.
6. Generate the symbols for the lookup and change values.
7. Use these symbols in the actual edit step. INREC will expand the record with SEQNUM and OUTREC will get rid off it.
@Bill :- Yes I will be copying the entire file from
input to output with the edited record and in the
same sequence.
@Skolusu :- I had similar thought , generating dynamic
symbols is something new can you please let me know
what's the MAX value that SEQNUM can handle and an
example of generating dynamic symbols ??
For eg :-
I have identified a file which is VB and LRECL 4000, the user wants
to edit line number 3000 with the value X'0000000C' in the column
position 78.
Conclusion :- Inserting a SEQNUM at the end of file(FB) or
after RDW(VB) is the best way to edit a file based on the line number.
I will give it a go and see where i end up with. Thanks for the advises...
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
The maximum for a sequence number is many more than you need. You can check for the exact figure in the manual (then you'll know) but you can safely make it ten times the maximum number of records on a file.
You'll need something like this
Code:
BUILD=(1,4,SEQNUM,10,ZD,5)
This will copy all your variable-length records, with the sequence number between the RDW and the actual data, the "10" allows for 9,999,999,999 which should be enough.
Remember that for a VB, the start of VALUE-TO-BE-TESTED,start,length,type, needs to be adjusted by four bytes for the RDW and then bear in mind that it also needs to be adjusted for the sequence number
Would be a neat way to do it, as your code to generate those last two symbols would not have to take the length of the sequence number directly into account, improving your flexibility.
For an FB, put the sequence number at the "end" of the record, so less of a problem, but the "displacement" method would still work.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
rajatbagga wrote:
@Skolusu :- I had similar thought , generating dynamic
symbols is something new can you please let me know
what's the MAX value that SEQNUM can handle and an
example of generating dynamic symbols ??
For eg :-
I have identified a file which is VB and LRECL 4000, the user wants
to edit line number 3000 with the value X'0000000C' in the column
position 78.
SEQNUM supports upto 16 digits. If you are worried about the size then use PD format which would help you store a larger value in less number of bytes. SEQNUM,8,PD will store 999,999,999,999,999 which is way bigger number than you need.
Generating dynamic symbols is quite easy. Here is a way for VB files. Since you said your change field is at position 78, We need to calculate it's position adding 8 bytes as we added a seqnum of 8 bytes for the record number.