Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
File-Aid comma-Separated file to Copybook Layout

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
karthik_sripal

New User


Joined: 28 Mar 2008
Posts: 67
Location: 125.16.180.5

PostPosted: Thu Mar 18, 2010 9:46 pm    Post subject: File-Aid comma-Separated file to Copybook Layout
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: 1775
Location: Bloomington, IL

PostPosted: Thu Mar 18, 2010 10:50 pm    Post subject:
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: 1775
Location: Bloomington, IL

PostPosted: Thu Mar 18, 2010 11:12 pm    Post subject: Reply to: File-Aid comma-Separated file to Copybook Layout
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10310
Location: italy

PostPosted: Thu Mar 18, 2010 11:26 pm    Post subject: Reply to: File-Aid comma-Separated file to Copybook Layout
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: 67
Location: 125.16.180.5

PostPosted: Fri Mar 19, 2010 7:35 pm    Post subject:
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: 67
Location: 125.16.180.5

PostPosted: Sun Mar 28, 2010 9:44 pm    Post subject:
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

http://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: 25
Location: Mumbai

PostPosted: Mon Mar 29, 2010 1:19 pm    Post subject: Reply to: File-Aid comma-Separated file to Copybook Layout
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: 67
Location: 125.16.180.5

PostPosted: Mon Mar 29, 2010 6:00 pm    Post subject:
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: 25
Location: Mumbai

PostPosted: Tue Mar 30, 2010 9:12 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Compare yesterday's date to the one o... migusd SYNCSORT 7 Fri Sep 22, 2017 11:35 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Skip file from delete pema_yozer All Other Mainframe Topics 3 Tue Aug 29, 2017 3:19 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us