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

DFSORT / ICETOOL - Use parameter from JCL in SORT IF/ELSE


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

New User


Joined: 14 May 2008
Posts: 12
Location: Milton Keynes

PostPosted: Wed Feb 22, 2012 9:40 pm
Reply with quote

How to use a dynamic parameter from JCL to handle IF THEN condition in the SORT.

My shop uses IBM DFSORT. My requirement is that I obtain a DATE in the JCL and do some manipulation on it to arrive at month 'X'.

Possible value of X = 0 or 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 or 0

Following is the sample input file
000010
000030
000021
000032
000443
000003
000004
000015
000077
000086
000088
000109

The digits in concern are the last ones (made bold)

Requirement:

When X = 0
Required Output File:
000086

When X = 1
Required Output File:
000077

When X = 2
Required Output File:
000088

When X = 3
Required Output File:
000109

When X = 6
Required Output File:
000010
000030

When X = 7
Required Output File:
000021

When X = 8
Required Output File:
000032

When X = 9
Required Output File:
000443
000003

When X = 10
Required Output File:
000004

When X = 11
Required Output File:
000015

I would appreciate if someone would help me with a DFSORT solution.
My apologies if a requirement of this type has been already solved in this forum.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Feb 22, 2012 9:53 pm
Reply with quote

the description of the requirement is clear as mud, anyway...
let' s start with

You define X values as one byte, but after You ask for ...
Quote:
When X = 10
Required Output File:
000004

When X = 11
Required Output File:
000015


should the logic for record build disregard all the other data,
for x = 6 and x = 9 emit two records ?
Back to top
View user's profile Send private message
elango_K

New User


Joined: 18 Aug 2011
Posts: 44
Location: India

PostPosted: Wed Feb 22, 2012 9:56 pm
Reply with quote

Hi aarthi,

I am still not clear with your requirement.

You have a input file in which character at position 6 will determine what output has to be posted.

What do you mean by 'required output file' ?
are you referring to the records or do you want your outputs to be directed to differennt output files???

icon_confused.gif
Back to top
View user's profile Send private message
mi.aarthi

New User


Joined: 14 May 2008
Posts: 12
Location: Milton Keynes

PostPosted: Wed Feb 22, 2012 10:16 pm
Reply with quote

Hello and Thank you for the interest.

Yes my mistake, X is of 2 bytes and can be a value from 0 to 11.

Yes the logic for record build should disregard the other data.

In this sample case when X = 6, there are 2 records in the input that end as 0 so INCLUDE them in the output

Again in the sample case when X=9, there are 2 records in the input that end as 3 so INCLUDE them in the output.

To elango_K

Required Output file - What I meant is -
Records that should be in the output file and in other words the output file should contain only these records.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Feb 22, 2012 10:25 pm
Reply with quote

this thread is going to take a while.

so, it is the last two digits that we are concerned about.

that means
01 > 07
11 > 17
21 > 27
31 ...
41
51
61
71
81
91

but if it is 11 it is to become 15
????????????????????????????????????????????????
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Feb 22, 2012 10:34 pm
Reply with quote

ok, the requirement is strange
snippet deleted, does not satisfy the requirement
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: Wed Feb 22, 2012 10:34 pm
Reply with quote

Can you please correct and re-post your sample input, in the Code tags.

Are you saying there is something which uniquely maps something on the input records to a date (month) that you want to supply as a parameter?

Supply 01, and you get records-which-map-to-01 etc? If so, be exact about the mapping, and make sure it all makes sense to the reader before clicking Submit.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Feb 22, 2012 10:36 pm
Reply with quote

code tagging the input data will not make the fog disappear !
Back to top
View user's profile Send private message
mi.aarthi

New User


Joined: 14 May 2008
Posts: 12
Location: Milton Keynes

PostPosted: Wed Feb 22, 2012 10:37 pm
Reply with quote

dbzTHEdinosauer wrote:
this thread is going to take a while.

so, it is the last two digits that we are concerned about.

that means
01 > 07
11 > 17
21 > 27
31 ...
41
51
61
71
81
91

but if it is 11 it is to become 15
????????????????????????????????????????????????


TO MAKE IT EVEN MORE CLEAR; HERE IS THE REQUIREMENT AGAIN

IF X = 0
Check the records in the input file and write/INCLUDE that record (6 bytes) that ends with '6' into the Output file

IF X = 1
Check the records in the input file and write/INCLUDE that record (6 bytes) that ends with '7' into the Output file

IF X = 2
Check the records in the input file and write/INCLUDE that record (6 bytes) that ends with '8' into the Output file

IF X = 3
Check the records in the input file and write/INCLUDE that record (6 bytes) that ends with '9' into the Output file

IF X = 6
Check the records in the input file and write/INCLUDE that record (6 bytes) that ends with '0' into the Output file

IF X = 7
Check the records in the input file and write/INCLUDE that record (6 bytes) that ends with '1' into the Output file

IF X = 8
Check the records in the input file and write/INCLUDE that record (6 bytes) that ends with '2' into the Output file

IF X = 9
Check the records in the input file and write/INCLUDE that record (6 bytes) that ends with '3' into the Output file

IF X = 10
Check the records in the input file and write/INCLUDE that record (6 bytes) that ends with '4' into the Output file

IF X = 11
Check the records in the input file and write/INCLUDE that record (6 bytes) that ends with '5' into the Output file

NOTE:
1. X is not obtained from the Input file and it is a parameter obtained from
the JCL
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Feb 22, 2012 10:40 pm
Reply with quote

Quote:
TO MAKE IT EVEN MORE CLEAR; HERE IS THE REQUIREMENT AGAIN

no reason to shout...
icon_evil.gif

the requirement is still foggy, ( might be skyclear in Your mind, but not for us simple people trying to help )

does the snippet I posted satisfy the overall logic
Back to top
View user's profile Send private message
mi.aarthi

New User


Joined: 14 May 2008
Posts: 12
Location: Milton Keynes

PostPosted: Wed Feb 22, 2012 10:54 pm
Reply with quote

enrico-sorichetti wrote:
Quote:
TO MAKE IT EVEN MORE CLEAR; HERE IS THE REQUIREMENT AGAIN

no reason to shout...
icon_evil.gif

the requirement is still foggy, ( might be skyclear in Your mind, but not for us simple people trying to help )

does the snippet I posted satisfy the overall logic


I am not trying to be rude and also I dint see your post because I was typing that long requirement. Thank you for your time and effort. However the solution needs to evaluate the value of X which will be passed from the JCL as a parameter to the SORT/ICETOOL program (something like a JPn function). And based on the value of X the choice of input record must be written (INCLUDE) in the output file.

Today I took a day off and I am at home so don't have access to Mainframes, but this requirement has kept me thinking.

The expectation is somewhere like this:

//SORT PGM = ICETOOL,(PARM JP1 is X)
//INP DD DSN=......
//OUT DD DSN=......
//TOOLIN
COPY FROM INP TO OUT USING CTLCN1
/*
CTLCN1
IFTHEN...WHEN X = 0
BUILD....INCLUDE=(6,CH,A,'6')
IFTHEN...WHEN X = 1
BUILD....INCLUDE=(6,CH,A,'7')
.
.
.
.

/*
//

There may be too many syntax errors but please don't be cross.

Thanks for the support

Cheers
Back to top
View user's profile Send private message
elango_K

New User


Joined: 18 Aug 2011
Posts: 44
Location: India

PostPosted: Wed Feb 22, 2012 10:55 pm
Reply with quote

So do you mean that you have two files.

One file to give you value of X.

Other file with input data.

depending on X you want to list the output extracting data from input.

If this is not the case , tell us from where you get the value of X.
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: Wed Feb 22, 2012 10:55 pm
Reply with quote

So, given the absence of 4 and 5, you have a modified 01-12 for your parameter which maps to the final digit of each of your input fields.

How do you want to specifiy the parameter? As a two-digit number? Or a month-name, excluding April and May?

You put your parameter in a file, generate a SYMNAME from that single record in the file, use that for the selection. There are several recent samples of similar solutions in this forum. Search for SYMNAMES from user SKOLUSU or Frank.Y* will get the best of them.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Feb 23, 2012 12:23 am
Reply with quote

mi.aarthi,

If I understand what you want to do, then you can use a DFSORT job like the following. nn in the SET statement would be one of your indicated values, e.g. 00, 01, 02, 03, 06, 07, 08. 09, 10 or 11.

Code:

// SET X=nn
//S1 EXEC PGM=SORT,PARM='JP1"&X"'
//SYSOUT DD SYSOUT=*
//SORTIN DD *
000010
000030
000021
000032
000443
000003
000004
000015
000077
000086
000088
000109
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  INREC OVERLAY=(81:JP1,83:81,2,CHANGE=(1,
     C'00',C'6',C'01',C'7',C'02',C'8',C'03',C'9',
     C'06',C'0',C'07',C'1',C'08',C'2',C'09',C'3',
     C'10',C'4',C'11',C'5'),NOMATCH=(C'*'))
  OUTFIL INCLUDE=(6,1,CH,EQ,83,1,CH),BUILD=(1,80)
/*
Back to top
View user's profile Send private message
mi.aarthi

New User


Joined: 14 May 2008
Posts: 12
Location: Milton Keynes

PostPosted: Thu Feb 23, 2012 1:17 am
Reply with quote

Thank you very much Frank and I think (AM SURE) what you have provided is the solution. It is amazing that the utility can handle programmatic requirements. I followed the SYSIN and it resolves the purpose icon_biggrin.gif

I am on leave from work today and tomorrow (preparing for a Prof Cert). Friday I will use the JCL and get the output results and post it here. At work We need this solution because a number of accounts need to be processed in equal chunks across a spread of 10 months and I believe that
processing records by the last digit mapped to the month would be the best way.

I am delighted and more than happy. Meanwhile thank you all dear forum members for your support and here are all the smilies that I can choose at this moment... icon_biggrin.gif icon_smile.gif icon_biggrin.gif icon_biggrin.gif icon_biggrin.gif icon_biggrin.gif icon_biggrin.gif icon_biggrin.gif icon_smile.gif

Speak to you all on Friday!!!!!!!!!!!
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Feb 23, 2012 2:34 am
Reply with quote

mi.aarthi wrote:
At work We need this solution because a number of accounts need to be processed in equal chunks across a spread of 10 months and I believe that processing records by the last digit mapped to the month would be the best way.


mi.aarth,

Had you stated that this is the requirement up ahead , we would have suggested you an alternative solution. DFSORT has many ways to group and perform date arithmetic instead of you resorting to this obscure method of calculating. I am sure this is just a part of the requirement as you still need to process the "equal chunks across a spread of 10 months" .
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top