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

Sort to Separate records in a file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mrdinesh

New User


Joined: 23 Sep 2006
Posts: 24
Location: India

PostPosted: Wed Feb 11, 2015 11:31 pm
Reply with quote

Hi,

I have a requirement where I receive a file with an example data as

Code:

ABCD1234567DH&GHGHS&
37647697AHFG&AKHGL&A
HJHJH&DJH736SDFDJHK&
SDGHJGFSHGJHSGFJGJJS
JGHHJKSHFGHGHGHJHJJF
SHGHJGJG&HDGFHJGJJJ&
SJH&SHGDHFGHG&


The requirement here is to format the file into as

Code:

37647697AHFG&
AKHGL&
AHJHJH&           
DJH736SDFDJHK&
SDGHJGFSHGJHSGFJGJJSJGHHJKSHFGHGHGHJHJJFSHGHJGJG&
HDGFHJGJJJ&
SJH&
SHGDHFGHG&


The data preceding the '&' would form a record in the output file. The issue that I am facing here is that the data for an output file record can be in two or more consecutive input file records I was thinking to write a small cobol program to solve this, but thought of checking whether this would be possible in Sort/Icetool. The input file is 80 bytes long.

Thanks,
Dinesh
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Feb 12, 2015 1:06 am
Reply with quote

What's the shortest possible record? What's the longest?
Back to top
View user's profile Send private message
mrdinesh

New User


Joined: 23 Sep 2006
Posts: 24
Location: India

PostPosted: Thu Feb 12, 2015 2:54 am
Reply with quote

All the records in the file are 80 byte long. In the example I gave a short rec length.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Feb 12, 2015 4:49 am
Reply with quote

OK, I worded that badly.

What is the shortest combination of characters followed by an & (so 123& is four) that there can be? What is the longest that there can be?

I seem to remember there was one of these before. Have you searched? Probably a couple of years ago.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Feb 12, 2015 5:13 am
Reply with quote

Here's one to look at, and another.
Back to top
View user's profile Send private message
mrdinesh

New User


Joined: 23 Sep 2006
Posts: 24
Location: India

PostPosted: Thu Feb 12, 2015 12:53 pm
Reply with quote

Thanks Bill. That worked perfectly.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Feb 12, 2015 1:20 pm
Reply with quote

Good, well done.

Can you post the control cards you came up with, it may help others to have a more up-to-date example?
Back to top
View user's profile Send private message
mrdinesh

New User


Joined: 23 Sep 2006
Posts: 24
Location: India

PostPosted: Wed Feb 18, 2015 9:33 pm
Reply with quote

Here's the sort card that I came up with

Code:


//STEP1   EXEC PGM=ICETOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN         DD DISP=(SHRS),DSN=INPUTFILE                             
//OUT      DD DISP=(NEW,CATLG,DELETE),                                 
//            DCB=(RECFM=FB,LRECL=80,BLKSIZE=0),                       
//            MGMTCLAS=MCM030BK,SPACE=(TRK,(7200,600),RLSE),           
//            DSN=OUTPUTFILE                                           
//TEMPFILE DD DSN=&&TEMPFILE,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS) 
//TOOLIN   DD *                                                         
 RESIZE FROM(IN) TO(TEMPFILE) TOLEN(81) USING(CTL1)                     
 COPY FROM(TEMPFILE) TO(OUT) USING(CTL2)                               
/*                                                                     
//CTL1CNTL DD *                                                         
  OPTION COPY                                                           
  INREC IFTHEN=(WHEN=INIT,                                             
      PARSE=(%01=(ENDAT=C'&',FIXLEN=81),                               
             %02=(ENDAT=C'&',FIXLEN=81),                               
             %03=(ENDAT=C'&',FIXLEN=81),                               
             %04=(ENDAT=C'&',FIXLEN=81),                               
             %05=(ENDAT=C'&',FIXLEN=81),                               
             %06=(ENDAT=C'&',FIXLEN=81),                               
             %07=(ENDAT=C'&',FIXLEN=81),                               
             %08=(ENDAT=C'&',FIXLEN=81),                               
             %09=(ENDAT=C'&',FIXLEN=81),                               
             %10=(ENDAT=C'&',FIXLEN=81),                               
             %11=(ENDAT=C'&',FIXLEN=81),                               
             %12=(ENDAT=C'&',FIXLEN=81),                               
             %13=(ENDAT=C'&',FIXLEN=81),                               
             %14=(ENDAT=C'&',FIXLEN=81),                               
             %15=(ENDAT=C'&',FIXLEN=81)),                               
      BUILD=(%01,%02,%03,%04,%05,%06,%07,%08,%10,%11,%12,%13,%14,%15)),
  IFTHEN=(WHEN=(0001,0081,SS,NE,C'&'),OVERLAY=(0081:C'B'),HIT=NEXT),   
  IFTHEN=(WHEN=(0082,0081,SS,NE,C'&'),OVERLAY=(0162:C'B'),HIT=NEXT),   
  IFTHEN=(WHEN=(0163,0081,SS,NE,C'&'),OVERLAY=(0243:C'B'),HIT=NEXT),   
  IFTHEN=(WHEN=(0244,0081,SS,NE,C'&'),OVERLAY=(0324:C'B'),HIT=NEXT),   
  IFTHEN=(WHEN=(0325,0081,SS,NE,C'&'),OVERLAY=(0405:C'B'),HIT=NEXT),   
  IFTHEN=(WHEN=(0406,0081,SS,NE,C'&'),OVERLAY=(0486:C'B'),HIT=NEXT),   
  IFTHEN=(WHEN=(0487,0081,SS,NE,C'&'),OVERLAY=(0567:C'B'),HIT=NEXT),   
  IFTHEN=(WHEN=(0568,0081,SS,NE,C'&'),OVERLAY=(0648:C'B'),HIT=NEXT),   
  IFTHEN=(WHEN=(0649,0081,SS,NE,C'&'),OVERLAY=(0729:C'B'),HIT=NEXT),   
  IFTHEN=(WHEN=(0730,0081,SS,NE,C'&'),OVERLAY=(0810:C'B'),HIT=NEXT),   
  IFTHEN=(WHEN=(0811,0081,SS,NE,C'&'),OVERLAY=(0891:C'B'),HIT=NEXT),   
  IFTHEN=(WHEN=(0892,0081,SS,NE,C'&'),OVERLAY=(0972:C'B'),HIT=NEXT),   
  IFTHEN=(WHEN=(0973,0081,SS,NE,C'&'),OVERLAY=(1053:C'B'),HIT=NEXT),   
  IFTHEN=(WHEN=(1054,0081,SS,NE,C'&'),OVERLAY=(1134:C'B'),HIT=NEXT),   
  IFTHEN=(WHEN=(1135,0081,SS,NE,C'&'),OVERLAY=(1215:C'B'),HIT=NEXT)     
                                                                       
  OUTFIL OMIT=(1,80,CH,EQ,C' '),                                       
  IFTHEN=(WHEN=GROUP,BEGIN=(81,1,CH,EQ,C'B'),                           
  PUSH=(82:1,80),RECORDS=2)                                             
/*                                                                     
//CTL2CNTL DD *                                                         
  OMIT COND=(81,1,CH,EQ,C'B')                                         
    INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,BUILD=(82,80,1,80)),       
    IFTHEN=(WHEN=INIT,BUILD=(1,160,SQZ=(SHIFT=LEFT)))                   
/*                                                                     
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Thu Feb 19, 2015 4:03 pm
Reply with quote

mrdinesh,

I see some discrepancy in the expected and actual result. This solution will work if row terminator '&' present in immediate next record.

Expected Output:

Code:
ABCD1234567DH&                                                    
GHGHS&
37647697AHFG&
AKHGL&
AHJHJH&           
DJH736SDFDJHK&
SDGHJGFSHGJHSGFJGJJSJGHHJKSHFGHGHGHJHJJFSHGHJGJG&
HDGFHJGJJJ&
SJH&
SHGDHFGHG&


Actual Output:
Code:
ABCD1234567DH&                         
GHGHS&                                 
37647697AHFG&                           
AKHGL&                                 
AHJHJH&                                 
DJH736SDFDJHK&                         
JGHHJKSHFGHGHGHJHJJFSHGHJGJG&           
HDGFHJGJJJ&                             
SJH&                                   
SHGDHFGHG&
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 FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
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