IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Editing a record value based on a line number.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Wed Feb 13, 2013 6:49 am
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Feb 13, 2013 12:15 pm
Reply with quote

I have not tried this

But what you could try is if you could use SYMNAMES and SUBSET with USING( )
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Feb 13, 2013 12:57 pm
Reply with quote

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
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Thu Feb 14, 2013 6:30 am
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Feb 14, 2013 11:19 am
Reply with quote

Probably then you can build the sort card dynamically too
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Thu Feb 14, 2013 11:49 am
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Feb 14, 2013 1:52 pm
Reply with quote

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
View user's profile Send private message
senjay

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Thu Feb 14, 2013 1:58 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Feb 14, 2013 2:38 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Feb 14, 2013 11:14 pm
Reply with quote

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
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Fri Feb 15, 2013 4:11 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Feb 15, 2013 4:59 am
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Feb 15, 2013 6:07 am
Reply with quote

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
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Mon Feb 18, 2013 10:43 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top