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
 

 

Copy records with matching strings from a FILE

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Copy records with matching strings from a FILE
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7233

PostPosted: Tue Mar 17, 2015 1:25 pm    Post subject: Reply to: Copy records with matching strings from a FILE
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    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7233

PostPosted: Tue Mar 17, 2015 8:09 pm    Post subject: Reply to: Copy records with matching strings from a FILE
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
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


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