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

Joining Alternate Lines in a file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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: 1436
Location: Bangalore,India

PostPosted: Fri Jun 22, 2007 3:28 pm
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 -


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
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
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
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 Developer


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

PostPosted: Fri Jun 22, 2007 8:57 pm
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
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 Developer


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

PostPosted: Mon Jun 25, 2007 8:43 pm
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
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 Developer


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

PostPosted: Tue Jun 26, 2007 7:36 pm
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:

Use [URL] BBCode for External Links
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
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 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 FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top