Page 1 of 2

inserting new row for a column

PostPosted: Thu Mar 21, 2013 8:01 pm
by nikesh_rai
Hi,

I have a file having input as given below:

12      12
12      24
 3      27
10      37
10      47
12      59


The expected output is:

12     
12      12
 3      24
10      27
10      37
12      47


I think this can be achieved by inserting a row for 2nd column.. I don't know if this approach is reasonable or not.. Please suggest me on this for a better approach...
the value in the second column can be extracted as below:

column1 of row1 + column2 of row1 = column2 of row2

is it possible to achieve this by using JCL..

Re: inserting new row for a column

PostPosted: Thu Mar 21, 2013 8:24 pm
by Robert Sample
A terminology note: files do not have rows. Data bases have rows. Files have records. Furthermore, the number of columns for a file is the LRECL (record length) of each record (which may or may not be the same for each record). Your post is about records and fields within each record, not rows and columns.

And what you want cannot be done -- period. JCL executes programs. If you had said you wanted to do this with SORT, or COBOL, or another program -- then it may be possible. But just using JCL, all you can do is execute programs.

Re: inserting new row for a column

PostPosted: Thu Mar 21, 2013 8:35 pm
by nikesh_rai
Thanks Robert

ya. you are correct.. If possible with DFSORT or ICETOOL.. that will be better.. bcz I would like to avoid writing a COBOL program for this...

Re: inserting new row for a column

PostPosted: Thu Mar 21, 2013 9:21 pm
by prino
nikesh_rai wrote: If possible with DFSORT or ICETOOL.. that will be better.. bcz I would like to avoid writing a COBOL program for this...

Yes, you would very much prefer to sit back and let someone else write the solution for you...

Re: inserting new row for a column

PostPosted: Fri Mar 22, 2013 12:08 am
by nikesh_rai
Thanks..

Its done now.. with ICETOOL.. :)

Re: inserting new row for a column

PostPosted: Fri Mar 22, 2013 12:12 am
by enrico-sorichetti
since in the past You received quite a bit of help
it would be nice on Your side to post Your solution for future reference

Re: inserting new row for a column

PostPosted: Sat Mar 23, 2013 12:40 pm
by nikesh_rai
Thanks Enrico/Prins,

Here is the code for ref:

//TOOLIN   DD *                                               
  COPY FROM(INDD) TO(OUT01) USING(CTL1)                       
  COPY FROM(OUT01) TO(OUT02) USING(CTL2)                     
  COPY FROM(OUT02) TO(OUT03) USING(CTL3)                     
  COPY FROM(OUT02) TO(OUT04) USING(CTL4)                     
  SPLICE FROM(OUT04) TO(OUT05) ON(103,4,ZD) WITH(01,90)    - 
         WITH(110,10) KEEPNODUPS                             
//CTL1CNTL DD *                                               
  OUTFIL PARSE=(%01=(ABSPOS=01,FIXLEN=90),                   
                %02=(ABSPOS=91,STARTAT=NONBLANK,FIXLEN=04)), 
         BUILD=(1:%01,/,1:90X,95:%02,99:42X)                 
//CTL2CNTL DD *                                               
  INREC  IFTHEN=(WHEN=GROUP,BEGIN=(01,90,CH,EQ,C' '),         
                 END=(01,90,CH,NE,C' '),RECORDS=2,           
                 PUSH=(103:ID=4))                             
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(01,50,CH,NE,C' '),         
                 RECORDS=1,PUSH=(110:ID=4))                   
//CTL3CNTL DD *                       
  OPTION COPY                         
  INCLUDE COND=(103,4,CH,EQ,C' ')     
//CTL4CNTL DD *                       
  OPTION COPY                         
  INCLUDE COND=(103,4,CH,NE,C' ')     
/*                                 

concatenation of OUT03 and OUT05 is giving me output as expected after applying OMIT for the last line
here is my input

@1         WXXX-HXXX-DXX-PX-IX                         10.                 12      12
@7         WXXX-HXXX-PX-IX                             10.                 12      24
@13        WXXX-BXXX-EXXX-CXX-CX                       $1.                  3      27
@14        WXXX-PXXX-BXXX-IX                           $8.                 10      37
@22        WXXX-BXXX-EXXX-CX                           $8.                 10      47
@30        WXXX-BXX-SXX-DX                             $10.                12      59


and the output is:

@1         WXXX-HXXX-DXX-PX-IX                         10.                 12     
@7         WXXX-HXXX-PX-IX                             10.                 12      12
@13        WXXX-BXXX-EXXX-CXX-CX                       $1.                  3      24
@14        WXXX-PXXX-BXXX-IX                           $8.                 10      27
@22        WXXX-BXXX-EXXX-CX                           $8.                 10      37
@30        WXXX-BXX-SXX-DX                             $10.                12      47


Please suggest me if there is a better way to do this.. bcz this code gives me a feeling like I have coded too much line for this small requirement.

Re: inserting new row for a column

PostPosted: Sat Mar 23, 2013 1:23 pm
by BillyBoyo
Although what is being done is different from what you want (it is showing the difference between successive lines) you should be able to base a "running total" on this itself or with the JOINKEYS-type solutions linked-to in the two posts at the bottom.

http://ibmmainframes.com/about60582.html

Re: inserting new row for a column

PostPosted: Sat Mar 23, 2013 1:45 pm
by nikesh_rai
Thanks Billy,

actually summation was done in previous step.. In this step i have just put the whole last column down to one row...and got the result.. but I will check with JOINKEYS as well if i can do the same..

Re: inserting new row for a column

PostPosted: Sat Mar 23, 2013 2:57 pm
by BillyBoyo
Yes, either technique can be used for taking data from one record and putting it on another. Putting it on the "next" record is the most straightforward.

How did you do the summation?