Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need to copy records with condition using SORT utility.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Rajesh S
Warnings : 1

New User


Joined: 11 Jul 2007
Posts: 54
Location: Chennai

PostPosted: Wed Dec 04, 2013 6:27 pm    Post subject: Need to copy records with condition using SORT utility.
Reply with quote

Hi All,

These is a requirement to copy the records from input file to output file with below conditions

Input file contains 10 columns, we have to validate the records in 5 conditional columns for the spaces or zeroes and copy those records in to output file. In that, first unconditional column contains, employee ID, based on that, we have to omit 1 conditional column if it is spaces or zeroes.

Could anyone help on this?

Thanks in advance,

Rajesh S
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed Dec 04, 2013 6:33 pm    Post subject:
Reply with quote

Perhaps if you explain in detail, giving examples of the input and expected output we may be able to offer some suggestions.

If there are different rules for different fields - Tell us now, all in one post.

We also need to know the DSORG, RECFM and LRECL of the files.

Also be aware that a column is a ONE byte field. Terminology is rather important in the IT game and it is very useful to use the correct terms.
Back to top
View user's profile Send private message
Rajesh S
Warnings : 1

New User


Joined: 11 Jul 2007
Posts: 54
Location: Chennai

PostPosted: Wed Dec 04, 2013 7:39 pm    Post subject:
Reply with quote

Hi,

Please find my requirement with examples.

Below input files 1 and 2 contains 7 columns, In that columns (3,4,5) are the conditional columns, We have to copy the records which contains spaces in conditional columns (3,4,5), and column-5 should omitted even it is spaces based on the column-1 value ‘55555’, Suppose if other 2 conditional columns are spaces, then that records should be captured in output file.

Code:
Input File -1:

COL-1    COL-2     COL-3    COL-4     COL-5            COL-6     COL-7
11111    DT       123456   0002      301720001     125812    HT25FG1315
22222    DT       659856   0006      301720002     125813    RE225FG133
33333    DT       125648                           125814    225FG13272
44444    DT                0002                              EW225FG27
55555    DT       256452   0002                    125819    YT225FG13               


Code:
Output File -1:
COL-1    COL-2    COL-3     COL-4     COL-5              COL-6       COL-7
33333    DT       125648                                125814    225FG13272
44444    DT                 0002                                  EW225FG27



Code:
Input File -2:

COL-1    COL-2     COL-3    COL-4     COL-5              COL-6     COL-7
11111    DT       123456   0002      301720001           125812    HT25FG1315
22222    DT       659856   0006      301720002           125813    RE225FG133
33333    DT       125648                                 125814    225FG13272
44444    DT                0002                                    EW225FG27
55555    DT                0002                          125819    YT225FG13


Code:
Output File -2:

COL-1    COL-2    COL-3     COL-4     COL-5              COL-6       COL-7
33333    DT       125648                                125814    225FG13272
44444    DT                 0002                                  EW225FG27
55555    DT                 0002                        125819    YT225FG13
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1712
Location: UK

PostPosted: Wed Dec 04, 2013 8:11 pm    Post subject:
Reply with quote

Those are NOT columns but fields. Columns occur in tables i.e. DB2. Otherwise a column is a single byte as expat said but you ignored.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed Dec 04, 2013 8:33 pm    Post subject:
Reply with quote

Along with ignoring ...........
expat wrote:
We also need to know the DSORG, RECFM and LRECL of the files.


Also, we need the positions and lengths of the FIELDS
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 645
Location: Pennsylvania

PostPosted: Wed Dec 04, 2013 8:56 pm    Post subject:
Reply with quote

I am a fan of pseudo-code in a case like this.

The TS could write the rules like this (for example):
Code:
IF FIELD-1 = '33333' THEN DO
  IF FIELD-4 = SPACES OR FIELD-5 = SPACES THEN WRITE OUTOUT
END

IF FIELD-1 = '44444' THEN DO....

Define your fields:
FIELD-1 is column 1 length 5
FIELD-4 is column 40 length 8

This could then easily be translated to SORT syntax

Probably too much to ask from them however. icon_confused.gif
Back to top
View user's profile Send private message
Rajesh S
Warnings : 1

New User


Joined: 11 Jul 2007
Posts: 54
Location: Chennai

PostPosted: Wed Dec 04, 2013 10:06 pm    Post subject:
Reply with quote

Hi

Thanks expat, Nic, daveporcelan for your response.

Please find the below details for your request.

Code:
Input file details:

DSORG : PS
Record Format: FB
Record Length : 80
Block size: 800


Code:
OutPut file details:

DSORG : PS
Record Format: FB
Record Length : 80
Block size: 800


Code:

Fields   Position    Length
Field-1           1   5
Field-2           8   2
Field-3          12   6
Field-4          20   4
Field-5          26   9
Field-6          37   6
Field-7          45   10
[/code]
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 645
Location: Pennsylvania

PostPosted: Wed Dec 04, 2013 11:03 pm    Post subject:
Reply with quote

What about the pseudo code to better explain your rules?

To be honest, your verbal description does not work well enough for me.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Dec 05, 2013 12:03 am    Post subject:
Reply with quote

If I understand correctly you can use the following control cards

Code:

//SYSIN    DD *                         
  OPTION COPY                           
  OMIT COND=((12,6,CH,GT,C' ',AND,       
              20,4,CH,GT,C' ',AND,       
              26,9,CH,GT,C' '),OR,       
             (01,5,CH,EQ,C'55555',AND,   
              12,6,CH,EQ,C' ',AND,       
              20,4,CH,GT,C' ',AND,       
              26,9,CH,GT,C' '),OR,       
             (01,5,CH,EQ,C'55555',AND,   
              12,6,CH,GT,C' ',AND,       
              20,4,CH,EQ,C' ',AND,       
              26,9,CH,GT,C' '),OR,       
             (01,5,CH,EQ,C'55555',AND,   
              12,6,CH,GT,C' ',AND,       
              20,4,CH,GT,C' ',AND,       
              26,9,CH,EQ,C' '))         
//*                                     


or

Code:

//SYSIN    DD *                                 
  OPTION COPY                                   
  INCLUDE COND=(12,6,CH,EQ,C' ',OR,             
                20,4,CH,EQ,C' ',OR,             
                26,9,CH,EQ,C' ')                 
                                                 
  OUTFIL OMIT=((01,5,CH,EQ,C'55555',AND,         
                12,6,CH,EQ,C' ',AND,             
                20,4,CH,GT,C' ',AND,             
                26,9,CH,GT,C' '),OR,             
               (01,5,CH,EQ,C'55555',AND,         
                12,6,CH,GT,C' ',AND,             
                20,4,CH,EQ,C' ',AND,             
                26,9,CH,GT,C' '),OR,             
               (01,5,CH,EQ,C'55555',AND,         
                12,6,CH,GT,C' ',AND,             
                20,4,CH,GT,C' ',AND,             
                26,9,CH,EQ,C' '))               
//*                                             
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 645
Location: Pennsylvania

PostPosted: Thu Dec 05, 2013 12:49 am    Post subject:
Reply with quote

Kolusu to rescue once again. Thanks.

My request for Pseudo code was an attempt for the TS to use their brain and determine the logic needed on their own.

Oh well, better luck next time.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Dec 05, 2013 9:57 pm    Post subject:
Reply with quote

daveporcelan wrote:
Kolusu to rescue once again. Thanks.

My request for Pseudo code was an attempt for the TS to use their brain and determine the logic needed on their own.

Oh well, better luck next time.


Dave,

I apologize for providing a complete solution. I agree with you about encouraging the posters to write psuedo code or work on solutions with clues provided, however very few people do that.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 645
Location: Pennsylvania

PostPosted: Thu Dec 05, 2013 10:22 pm    Post subject:
Reply with quote

Quote:
Dave,

I apologize for providing a complete solution. I agree with you about encouraging the posters to write psuedo code or work on solutions with clues provided, however very few people do that.


No apology necessary.

The knowledge and service you provide is very valuable and appreciated.

What the people do with the information is questionable.

When a TS comes back with a silly adjustment or error, refusing to try to figure out, that is when the brakes should be applied.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 1 Fri Dec 02, 2016 9:47 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us