Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How do I replace spaces with value from prev record?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
timburkart

New User


Joined: 17 Mar 2007
Posts: 30
Location: USA

PostPosted: Thu Apr 26, 2007 1:23 am    Post subject: How do I replace spaces with value from prev record?
Reply with quote

I am reformatting a utility report into a CSV file for loading into a database. After stripping out the non-essential information and inserting delimiting commas (using DFSORT) I have a file that looks like this.

Code:

HWA,04/19/07,      47.88
   ,04/20/07,    1:30.32
   ,04/21/07,       0.17
   ,04/22/07,       0.18
   ,04/23/07,    1:32.02
   ,04/24/07,    1:44.60
   ,04/25/07,      12.28
HWB,04/24/07,       4.60
HWC,04/19/07,      10.41
   ,04/20/07,      55.55
   ,04/23/07,    1:22.26
   ,04/24/07,    1:16.14
HWE,04/19/07,       0.56


The utility report writer does not repeat values in subsequent records hence the spaces in locations 1-3. How can I carry over the non-blank value into subsequent records during the same process? I want my output file to look like this.

Code:

HWA,04/19/07,      47.88
HWA,04/20/07,    1:30.32
HWA,04/21/07,       0.17
HWA,04/22/07,       0.18
HWA,04/23/07,    1:32.02
HWA,04/24/07,    1:44.60
HWA,04/25/07,      12.28
HWB,04/24/07,       4.60
HWC,04/19/07,      10.41
HWC,04/20/07,      55.55
HWC,04/23/07,    1:22.26
HWC,04/24/07,    1:16.14
HWE,04/19/07,       0.56


I think I should use IFTHEN and INREC but don't know how all of the pieces fit together.

Code:

  INREC  IFTHEN=(WHEN=(2,3,CH,NE,C'   '),                       
               BUILD=(1:2,3,4:C',',5:44,8,13:C',',14:57,11,25:2,3)),
???         IFTHEN=(WHEN=(2,3,CH,EQ,C'   '),                       
              BUILD=(1:25,3,4:C',',5:44,8,13:C',',14:57,11))       
  OUTFIL OUTREC=(1:1,24) 


Thank you!!


tim
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Apr 26, 2007 1:56 am    Post subject:
Reply with quote

You need to use the IFTHEN group technique. Here's a DFSORT/ICETOOL job that will 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. You'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use INREC with SPLICE. If you don't have the April, 2006 PTF, you won't get the correct output, so ask your System Programmer to install the PTF (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, 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 (FB/80)
//OUT DD DSN=...  output file (FB/80)
//TOOLIN   DD    *
SPLICE FROM(IN) TO(OUT) ON(81,8,ZD) KEEPNODUPS -
  WITHALL WITH(4,77) USING(CTL1)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,3,CH,NE,C' '),
                OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(89:SEQNUM,8,ZD,
                         81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
  OUTFIL FNAMES=OUT,BUILD=(1,80)
/*
Back to top
View user's profile Send private message
timburkart

New User


Joined: 17 Mar 2007
Posts: 30
Location: USA

PostPosted: Thu Apr 26, 2007 3:14 am    Post subject: Re: How do I replace spaces with value from prev record?
Reply with quote

I always appreciate your help, Frank!! With minor adjustments it works like a charm.

Thank you very much!

regards,

tim
Back to top
View user's profile Send private message
mcollins

New User


Joined: 28 Apr 2007
Posts: 2
Location: England

PostPosted: Thu May 03, 2007 11:59 pm    Post subject: Re: How do I replace spaces with value from prev record?
Reply with quote

Could you tell me what adjustments you made? I tried the solution but the unique non-blank records i.e
HWA,04/19/07, 47.88
HWC,04/19/07, 10.41
were missing from the output.
I've ended up extracting the non blanks to another outfile and then merging it back into OUT and deduplicating, but I think I've gone a long way for a short cut.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri May 04, 2007 12:32 am    Post subject:
Reply with quote

mcollins,

Oops. Somehow I missed that when I looked at the output from my testing. To get the missing records, just add KEEPBASE to the SPLICE operator:

Code:

SPLICE FROM(IN) TO(OUT) ON(81,8,ZD) KEEPNODUPS KEEPBASE -
  WITHALL WITH(4,77) USING(CTL1)
Back to top
View user's profile Send private message
mcollins

New User


Joined: 28 Apr 2007
Posts: 2
Location: England

PostPosted: Fri May 04, 2007 2:45 pm    Post subject: Re: How do I replace spaces with value from prev record?
Reply with quote

Thanks for that - actually omitting the keepbase will come in useful in future
Back to top
View user's profile Send private message
timburkart

New User


Joined: 17 Mar 2007
Posts: 30
Location: USA

PostPosted: Fri May 04, 2007 7:50 pm    Post subject: Re: How do I replace spaces with value from prev record?
Reply with quote

Oh my! I did not check for any missing records. Thank you for catching this. I made three changes.

1-the sample data I provided had the desired data starting in column one however it actually began in column two
2-Frank's solution assumed an 80 byte output record, mine is 25
3-added SQZ=(SHIFT=LEFT)) to left justify the 3rd column of data

Code:

//TOOLIN   DD    *                                         
  SPLICE FROM(IN) TO(OUT) ON(81,8,ZD) KEEPNODUPS KEEPBASE -
    WITHALL WITH(5,77) USING(CTL1)                         
/*                       
                                 
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),         
      IFTHEN=(WHEN=(2,3,CH,NE,C' '),                       
              OVERLAY=(81:SEQNUM,8,ZD)),                   
      IFTHEN=(WHEN=NONE,                                   
              OVERLAY=(89:SEQNUM,8,ZD,                     
                       81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
  OUTFIL FNAMES=OUT,                                         
       BUILD=(1:2,3,4:2C',',6:44,8,14:C',',                 
              15:57,11,SQZ=(SHIFT=LEFT))       
/*
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Sort Large record length cmsmoon DFSORT/ICETOOL 14 Tue Apr 11, 2017 5:49 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us