|
View previous topic :: View next topic
|
| Author |
Message |
Gunapala CN
New User
Joined: 13 Oct 2016 Posts: 16 Location: India
|
|
|
|
I've a requireent, I have done some research with help of google but couldn't get any proper solution, could some one help me on!
Requirement: There are 3 datasets,dataset1 : is having one key row(Value1/Value2/value3). Datasets2/3/4: have data i.e many records which need to be write into the output/another dataset based on value present in first dataset key.
Suppose - case 1: if dataset1.value = Value1 then write dataset2 records into another/output dataset. Case 2: if dataset1.value = Value2 then write dstaset3 records into another/output dataset. Case 3: if dataset1.value = Value3 then write dataset4 records into another/output dataset.
Seems like using RC code, we can achive above requiremnt but not sure until i test. hence if anyone knows any other way of doing it, please help me
Editd - changed 'file' to 'dataset' many times. corrected spelling |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Your requirement is not particularly clear. I can guess but we do not deal in guesses. Show us example data of what you mean - using the code tags to preserve spacing.
Don't know how to use the code tags? Search the forum or, more easily, use the full editor for your post. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
Gunapala CN,
Welcome to the forums! How many output files ('another/output dataset') do you have? As suggested by Nic, use "Code" tags in the editor to post sample data and/or JCL. You can use the preview button to make sure it looks the way you expect, before submitting. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
| Quote: |
| I can guess but we do not deal in guesses. |
Psychic day was yesterday, the TS will have to wait until next wednesday  |
|
| Back to top |
|
 |
Gunapala CN
New User
Joined: 13 Oct 2016 Posts: 16 Location: India
|
|
|
|
Thanks for all your time.
sorry for putting plain problem statement in front of you!
My requirement would be like below -
File1 will be having data/record :OFF/ON/TRIAL
File 2 will be having records eg :AAAAAAAA and many more
File3 will be having records eg: BBBBBBBB and many more
File 4 will be having records eg:CCCCCCCC and many more
File 5 will be the Output file :
what i need to here is that :
if File1 record = OFF
File 2 data is need to populate into Output file i.e. File5
else If File1 record =ON
File 3 data is need to be populate into the same File5 file
else
if File1 Record = TRAIL
File4 data is need to be populate into the same File5 file.
end if
Note : i know this scenarios we can handle it in Cobol but we would like try wthr its possible do it with complete JCL/SORT CARDS help. Also with help of RC(return codes , explicit SET in previous step based on condition) we can achieve. we are trying out this. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
is this some kind of a joke  |
|
| Back to top |
|
 |
Abid Hasan
New User
Joined: 25 Mar 2013 Posts: 88 Location: India
|
|
|
|
Hello,
| Gunapala CN wrote: |
...
Note : i know this scenarios we can handle it in Cobol but we would like try wthr its possible do it with complete JCL/SORT CARDS help. Also with help of RC(return codes , explicit SET in previous step based on condition) we can achieve. we are trying out this. |
Not sure if this is an assignment or an actual PRODuction scenario, if it is, then whoever thought of an all *SORT solution is off their pills.
Fwiw, because you haven't defined any specific rules for this task- well, here goes nothing:
a. Have a simple SORT FIELDS=COPY for FILE1 (and it is dataset, not file), have 3 OUTFIL statements for your OUTPUT dataset.
b. In each OUTFIL statement test using INCLUDE for the flags you have in FILE1.
c. If the respective flag matches, write a simple JCL in that OUTFIL, using BUILD, within this JCL, override the dataset names- you can either hard-code the name, or go a step ahead and use SYMNAMES here and pass symbolic values for DSNs you want.
d. Route the 3 OUTFIL DS to INTRDR in SORTOUT DD names.
Now, what is going to happen is, depending on WHAT your flag value is, a fresh JCL will be created and submitted, within which DS2 to DS5 and so on will get processed - individually.
Like I'd said earlier - you didn't define the rules clearly here, so this solution does get the job done - fairly easily.  |
|
| Back to top |
|
 |
Gunapala CN
New User
Joined: 13 Oct 2016 Posts: 16 Location: India
|
|
|
|
Thank you so much Abid Hasan
Approch which you have suggested looks great to me. Thanks for all your suggestions
Kind Regards
Gunapal |
|
| Back to top |
|
 |
Gunapala CN
New User
Joined: 13 Oct 2016 Posts: 16 Location: India
|
|
|
|
| enrico-sorichetti wrote: |
is this some kind of a joke  |
Not really!! |
|
| Back to top |
|
 |
magesh23586
Active User

Joined: 06 Jul 2009 Posts: 213 Location: Chennai
|
|
|
|
Assuming
Your Header or FILE1 has
| Code: |
----+----1----+----2
ON
|
OR
| Code: |
----+----1----+----2
OFF
|
OR
| Code: |
----+----1----+----2
TRAIL
|
And assuming LRECL=80
you may try below code.
| Code: |
//STEP01 EXEC PGM=SORT
//SORTIN DD DSN=FILE1,DISP=SHR
// DD *
FILE2
// DD DSN=FILE2,DISP=SHR
// DD *
FILE3
// DD DSN=FILE3,DISP=SHR
// DD *
FILE4
// DD DSN=FILE4,DISP=SHR
//SORTOUT DD DSN=FILE5,DISP=(,CATLG,DELETE),SPACE=(CYL,(10,10),RLSE)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'OFF',OR,
1,2,CH,EQ,C'ON',OR,
1,5,CH,EQ,C'TRAIL'),
PUSH=(81:1,5)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'FILE2'),
PUSH=(86:1,5)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'FILE3'),
PUSH=(86:1,5)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'FILE4'),
PUSH=(86:1,5))
OUTFIL INCLUDE=(1,5,SS,NE,C'FILE2,FILE3,FILE4',AND,
1,3,CH,NE,C'OFF',AND,
1,2,CH,NE,C'ON',AND,
1,5,CH,NE,C'TRAIL',AND,
(81,10,SS,EQ,C'OFF FILE2,ON FILE3,TRAILFILE4')),
BUILD=(1,80)
|
|
|
| Back to top |
|
 |
magesh23586
Active User

Joined: 06 Jul 2009 Posts: 213 Location: Chennai
|
|
|
|
Note: I have used FILE2, FILE3, FILE4 as instream data, because I don't know whether you have a unique identifier for each file.
If you have the unique identifier for each file, then you may use that in IFTHEN=(WHEN=GROUP,BEGIN/KEYBEGIN=.. and remove FILE1,FILE2,FILE3 instream data |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
| what a shameful waste of resources ! |
|
| Back to top |
|
 |
Gunapala CN
New User
Joined: 13 Oct 2016 Posts: 16 Location: India
|
|
|
|
| magesh23586 wrote: |
Assuming
Your Header or FILE1 has
| Code: |
----+----1----+----2
ON
|
OR
| Code: |
----+----1----+----2
OFF
|
OR
| Code: |
----+----1----+----2
TRAIL
|
And assuming LRECL=80
you may try below code.
| Code: |
//STEP01 EXEC PGM=SORT
//SORTIN DD DSN=FILE1,DISP=SHR
// DD *
FILE2
// DD DSN=FILE2,DISP=SHR
// DD *
FILE3
// DD DSN=FILE3,DISP=SHR
// DD *
FILE4
// DD DSN=FILE4,DISP=SHR
//SORTOUT DD DSN=FILE5,DISP=(,CATLG,DELETE),SPACE=(CYL,(10,10),RLSE)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'OFF',OR,
1,2,CH,EQ,C'ON',OR,
1,5,CH,EQ,C'TRAIL'),
PUSH=(81:1,5)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'FILE2'),
PUSH=(86:1,5)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'FILE3'),
PUSH=(86:1,5)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'FILE4'),
PUSH=(86:1,5))
OUTFIL INCLUDE=(1,5,SS,NE,C'FILE2,FILE3,FILE4',AND,
1,3,CH,NE,C'OFF',AND,
1,2,CH,NE,C'ON',AND,
1,5,CH,NE,C'TRAIL',AND,
(81,10,SS,EQ,C'OFF FILE2,ON FILE3,TRAILFILE4')),
BUILD=(1,80)
|
|
Thank you Magesh I will try out with my Test data.. Thanks for your time. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
Welcome!!
1.You could have finished coding + testing in 1 hour, if you have done through COBOL or any other known language to you and whoever forcing you to do through DFSORT should be asked for justifications else should quit the job.
2.Now coming to your original post, (Value1/Value2/value3) are they mutually exclusive? if so then you can set the RC accordingly (which you already know/told) in previous step and in next step you can pick dataset based on RC.
3.Abid Hasan has a nice suggestion too but why make things complex when you know COBOL is easiest and simple to code and maintain. |
|
| Back to top |
|
 |
Gunapala CN
New User
Joined: 13 Oct 2016 Posts: 16 Location: India
|
|
|
|
Hello Rohit sir,
Fantastic!!
I agree with you, this is not forced do it from some one! Just I am curious to know any other way of doing it.
As you told we can do it by having RC code set in previous step since those three values are constant always. Actually those I'm fetching from table in previous step by passing key and these are expect to be same all time.
Comming to have cobol module for this problem statement is not suggestable, if we can achieve using sort utilities which are in hand. And as you know, maintaining or implementing cobol changes to live is not easy as compare to jcls changes.
Anyway thanks for your time and suggestions.
Regards
Gunapal |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| Gunapala CN wrote: |
| Comming to have cobol module for this problem statement is not suggestable, if we can achieve using sort utilities which are in hand. And as you know, maintaining or implementing cobol changes to live is not easy as compare to jcls changes. |
I don't know how you arrived at such a 'conclusion'. Reading a one record data set and issuing a return-code/copying other files is so difficult to maintain and implement in COBOL? May be the definition of 'easy' for you might be different from the vast majority. Did you realize that the DFSORT 'solution' is processing through all the 3 input data sets, where your original requirement was to copy only one of these? And you '#ignore' waste of resources. Good luck.
"When all you have is a hammer, everything looks like a nail" |
|
| Back to top |
|
 |
Gunapala CN
New User
Joined: 13 Oct 2016 Posts: 16 Location: India
|
|
|
|
| Arun Raj wrote: |
| Gunapala CN wrote: |
| Comming to have cobol module for this problem statement is not suggestable, if we can achieve using sort utilities which are in hand. And as you know, maintaining or implementing cobol changes to live is not easy as compare to jcls changes. |
I don't know how you arrived at such a 'conclusion'. Reading a one record data set and issuing a return-code/copying other files is so difficult to maintain and implement in COBOL? May be the definition of 'easy' for you might be different from the vast majority. Did you realize that the DFSORT 'solution' is processing through all the 3 input data sets, where your original requirement was to copy only one of these? And you '#ignore' waste of resources. Good luck.  |
Yup Agreed!! Regarding 'conclusion' process which follow to new amendments to existing modules and jcls are likely to be different and it's different across project to project... Anyway the topic is not that here...
But few ppl responses to the request is seems to be not fine because you can't decide someone capability just like that and none of our job here.. Ppl can ignore such request which incomplete or may ask for repost it rather than talking in bad manner. Also I understand other ppl time so I alway gfeatful for that! |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
| Don't take it personally Gunapala but people here have tremendous knowledge and hands on and based on that they comment and advise so if we are at the receiving end of the HELP then one should be submissive and obliged by accepting the way they advise us and most importantly take that in positive way. Btw, COBOL is easy for maintenance than anything. I see this topic is getting locked soon. |
|
| Back to top |
|
 |
Gunapala CN
New User
Joined: 13 Oct 2016 Posts: 16 Location: India
|
|
|
|
| Rohit Umarjikar wrote: |
| Don't take it personally Gunapala but people here have tremendous knowledge and hands on and based on that they comment and advise so if we are at the receiving end of the HELP then one should be submissive and obliged by accepting the way they advise us and most importantly take that in positive way. Btw, COBOL is easy for maintenance than anything. I see this topic is getting locked soon. |
Hi Sir
You are right, Yes i've got many approaches to do my tasks now. I'm sure at least one of those will work out esle I will go with cobol which is completely easy to me as well.
Thanks a lot.. Soon will be comming with new doubts with complete information  |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
| Quote: |
| Soon will be comming with new doubts with complete information |
Thanks and always Welcome!! |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
Magesh has realized the wasting of resources and came up with this solution as per point#2 from my post.
| Code: |
//CPYJK EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DISP=FILE1,DISP=SHR
//OUT2 DD SYSOUT=*
//TOOLIN DD *
COUNT FROM(IN1) NOTEMPTY RC4 USING(CTL1)
COUNT FROM(IN1) NOTEMPTY RC8 USING(CTL2)
/*
//CTL1CNTL DD *
INCLUDE COND=(1,3,CH,EQ,C'OFF')
//CTL2CNTL DD *
INCLUDE COND=(1,2,CH,EQ,C'ON')
//COND1 IF RC = 04 THEN
//SORT01 EXEC PGM=SORT
//SORTIN DD DISP=FILE2,DISP=SHR
//SORTOUT DD DISP=(,CATLG,DELETE),
// SPACE=(CYL,(10,10),RLSE),
// DSN=FILE5
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
// ENDIF
//COND2 IF RC = 08 THEN
//SORT02 EXEC PGM=SORT
//SORTIN DD DISP=FILE3,DISP=SHR
//SORTOUT DD DISP=(,CATLG,DELETE),
// SPACE=(CYL,(10,10),RLSE),
// DSN=FILE5
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
// ENDIF
//COND3 IF RC = 00 THEN
//SORT03 EXEC PGM=SORT
//SORTIN DD DISP=FILE4,DISP=SHR
//SORTOUT DD DISP=(,CATLG,DELETE),
// SPACE=(CYL,(10,10),RLSE),
// DSN=FILE5
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
// ENDIF |
|
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
thanks &deity
sometime it is necessary to use borderline methods - locking a topic -
to make people understand that they are on the wrong path
by the way
| Quote: |
| one should be submissive and obliged by accepting the way they advise us |
I do not pretend submission, just consideration for the experience we share  |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
My apologies for posting on a locked one. Just thought of sharing something that came to me.
| Code: |
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN= Input control data set (FB/80) : (ON/OFF/TRIAL)
//SORTOUT DD DSN=&C1,DISP=(NEW,PASS),SPACE=(TRK,(1,1))
//SYSIN DD *
OPTION COPY
INREC FINDREP=(INOUT=(C'OFF',C'FROM(IN1)-',
C'ON',C'FROM(IN2)-',
C'TRIAL',C'FROM(IN3)-'),ENDPOS=5)
/*
//STEP02 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN= Input data set1
//IN2 DD DSN= Input data set2
//IN3 DD DSN= Input data set3
//OUT DD DSN= Output data set
//TOOLIN DD *
COPY -
// DD DSN=&C1,DISP=SHR
// DD *
TO(OUT)
//* |
|
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
nothing to worry about that,
it' s one of the privileges of the moderators  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|