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: 7315

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: 7315

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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am


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