dynamic jcl through Rexx



IBM's Command List programming language & Restructured Extended Executor

dynamic jcl through Rexx

Postby coolpinky » Fri Jun 07, 2013 10:25 pm

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??
coolpinky
 
Posts: 11
Joined: Fri Jun 07, 2013 4:58 pm
Has thanked: 0 time
Been thanked: 0 time

Re: dynamic jcl through Rexx

Postby Akatsukami » Fri Jun 07, 2013 10:28 pm

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.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: dynamic jcl through Rexx

Postby coolpinky » Sat Jun 08, 2013 4:28 pm

Can you please give me guidelines on how to use ISPF for above case ( in case you can share a example / workcase )

Thanks
coolpinky
 
Posts: 11
Joined: Fri Jun 07, 2013 4:58 pm
Has thanked: 0 time
Been thanked: 0 time

Re: dynamic jcl through Rexx

Postby Pedro » Sat Jun 08, 2013 7:03 pm

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.
Pedro Vera
User avatar
Pedro
 
Posts: 684
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: dynamic jcl through Rexx

Postby Akatsukami » Sat Jun 08, 2013 7:35 pm

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
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: dynamic jcl through Rexx

Postby Akatsukami » Sat Jun 08, 2013 7:39 pm

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.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: dynamic jcl through Rexx

Postby Akatsukami » Sat Jun 08, 2013 8:48 pm

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.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: dynamic jcl through Rexx

Postby coolpinky » Sat Jun 08, 2013 11:22 pm

Could you please explain what are you doing in the above step./.
coolpinky
 
Posts: 11
Joined: Fri Jun 07, 2013 4:58 pm
Has thanked: 0 time
Been thanked: 0 time

Re: dynamic jcl through Rexx

Postby Akatsukami » Sat Jun 08, 2013 11:41 pm

coolpinky wrote:Could you please explain what are you doing in the above step./.

And what do you find in it that requires elucidation?
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: dynamic jcl through Rexx

Postby dick scherrer » Sun Jun 09, 2013 6:52 am

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?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post