Including delimiter in a PS file



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Including delimiter in a PS file

Postby nm992 » Mon Oct 24, 2011 10:47 pm

Hi..

I have a PS File.I need to include a delimiter between each field and generate an output..

For ex : My Inpput is:

Rachita       Bangalore          City
Mohan         Delhi              Capital


I want output as

Rachita/bangalore/Ciby
Mohan/Delhi/Capital
nm992
 
Posts: 43
Joined: Sun Jul 11, 2010 11:31 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Including delimiter in a PS file

 

Re: Including delimiter in a PS file

Postby Frank Yaeger » Mon Oct 24, 2011 11:04 pm

nm992,

You can use a DFSORT job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

//S1 EXEC PGM=SORT                                   
//SYSOUT DD SYSOUT=*                                 
//SORTIN DD *                                       
Rachita       Bangalore          City               
Mohan         Delhi              Capital             
//SORTOUT DD SYSOUT=*                               
//SYSIN DD *                                         
  OPTION COPY                                       
  INREC BUILD=(1,80,SQZ=(SHIFT=LEFT,MID=C'/'))       
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: Including delimiter in a PS file

Postby nm992 » Tue Oct 25, 2011 12:52 pm

Hi Frank

Its not coming correct in fields where there is no space..

For exacmple if my Name is long

rachitadasguptabangalore
dennis delhi
ricksi chennai

/ is not coming in the first ro as this is continous and occupy full byte assigned to it.
nm992
 
Posts: 43
Joined: Sun Jul 11, 2010 11:31 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Including delimiter in a PS file

Postby BillyBoyo » Tue Oct 25, 2011 1:46 pm

Well, you should have provided this example in your sample input if you want anyone to know it is a possible situation. Without such an example, the natural assumption is that the fields are seperated by at least one blank. Have you tried the code with combinations of blank fields as well?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Including delimiter in a PS file

Postby Frank Yaeger » Tue Oct 25, 2011 10:41 pm

Its not coming correct in fields where there is no space..

For exacmple if my Name is long

rachitadasguptabangalore
dennis delhi
ricksi chennai

/ is not coming in the first ro as this is continous and occupy full byte assigned to it.


Huh? In your first post, you said
I need to include a delimiter between each field


Why would you expect a delimiter for just one field? There's no "between" in that case.

I have no idea what output you're looking for with your new input example - what are you expecting for output? Where/why would you expect a / for that long field and what are the "rules" for that? I really can't read your mind. You need to show an example of input and expected output for all possible variations if you want me to show you how to handle all possible variations.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: Including delimiter in a PS file

Postby nm992 » Tue Oct 25, 2011 10:55 pm

Hi,

My Input is as below

NAME(20 Bytes) CITY(15 BYTES) AGE(3 BYTES) A/C BANK(10 Bytes)

Rachita Bangalore 24 HDFC
Mohan Bangalore 23 ICICI
Mhandasgupta Delhi 23 HDFC
ParvRVenkateshwaraaaBangalore 56 SBI

I want ouptput as

rachita/bangalore/24/hdfc
mohan/bangalore/23/icici
mohandasgupta/delhi/23/hdfc
ParvRVenkateshwaraaa/bangalore/56/sbi

The above solution you posted is working fine but it is not working and not introducing / if any field value is occupying maximum bytes(i.e there is no space between consequent fields)
nm992
 
Posts: 43
Joined: Sun Jul 11, 2010 11:31 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Including delimiter in a PS file

Postby Frank Yaeger » Tue Oct 25, 2011 11:06 pm

Given those new rules, here's a DFSORT job that will do what you asked for:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/48)
//SORTOUT DD DSN=...  output file (FB/48)
//SYSIN DD *
   OPTION COPY
   INREC IFOUTLEN=48,
    IFTHEN=(WHEN=INIT,
     BUILD=(1,20,C'/',21,15,C'/',36,3,C'/',39,10)),
    IFTHEN=(WHEN=INIT,BUILD=(1,51,SQZ=(SHIFT=LEFT)))
/*


Input:

Rachita             Bangalore      24 HDFC           
Mohan               Bangalore      23 ICICI         
Mhandasgupta        Delhi          23 HDFC           
ParvRVenkateshwaraaaBangalore      56 SBI           
ParvRVenkateshwaraaaBangalorexxxxxx561SBIxxxxxxx     


Output:

Rachita/Bangalore/24/HDFC                               
Mohan/Bangalore/23/ICICI                                 
Mhandasgupta/Delhi/23/HDFC                               
ParvRVenkateshwaraaa/Bangalore/56/SBI                   
ParvRVenkateshwaraaa/Bangalorexxxxxx/561/SBIxxxx         
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: Including delimiter in a PS file

Postby nm992 » Fri Oct 28, 2011 6:21 pm

What is the significance of 51in your data
nm992
 
Posts: 43
Joined: Sun Jul 11, 2010 11:31 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Including delimiter in a PS file

Postby enrico-sorichetti » Fri Oct 28, 2011 8:39 pm

why not show a bit of ingenuity and try to find out Yourself ...
anyway,

51 = length of first field + length of second field + length of third field + length of fourth field + 3 * length of separator

51 = 20 + 15 + 3 + 10 + 3
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post