Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sort card to replace text using cross reference file
Goto page 1, 2  Next
 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
Susanta

Active User


Joined: 17 Nov 2009
Posts: 118
Location: India

PostPosted: Tue Sep 13, 2016 4:17 pm    Post subject: Sort card to replace text using cross reference file
Reply with quote

Hi

I have below 2 input files,

File1 ..(need to replace string start pos=1, len=8 based on cross-ref file
Code:
Aitem1old
Aitem2old
Aitem3old


Cross ref File:two fileds of 8 byte
Code:
item1olditem1new
item3olditem3new
item4olditem4new


Desired output file: (string startpos=1,len=8 replaced based oncross ref file)
Code:
Aitem1new
Aitem2old
Aitem3new

can we do it using dfsort.

Could you please help

Thanks.
Susanta
Back to top
View user's profile Send private message

mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Sep 13, 2016 4:51 pm    Post subject:
Reply with quote

Yes. It can be done in DFSORT using JOIN. Please search the forum. There are many examples.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Sep 13, 2016 5:23 pm    Post subject:
Reply with quote

It is a simple JOINKEYS with JOIN UNPAIRED,F1 and a REFORMAT statement (entire F1 and the new value from cross-ref file and ?), and couple of IFTHEN statements to BUILD the desired output.

To reorder file in original order after processing - Use SEQNUM before the JOINKEYS in file 1, do the join, sort on the sequence numbers.
Back to top
View user's profile Send private message
Susanta

Active User


Joined: 17 Nov 2009
Posts: 118
Location: India

PostPosted: Tue Sep 13, 2016 5:26 pm    Post subject:
Reply with quote

tHNAKS for the inputs, i will try it out..
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Tue Sep 13, 2016 6:19 pm    Post subject:
Reply with quote

After seven years you don't know the difference between JCL and Sort? Moving to DFSort.
Also, you should know by now that you present data etc within code tags.

Also, Also: you have a data set not a file.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Tue Sep 13, 2016 11:59 pm    Post subject:
Reply with quote

Always bookmark, Smart DFSORT Tricks Look at page-14 onwards please.
Back to top
View user's profile Send private message
Susanta

Active User


Joined: 17 Nov 2009
Posts: 118
Location: India

PostPosted: Wed Sep 21, 2016 12:22 pm    Post subject:
Reply with quote

Hi I am facing a issue , job fails saying

Code:
WER481I  JOINKEYS REFORMAT RECORD LENGTH=  135, TYPE = F     
WER110I  F2ONLY   : RECFM=FB   ; LRECL=    80; BLKSIZE= 27920
WER074I  F2ONLY   : DSNAME=TXX.XATA.XXXX.VX         
WER247A  F2ONLY   HAS INCOMPATIBLE LRECL                     


the card is

Code:
JOINKEYS FILE=F1,FIELDS=(1,14,CH,A)               
JOINKEYS FILE=F2,FIELDS=(2,14,CH,A)               
JOIN UNPAIRED,F1,F2                               
REFORMAT FIELDS=(F1:1,80,F2:1,55),FILL=C'$'       
OPTION COPY                                       
                                                 
OUTFIL FNAMES=F2ONLY,                             
IFTHEN=(WHEN=(1,1,CH,NE,C'$',AND,81,1,CH,EQ,C'$'),
       BUILD=(1,80)),                             
IFTHEN=(WHEN=(1,1,CH,NE,C'$',AND,81,1,CH,NE,C'$'),
       OVERLAY=(1:96,14))
Back to top
View user's profile Send private message
Susanta

Active User


Joined: 17 Nov 2009
Posts: 118
Location: India

PostPosted: Wed Sep 21, 2016 1:45 pm    Post subject:
Reply with quote

changed the card as below and its working now.. the only issue now is it does not presevres the original files(F1) order... Is there any way we can preserve the order.

Code:
 JOINKEYS FILE=F1,FIELDS=(1,14,CH,A)               
 JOINKEYS FILE=F2,FIELDS=(2,14,CH,A)               
 JOIN UNPAIRED,F1                                 
 REFORMAT FIELDS=(F1:1,80,F2:1,55),FILL=C'$'       
 OPTION COPY                                       
                                                   
 OUTFIL FNAMES=F2ONLY,                             
 IFTHEN=(WHEN=(1,1,CH,NE,C'$',AND,81,1,CH,EQ,C'$'),
        BUILD=(1,80)),                             
 IFTHEN=(WHEN=(1,1,CH,NE,C'$',AND,81,1,CH,NE,C'$'),
        BUILD=(96,14,15,64))
Back to top
View user's profile Send private message
Abid Hasan

New User


Joined: 25 Mar 2013
Posts: 65
Location: India

PostPosted: Wed Sep 21, 2016 1:58 pm    Post subject:
Reply with quote

Hello,

Susanta wrote:
... the only issue now is it does not presevres the original files(F1) order... Is there any way we can preserve the order.

JOINKEYS FILE=F1,FIELDS=(1,14,CH,A)
JOINKEYS FILE=F2,FIELDS=(2,14,CH,A)


If your input 'keys' are already in the order you need, you can add SORTED on your JOINKEYS statement, which tells *SORT to not sort the data in 'FILE' mentioned.
OR
A lengthy-inefficient approach, but will get the job done: pad a sequence number to the dataset whose records you donot want SORTED, using INREC coupled with a JOINKEYS CONTROL statement. Now, replace your OPTION COPY with a SORT FIELDS on the sequence number you added earlier; drop these sequence numbers in your BUILD statements.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Sep 21, 2016 2:07 pm    Post subject: Reply to: Sort card to replace text using cross reference file
Reply with quote

after 7 years of hanging around You have not learned yet how to use the code tags

very inconsiderate behaviour

learn to help peoplw who spend their time helping You icon_evil.gif

Your data snippets were CODE'd
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Wed Sep 21, 2016 3:35 pm    Post subject:
Reply with quote

Abid Hasan wrote:

A lengthy-inefficient approach, but will get the job done: pad a sequence number to the dataset whose records you donot want SORTED, using INREC coupled with a JOINKEYS CONTROL statement. Now, replace your OPTION COPY with a SORT FIELDS on the sequence number you added earlier; drop these sequence numbers in your BUILD statements.


Why this is a lengthy-inefficient approach, if datasets are not already sorted?
Back to top
View user's profile Send private message
Abid Hasan

New User


Joined: 25 Mar 2013
Posts: 65
Location: India

PostPosted: Wed Sep 21, 2016 3:51 pm    Post subject:
Reply with quote

Hello,

Imho, second approach is lengthy and inefficient When compared to the first approach.
Note that the output will be sorted again on the sequence numbers - which can be avoided altogether if addition of SORTED,NOSEQCK 'IS' getting the job done.

Any new instruction added, which causes the data to be parsed more than once is bad. If SORTED is not added, data will be sorted by JOINKEYS come-what-may - unless we tell it not to; the sequence will not change because of SEQNUM - BUT data will be sorted. It will be sorted again just before the OUTFIL processing - which is at least 2 passes of data, now if user has a mill. and above records - Bad.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Wed Sep 21, 2016 4:55 pm    Post subject:
Reply with quote

Susanta, please check you joinkeys, looks that's you have a flip flop plus it should be 8 byte per your original post, please read some dfsort documentation at the top of this page there is a link which will answer your question on how to preserve the sort order of file1 in output. However Abid has told you the Hint so follow that.
SYNCSORT, should be following DFSORT's most of the function so that info should help from documentation.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Sep 21, 2016 4:58 pm    Post subject: Reply to: Sort card to replace text using cross reference file
Reply with quote

the WER messages imply that the TS is using SYNCSORT
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2163
Location: @my desk

PostPosted: Wed Sep 21, 2016 6:17 pm    Post subject:
Reply with quote

Susanta,

If your Syncsort/MFX version allows (>=1.4.2 IIRC), you can make use of the "?" operator in the REFORMAT statement to know if the reformatted record is a matched record or an 'F1 only'/'F2 only' record, and get rid of the '$' FILLing logic. "?" will return any of these 3 possible values - 1,2 or B indicating if it is an 'F1 only' record, 'F2 only' record or a matched record respectively.

Something like this (untested)
Code:
 JOINKEYS FILE=F1,FIELDS=(1,14,CH,A)               
 JOINKEYS FILE=F2,FIELDS=(2,14,CH,A)               
 JOIN UNPAIRED,F1                                 
 REFORMAT FIELDS=(F1:1,80,F2:1,55,?)       
 OPTION COPY                                       
                                                     
 OUTFIL FNAMES=F2ONLY,                             
 IFTHEN=(WHEN=(136,1,CH,EQ,C'1'),
        BUILD=(1,80)),                             
 IFTHEN=(WHEN=(136,1,CH,EQ,C'B'),
        BUILD=(96,14,15,64))
Also you are writing all the records from F1 to output. But the DDname suggests "F2ONLY"?
Back to top
View user's profile Send private message
Susanta

Active User


Joined: 17 Nov 2009
Posts: 118
Location: India

PostPosted: Thu Sep 22, 2016 11:42 am    Post subject:
Reply with quote

Thnaks All for the suggestions, i corrected the F2only to F1ONLY.
Also i have used SEQnum to solve ordering issue.kept 10 byte for seqnum.

Now the issue is .. i need the final o/p to be similar to file F1 in structure , i mean LRECL as 90 . But it fails when i put lrecl as 90 in the F1ONLY dd card.
i had to put lrecl as 90 + 55 . in this way i have to add one more step to discard extra bytes from the final o/p file. can it be solved without using any further jcl step.
Back to top
View user's profile Send private message
Abid Hasan

New User


Joined: 25 Mar 2013
Posts: 65
Location: India

PostPosted: Thu Sep 22, 2016 12:15 pm    Post subject:
Reply with quote

Hello,

Susanta wrote:
.. i need the final o/p to be similar to file F1 in structure , i mean LRECL as 90 . But it fails when i put lrecl as 90 in the F1ONLY dd card. ...


Why specify the DCB/LRECL at all, let *SORT decide it for you. The BUILD statement here is the one deciding the output dataset's LRECL, so till the time the LRECL calculated in BUILD corresponds to what is specified in the DCB information, you're good, else an error; revisit the BUILD statement, correct it to fit your requirement, if 90 bytes is needed, and your actual output data is only - say 50 bytes, simply add a '90:X' in your build, which says add a space at 90th byte, this will force the output dataset's LRECL to be of 90 bytes; this is just one of the many ways of forcing a LRECL via a *SORT card.
Back to top
View user's profile Send private message
Susanta

Active User


Joined: 17 Nov 2009
Posts: 118
Location: India

PostPosted: Thu Sep 22, 2016 1:26 pm    Post subject:
Reply with quote

Hi
This is the final card that working for me..

Code:
JOINKEYS FILE=F1,FIELDS=(11,14,CH,A)             
JOINKEYS FILE=F2,FIELDS=(2,14,CH,A)               
JOIN UNPAIRED,F1                                 
REFORMAT FIELDS=(F1:1,90,F2:1,55),FILL=C'$'       
SORT FIELDS=(1,10,ZD,A)                           
                                                 
OUTFIL FNAMES=F1ONLY,                             
IFTHEN=(WHEN=(1,1,CH,NE,C'$',AND,91,1,CH,EQ,C'$'),
       BUILD=(1,90)),                             
IFTHEN=(WHEN=(1,1,CH,NE,C'$',AND,91,1,CH,NE,C'$'),
       BUILD=(1,10,106,14,25,64))                 


but job works only if i put F1ONLY dd LRECL as 145 and not 90 .
but you can see my build cards conforming to 90.
Back to top
View user's profile Send private message
Abid Hasan

New User


Joined: 25 Mar 2013
Posts: 65
Location: India

PostPosted: Thu Sep 22, 2016 1:54 pm    Post subject:
Reply with quote

Hello,

To start with, your BUILD statements are inconsistent in terms of length. First points to 90, second - 10+14+64 = 88.

Look at the SYSOUTs generated by *SORT, they clearly point out the various stages of *SORT alongwith the phase wherein the length was calculated, you should be able to see how a 145 came up there.
if not then, please share the JCL and the SYSOUT here.
Back to top
View user's profile Send private message
Susanta

Active User


Joined: 17 Nov 2009
Posts: 118
Location: India

PostPosted: Thu Sep 22, 2016 2:12 pm    Post subject:
Reply with quote

Hi ... ran job ... still same issue

Code:
JOINKEYS FILE=F1,FIELDS=(11,14,CH,A)                             
 JOINKEYS FILE=F2,FIELDS=(2,14,CH,A)                               
 JOIN UNPAIRED,F1                                                 
 REFORMAT FIELDS=(F1:1,90,F2:1,55),FILL=C'$'                       
 SORT FIELDS=(1,10,ZD,A)                                           
                                                                   
 OUTFIL FNAMES=F1ONLY,                                             
 IFTHEN=(WHEN=(1,1,CH,NE,C'$',AND,91,1,CH,EQ,C'$'),               
        BUILD=(1,90)),                                             
 IFTHEN=(WHEN=(1,1,CH,NE,C'$',AND,91,1,CH,NE,C'$'),               
        BUILD=(1,10,106,14,25,66))                                 
WER813I  INSTALLATION OPTIONS IN MFX LOAD LIBRARY WILL BE USED     
WER164B  17,736K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,
WER164B     0 BYTES RESERVE REQUESTED, 416K BYTES USED             
WER146B  32K BYTES OF EMERGENCY SPACE ALLOCATED                   
WER481I  JOINKEYS REFORMAT RECORD LENGTH=  145, TYPE = F           
WER110I  F1ONLY   : RECFM=FB   ; LRECL=    90; BLKSIZE= 27990     
WER074I  F1ONLY   : DSNAME=XXX.XXXX.XXXXX
WER247A  F1ONLY   HAS INCOMPATIBLE LRECL                           
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> SYNCSORT All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us