MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

formatting the input records

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
radkrish
Beginner


Joined: 12 Aug 2005
Posts: 102
Topics: 19

PostPosted: Fri Nov 10, 2006 10:39 am    Post subject: formatting the input records Reply with quote

My requirement is to pick up first SEQ and LAST SEQ and write a single record.
Key is FILE,BTCH,SERIAL.seq num gets incremented if the 3 are same.
For SEQ=1,I need to write create-by-pgm,mod-by-pgm and date-time-create
Write remainingg output layout fields for the last seq num of the same file batch serial key.

space differentiates each field.

Code:
Input file
----------
  FILE  BTCH  sERIAL SEQ SUB RCD-CD DATE-TIME-CREATE        CREATE-BY-PGM   DATE-TIME-MOD       MOD-BY-PGM
  ----------------------------------------------------------------------------------------------------------------
 

  RT1   11   1145    1    M    E    2006-02-14-14.21.05.637111  AAB   2006-02-25-14.21.05.637111 AAC
  RT1   11   1145    2    M    E    2006-02-14-14.21.05.637111  AAB   2006-02-26-14.21.05.637111 AAD
  RT1   11   1145    3    M    E    2006-02-14-14.21.05.637111  AAB   2006-02-27-14.21.05.637111 AAC
  RT1   11   1145    4    M    S    2006-02-14-14.21.05.637111  AAB   2006-02-28-14.21.05.637111 AAC
  RT1   11   1145    5    M    E    2006-02-14-14.21.05.637111  AAB   2006-02-29-14.21.05.637111 AAE
  RT1   11   1146    1    M    E    2006-02-14-14.21.05.637111  AAB   2006-02-25-14.21.05.637111 AAC
  RT1   11   1146    2    M    E    2006-02-14-14.21.05.637111  AAB   2006-02-26-14.21.05.637111 AAD
  RT3   12   1145    1    M    E    2006-02-14-14.21.05.637111  AAB   2006-02-25-14.21.05.637111 AAC
  RT3   12   1145    2    M    S    2006-02-14-14.21.05.637111  AAB   2006-02-25-15.21.05.637111 AAE
  RT3   12   1145    3    M    E    2006-02-14-14.21.05.637111  AAB   2006-02-25-16.21.05.637111 AAC
  RT1   11   1145    1    M    E    2006-02-14-14.21.05.637111  AAB   2006-02-25-14.21.05.637111 AAM

Input file layout
-----------------
05 FILE                 PIC X(08)
05 FILLER               PIC X(02)
                             
05 BTCH                 PIC S9(9) COMP                             
05 FILLER               PIC X(02)
                             
05 SERIAL               PIC S9(9) COMP                             
05 FILLER               PIC X(02)                             
05 SEQ                  PIC S9(4) COMP                             
05 FILLER               PIC X(02)                             
05 SUB                  PIC X(1)                       
05 FILLER               PIC X(02)                         
05 RCD-CD               PIC X(1)                         
05 FILLER               PIC X(02)                         
05 DATE-TIME-CREAT      PIC X(26)                         
05 FILLER               PIC X(02)                         
05 CREATE-BY-PGM-ID     PIC X(8)                         
05 FILLER               PIC X(02)                         
05 DATE-TIME-MOD        PIC X(26)                         
05 FILLER               PIC X(02)                         
05 MOD-BY-PGM-ID        PIC X(8)                         
05 FILLER               PIC X(02)                         

outputfile
----------

FILE BTCH SERIAL SEQ  SUB RCD-CD  DATE-TIME-CREATE  CREATE-BY-PGM   DATE-TIME-MOD     MOD-BY-PGM-FIRT   MOD-BY-PGM-LAST               
---------------------------------------------------------------------------------------------------------------------------------
 

RT1  11  1145  5  M  E   2006-02-14-14.21.05.637111  AAB       2006-02-29-14.21.05.637111 AAB   AAE 

RT1  11  1146  2  M  E   2006-02-14-14.21.05.637111  AAB       2006-02-26-14.21.05.637111 AAC   AAD

RT3  12  1145  3  M  E   2006-02-14-14.21.05.637111  AAB       2006-02-25-16.21.05.637111 AAC   AAC

RT1  11  1145  1  M  E   2006-02-14-14.21.05.637111  AAB       2006-02-25-14.21.05.637111 AAM   AAM

outputfile layout
------------------

05 FILE                 PIC X(08)
05 FILLER               PIC X(02)
05 BTCH                 PIC S9(9) COMP                             
05 FILLER               PIC X(02)
05 SERIAL               PIC S9(9) COMP                             
05 FILLER               PIC X(02)                             
05 SEQ                  PIC S9(4) COMP                             
05 FILLER               PIC X(02)                             
05 SUB                  PIC X(1)                       
05 FILLER               PIC X(02)                         
05 RCD-CD               PIC X(1)                         
05 FILLER               PIC X(02)                         
05 DATE-TIME-CREAT      PIC X(26)                         
05 FILLER               PIC X(02)                         
05 CREATE-BY-PGM-ID     PIC X(8)                         
05 FILLER               PIC X(02)                         
05 DATE-TIME-MOD        PIC X(26)                         
05 FILLER               PIC X(02)                         
05 MOD-BY-PGM-ID-FIRST  PIC X(8)                         
05 FILLER               PIC X(02)                         
05 MOD-BY-PGM-ID-LAST   PIC X(8)                         
05 FILLER               PIC X(02)                     

Hope the query is clear.
Expecting your valuable response to get the output.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Nov 10, 2006 11:37 am    Post subject: Reply with quote

radkrish,

Your output does NOT match the requirement. How did you get the last record in your output?

Code:

RT1  11  1145  1


Clarify to us as to why you picked that record.


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Fri Nov 10, 2006 11:57 am    Post subject: Reply with quote

small design problem, maybe. if the input was sorted correctly, you have 2 records with the same key (including ts) only difference is pgm mod.

1. how do you plan to handle duplicates? Need to come up with a plan.

2. if you are going to use a timestamp, use a different one for each record. Otherwise, use the date,hms and leave it at that.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
radkrish
Beginner


Joined: 12 Aug 2005
Posts: 102
Topics: 19

PostPosted: Fri Nov 10, 2006 1:23 pm    Post subject: Reply with quote

Kolusu,
The output should pick that record.
Else i can seperate the single seq num record from the other.
For single seq record,there is no need for formatting.we can append it later.

Actually,I thought of extracting the first and last seq num of FIL BTCH SERIAL.
By FIRSTDUp and LASTDUP.But from these 2 records,we need to format the fields.
Not sure how to go along with it.

Duplicates are identified based on FILE BTCH and SERIAL.(first 3 fields)
these 3 fields are the key.
Back to top
View user's profile Send private message
radkrish
Beginner


Joined: 12 Aug 2005
Posts: 102
Topics: 19

PostPosted: Fri Nov 10, 2006 1:25 pm    Post subject: Reply with quote

i.e. if the seq num for FILE BTCH SERIAL fields are 1,2,3,4,5
I need to pick create-by-pgm,mod-by-pgm and date-time-create from the first seq num and the remaining will be picked from the last (i.e 5 here) record.fields picked from first seq num and last seq num should be written as a single record.

Hope I clarified my query.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Nov 10, 2006 1:37 pm    Post subject: Reply with quote

Quote:

Duplicates are identified based on FILE BTCH and SERIAL.(first 3 fields)
these 3 fields are the key.


radkrish,

Something doesn't make sense. If the first 3 fields are key then why do you have 2 records for RT1 11 1145 key combo?

Quote:

RT1 11 1145
RT1 11 1146
RT3 12 1145
RT1 11 1145


In your output you showed 4 records. Rec #1 and rec # 4 are both having the same key.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
radkrish
Beginner


Joined: 12 Aug 2005
Posts: 102
Topics: 19

PostPosted: Fri Nov 10, 2006 1:43 pm    Post subject: Reply with quote

Kolusu,
Oops.Iam extremely sorry.Pls ignore the 4 record.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Nov 10, 2006 2:14 pm    Post subject: Reply with quote

The following DFSORT/ICETOOL will give you the desired results. The first sort operator gets the first the last seq num based on the combo of file,btch,serial. The second SPlice operator pads the pgm name at the end.

Code:

//STEP0100 EXEC PGM=ICETOOL                             
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//IN       DD DSN=your input dataset,               
//            DISP=SHR                                   
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(x,y),RLSE)
//OUT      DD DSN=your output dataset,                 
//            DISP=(NEW,CATLG,DELETE),                   
//            UNIT=SYSDA,                                 
//            SPACE=(CYL,(X,Y),RLSE)
//*
//TOOLIN   DD *                                         
  SORT FROM(IN) USING(CTL1)                             
  SPLICE FROM(T1) TO(OUT)   -                           
         ON(01,08,CH)       -                           
         ON(11,04,BI)       -                           
         ON(17,04,BI)       -                           
         WITH(109,010)      -                           
         WITHEACH                                       
//CTL1CNTL DD *                                         
  SORT FIELDS=(01,08,CH,A,      $ FILE                   
               11,04,BI,A,      $ BTCH                   
               17,04,BI,A,      $ SERIAL                 
               23,02,BI,A)      $ SEQ                   
                                                         
  OUTREC FIELDS=(001,108,10X)                           
                                                         
  OUTFIL FNAMES=T1,REMOVECC,NODETAIL,                   
  SECTIONS=(01,23,                                       
  HEADER3=(01,108,10X),                                 
  TRAILER3=(01,098,10X,99,10))                           
/*


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
radkrish
Beginner


Joined: 12 Aug 2005
Posts: 102
Topics: 19

PostPosted: Tue Nov 14, 2006 8:39 am    Post subject: Reply with quote

Thanks,Kolusu.
Also,I tried by extracting first dup,lst dup and no dups.Then formatting it.It worked well.Though I have another query.

consider the following records

Input
------
Code:
1-4           8-32
AAAA        53235326456457457
AAAA        31213253643646466
BBBB        12345678901234560
CCCC       98765432198765432

output should be
-------------------
Code:
1-4           8-32                               40-46
id              desc                               serial
AAAA        53235326456457457
AAAA        31213253643646466
BBBB        12345678901234560
CCCC       98765432198765432


The 40-46(serial) should get popularted with 22-26 charcter in DESC field.
If the record is AAAA then fill serial with 22-26 char from DESC
If the record is bbbb then fill serial with 24-28 char from DESC
If the record is cccc then fill serial with 25-29 char from DESC
serial field is of s9(4)v9(1) or some ZD.

hope my query is clear.
expecting your valuable reply.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Nov 14, 2006 9:14 am    Post subject: Reply with quote

radkrish,

Quite simple . Just use IFTHEN statement to overlay with desired contents

check this DFSORT JCL

Code:

//STEP0100 EXEC PGM=SORT                 
//SYSOUT   DD SYSOUT=*                   
//SORTIN   DD *                           
AAAA   53235326456457457                 
AAAA   31213253643646466                 
BBBB   12345678901234560                 
CCCC   98765432198765432                 
//SORTOUT  DD SYSOUT=*                   
//SYSIN    DD *                           
  SORT FIELDS=COPY                       
  INREC IFTHEN=(WHEN=(1,4,CH,EQ,C'AAAA'),
       OVERLAY=(40:22,05)),               
        IFTHEN=(WHEN=(1,4,CH,EQ,C'BBBB'),
       OVERLAY=(40:24,05)),               
        IFTHEN=(WHEN=(1,4,CH,EQ,C'CCCC'),
       OVERLAY=(40:25,05))               
                                         
/*                                       


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group