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

How to use 2 input files in control control card


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
Gunapala CN

New User


Joined: 13 Oct 2016
Posts: 16
Location: India

PostPosted: Thu Oct 13, 2016 3:42 pm
Reply with quote

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 icon_smile.gif

Editd - changed 'file' to 'dataset' many times. corrected spelling
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Oct 13, 2016 4:22 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Oct 13, 2016 5:45 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Oct 13, 2016 6:19 pm
Reply with quote

Quote:
I can guess but we do not deal in guesses.


Psychic day was yesterday, the TS will have to wait until next wednesday icon_cool.gif
Back to top
View user's profile Send private message
Gunapala CN

New User


Joined: 13 Oct 2016
Posts: 16
Location: India

PostPosted: Thu Oct 13, 2016 7:56 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Oct 13, 2016 8:15 pm
Reply with quote

is this some kind of a joke icon_eek.gif
Back to top
View user's profile Send private message
Abid Hasan

New User


Joined: 25 Mar 2013
Posts: 88
Location: India

PostPosted: Thu Oct 13, 2016 8:32 pm
Reply with quote

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. icon_razz.gif
Back to top
View user's profile Send private message
Gunapala CN

New User


Joined: 13 Oct 2016
Posts: 16
Location: India

PostPosted: Thu Oct 13, 2016 9:15 pm
Reply with quote

Thank you so much Abid Hasan icon_smile.gif

Approch which you have suggested looks great to me. Thanks for all your suggestions

Kind Regards
Gunapal
Back to top
View user's profile Send private message
Gunapala CN

New User


Joined: 13 Oct 2016
Posts: 16
Location: India

PostPosted: Thu Oct 13, 2016 9:16 pm
Reply with quote

enrico-sorichetti wrote:
is this some kind of a joke icon_eek.gif


Not really!!
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Thu Oct 13, 2016 9:36 pm
Reply with quote

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
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Thu Oct 13, 2016 9:48 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Oct 13, 2016 10:03 pm
Reply with quote

what a shameful waste of resources !
Back to top
View user's profile Send private message
Gunapala CN

New User


Joined: 13 Oct 2016
Posts: 16
Location: India

PostPosted: Thu Oct 13, 2016 10:36 pm
Reply with quote

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 icon_smile.gif I will try out with my Test data.. Thanks for your time.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Thu Oct 13, 2016 10:49 pm
Reply with quote

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
View user's profile Send private message
Gunapala CN

New User


Joined: 13 Oct 2016
Posts: 16
Location: India

PostPosted: Thu Oct 13, 2016 11:05 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Oct 13, 2016 11:23 pm
Reply with quote

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. icon_smile.gif

"When all you have is a hammer, everything looks like a nail"
Back to top
View user's profile Send private message
Gunapala CN

New User


Joined: 13 Oct 2016
Posts: 16
Location: India

PostPosted: Thu Oct 13, 2016 11:44 pm
Reply with quote

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. icon_smile.gif


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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Thu Oct 13, 2016 11:51 pm
Reply with quote

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
View user's profile Send private message
Gunapala CN

New User


Joined: 13 Oct 2016
Posts: 16
Location: India

PostPosted: Fri Oct 14, 2016 12:11 am
Reply with quote

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 icon_razz.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Fri Oct 14, 2016 12:18 am
Reply with quote

Quote:
Soon will be comming with new doubts with complete information
Thanks and always Welcome!!
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Fri Oct 14, 2016 2:05 am
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Oct 14, 2016 2:30 am
Reply with quote

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 icon_wink.gif
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Oct 14, 2016 7:54 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Oct 14, 2016 8:03 pm
Reply with quote

nothing to worry about that,
it' s one of the privileges of the moderators icon_wink.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
Search our Forums:

Back to Top