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

How to append comma at the end of each variable len rec


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

New User


Joined: 29 Apr 2010
Posts: 28
Location: chennai

PostPosted: Sun Apr 15, 2012 3:03 am
Reply with quote

Hi,

I have a requirement like this:

1)Each record has one field of variable length in a flat file of length 10.
aaa
bbbbb
ccccccc

I want each record to be suffixed with ,(comma) at the end of non blank chars in the record.

i.e.

o/p should be:::

aaa,
bbbbb,
ccccccc,

I had tried with PARSE but no use as it uses FIXLENGTH. Whenever PARSE finds blank, i moved it to FIXLENGTH of 7 and used BUILD to append comma.i could see few spacess before comma.

o/p was :
aaa ,
bbbbb ,
ccccccc,

Will it be possible to do with icetool/sort.

Thanks a lot.
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: Sun Apr 15, 2012 3:18 am
Reply with quote

Can you have embedded spaces in your data?

If not, FINDREP (which finds and replaces) can do it for you. Change a space to a comma, and DO it only once.

Edit: This looks related to your previous question. If so, it is probably best to list the whole requirement, otherwise we might spend time on things we later find aren't necessary.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Sun Apr 15, 2012 5:33 am
Reply with quote

Hi,

what if there is no space in last byte ?

If there are no embedded spaces then this might help

Code:
//STEP0001 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                       
1234567890                                             
123456789                                             
12345678                                               
1234567                                               
123456                                                 
12345                                                 
1234                                                   
123                                                   
12                                                     
1                                                     
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                       
  OPTION COPY                                         
  INREC IFTHEN=(WHEN=(10,1,CH,EQ,C' '),               
        OVERLAY=(10:C','))                             
  OUTREC BUILD=(1,10,SQZ=(SHIFT=LEFT))                 
/*                                                     



Gerry
Back to top
View user's profile Send private message
sudhanaveenkumar

New User


Joined: 29 Apr 2010
Posts: 28
Location: chennai

PostPosted: Sun Apr 15, 2012 2:29 pm
Reply with quote

Good call, worked a treat!

Thanks a lot gcicchet and Bill.

There will be a space in last byte and no embedded spaces.
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: Sun Apr 15, 2012 4:15 pm
Reply with quote

OK, no problem.

Remember, if connected to your previous question and one of the every-third input records contains eight characters, the trailing comma will be chopped off when it becomes one of three parts of a 28-byte record.

I'd done on for the "embedded spaces", so it may as well appear...

Code:

//TRLCOMMA EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN DD *
 SORT FIELDS=COPY
 INREC IFTHEN=(WHEN=(01,10,CH,EQ,C' '),OVERLAY=(01:C' ')),
       IFTHEN=(WHEN=(02,09,CH,EQ,C' '),OVERLAY=(02:C',')),
       IFTHEN=(WHEN=(03,08,CH,EQ,C' '),OVERLAY=(03:C',')),
       IFTHEN=(WHEN=(04,07,CH,EQ,C' '),OVERLAY=(04:C',')),
       IFTHEN=(WHEN=(05,06,CH,EQ,C' '),OVERLAY=(05:C',')),
       IFTHEN=(WHEN=(06,05,CH,EQ,C' '),OVERLAY=(06:C',')),
       IFTHEN=(WHEN=(07,04,CH,EQ,C' '),OVERLAY=(07:C',')),
       IFTHEN=(WHEN=(08,03,CH,EQ,C' '),OVERLAY=(08:C',')),
       IFTHEN=(WHEN=(09,02,CH,EQ,C' '),OVERLAY=(09:C',')),
       IFTHEN=(WHEN=(10,01,CH,EQ,C' '),OVERLAY=(10:C','))
                                                         
//SORTIN   DD *
                                                         
         0
1234567 9
12345 78
123 567
1 3456
1 3 5
12 4
1 3
12
1


Output is:

Code:
         
         0
1234567 9,
12345 78,
123 567, 
1 3456,   
1 3 5,   
12 4,     
1 3,     
12,       
1,       
Back to top
View user's profile Send private message
sudhanaveenkumar

New User


Joined: 29 Apr 2010
Posts: 28
Location: chennai

PostPosted: Sun Apr 15, 2012 5:34 pm
Reply with quote

Many thanks Bill for your inputs.

Regards
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Apr 16, 2012 9:57 pm
Reply with quote

sudhanaveenkumar wrote:
Good call, worked a treat!

Thanks a lot gcicchet and Bill.

There will be a space in last byte and no embedded spaces.


If there are no embedded spaces then you can use the following DFSORT JCL
Code:

//STEP0100 EXEC PGM=SORT                       
//SYSOUT   DD SYSOUT=*                         
//SORTIN   DD *                                 
1234567890                                     
123456789                                       
12345678                                       
1234567                                         
123456                                         
12345                                           
1234                                           
123                                             
12                                             
1                                               
//SORTOUT  DD SYSOUT=*                         
//SYSIN    DD *                                 
  OPTION COPY                                   
  INREC BUILD=(1,10,SQZ=(SHIFT=LEFT,TRAIL=C','))
//*   
Back to top
View user's profile Send private message
sudhanaveenkumar

New User


Joined: 29 Apr 2010
Posts: 28
Location: chennai

PostPosted: Tue Apr 17, 2012 12:34 pm
Reply with quote

Thanks Kolusu.

I have one more question.

I want to do a specific processing for the last record in an input file and i dont know how many records are in the input file and i cant uniquely identify the last record.

For the same sample jcl you have given above ,
For example if i want to append semicolon (;) to the last record alone in an input file.How can it be done?






Thanks a lot
Back to top
View user's profile Send private message
sudhanaveenkumar

New User


Joined: 29 Apr 2010
Posts: 28
Location: chennai

PostPosted: Tue Apr 17, 2012 12:40 pm
Reply with quote

Of course, i can include all possibilities as mentioned in Bill Woodger sample jcl.

But It will be too lengthy if the field size increases to 20(10 shown above).

Would you please advise much simpler way to perform specific processing on last record alone where i cant uniquely identify it?
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Apr 17, 2012 10:01 pm
Reply with quote

sudhanaveenkumar wrote:
Thanks Kolusu.

I have one more question.

I want to do a specific processing for the last record in an input file and i dont know how many records are in the input file and i cant uniquely identify the last record.

For the same sample jcl you have given above ,
For example if i want to append semicolon (;) to the last record alone in an input file.How can it be done?
Thanks a lot


Use the following DFSORT/ICETOOL JCL which will give you the desired results
Code:

//STEP0100 EXEC PGM=ICETOOL                                       
//TOOLMSG  DD SYSOUT=*                                             
//DFSMSG   DD SYSOUT=*                                             
//IN       DD *                                                   
1234567890                                                         
123456789                                                         
12345678                                                           
1234567                                                           
123456                                                             
12345                                                             
1234                                                               
123                                                               
12                                                                 
1                                                                 
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)         
//LR       DD DSN=&&LR,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)         
//TOOLIN   DD *                                                   
  SUBSET FROM(IN) TO(LR) DISCARD(T1) INPUT KEEP TRAILER USING(CTL1)
//CTL1CNTL DD *
  INREC BUILD=(1,10)                                                     
  OUTFIL FNAMES=LR,OVERLAY=(1,10,SQZ=(SHIFT=LEFT,TRAIL=C','))     
//*                                                               
//STEP0200 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DSN=&&T1,DISP=SHR                                   
//         DD DSN=&&LR,DISP=SHR                                   
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                                 
//*
Back to top
View user's profile Send private message
sudhanaveenkumar

New User


Joined: 29 Apr 2010
Posts: 28
Location: chennai

PostPosted: Tue Apr 17, 2012 10:43 pm
Reply with quote

Thanks Kolusu.
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts How to append a PS file into multiple... JCL & VSAM 3
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
Search our Forums:

Back to Top