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 

DFSORT - Delimiting by Period
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
arungr
Beginner


Joined: 12 Feb 2005
Posts: 16
Topics: 4

PostPosted: Mon Dec 17, 2007 8:45 pm    Post subject: DFSORT - Delimiting by Period Reply with quote

Hello,

This is an extension of the below topic:
http://www.mvsforums.com/helpboards/viewtopic.php?t=4036&highlight=delimited

I have a file like the one below:
FB;REC LENGTH IS 80
1..................................................80
AAAA BBBB CCCC. DDDD EEEE FFFFF
GGG HHHHH.IIIII OOOOO PPP.XXXXX
YYYY.AAAA KKKK.

I have to get the output file as

AAAA BBBB CCCC
DDDD EEEE FFFFFGGG HHHHH
IIIII OOOOO PPP
XXXXXYYYY
AAAA KKKK

The records in input file has to be delimited by period into seperate Records. In Input file the length of data between periods may vary and can continue in next line also like FFFFFGGG in above example.

Will it be possible to be done in DFSORT? Solution given in http://www.mvsforums.com/helpboards/viewtopic.php?t=4036&highlight=delimited does not work for continuing lines.
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 Dec 18, 2007 11:19 am    Post subject: Reply with quote

arungr,

What is the max number of delimiters you can have in a single 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
arungr
Beginner


Joined: 12 Feb 2005
Posts: 16
Topics: 4

PostPosted: Tue Dec 18, 2007 1:01 pm    Post subject: Reply with quote

Kolusu,

Thanks for the response. There could be maximum of 2 delimiters(period) in each line. Most of the lines have one Delimiter only.

Thanks,
Arun.
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 Dec 18, 2007 4:14 pm    Post subject: Reply with quote

arungr,

The following DFSORT/ICETOOL JCL will give you the desired results.


Code:

//STEP0100 EXEC PGM=ICETOOL                               
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//IN       DD *                                           
AAAA BBBB CCCC. DDDD EEEE FFFFF                           
GGG HHHHH.IIIII OOOOO PPP.XXXXX                           
YYYY.AAAA KKKK.                                           
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T2       DD DSN=&&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT      DD SYSOUT=*                                   
//TOOLIN   DD *                                           
  COPY FROM(IN) USING(CTL1)                               
  SPLICE FROM(T1) TO(T2) ON(161,9,CH) WITHEACH -         
          WITH(81,80) KEEPNODUPS USING(CTL2)             
  SORT FROM(T2) USING(CTL3)
//CTL1CNTL DD *                                                   
  INREC PARSE=(%00=(ENDAT=C'.',FIXLEN=080),                       
               %01=(ENDAT=C'.',FIXLEN=080),                       
               %02=(FIXLEN=80)),                                   
         BUILD=(%00,%01,%02)                                       
                                                                   
  OUTREC IFTHEN=(WHEN=INIT,                                       
        OVERLAY=(241:C'000',SEQNUM,8,ZD),HIT=NEXT),               
         IFTHEN=(WHEN=(001,80,SS,EQ,C'.'),                         
        OVERLAY=(241:C'1'),HIT=NEXT),                             
         IFTHEN=(WHEN=(081,80,SS,EQ,C'.'),                         
        OVERLAY=(242:C'1'),HIT=NEXT),                             
         IFTHEN=(WHEN=(161,80,SS,EQ,C'.'),                         
        OVERLAY=(243:C'1'))                                       
                                                                   
  OUTFIL FNAMES=T1,                                               
         IFTHEN=(WHEN=(241,3,CH,EQ,C'100'),                       
         BUILD=(001,80,80X,C'A',SEQNUM,8,ZD,244,8,/,               
                081,80,80X,C'B',SEQNUM,8,ZD,244,8)),               
         IFTHEN=(WHEN=(241,3,CH,EQ,C'110'),                       
         BUILD=(80X,001,80,C'B',SEQNUM,8,ZD,244,8,/,               
                081,80,80X,C'A',SEQNUM,8,ZD,START=2,INCR=1,244,8,/,
                161,80,80X,C'B',SEQNUM,8,ZD,START=2,INCR=1,244,8))
                                                                   
//CTL2CNTL DD *                                                   
  OMIT COND=(01,160,CH,EQ,C' ')                                   
//CTL3CNTL DD *                                                   
  SORT FIELDS=(170,8,CH,A)                                         
  INREC OVERLAY=(1,160,SQZ=(SHIFT=LEFT,MID=C' '))                           
  OUTFIL FNAMES=OUT,                                               
  BUILD=(01,80,TRAN=ALTSEQ)                                       
  ALTSEQ CODE=(4B40)                                               
/*


Hope this helps...

Cheers
_________________
Kolusu
www.linkedin.com/in/kolusu


Last edited by kolusu on Wed Dec 19, 2007 11:35 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Dec 19, 2007 12:59 am    Post subject: Reply with quote

Kolusu,

The output I got from your code is as below.
Code:

AAAABBBBCCCC         
DDDDEEEEFFFFFGGGHHHHH
IIIIIOOOOOPPP       
XXXXXYYYY           
AAAAKKKK             

I think OP wnats the output like below.
Code:

AAAA BBBB CCCC         
DDDD EEEE FFFFFGGG HHHHH
IIIII OOOOO PPP       
XXXXXYYYY           
AAAA KKKK             
Back to top
View user's profile Send private message Send e-mail
blitz2
Beginner


Joined: 23 Jan 2007
Posts: 84
Topics: 14

PostPosted: Wed Dec 19, 2007 1:21 am    Post subject: Reply with quote

Kolusu, can you please include a description of the steps in your post?
________
The cigar boss


Last edited by blitz2 on Thu Mar 10, 2011 5:36 pm; edited 1 time in total
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: Wed Dec 19, 2007 11:34 am    Post subject: Reply with quote

vkphani wrote:
Kolusu,

The output I got from your code is as below.
Code:

AAAABBBBCCCC         
DDDDEEEEFFFFFGGGHHHHH
IIIIIOOOOOPPP       
XXXXXYYYY           
AAAAKKKK             

I think OP wnats the output like below.
Code:

AAAA BBBB CCCC         
DDDD EEEE FFFFFGGG HHHHH
IIIII OOOOO PPP       
XXXXXYYYY           
AAAA KKKK             


I forgot to add the MID=C' ' parm in there. Thanks for pointing it out I will update the post
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Dec 19, 2007 12:07 pm    Post subject: Reply with quote

blitz2 wrote:
Kolusu, can you please include a description of the steps in your post?


Blitz,

Here is a detailed explanation of the job.

The input may contain 1 or 2 delimiters.

1. Copy step :

INREC PARSE splits the record into 3 80 byte fields based on the delim and also add the seqnum to retain the order of records
ex: input

Code:

AAAA BBBB CCCC. DDDD EEEE FFFFF                           
GGG HHHHH.IIIII OOOOO PPP.XXXXX                           
YYYY.AAAA KKKK.         


and the output is

Code:

1-80                   81-160                  161-240
======                 =======                 =======
AAAA BBBB CCCC.        DDDD EEEE FFFFF   
GGG HHHHH.             IIIII OOOOO PPP.        XXXXX
YYYY.                  AAAA KKKK.     


Now we need to check as to how many delimiters are present in each record

We use OUTREC IFTHEN to check the num of delimiters. If a delimiter is found in the first 80 bytes we update with a value of '1' at pos 241. Similary we check the bytes 81 thru 160 and 161 thru 240 for the delimiter and update the position 241 and 242.

This check is necessary to ensure we join overflowing records.

Now on OUTFIL we validate the delimit count and then Split the records in to 160 byte records

Code:

1-80                   81-160              161-180    orig
======                 =======             ======== ========
AAAA BBBB CCCC.                            A0000000100000001       
DDDD EEEE FFFFF                            B0000000100000001
                       GGG HHHHH.          B0000000100000002
IIIII OOOOO PPP.                           A0000000200000002       
XXXXX                                      B0000000200000001
                        YYYY.              B0000000200000003
AAAA KKKK.                                 A0000000300000003
                                           B0000000300000003



Now look at columns in 161-180 . Every record which has a 'B' in byte 161 needs to Clubbed as a single record which means it is a overflowing records and other we dont have to do any thing.

The SPLICE will club the records together based on the tags at position 161 for 9 bytes,but the original order of records is changed.

Code:

1-80                81-160          161 - 180
=============       ========        ===========
AAAA BBBB CCCC.                     A0000000100000001
IIIII OOOOO PPP.                    A0000000200000002
AAAA KKKK.                          A0000000300000003
 DDDD EEEE FFFFF   GGG HHHHH.       B0000000100000001
XXXXX              YYYY.            B0000000200000002


Now we sort on the original seqnum and re-arrange the records in their original order and use the JFY function to left justify the contents with a space in between. And we use the ALTSEQ to change to the delim c'.' to a space.


To understand it better I suggest that you run the job with permanent datasets instead of temp datasets and see the contents in them which will give you an idea on what I am trying to do

Hope this helps...

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


Joined: 12 Feb 2005
Posts: 16
Topics: 4

PostPosted: Wed Dec 19, 2007 12:58 pm    Post subject: Reply with quote

Thanks for help Kolusu. I am getting the following output when I ran the above code.

AAAA BBBB CCCC
DDDD EEEE FFFFF 00090011 GGG HHHHH
XXXXX 00100011 YYYY
IIIII OOOOO PPP
AAAA KKKK
00110011

Let me try to go through the explanation provided by Kolusu and try once again...
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: Wed Dec 19, 2007 1:25 pm    Post subject: Reply with quote

arungr,

I bet you have line numbers at the end(col 72 - 80) of your records. try this

Type NUM OFF at the command prompt and press ENTER in edit mode

Type
[code:1:bd29355d43]
C p'
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
arungr
Beginner


Joined: 12 Feb 2005
Posts: 16
Topics: 4

PostPosted: Wed Dec 19, 2007 2:42 pm    Post subject: Reply with quote

Sorry for the overlook.

With the above code I feel that the output is not in exact order of input. Due to this the output is in a jumbled fashion. My original input file is
Code:

sue kumar||13|| 1||40002369||02012007||09012007.Test Sep I
nvoluntary Craig||14||"Managing Dir, EH & S"||||02012007.Craig
 Test ||16||"Managing Dir, EH & S",40000059||02012007||02012007.C
raig ||17||"Managing Dir, EH & S"||40000059||02012007||0201207.Crai
g Test ||18||"Managing Dir, EH & S"||40000059||02012007||02012007

and the expected output file is
Code:

sue kumar||13|| 1||40002369||02012007||09012007.
Test Sep Involuntary Craig||14||"Managing Dir, EH & S"||||02012007.
Craig Test ||16||"Managing Dir, EH & S",40000059||02012007||02012007.
Craig ||17||"Managing Dir, EH & S"||40000059||02012007||0201207.
Craig Test ||18||"Managing Dir, EH & S"||40000059||02012007||02012007

but the output file we got is
Code:

sue kumar||13|| 1||40002369||02012007||09012007           
Test Sep I                                                                     
Craig                                                                           
nvoluntary Craig||14||"Managing Dir, EH & S"||||02012007     
Test ||16||"Managing Dir, EH & S",40000059||02012007||02012007   
C                                                                               
Crai                                                                           
raig ||17||"Managing Dir, EH & S"||40000059||02012007||02012007     
g ||18||"Managing Dir, EH & S"||40000059||02012007||02012007   
 


Again am I missing some where??
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: Wed Dec 19, 2007 3:26 pm    Post subject: Reply with quote

arungr,

Now your input is different from your initial post. The last line does not have a delimiter at all. can there be lines without a delimiter at all?

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


Joined: 12 Feb 2005
Posts: 16
Topics: 4

PostPosted: Wed Dec 19, 2007 3:56 pm    Post subject: Reply with quote

It is a copy paste error. There will not be any line without a delimiter at all.

Thanks,
Arun.
Back to top
View user's profile Send private message
arungr
Beginner


Joined: 12 Feb 2005
Posts: 16
Topics: 4

PostPosted: Wed Dec 19, 2007 4:18 pm    Post subject: Reply with quote

Kolusu,
The last line will not have any Delimiter
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: Wed Dec 19, 2007 6:07 pm    Post subject: Reply with quote

arungr,

I still have 1 minor cosmetic change to fix , but this would give you the desired results. Let me know if you see the cosmetic bug

Code:

//TOOLIN   DD *                                   
  COPY FROM(IN) USING(CTL1)                       
  SPLICE FROM(T1) TO(T2) ON(161,9,CH) WITHEACH - 
          WITH(81,80) KEEPNODUPS USING(CTL2)     
  SORT FROM(T2) USING(CTL3)                       
//CTL1CNTL DD *                                                 
  INREC PARSE=(%00=(ENDAT=C'.',FIXLEN=080),                     
               %01=(ENDAT=C'.',FIXLEN=080),                     
               %02=(FIXLEN=80)),                               
         BUILD=(%00,%01,%02)                                   
                                                               
  OUTREC IFTHEN=(WHEN=INIT,                                     
        OVERLAY=(241:C'000',SEQNUM,8,ZD),HIT=NEXT),             
         IFTHEN=(WHEN=(001,80,SS,EQ,C'.'),                     
        OVERLAY=(241:C'1'),HIT=NEXT),                           
         IFTHEN=(WHEN=(081,80,SS,EQ,C'.'),                     
        OVERLAY=(242:C'1'),HIT=NEXT),                           
         IFTHEN=(WHEN=(161,80,SS,EQ,C'.'),                     
        OVERLAY=(243:C'1'))                                     
                                                               
  OUTFIL FNAMES=T1,                                             
         IFTHEN=(WHEN=(241,3,CH,EQ,C'100',AND,                 
                       244,8,ZD,EQ,1),                         
         BUILD=(001,80,80X,C'A',244,8,/,                       
                081,80,80X,C'B',244,8)),                       
         IFTHEN=(WHEN=(241,3,CH,EQ,C'100',AND,                 
                       244,8,ZD,GT,1),                         
         BUILD=(80X,001,80,C'B',+1,SUB,244,8,ZD,M11,LENGTH=8,/,
                081,80,80X,C'B',244,8)),                       
         IFTHEN=(WHEN=(241,3,CH,EQ,C'110'),                     
         BUILD=(80X,001,80,C'B',+1,SUB,244,8,ZD,M11,LENGTH=8,/,
                081,80,80X,C'A',244,8,/,                       
                161,80,80X,C'B',244,8)),                       
         IFTHEN=(WHEN=NONE,                                     
         BUILD=(80X,001,80,C'B',+1,SUB,244,8,ZD,M11,LENGTH=8)) 
//CTL2CNTL DD *                                                 
  OMIT COND=(01,160,CH,EQ,C' ')                                 
//CTL3CNTL DD *                                                 
  SORT FIELDS=(162,8,CH,A)                                     
  INREC OVERLAY=(1,160,SQZ=(SHIFT=LEFT,MID=C' '))               
  OUTFIL FNAMES=OUT,                                           
  BUILD=(01,80)                                                 
//*


Hope this helps...

Cheers
_________________
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
Goto page 1, 2  Next
Page 1 of 2

 
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