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

File-Aid comma-Separated file to Copybook Layout


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
karthik_sripal

New User


Joined: 28 Mar 2008
Posts: 69
Location: 125.16.180.5

PostPosted: Thu Mar 18, 2010 9:46 pm
Reply with quote

Hi all,

I have Requirement in which i have a comma separated file like

Code:

 ****** ***************************** Top of Data ******************************
 000001 ALPHA;BETA;OMEGA                                                       
 ****** **************************** Bottom of Data ****************************


and want my output file like


Code:
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
****** ***************************** Top of Data *****************************
000001 ALPHA     BETA      OMEGA                                             
****** **************************** Bottom of Data ***************************


where each of my copybook element length is 10.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Thu Mar 18, 2010 10:50 pm
Reply with quote

I would use Rexx, myself.

It can probably be done using sort -- either DFSORT or SyncSort. Frank Yaeger, Kolusu, and Alissa Margulies are the experts in these utilities; I will leave it to them for the moment to explain how to so do it.

I do not think that this can be done via File-AID or StarTool, not easily at any rate, although if someone more experienced with these tools thinks differently, I will acquiesce in this matter.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Thu Mar 18, 2010 11:12 pm
Reply with quote

Since I am in a good mood and no pain to speak of today, I will provide the Rexx. Note that there is no error checking to speak of; it assumes the length of each token is less than 10 bytes, and that the delimiter is always a semi-colon.

Code:

/* Rexx */                                                             
  trace i                                                             
  arg in out .                                                         
  "ALLOC DA(" || in  || ") FI(TOOLIN)  SHR"                           
  "ALLOC DA(" || out || ") FI(TOOLOUT) OLD"                           
  "EXECIO 1 DISKR TOOLIN"                                             
                                                                       
  do while (rc=0)                                                     
    outbuf = ''                                                       
    pull inbuf                                                         
    p = pos(';',inbuf)                                                 
                                                                       
    do while (p¬=0)                                                   
      car    = substr(inbuf,1,p-1)                                     
      inbuf  = substr(inbuf,p+1)                                       
      outbuf = outbuf || car || repeat(10-length(car))                 
      p      = pos(';',inbuf)                                         
    end                                                               
                                                                       
    outbuf   = outbuf || inbuf                                         
    push outbuf                                                       
    "EXECIO 1 DISKW TOOLOUT"                                           
    "EXECIO 1 DISKR TOOLIN"                                           
  end                                                                 
                                                                       
  exit 0                                                               
/*********************************************************************/
/*                                                                   */
/* repeat                                                            */
/*                                                                   */
/*********************************************************************/
  repeat: procedure                                                   
  trace o                                                             
  arg how_many, what                                                   
                                                                       
  if ((what="WHAT") | (what='')) then                                 
    what = ' '                                                         
                                                                       
  result = ''                                                         
                                                                       
  do i = 1 to how_many                                                 
    result = result || what                                           
  end                                                                 
                                                                       
  trace o                                                             
  return result                                                       
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Mar 18, 2010 11:26 pm
Reply with quote

my preferred coding would be ...

Code:
istring = "abcd;efg;hkj;lmnopqrst"
ostring = ""
do while istring <> ""
   parse var istring token ";" istring
   ostring = ostring || left(token,10)
end


tested
Back to top
View user's profile Send private message
karthik_sripal

New User


Joined: 28 Mar 2008
Posts: 69
Location: 125.16.180.5

PostPosted: Fri Mar 19, 2010 7:35 pm
Reply with quote

Thanks for the information Akatsukami and enrico-sorichetti.It has been helpful
Back to top
View user's profile Send private message
karthik_sripal

New User


Joined: 28 Mar 2008
Posts: 69
Location: 125.16.180.5

PostPosted: Sun Mar 28, 2010 9:44 pm
Reply with quote

On browsing through the forum.. found another similar topic and solved using syncsort... posting the link here hoping this would help someone

ibmmainframes.com/viewtopic.php?t=47711&start=0&postdays=&postorder=&highlight=
Back to top
View user's profile Send private message
Uday Kumar R

New User


Joined: 07 Nov 2007
Posts: 27
Location: Mumbai

PostPosted: Mon Mar 29, 2010 1:19 pm
Reply with quote

Hello,

Hope this help.

//STEP01 EXEC PGM=SORT
//SORTIN DD DSN=input dataset name
//SORTOUT DD DSN=output dataset name%
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC PARSE=(%01=(ENDBEFR=C';',FIXLEN=10),
%02=(ENDBEFR=C';',FIXLEN=10),
%03=(ENDBEFR=C';',FIXLEN=10),
BUILD=(%01,%02,%03)
/*

Regards,
Uday
Back to top
View user's profile Send private message
karthik_sripal

New User


Joined: 28 Mar 2008
Posts: 69
Location: 125.16.180.5

PostPosted: Mon Mar 29, 2010 6:00 pm
Reply with quote

Thanks Uday.
Perfectly fits ..kinda thing i have been lookin for icon_smile.gif .. Now am planning to get this sortcard generated dynamically based on the Inputs like num of fields and its length and delimiter .. and sub this sort job via REXX and put it in lime light.. ;)

I definetly think that it would be helpful. Wish me luck icon_smile.gif
Back to top
View user's profile Send private message
Uday Kumar R

New User


Joined: 07 Nov 2007
Posts: 27
Location: Mumbai

PostPosted: Tue Mar 30, 2010 9:12 am
Reply with quote

You are right Karthik. By assuming each line has 3 words which are seperated by ";" i have coded the above logic. If there are 4 words the sort card skips the last word and produces erreneous results. I forgot to mention this. My apologies. Please take care of the length and change susequently the PARSE parameters (%) in the sort card. All the best.

Regards,
Uday
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
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