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

Need to copy records with condition using SORT utility.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Wed Dec 04, 2013 6:33 pm
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
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: 2455
Location: Hampshire, UK

PostPosted: Wed Dec 04, 2013 8:11 pm
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: 8797
Location: Welsh Wales

PostPosted: Wed Dec 04, 2013 8:33 pm
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: 792
Location: Pennsylvania

PostPosted: Wed Dec 04, 2013 8:56 pm
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
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: 792
Location: Pennsylvania

PostPosted: Wed Dec 04, 2013 11:03 pm
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
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: 792
Location: Pennsylvania

PostPosted: Thu Dec 05, 2013 12:49 am
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
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: 792
Location: Pennsylvania

PostPosted: Thu Dec 05, 2013 10:22 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top