MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Variable length fields separated by delimiters

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
manojagrawal
Beginner


Joined: 25 Feb 2003
Posts: 124
Topics: 29

PostPosted: Wed Apr 27, 2005 9:29 am    Post subject: Variable length fields separated by delimiters Reply with quote

Hello,

I have a file, RECFM=FB, RECL=80, and all the words(variable length) have a . as the delimiter. I need to separate these words onto separate lines. Is it possible using JCL? Delimiter . is hex 25. Also a word may continue onto the next line. Thanks!

Input
Quote:
el.odphibf.hbwecczk.fojpebtwxlhapj.yysexrayno.kbtgmdf.zfatqpqjer.ihvkmsugml.jyzo
mukog.uabbhjk.conoaagxqeay.rrsz.lvenotp.zliu.sfilrdujrq.xgsxgfbqj.apisesqb.hvvdt
jxc.ogclqezrtujf.khqdzvcwpxcxbm.xlypmmm.vwgupbpmfzfd.tzbedfg.bypnxmnf.rzmuzhqfzj


Output
Quote:
el
odphibf
hbwecczk
fojpebtwxlhapj
yysexrayno
kbtgmdf
zfatqpqjer
ihvkmsugml
jyzomukog
uabbhjk
conoaagxqeay
rrsz
lvenotp
zliu
sfilrdujrq
xgsxgfbqj
apisesqb
hvvdtjxc
ogclqezrtujf
khqdzvcwpxcxbm
xlypmmm
vwgupbpmfzfd
tzbedfg
bypnxmnf
rzmuzhqfzj

_________________
Thanks & Regards,
Manoj.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Apr 27, 2005 11:13 am    Post subject: Reply with quote

If you have easytrieve at your shop then the following JCL will give you the desired results.

Code:

//STEP0100 EXEC PGM=EZTPA00                     
//STEPLIB  DD DSN=EASYTREV.LOADLIB,   
//            DISP=SHR                         
//SYSPRINT DD SYSOUT=*                         
//SYSOUT   DD SYSOUT=*                         
//SYSSNAP  DD SYSOUT=*                         
//SYSUDUMP DD SYSOUT=*                         
//INFILE   DD DSN=YOUR INPUT FILE,           
//            DISP=SHR                         
//OUTPUT   DD SYSOUT=*,                         
//            DCB=(LRECL=80,RECFM=FB,BLKSIZE=0)
//SYSIN    DD *                                       
                                                     
  FILE INFILE                                         
       IN-REC           01 01  A OCCURS 80 INDEX IDX 
                                                     
  FILE OUTPUT  FB(0 0)                               
       OUT-REC          01 80  A                     
       OUT-WORD         01 01  A OCCURS 80 INDEX ODX 
                                                     
***********************************************
* MAINLINE                                    *
***********************************************
                                               
 JOB INPUT INFILE  FINISH LAST-WORD                             
                                               
   IDX = 1                                     
                                               
   IF ODX <= 1                                 
      ODX = 1                                 
   END-IF                                     
                                               
   DO UNTIL IDX GT 80                         
      IF IN-REC (IDX) = '.'                   
         PUT OUTPUT                           
         OUT-REC      = ' '                   
         ODX          = 1                     
      ELSE                                     
         OUT-WORD(ODX)   = IN-REC (IDX)       
         ODX             = ODX + 1             
      END-IF                                   
      IDX    = IDX + 1                         
   END-DO                                     

 LAST-WORD. PROC 
    PUT OUTPUT   
 END-PROC                                                       
/*


Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
manojagrawal
Beginner


Joined: 25 Feb 2003
Posts: 124
Topics: 29

PostPosted: Thu Apr 28, 2005 1:36 am    Post subject: Reply with quote

Hello Kolusu,

Thanks for the reply. Unfortunately I do not have easytrieve.

Do you think there is any other way?

Thanks
_________________
Thanks & Regards,
Manoj.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Apr 28, 2005 7:30 am    Post subject: Reply with quote

Quote:

Do you think there is any other way?


Manoj,

I can't think of a way doing it using the traditional features of sort. Sorry. You can always code a program.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Thu Apr 28, 2005 7:50 am    Post subject: Reply with quote

The SAS language has a built-in method for reading delimited files. I'm not a SAS expert, but here is an example:
Code:

//SASSTEP  EXEC SAS                                         
//SAS.SASLOG  DD SYSOUT=*                                   
//SAS.SYSDUMP DD SYSOUT=*                                   
//SAS.SASLIST DD SYSOUT=*                                   
//SYSUT1   DD   DATA                                         
el odphibf hbwecczk fojpebtwxlhapj yysexrayno kbtgmdf zfatqpq ...
/*                                                           
//SYSUT2   DD   SYSOUT=*                                     
//SYSIN    DD   DATA         
DATA TEMP;                                       
INFILE SYSUT1 DLM='25'X DSD LRECL=80 TRUNCOVER;   
FILE SYSUT2;                                     
INPUT CHAR1  :$80.                               
      CHAR2  :$80.                               
      CHAR3  :$80.                               
      CHAR4  :$80.                               
      CHAR5  :$80.                               
      CHAR6  :$80.                               
      CHAR7  :$80.                               
      CHAR8  :$80.                               
      CHAR9  :$80.                               
      CHAR10 :$80.;                               
PUT @1 CHAR1;                                     
PUT @1 CHAR2;                                     
PUT @1 CHAR3;                                     
PUT @1 CHAR4;                                     
PUT @1 CHAR5;                                     
PUT @1 CHAR6;                                     
PUT @1 CHAR7;                                     
PUT @1 CHAR8;                                     
PUT @1 CHAR9;                                     
PUT @1 CHAR10;   
/*               
//*             
Back to top
View user's profile Send private message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Thu Apr 28, 2005 8:05 am    Post subject: Reply with quote

And, of course, a REXX exec works nicely for unwrapping delimited files:
Code:

//*                                               
//STEP0001 EXEC PGM=IEBGENER                       
//SYSUT1   DD   DATA,DLM=@@                       
/* REXX */                                         
old = ""                                           
Do Forever                                         
  "EXECIO 1 DISKR SYSUT1"                         
  If rc <> 0 Then Leave                           
  Parse Pull inrec                                 
  inrec = old||inrec                               
  cntr = 0                                         
  Do i = 1 To Length(Strip(inrec))                 
    cntr = cntr + 1                               
    Parse Var inrec var.cntr '25'x inrec           
    If Length(inrec) = 0 Then Leave               
  End                                             
  Do i = 1 To (cntr - 1)                           
    Push var.i                                     
    "EXECIO 1 DISKW SYSUT2"                       
    End                                                 
  old = var.cntr                                     
  Drop var                                           
End                                                   
"EXECIO 0 DISKR SYSUT1 (FINIS"                       
If Length(old) > 0 Then                               
  Do                                                 
    Push old                                         
    "EXECIO 1 DISKW SYSUT2"                           
  End                                                 
"EXECIO 0 DISKW SYSUT2 (FINIS"                       
Exit 0                                               
@@                                                   
//SYSUT2   DD   DSN=&&PDS(UNWRAP),DISP=(NEW,PASS),   
//         UNIT=VIO,SPACE=(TRK,(1,1,1),RLSE)         
//SYSPRINT DD   SYSOUT=*                             
//SYSIN    DD   DUMMY                                 
//*                                                   
//STEP0002 EXEC PGM=IRXJCL,PARM='UNWRAP'             
//SYSEXEC  DD   DSN=&&PDS,DISP=(OLD,PASS)             
//SYSTSIN  DD   DUMMY                                 
//SYSTSPRT DD   SYSOUT=*                             
//SYSUT1   DD   DATA                                     
el odphibf hbwecczk fojpebtwxlhapj yysexrayno kbtgmdf zfa ...                     
/*                                                       
//SYSUT2   DD   SYSOUT=*                                 
//*                                                     
Back to top
View user's profile Send private message
manojagrawal
Beginner


Joined: 25 Feb 2003
Posts: 124
Topics: 29

PostPosted: Sun May 01, 2005 8:44 am    Post subject: Reply with quote

Thanks Kolusu and Superk!

No SAS and no Rexx too - I was just wondering shouldnt the traditional sort/icetool etc have such a mechanism, or something similar, as comma, etc delimited data could be a possiblity in any situation.
_________________
Thanks & Regards,
Manoj.
Back to top
View user's profile Send private message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Sun May 01, 2005 10:17 am    Post subject: Reply with quote

Usually, when you are dealing with delimited data types, you are dealing with data that is in a specific format, such as ANSI X.12, EDIFACT, or XML. Processing this type of data requires much more than just un-wrapping the files. It typically requires looping structures, data and field validations, sequence counters, etc. Companies that use this type of data typically use products that are designed to handle the data, typically referred to as "data mapping engines". Products along these lines include Gentram Mercator, Cloverleaf, Harbinger, Trusted Link, etc.
Back to top
View user's profile Send private message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Sun May 01, 2005 10:20 am    Post subject: Reply with quote

Typo.

That's "Gentran, Mercator, Cloverleaf, Harbinger, Trusted Link, etc.".
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Sun May 01, 2005 10:47 am    Post subject: Reply with quote

Why is there such a terrible fear of programming here? This is a fairly simple rexx program. If you use the unix command line it short 1 liner:

cat filename | tr '\n' '?' |sed -e 's/[ ?]//g' -e 's/\./\n/gm'

(This could probably be much simpler, but the idea is there)

But I'm fascinated that most of the questions here say No Rexx, no common utilities, no programming... nothing but "jcl" which, of course, means a flavor of SORT.

Why is programming not allowed in these questions? Confused
Back to top
View user's profile Send private message Visit poster's website
manojagrawal
Beginner


Joined: 25 Feb 2003
Posts: 124
Topics: 29

PostPosted: Mon May 02, 2005 12:33 am    Post subject: Reply with quote

Its not that programming is "not" allowed. I know its possible to do it with a program, but I was looking into other ways to do this.
_________________
Thanks & Regards,
Manoj.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu May 04, 2006 12:02 pm    Post subject: Reply with quote

Here's a DFSORT/ICETOOL job that use the new PARSE function available with z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) to handle these delimited fields. For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTFs, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...  input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
COPY FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
 OUTFIL FNAMES=T1,
   PARSE=(%00=(FIXLEN=14,ENDBEFR=X'25',ENDBEFR=C' '),
          %01=(FIXLEN=14,ENDBEFR=X'25',ENDBEFR=C' '),
          %02=(FIXLEN=14,ENDBEFR=X'25',ENDBEFR=C' '),
          %03=(FIXLEN=14,ENDBEFR=X'25',ENDBEFR=C' '),
          %04=(FIXLEN=14,ENDBEFR=X'25',ENDBEFR=C' '),
          %05=(FIXLEN=14,ENDBEFR=X'25',ENDBEFR=C' '),
          %06=(FIXLEN=14,ENDBEFR=X'25',ENDBEFR=C' '),
          %07=(FIXLEN=14,ENDBEFR=X'25',ENDBEFR=C' '),
          %08=(FIXLEN=14,ENDBEFR=X'25',ENDBEFR=C' '),
          %09=(FIXLEN=14,ENDBEFR=X'25',ENDBEFR=C' '),
          %10=(FIXLEN=14,ENDBEFR=X'25',ENDBEFR=C' ')),
   BUILD=(%00,80:X,/,%01,/,%02,/,%03,/,%04,/,%05,/,
          %06,/,%07,/,%08,/,%09,/,%10)
//CTL2CNTL DD *
  OMIT COND=(1,1,CH,EQ,C' ')
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group