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

Sort card to replace text using cross reference file


IBM Mainframe Forums -> SYNCSORT
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
Susanta

Active User


Joined: 17 Nov 2009
Posts: 126
Location: India

PostPosted: Tue Sep 13, 2016 4:17 pm
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: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Sep 13, 2016 4:51 pm
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: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Sep 13, 2016 5:23 pm
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: 126
Location: India

PostPosted: Tue Sep 13, 2016 5:26 pm
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: 2455
Location: Hampshire, UK

PostPosted: Tue Sep 13, 2016 6:19 pm
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Tue Sep 13, 2016 11:59 pm
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: 126
Location: India

PostPosted: Wed Sep 21, 2016 12:22 pm
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: 126
Location: India

PostPosted: Wed Sep 21, 2016 1:45 pm
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: 88
Location: India

PostPosted: Wed Sep 21, 2016 1:58 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Sep 21, 2016 2:07 pm
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: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Wed Sep 21, 2016 3:35 pm
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: 88
Location: India

PostPosted: Wed Sep 21, 2016 3:51 pm
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Wed Sep 21, 2016 4:55 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Sep 21, 2016 4:58 pm
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: 2481
Location: @my desk

PostPosted: Wed Sep 21, 2016 6:17 pm
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: 126
Location: India

PostPosted: Thu Sep 22, 2016 11:42 am
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: 88
Location: India

PostPosted: Thu Sep 22, 2016 12:15 pm
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: 126
Location: India

PostPosted: Thu Sep 22, 2016 1:26 pm
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: 88
Location: India

PostPosted: Thu Sep 22, 2016 1:54 pm
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: 126
Location: India

PostPosted: Thu Sep 22, 2016 2:12 pm
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
Abid Hasan

New User


Joined: 25 Mar 2013
Posts: 88
Location: India

PostPosted: Thu Sep 22, 2016 2:32 pm
Reply with quote

And the JCL, please?!

Edit: Aah, the things *SORT does icon_smile.gif

Refer this link, it has precisely what you need: ibmmainframes.com/about60103.html
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Sep 22, 2016 5:05 pm
Reply with quote

Show us the JCL for DDname F1ONLY.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Thu Sep 22, 2016 5:25 pm
Reply with quote

Susanta - You might want to use IFOUTLEN to limit the output record length like this.
Code:
OUTFIL FNAMES=F1ONLY,IFOUTLEN=90,
Back to top
View user's profile Send private message
Susanta

Active User


Joined: 17 Nov 2009
Posts: 126
Location: India

PostPosted: Thu Sep 22, 2016 5:29 pm
Reply with quote

HI..

i have another need where f1 file is of VB format.

and F2 is still of FB format.

what changes required for the bewlo card for this scenario.
could you please help.

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))                 

Back to top
View user's profile Send private message
Abid Hasan

New User


Joined: 25 Mar 2013
Posts: 88
Location: India

PostPosted: Thu Sep 22, 2016 5:42 pm
Reply with quote

Hello NicC, the problem will keep coming unless the length is handled explicitly as tested by Pandora/Mr. Woodgar in the earlier tagged post; at least for SYNCSORT.

Aside, Susanta, for a VB dataset, you add 4 to the already specified start-of-data positions; for example, from: FIELDS=(11,14,CH,A) , 11 changes to 15; from FIELDS=(2,14,CH,A), 2 changes to 6; and so on. Play around with it a bit, and you should be able to work it out. There are hundreds of examples for this available on the forum as well as the good ol' web (if the manual is not around).

Do confirm if the information from the link shared and stated by Mr. Raj a few posts earlier was helpful in to resolving the issue, because your last sort-card doesn't show any changes.
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. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top