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
 

 

Joining Alternate Lines in a file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Nimesh.Srivastava

New User


Joined: 30 Nov 2006
Posts: 78
Location: SINGAPORE

PostPosted: Fri Jun 22, 2007 12:59 pm    Post subject: Joining Alternate Lines in a file
Reply with quote

Hi,
I have requirement and can somebody help me out
I want to join the alternate lines of a file in one line, with odd or even number of records (in latter case last record remains unjoined)
I have file (FB, LRECL = 80) containing records
ex
Code:

ABCD..................
,,,,,,,,,,,,,,---records found1---,,,,,,,,,,,,,,,,,,
byz.....................
,,,,,,,,,,,,,,---records found2---,,,,,,,,,,,,,,,,,,

output file should become
Code:

ABCD..................,,,,,,,,,,,,,,---records found1---,,,,,,,,,,,,,,,,,,
byz.....................,,,,,,,,,,,,,,---records found2---,,,,,,,,,,,,,,,,,,
or if possible (better)
ABCD---records found1---
byz---records found2---


Here "." and "," signifies spaces (different symbols just to differentiate spaces on alternate line.
Thanks in advance
Nimesh
Back to top
View user's profile Send private message

Nimesh.Srivastava

New User


Joined: 30 Nov 2006
Posts: 78
Location: SINGAPORE

PostPosted: Fri Jun 22, 2007 1:17 pm    Post subject:
Reply with quote

Also forgot one thing while joining it should skip the empty line for ex.
Code:

ABCD..................

,,,,,,,,,,,,,,---records found1---,,,,,,,,,,,,,,,,,,
byz.....................
,,,,,,,,,,,,,,---records found2---,,,,,,,,,,,,,,,,,,

should become

Code:

ABCD---records found1---
byz---records found2---


its fine if this requirement cannot be fulfilled, I will eliminate the blank lines first before starting with the asked solution.[/code]
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Fri Jun 22, 2007 3:28 pm    Post subject:
Reply with quote

Nimesh,

The following step divides your input file records into two files. Odd file contains odd records whereas even dsn contain even records. Please remeber the split is after remove blank records.

Code:
//SPLIT  EXEC PGM=ICETOOL                               
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG DD SYSOUT=*                                     
//IN1   DD dsn=input.file                               
//TEMP DD DSN=&&TEMPFILE,DISP=(MOD,CATLG,CATLG),         
//       LRECL=88,RECFM=FB,SPACE=(.....)                 
//ODD DD DSN=CONTAINS.ODD.RECORDS,.....                 
//EVEN DD DSN=CONTAINS.EVEN.RECORDS,.....               
//TOOLIN DD *                                           
  COPY FROM(IN1) TO(TEMP) USING(SEQN)                   
  COPY FROM(TEMP) USING(DIVI)                           
/*                                                       
//SEQNCNTL DD *                                         
  INCLUDE COND=(1,80,CH,NE,C' ')                         
  OUTREC OVERLAY=(81:SEQNUM,8,ZD,START=0,INCR=5)         
/*                                                       
//DIVICNTL DD *                                         
  OUTFIL FNAMES=ODD,                                     
  INCLUDE=(88,1,ZD,EQ,0),                               
  BUILD=(1,80)         
*                               
  OUTFIL FNAMES=EVEN,           
  INCLUDE=(88,1,ZD,EQ,5),       
  BUILD=(1,80)                   
/*                                                               


From the following link download sorttrck.pdf. Use the topic Join fields from two files record-by-record to acheive your req -


http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
Back to top
View user's profile Send private message
ibmmainframesyntel

Active User


Joined: 26 Feb 2007
Posts: 126
Location: Chennai

PostPosted: Fri Jun 22, 2007 3:43 pm    Post subject: Re: Joining Alternate Lines in a file
Reply with quote

Go thr JCl
Code:

 //S1       EXEC  PGM=ICETOOL                                           
 //TOOLMSG  DD SYSOUT=*                                                 
 //DFSMSG   DD SYSOUT=*                                                 
 //IN1      DD DSN=I088.FLAT.SEQ.INPUT101,DISP=SHR                       
 //OUT1     DD DISP=(,PASS),                                             
 //  SPACE=(CYL,(1000,200),RLSE),DCB=(LRECL=80,RECFM=FB,BLKSIZE=0),     
 //  UNIT=(SYSALLDA,50)                                                 
 //OUT2     DD DISP=(,PASS),                                             
 //  SPACE=(CYL,(1000,200),RLSE),DCB=(LRECL=88,RECFM=FB,BLKSIZE=0),     
 //  UNIT=(SYSALLDA,50)                                                 
 //OUT3     DD DISP=(,CATLG),                                           
 //  SPACE=(CYL,(1000,200),RLSE),DCB=(LRECL=88,RECFM=FB,BLKSIZE=0),     
 //  UNIT=(SYSALLDA,50),                                                 
 //  DSN=I088.FLAT.SEQ.OUTPUT57                                         
 //TOOLIN    DD    *                                                     
   SORT FROM(IN1)  TO(OUT1) USING(CTL1)                                 
   SPLICE FROM(OUT1) TO(OUT3) ON(81,8,ZD) KEEPNODUPS -                   
   WITHALL WITH(5,76)  USING(CTL2)                                       
 //CTL1CNTL DD *                                                         
      SORT FIELDS=COPY                                             
      OUTFIL FNAMES=OUT1,OMIT=(1,2,CH,EQ,C'  ')                     
 /*                                                                 
 //CTL2CNTL DD *                                                   
   INREC IFTHEN=(WHEN=(1,1,CH,NE,C','),OVERLAY=(81:SEQNUM,8,ZD)),   
       IFTHEN=(WHEN=(1,1,CH,EQ,C','),OVERLAY=(81:SEQNUM,8,ZD))     
   SORT FIELDS=COPY                                                 
 /*                                                                 


I/P - file

Code:

 a111...........................                                         
                                                                         
 ,,,,,,,,,,,,,,,,,,,,,,a222                                             
                                                                         
 b11.........................                                           
 ,,,,,,,,,,,,,,,,,,,,,,,b22                                             
                                                                         
 c11.................                                                   
                                                                         
 ,,,,,,,,,,,,,,,,,,c22                                                   
                                                                         
 d11.................                                                   
                                                                         
 ,,,,,,,,,,,,,,,,,,d22                                                   


O/P file

Code:

 a111,,,,,,,,,,,,,,,,,,a222                                             
 b11.,,,,,,,,,,,,,,,,,,,b22                                             
 c11.,,,,,,,,,,,,,,c22                                                 
 d11.,,,,,,,,,,,,,,d22                                                 


Taking first four bytes from ODD Record and remaining from EVEN records
Back to top
View user's profile Send private message
ibmmainframesyntel

Active User


Joined: 26 Feb 2007
Posts: 126
Location: Chennai

PostPosted: Fri Jun 22, 2007 4:59 pm    Post subject: Re: Joining Alternate Lines in a file
Reply with quote

Other wise if u change the contol card like this.....
Code:

//TOOLIN    DD    *                                                 
  SORT FROM(IN1)  TO(OUT1) USING(CTL1)                               
  SPLICE FROM(OUT1) TO(OUT2) ON(81,8,ZD) KEEPNODUPS -               
  WITHALL WITH(5,76)  USING(CTL2)                                   
  SORT FROM(OUT2)  TO(OUT3) USING(CTL3)                             
//CTL1CNTL DD *                                                     
     SORT FIELDS=COPY                                               
     OUTFIL FNAMES=OUT1,OMIT=(1,2,CH,EQ,C'  ')                       
/*                                                                   
//CTL2CNTL DD *                                                     
  INREC IFTHEN=(WHEN=(1,1,CH,NE,C','),OVERLAY=(81:SEQNUM,8,ZD)),     
      IFTHEN=(WHEN=(1,1,CH,EQ,C','),OVERLAY=(81:SEQNUM,8,ZD))       
  SORT FIELDS=COPY                                                   
/*                                                                   
//CTL3CNTL DD *                                                     
    INREC IFTHEN=(WHEN=INIT,    -                                   
   OVERLAY=(1,80,SQZ=(SHIFT=LEFT,PREBLANK=C','))),                   
   IFTHEN=(WHEN=INIT,OVERLAY=(1,80,SQZ=(SHIFT=LEFT,PREBLANK=C'.'))) 
  SORT FIELDS=COPY     
/*                                             


U will get ur required output like...

I/P file
Code:

a1...........................     
                                 
,,,,,,,,,,,,,,,,,,,,,,record1     
                                 
b11.........................     
,,,,,,,,,,,,,,,,,,,,,,,record2   
                                 
c111................             
                                 
,,,,,,,,,,,,,,,,,,record3         
                                 
d1111...............             
                                 
,,,,,,,,,,,,,,,,,,record4         


O/P File
Code:

a1record1                                 
b11record2                                 
c111record3                               
d111record4                               



IS it OK?

let me knw ur feedback..
Back to top
View user's profile Send private message
Nimesh.Srivastava

New User


Joined: 30 Nov 2006
Posts: 78
Location: SINGAPORE

PostPosted: Fri Jun 22, 2007 5:30 pm    Post subject:
Reply with quote

Thanks a lot for the effort man ... would try and let you know
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Jun 22, 2007 8:57 pm    Post subject:
Reply with quote

Nimesh,

Unfortunately, MP's solution depends on having . and , in the records whereas you've said those are actually blanks. MP's solution is also inefficient in that it uses three passes whereas one pass would do.

I can show you how to do what you want, but I need to understand what it is you actually want first. It's not clear what exactly you want for the output. You show two different versions and mp shows another. If you explain the "rules" you want to use for going from input to output, I can probably show you a better way to do what you want to do. For example, do you want the string before the first blank in the even records (e.g. ABCD) and the string between the first non-blank and the next blank in the odd records (e.g. ---records found1---)? Or do you want something else? What is the maximum length of the string from the odd and even records? Etc.

What is the RECFM and LRECL of the input and output files?

Give me more information about what you want and I'll show you how to do it.
Back to top
View user's profile Send private message
Nimesh.Srivastava

New User


Joined: 30 Nov 2006
Posts: 78
Location: SINGAPORE

PostPosted: Mon Jun 25, 2007 3:54 pm    Post subject:
Reply with quote

Quote:
I have file (FB, LRECL = 80) containing records

both the input and output file have the same format.
Ok Frank, what I need is blank lines should be ignored before proceeding to join alternate lines. i.e.
Code:

......abcd....efgh......
.............................
wed,,,,,,,efg,,,,,,,jkl
.........rty.fgdfg.......
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
qweffogkfg.klfjgdjg.

the first pass should read the file as
Code:

......abcd....efgh......
wed,,,,,,,efg,,,,,,,jkl
.........rty.fgdfg.......
qweffogkfg.klfjgdjg.


and then the final output should be
Code:

......abcd....efgh......wed,,,,,,,efg,,,,,,,jkl
.........rty.fgdfg.......qweffogkfg.klfjgdjg.

or only the leading and trailing blanks removed (pls note middle ones are not removed)
abcd....efghwed,,,,,,,efg,,,,,,,jkl
rty.fgdfgqweffogkfg.klfjgdjg

Please let me know is this information sufficient
Thanks
Nimesh
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Jun 25, 2007 8:43 pm    Post subject:
Reply with quote

Here's a DFSORT/ICETOOL job that will join each pair of records with the data from the first record in positions 1-80 of the output record and the data from the second record in positions 81-160 of the output record:

Code:

1                       81
      abcd    efgh      wed       efg       jkl
         rty fgdfg      qweffogkfg klfjgdjg



You can't really squeeze out some of the blanks but not all of the blanks since there's no way to tell which blanks are which. (You could left justify the data in the second record so the first nonblank characters starts in position 81, but I didn't bother showing that since your example shows the data already starting in position 1 of the second record.)

You'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use INREC with SPLICE. If you don't have the April, 2006 PTF, you won't get the correct output, so ask your System Programmer to install the PTF (it's free).

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=... input file (FB/80)
//OUT DD DSN=...  output file (FB/160)
//TOOLIN    DD    *
SPLICE FROM(IN) TO(OUT) ON(169,8,ZD) KEEPNODUPS -
  WITHALL WITH(81,80) USING(CTL1)
/*
//CTL1CNTL DD *
  OMIT COND=(1,80,CH,EQ,C' ')
  INREC IFTHEN=(WHEN=INIT,
           OVERLAY=(161:SEQNUM,1,ZD,START=0,INCR=5)),
    IFTHEN=(WHEN=(161,1,ZD,EQ,0),OVERLAY=(169:SEQNUM,8,ZD)),
    IFTHEN=(WHEN=NONE,BUILD=(81:1,80,169:SEQNUM,8,ZD))
  OUTFIL FNAMES=OUT,BUILD=(1,160)
/*
Back to top
View user's profile Send private message
Nimesh.Srivastava

New User


Joined: 30 Nov 2006
Posts: 78
Location: SINGAPORE

PostPosted: Tue Jun 26, 2007 11:42 am    Post subject:
Reply with quote

Ok Thanks Frank I am getting the correct results.
Can you clear one doubt of mine my shop has both DFSORT V1R5 and DFSORT R14 on two different LPAR's when I run the job with DFSORT V1R5 I get the correct output i.e.
Code:

input
DABCD GDFGSDF GFDGSDG

COPYA

EDFG

DFGHJK

output
DABCD GDFGSDF GFDGSDG....COPYA
EDFG......................................DFGHJK

but when I run through DFSORT R14 I get output as
Code:

DABCD GDFGSDF GFDGSDG

EDFG


could it be because PTF's are not applied for DFSORT R14, what is the difference between these two DFSORT's. The LPAR that has DFSORT V1R5 is on z/OS 1.7 and other has z/OS 1.4.
Thanks
Nimesh
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Jun 26, 2007 7:36 pm    Post subject:
Reply with quote

Quote:
could it be because PTF's are not applied for DFSORT R14


Yes. You need the April, 2006 PTF to get the correct results. From what you've said, it appears that you have the PTF for z/OS DFSORT V1R5 on your z/OS 1.7 system, but you don't have the PTF for DFSORT R14 on your z/OS 1.4. system.

Note: z/OS DFSORT V1R5 runs on z/OS 1.5 and above. DFSORT R14 runs on z/OS 1.4 and below.

Ask your System Programmer to install DFSORT R14 PTF UK90006.

For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/
Back to top
View user's profile Send private message
Nimesh.Srivastava

New User


Joined: 30 Nov 2006
Posts: 78
Location: SINGAPORE

PostPosted: Tue Jun 26, 2007 7:47 pm    Post subject:
Reply with quote

Ok thanks Frank, I remember having a similar problem before for SQZ and this was the cause of it. Probably as we are migrating on both LPARs to z/OS 1.7 thats why no upgradations are done to the older LPAR.
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
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm


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