|
View previous topic :: View next topic
|
| Author |
Message |
rajatbagga
Active User

Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
Hello People,
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 ??
Thank You,
Rajat |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
I have not tried this
But what you could try is if you could use SYMNAMES and SUBSET with USING( ) |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
DFSORT isn't going to "edit" a record.
It's going to read all the records on a file and write out the ones you tell it to in the format you tell it.
Is the "edit" you want always in a fixed-position, and is the value to be changed fixed as well? |
|
| Back to top |
|
 |
rajatbagga
Active User

Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
| Bill Woodger wrote: |
| 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.
Thank You,
Rajat |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
| Probably then you can build the sort card dynamically too |
|
| Back to top |
|
 |
rajatbagga
Active User

Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
| Pandora-Box wrote: |
| Probably then you can build the sort card dynamically too |
That's exactly what i am trying to achieve, all i want to know is the best sort syntax to achieve this task.
Thank You,
Rajat |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
If you wanted to edit that particular nth record
You can generate the sequence number through INREC
and edit the nth record using IFTHEN in INREC
Lot of samples in forum
So use your Rexx/Clist generate the sort card by manipulating the value of n |
|
| Back to top |
|
 |
senjay
Active User

Joined: 10 May 2007 Posts: 147 Location: India
|
|
|
|
Pandora-box,
| Quote: |
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 |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
rajatbagga,
Can you confirm that by "edit" you mean "identify a particular record and update whilst copying the entire input to a new output dataset", please?
What are the LRECL and RECFM of you dataset?
You could have your SORT cards fixed, and just generate a few symbols/SYMNAMES.
| Code: |
VALUE-TO-BE-TESTED,start,length,type
VALUE-TO-OVERLAY,C/X'value'
RECORD-TO-BE-SELECTED,+nnnn
|
|
|
| Back to top |
|
 |
Skolusu
Senior Member
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. |
|
| Back to top |
|
 |
rajatbagga
Active User

Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
Thanks Skolusu and Bill Woodger,
@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...
Cheers,
Rajat |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
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
| Code: |
RECORD-RDW,1,4,A
GENERATED-SEQNUM,*,10,ZD
DISPLACEMENT-TO-FIELD,*,length,CH
VALUE-TO-BE-TESTED,*,length,type |
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. |
|
| Back to top |
|
 |
Skolusu
Senior Member
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.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
VB 255 6233 PS
//SORTOUT DD DSN=&&S,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
OPTION COPY
OUTFIL IFTHEN=(WHEN=(3,1,CH,EQ,C'V'),
BUILD=(C'RECORD-RDW,1,4,BI',/,
C'ORIG-REC,*',/,
C'GENSEQ,*,8,PD',/,
C'MOD-REC,*',/,
C'CHNG-FLD-POS,',+78,ADD,+8,M11,LENGTH=5,C',4,PD',/,
C'CHNG-FLD-VAL,X''',C'0000000C''',80:X))
//* |
The translated symbols will be
| Code: |
RECORD-RDW,1,4,BI
ORIG-REC,5
GENSEQ,5,8,PD
MOD-REC,13
CHNG-FLD-POS,86,4,PD
CHNG-FLD-VAL,X'0000000C'
|
Now you can use them in the control cards that does the actual update like shown below
| Code: |
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,BUILD=(RECORD-RDW,SEQNUM,8,PD,ORIG-REC)),
IFTHEN=(WHEN=(GENSEQ,EQ,3000),OVERLAY=(CHNG-FLD-POS:CHNG-FLD-VAL))
OUTREC BUILD=(RECORD-RDW,MOD-REC)
//* |
It is quite simple as that. Now you can work on that model and create for FB type |
|
| Back to top |
|
 |
rajatbagga
Active User

Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
Thanks Skolusu and Bill
I will try the above and will get back if i encounter any issues while getting through it... Thanks again.. this was nicely explained.. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|