Page 1 of 2

dynamic jcl through Rexx

PostPosted: Fri Jun 07, 2013 10:25 pm
by coolpinky
Hi..

I am using REXX to split a file to n number of files based on key..

Say my input file is
1234****
1234****
1234****
4567****
4849****
4849****

Since number of records s not fixed and number of occurences are also not fixed..I am using rexx to split input file and create 3 files in the above case dynamically..
Next I want to process these files for formatting into a particular layout..How to I build dynamic JCL for this using Rexx??

Re: dynamic jcl through Rexx

PostPosted: Fri Jun 07, 2013 10:28 pm
by Akatsukami
First, note that Rexx is not a good choice if your input is more than a thousand records or so.

I would recommend using using ISPF services to tailor a skeleton for each data set.

Re: dynamic jcl through Rexx

PostPosted: Sat Jun 08, 2013 4:28 pm
by coolpinky
Can you please give me guidelines on how to use ISPF for above case ( in case you can share a example / workcase )

Thanks

Re: dynamic jcl through Rexx

PostPosted: Sat Jun 08, 2013 7:03 pm
by Pedro
Use the PARSE statement to break your record into individual fields.

Rexx is not a good choice if your input is more than a thousand records or so.

I am not convinced that file tailoring is a good choice either. You have to invoke it a thousand times also. Or do TBADD a thousand times and then file tailoring with )DOT statement. I think rexx by itself to build a stem and EXECIO is better than 1000 ISPF service calls.

Re: dynamic jcl through Rexx

PostPosted: Sat Jun 08, 2013 7:35 pm
by Akatsukami
OK. Now, I won't have the opportunity to test for a couple of days, so I won't guarantee that it's error-free; to the left, debugging is one of the joys of the software developer's life.

Your exec will look about like this;
/* Rexx */

lastkey = ''
dsn     = ''
drop record.
"EXECIO 1 DISKR TULIN"

do while (rc=0)
  pull record.1
  thiskey = substr(record.1,1,4)
 
  if (thiskey¬lastkey) then do
    if (lastkey¬='') then do
      "EXECIO 0 DISKW TULOUT (FINIS"
      "FREE FI(TULOUT)"
      address ispexec "FTOPEN  TEMP"
      address ispexec "FTINCL  FOO"
      address ispexec "FTCLOSE"
      address ispexec "VGET ZTEMPF"
      "SUBMIT '"ztempf"'"
      dsn = "BARIN.#"thiskey
      "ALLOC FI(TULOUT) DA("dsn") NEW SPACE(1,1) TRACKS LRECL(80)",
            "RECFM(F B)"
    end

    lastkey = thiskey
  end
 
  "EXECIO 1 DISKW TULOUT (STEM RECORD.)"
  "EXECIO 1 DISKR TULIN"
end

I assume that you're running this in background ISPF, and that TULIN is allocated in the JCL. It appears that the key is the first four characters of the record; if not, adjust the parameters of the substr function accordingly.

The skeleton FOO will be:
//&SYSUID.BAR JOB other parameters
//*
//STEP0001 EXEC PGM=BAR
//BARIN    DD   DSN=&DSN,DISP=SHR
//BAROUT   DD   DSN=&SYSUID..BAROUT.#&LASTKEY,other parameters
   other DD statements as needed

Re: dynamic jcl through Rexx

PostPosted: Sat Jun 08, 2013 7:39 pm
by Akatsukami
Pedro wrote:
Rexx is not a good choice if your input is more than a thousand records or so.

I am not convinced that file tailoring is a good choice either. You have to invoke it a thousand times also. Or do TBADD a thousand times and then file tailoring with )DOT statement. I think rexx by itself to build a stem and EXECIO is better than 1000 ISPF service calls.

I'd understood (possibly incorrectly, of course) that the processing would be done on each group of records with the same key, a number that would be significantly less than the total number of records.

Re: dynamic jcl through Rexx

PostPosted: Sat Jun 08, 2013 8:48 pm
by Akatsukami
And I notice that I left out the logic for generating a skeleton to process the last group of records. That's what I get for trying to write code whilst still working on my first cigar and cup of coffee.

Re: dynamic jcl through Rexx

PostPosted: Sat Jun 08, 2013 11:22 pm
by coolpinky
Could you please explain what are you doing in the above step./.

Re: dynamic jcl through Rexx

PostPosted: Sat Jun 08, 2013 11:41 pm
by Akatsukami
coolpinky wrote:Could you please explain what are you doing in the above step./.

And what do you find in it that requires elucidation?

Re: dynamic jcl through Rexx

PostPosted: Sun Jun 09, 2013 6:52 am
by dick scherrer
Hello and welcome to the forum,

Lots of new folks struggle writing REXX with ISPF. It is another issue if the struggle is reading/understanding it. As you are relatively new to both REXX and ISPF, it will be slow going for a while.

Is there some reason to do this with REXX rather than your Sort product?