Write output on a condition in SORT.

IBM's Sort Product, ICETOOL, ICEMAN and ICEGENER.
Post Reply
Akash Vairan
New Member
Posts: 1
Joined: Tue Mar 17, 2015 2:15 pm

Write output on a condition in SORT.

Post by Akash Vairan »

I have a file which has got fields in it. Two fields are like department and somme other description. All the records has same department name but description part is populated only once for a given department. So the input will look like the following example:

Code: Select all

-----5----------------15
Dept1 
Dept1  
Dept1 description1
Dept1  
Dept1  
Dept2 
Dept2  
Dept2 description2
Dept2  
Dept2 



Now my SORT should write only that record in the output which has got some description. In most of the case one of the records will have a description. In case if all the records don't have any description than any one of the record can be put in the output.

My input is FB and LRECL is 80. Output should be of same attributes. The Department can be repeated 5 times and 5 bytes long. Description is 10 bytes long. Can soomeone please help me on this.

Coded for your
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: Write output on a condition in SORT.

Post by nicc »

Please use the code tags to present your data.
You do not have a file but a data set
Will the description always be on the third record - if it there at all?
Regards
Nic
User avatar
Magesh_j
Registered Member
Posts: 33
Joined: Sun Sep 04, 2016 8:50 pm

Re: Write output on a condition in SORT.

Post by Magesh_j »

Is there is a possibility where you have more than one record having description ?

Code: Select all

Dept1 
Dept1  
Dept1 descripti1
Dept1 descripti2 
Dept1 
If yes what should be the output ?

Here is the code for you. Assuming 1,5 is dept and 7,10 is description and you have only one or no description for a dept

Code: Select all

INREC IFTHEN=(WHEN=GROUP,                    
              KEYBEGIN=(1,5),                
              BEGIN=(7,10,CH,NE,C' '),       
              PUSH=(7:7,10))                 
                                             
OPTION COPY                                  
                                             
OUTFIL SECTIONS=(1,5,TRAILER3=(1,80)),       
       REMOVECC,                             
       NODETAIL                              
Thanks
Magesh
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DFSort, ICETOOL, ICEMAN, ICEGENER.”