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

Copy records with matching strings from a FILE


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

Active User


Joined: 17 May 2006
Posts: 310

PostPosted: Tue Mar 17, 2015 1:09 pm
Reply with quote

Current Requirement:
SOURCE File Length = 80 bytes.
Generate a report by Copying all the records that have the following strings at the position 28.
Code:
ABCDEF
STRING
STRNG2
PQRSTU


Note 1: String length is always fixed - 6 bytes
Note 2: Strings and/or String count may vary every fort-night.

Following SORT card achieves this.

Code:
SORT FIELDS=COPY
INCLUDE COND=(28,6,CH,EQ,C'ABCDEF',OR,
              28,6,CH,EQ,C'STRING',OR,
              28,6,CH,EQ,C'STRNG2',OR,
              28,6,CH,EQ,C'PQRSTU')


Now, I would like to automate the process of generating the report as follows
1. To accept the strings in a flat file called INFILE from SOURCE file.
INFILE will have the strings like this
ABCDEF
STRING
STRNG2
PQRSTU
2. Write a SORT card that inputs the strings from INFILE

My question is, how to read the strings from INFILE and then copy the records from source file that matches the strings at position 28 ?
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: Tue Mar 17, 2015 1:25 pm
Reply with quote

You read your dataset as SORTIN and get SORT to generate a dataset with the SORT Control Cards you need, and then use that dataset in your actual SORT step.

If there will always be four pieces of data, you won't have a problem identifying the last one...
Back to top
View user's profile Send private message
mkk157

Active User


Joined: 17 May 2006
Posts: 310

PostPosted: Tue Mar 17, 2015 3:03 pm
Reply with quote

@Bill Woodger,
Quote:
If there will always be four pieces of data, you won't have a problem identifying the last one...

The number of strings will always change. So till now, I build an ADHOC job and ran it manually. Now, We would like to automate the process by keeping all the strings in a flat-file and to run every fort-night.

Currently I'm using the below code.

Code:
//STEP1 EXEC PGM=SORT                                 
//SORTLIB  DD DSN=Dataset,DISP=SHR               
//SYSUDUMP DD SYSOUT=*                                 
//SYSOUT   DD SYSOUT=*                                 
//SORTLIST DD SYSOUT=*                                 
//SORTIN   DD DSN=SOURCE.FILE,DISP=SHR           
//SORTOUT  DD DSN=REPORT.FILE,DISP=OLD   
//SYSIN    DD *                                       
  SORT FIELDS=COPY
  INCLUDE COND=(28,6,CH,EQ,C'ABCDEF',OR,
                28,6,CH,EQ,C'STRING',OR,
                28,6,CH,EQ,C'STRNG2',OR,
                28,6,CH,EQ,C'PQRSTU')
Back to top
View user's profile Send private message
rinsio

New User


Joined: 16 Feb 2015
Posts: 13
Location: Madrid, Spain

PostPosted: Tue Mar 17, 2015 7:39 pm
Reply with quote

In my opinion you could use joinkeys

something like this:

JOINKEYS F1=IN1,FIELDS=(28,6,A) <== the input file
JOINKEYS F2=IN2,FIELDS=(1,6,A) <== the strings file
REFORMAT FIELDS=(F1:1,72,F2:01,28) <== is an example

OPTION COPY

try this and give your feedback

Best regards
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: Tue Mar 17, 2015 8:09 pm
Reply with quote

rinsio,

A working example would be interesting if you have a moment. I'm not sure how you intend to do it, but it would be useful (though resource-heavy) if it worked.
Back to top
View user's profile Send private message
mkk157

Active User


Joined: 17 May 2006
Posts: 310

PostPosted: Thu Mar 19, 2015 3:58 pm
Reply with quote

@rinsio, @ Bill Wooder,
Thanks for the sample code.

Code:
JOINKEYS F1=IN1,FIELDS=(28,6,A) <== the input file
JOINKEYS F2=IN2,FIELDS=(1,6,A) <== the strings file
REFORMAT FIELDS=(F1:1,80) <== is an example
OPTION COPY
OUTFIL FNAMES=OUT,BUILD=(1,80)


The above code worked for the criterion mentioned above. But found one exception now. I see few records from the SOURCE file contains the search strings in different position other than 28 as mentioned earlier. I'm trying to modify the SORT control card to cover the exception with search string (SS), but of no luck yet on it.

Is there anyway I can get it done ?
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top