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
 

 

Sort to Separate records in a file

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

New User


Joined: 23 Sep 2006
Posts: 21
Location: India

PostPosted: Wed Feb 11, 2015 11:31 pm    Post subject: Sort to Separate records in a file
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Thu Feb 12, 2015 1:06 am    Post subject: Reply to: Sort to Separate records in a file
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: 21
Location: India

PostPosted: Thu Feb 12, 2015 2:54 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Thu Feb 12, 2015 4:49 am    Post subject: Reply to: Sort to Separate records in a file
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Thu Feb 12, 2015 5:13 am    Post subject: Reply to: Sort to Separate records in a file
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: 21
Location: India

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

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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Thu Feb 12, 2015 1:20 pm    Post subject: Reply to: Sort to Separate records in a file
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: 21
Location: India

PostPosted: Wed Feb 18, 2015 9:33 pm    Post subject:
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    Post subject:
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    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
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


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