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

DFSORT/ICETOOL IFTHEN ELSE


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Kranthi M

New User


Joined: 07 Oct 2011
Posts: 20
Location: India

PostPosted: Tue Nov 22, 2011 6:13 pm
Reply with quote

Hi,

I am trying to generate a output file based on below conditions. I have a control card that have 5 fileds in it. But to simplify, i am giving an example with only 2 fileds in it. Have one input file as well.

Example:
I have a control card as input that can have 2 fields. Those 2 fields can have default values or some value in it. Default being 9's.

Control card:
EMP-ID can have 99999 or some value like 34567
Emp-Loc can have 99 or value like OH

Input file: Example records. My input file is much more complicated than this.

12345OH
67890IL
34567PA
23456OH
98765PA
45678OH
34567OH

Now, control card can have both location details and emp-id detials or only one of them.
If Emp-id is given and not location then all records with that emp-id needs to be pulled. If only location is given then pull all records that match the criteria. The absence of a field is seen by having 9's in that position in control card. If both location and emp-id are given then pull details from input file using both.

Say, I have 99999OH in my control card as input then o/p should look like
12345OH
23456OH
45678OH
34567OH

If I have 3456799 in my control card then o/p has to look like

34567PA
34567OH

If i/p is 34567OH then o/p should look like
34567OH

Using cobol will make it complicated with too many IF's. So I wan to do it using DFSORT/ICETOOL. Need code for the same.
My idea was to check
if EMP-ID has 99999 in it then copy all records else
try to match records based on EMP_ID and pull those into a file.

after that IF LOCATION = 99 then copy file1 to file2
else try to match records based on LOCATION and pull those into another file.

Please let me know if you need more details.

Thanks,
Kranthi
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Tue Nov 22, 2011 7:36 pm
Reply with quote

Hi,
You could try something like this,
By generating the necessary INCLUDE statments in 1st step and using the control statements in step2.

Code:
//JS010    EXEC PGM=SORT                                       
//SORTIN   DD *                                                 
99999OH                    <-CONTROL CARD                                     
/*                                                             
//SORTOUT  DD DSN=&&TEMP,DISP=(NEW,PASS,DELETE),               
//          UNIT=SYSDA,SPACE=(TRK,(2,2),RLSE),                 
//          DCB=(BLKSIZE=0,LRECL=80,RECFM=FB)                   
//SYSOUT   DD SYSOUT=*                                         
//SYSIN DD *                                                   
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=(1,7,CH,EQ,C'9999999'),                   
  BUILD=(1:C'//*')),                                           
        IFTHEN=(WHEN=(1,5,CH,EQ,C'99999'),                     
  BUILD=(1:3X,4:C'INCLUDE COND=(6,2,CH,EQ,C''',6,2,C'''',C')')),
        IFTHEN=(WHEN=(6,2,CH,EQ,C'99'),                         
  BUILD=(1:3X,4:C'INCLUDE COND=(1,5,CH,EQ,C''',1,5,C'''',C')')),
        IFTHEN=(WHEN=(1,7,CH,NE,C'9999999'),                   
  BUILD=(1:3X,4:C'INCLUDE COND=(1,7,CH,EQ,C''',1,7,C'''',C')'))
/*                                                             
//JS020    EXEC PGM=ICETOOL                                     
//TOOLMSG  DD SYSOUT=*                                         
//DFSMSG   DD SYSOUT=*                                         
//IN       DD DISP=SHR,DSN=WELLS.SORTIN                         
//OUT      DD DISP=OLD,DSN=WELLS.SORTOUT                       
//SYSOUT   DD SYSOUT=*                                         
//TOOLIN   DD *                                                 
  COPY FROM(IN) TO(OUT) USING(CTL1)                             
/*                                                             
//CTL1CNTL DD DSN=&&TEMP,DISP=(OLD,DELETE,DELETE)       


*partially tested*.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Tue Nov 22, 2011 7:56 pm
Reply with quote

Works good for the above mentioned 4 scenarios and input/output data.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Nov 22, 2011 11:12 pm
Reply with quote

Kranti M wrote:
I am trying to generate a output file based on below conditions. I have a control card that have 5 fileds in it. But to simplify, i am giving an example with only 2 fileds in it. Have one input file as well.

Input file: Example records. My input file is much more complicated than this.


Kranthi M,

You need to provide more details.

1. What is the LRECL and RECFM of the control file?
2. What is the position and format of ALL the 5 fields in the control file?
3. What is the LRECL and RECFM of the Input file?
4. Post the cobol layout of the input file and explain all the rules to pick a record. As you have 5 different fields , is it an AND cond for all the 5 fields if present in the control file?

i.e if you provide 4 values in the control file and 1 field is all 9's then you want to include the records with the following condition?

Code:

IF FIELD1 = 'CONTROL VALUE 1' AND,
   FIELD2 = 'CONTROL VALUE 2' AND
   FIELD3 = 'CONTROL VALUE 3' AND
   FIELD4 = 'CONTROL VALUE 4'
   write output
END-IF
Back to top
View user's profile Send private message
Kranthi M

New User


Joined: 07 Oct 2011
Posts: 20
Location: India

PostPosted: Wed Nov 23, 2011 11:07 am
Reply with quote

Hi,
Thanks for the replies. I am trying to use the code given by Vasanth. Will get back with more details.
Back to top
View user's profile Send private message
Kranthi M

New User


Joined: 07 Oct 2011
Posts: 20
Location: India

PostPosted: Thu Dec 08, 2011 12:45 pm
Reply with quote

HI ,
I have done this in COBOL and it is working. THere was change in requirement to allow multiple rows in the control card. It means, I would need to have AND condition with 1st record fields and then OR with 2nd record and with in 2nd record i had to do AND. Total of 10 records needs to be allowed.

So, I tried to BUILD
INCLUDE COND=(((1,2,CH,'C'12'),&,
(3,5,CH,C'12345')),OR,
((1,2,CH,C'13')),OR,
((1,2,CH,C'14'),&,
(3,5,CH,C'23456')))
SORT FIELDS = COPY

I could get this for a control card that has 3 record with record having 5 fields and a record can have combination of fields. Missin input field will be 9's.

and then used the above in SORT Step to get my output.

Thanks again for the replies.
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 Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
No new posts Shift left VB record without x00 endi... DFSORT/ICETOOL 11
Search our Forums:

Back to Top