inserting new row for a column



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

inserting new row for a column

Postby nikesh_rai » Thu Mar 21, 2013 8:01 pm

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..
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: inserting new row for a column

Postby Robert Sample » Thu Mar 21, 2013 8:24 pm

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.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: inserting new row for a column

Postby nikesh_rai » Thu Mar 21, 2013 8:35 pm

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...
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: inserting new row for a column

Postby prino » Thu Mar 21, 2013 9:21 pm

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...
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 635
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 28 times

Re: inserting new row for a column

Postby nikesh_rai » Fri Mar 22, 2013 12:08 am

Thanks..

Its done now.. with ICETOOL.. :)
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: inserting new row for a column

Postby enrico-sorichetti » Fri Mar 22, 2013 12:12 am

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: inserting new row for a column

Postby nikesh_rai » Sat Mar 23, 2013 12:40 pm

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.
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: inserting new row for a column

Postby BillyBoyo » Sat Mar 23, 2013 1:23 pm

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
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: inserting new row for a column

Postby nikesh_rai » Sat Mar 23, 2013 1:45 pm

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..
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: inserting new row for a column

Postby BillyBoyo » Sat Mar 23, 2013 2:57 pm

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?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Next

Return to JCL

 


  • Related topics
    Replies
    Views
    Last post