|
View previous topic :: View next topic
|
| Author |
Message |
mkk157
Active User

Joined: 17 May 2006 Posts: 310
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
mkk157
Active User

Joined: 17 May 2006 Posts: 310
|
|
|
|
@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 |
|
 |
rinsio
New User
Joined: 16 Feb 2015 Posts: 13 Location: Madrid, Spain
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
mkk157
Active User

Joined: 17 May 2006 Posts: 310
|
|
|
|
@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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|