Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Rexx - File tailoring

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
samzee71

New User


Joined: 01 Feb 2010
Posts: 8
Location: Dallas, TX, USA

PostPosted: Thu Nov 30, 2017 10:47 pm    Post subject: Rexx - File tailoring
Reply with quote

I am using File Tailoring to generate jobs using templates in the skeleton library.

The template job JOBN0001 has 1100 rows, and JOBN0002 has 600 rows.

Issue:

The final generated job JOBN0001 is good and contains all 1100 rows from template JOBN0001.

The job JOBN0002 is also generated with 1100 rows instead of 600 rows.

In JOBN0002, rows 1-600 are ok, from the template job JOBN0002. Then it includes rows 601-1100 from JOBN0001.


I guess the temp buffer area needs some initialization.

Please advice a solution.

The code is below:

TMPDSN = "AAAA.BBBB.CCCC.DDDD"
JOBID = '1'

/* BUILD JOBS USING TEMPLATE JOBS */
DO UNTIL JOBID = 4
JOBID = RIGHT(JOBID,2,'0')
JOBNAME = "JOBN00" || JOBID
TMPJOB = JOBNAME
ADDRESS TSO "ALLOC FI(TMPJCL) DA('"TMPDSN"("TMPJOB")') SHR"
ADDRESS ISPEXEC "FTOPEN TEMP" /*File Tailoring*/
ADDRESS ISPEXEC "FTINCL" JOBNAME /*File Tailoring*/
ADDRESS ISPEXEC "FTCLOSE" /*File Tailoring*/
ADDRESS ISPEXEC "VGET (ZTEMPN)"
ADDRESS TSO "EXECIO * DISKR "ZTEMPN" (FINIS STEM SKEL."
ADDRESS TSO "EXECIO * DISKW TMPJCL (FINIS STEM SKEL."
ADDRESS TSO "FREE FI(TMPJCL)"
ADDRESS TSO "EXECIO * DISKW JCLFILE (STEM JCL. FINIS)"
JOBID = JOBID + 1
END
Back to top
View user's profile Send private message

daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 688
Location: Pennsylvania

PostPosted: Fri Dec 01, 2017 1:22 am    Post subject:
Reply with quote

I believe as though you have too many moving parts.
Not using TEMP output, going directly into your dataset
This setup has worked for me many times.

Try this:

Code:
/* LIBDEF for PDS for Output of File Tailoring */
ADDRESS ISPEXEC "LIBDEF ISPFILE DATASET ID('"TMPDSN"')"

/* BUILD JOBS USING TEMPLATE JOBS */
DO UNTIL JOBID = 4
  JOBID = RIGHT(JOBID,2,'0')
  JOBNAME = "JOBN00" || JOBID
  ADDRESS ISPEXEC "FTOPEN"                   /*File Tailoring*/
  ADDRESS ISPEXEC "FTINCL" JOBNAME           /*File Tailoring*/
  ADDRESS ISPEXEC "FTCLOSE NAME("JOBNAME")" /*File Tailoring*/
  JOBID = JOBID + 1
  /* You may or may not need these two lines below (I did need them) */
  ADDRESS TSO "ALLOC FI(TMPJCL) DA('"TMPDSN"') SHR"
  ADDRESS TSO "FREE FI(TMPJCL)"
END


Read more: http://ibmmainframes.com/viewtopic.php?p=342190#342190#ixzz4zwge5Qdg
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 232
Location: Maryland

PostPosted: Fri Dec 01, 2017 2:18 am    Post subject: Re: Rexx - File tailoring
Reply with quote

This statement writes the content of stem JCL.
samzee71 wrote:

Code:
ADDRESS TSO "EXECIO * DISKW JCLFILE (STEM JCL. FINIS)"

but from your fragment of code it's not clear how the stem itself is prepared?

Also: JCLFILE is constant DDNAME. Depending on DISP value, it can be either overridden, or appended - for 4 of created jobs?
Back to top
View user's profile Send private message
samzee71

New User


Joined: 01 Feb 2010
Posts: 8
Location: Dallas, TX, USA

PostPosted: Fri Dec 01, 2017 2:31 am    Post subject: Reply to: Rexx - File tailoring
Reply with quote

Thanks.

I initialized the STEM variable to make it work.
SKEL. = ''

Also, removed this statement:
ADDRESS TSO "EXECIO * DISKW JCLFILE (STEM JCL. FINIS)"
Back to top
View user's profile Send private message
samzee71

New User


Joined: 01 Feb 2010
Posts: 8
Location: Dallas, TX, USA

PostPosted: Fri Dec 01, 2017 2:35 am    Post subject:
Reply with quote

Working code:

Code:
TMPDSN = "AAAA.BBBB.CCCC.DDDD"
JOBID = '1'

/* BUILD JOBS USING TEMPLATE JOBS */
DO UNTIL JOBID = 4
   JOBID = RIGHT(JOBID,2,'0')
   JOBNAME = "JOBN00" || JOBID
   ADDRESS TSO "ALLOC FI(TMPJCL) DA('"TMPDSN"("JOBNAME")') SHR"
   ADDRESS ISPEXEC "FTOPEN TEMP"        /*File Tailoring*/
   ADDRESS ISPEXEC "FTINCL" JOBNAME     /*File Tailoring*/
   ADDRESS ISPEXEC "FTCLOSE"            /*File Tailoring*/
   ADDRESS ISPEXEC "VGET (ZTEMPN)"
   ADDRESS TSO "EXECIO * DISKR "ZTEMPN" (FINIS STEM SKEL."
   ADDRESS TSO "EXECIO * DISKW TMPJCL (FINIS STEM SKEL."
   ADDRESS TSO "FREE FI(TMPJCL)"
   SKEL. = ''
   JOBID = JOBID + 1
END
[/code]
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 232
Location: Maryland

PostPosted: Fri Dec 01, 2017 3:12 am    Post subject:
Reply with quote

Though this is not directly related to this topic issue, but I can never pass by any senseless, and/or useless statements:
Code:
TMPDSN = "AAAA.BBBB.CCCC.DDDD"

/* BUILD JOBS USING TEMPLATE JOBS */
DO JOBID = 1 To 4
   JOBNAME = "JOBN00" || RIGHT(JOBID,2,'0')
   ADDRESS TSO "ALLOC FI(TMPJCL) DA('"TMPDSN"("JOBNAME")') SHR"
   ADDRESS ISPEXEC "FTOPEN TEMP"        /*File Tailoring*/
   ADDRESS ISPEXEC "FTINCL" JOBNAME     /*File Tailoring*/
   ADDRESS ISPEXEC "FTCLOSE"            /*File Tailoring*/
   ADDRESS ISPEXEC "VGET (ZTEMPN)"
   ADDRESS TSO "EXECIO * DISKR" ZTEMPN "(FINIS STEM SKEL."
   ADDRESS TSO "EXECIO * DISKW TMPJCL (FINIS STEM SKEL."
   ADDRESS TSO "FREE FI(TMPJCL)"
END

1) loop variable supposed to be controlled by DO statement, not by several arithmetic calculation spread all over the code

2) special formatting (of JOBID) must be done ONLY where it is REALLY needed

3) "...* DISKR ... (STEM" is preparing the stem variable in full; no need to perform any reset of it

4) (minor thing, but still...) distribute quotes/spaces more reasonable, to clarify the code
Code:
   ADDRESS TSO "EXECIO * DISKR" ZTEMPN "(FINIS STEM SKEL."
/* the one above is more reasonable than the original one:
   ADDRESS TSO "EXECIO * DISKR "ZTEMPN" (FINIS STEM SKEL." */
Back to top
View user's profile Send private message
samzee71

New User


Joined: 01 Feb 2010
Posts: 8
Location: Dallas, TX, USA

PostPosted: Fri Dec 01, 2017 3:18 am    Post subject:
Reply with quote

Thanks alot to all for useful tips and solutions. I just started working on REXX.
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 232
Location: Maryland

PostPosted: Fri Dec 01, 2017 3:38 am    Post subject:
Reply with quote

I forgot one more tricky thing.

Code:
ADDRESS TSO "EXECIO * DISKW TMPJCL (FINIS STEM SKEL."

actually ignores the stem size set after DISKR in SKEL.0
Instead, it writes all lines till the first either undefined (e.g. 'STEM.nnn' value), or empty line (e.g. '' - empty string)

To make the code more robust, it is recommended to use this format:
Code:
ADDRESS TSO "EXECIO" SKEL.0 "DISKW TMPJCL (FINIS STEM SKEL."
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8619
Location: Back in jolly old England

PostPosted: Fri Dec 01, 2017 1:39 pm    Post subject:
Reply with quote

As a contractor I have found that moving from site to site there are often different rules and settings at each one and as such always tend to use ISPFILE as one that I have defined myself. The one constant I have found is that ISPFILE is the default output at every site I have worked.

It keeps it simple for me that every REXX that I create will work pretty much unchanged at any site that I work without having to wander about looking at names and DD allocations.

And of course, you could always DELETE / REDEFINE the ISPFILE so that you know it will be empty each time, and if you still get naff results then it is time to review your code icon_biggrin.gif
Code:

  "FREE  FI(ISPFILE)"
  "DEL  '"UID".ISPFILE'"
  "ALLOC FI(ISPFILE) DA('"UID".ISPFILE') NEW TRACKS SPACE(5 5)
         RECFM(F B)LRECL(80)"
.
.
.
.
/* EDIT The tailored file and submit manually   */
   "ISPEXEC FTOPEN"
   "ISPEXEC FTINCL  DEFRAG1A"
   "ISPEXEC FTCLOSE"
   "ISPEXEC EDIT DATASET('"UID".ISPFILE')"
.
.
.
.
.
/* Just submit the little bugger                */
   "ISPEXEC FTOPEN"
   "ISPEXEC FTINCL  DEFRAG1B"
   "ISPEXEC FTCLOSE"
   "SUBMIT '"UID".ISPFILE'"
Back to top
View user's profile Send private message
Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 186
Location: Switzerland

PostPosted: Fri Dec 01, 2017 2:50 pm    Post subject:
Reply with quote

I too prefer to write directly to ISPFILE, but I tried allocating a pds member to ISPFILE and it did not work, so I am using the ISPF temporary dataset here. I will investigate the failing pds output later, the manual indicates that it should work.
Anyway, this sample works for me. I like to use the REPRO command to copy between datasets with like attributes. And I also like to test statements for failures.
Code:

 address ispexec "vget ztempn"                                 
 do jobid=1 to 2                                               
  jobnr=right(jobid,2,0)  /* used in the skeleton */                                     
  address ispexec                                               
  "ftopen temp"                                                 
  if rc<>0 then exit xmsg('ftopen' jobid 'failed rc' rc,8)     
  "ftincl zskel"jobid                                           
  if rc<>0 then exit xmsg('ftincl' jobid 'failed rc' rc,8)     
  "ftclose"                                                     
  if rc<>0 then exit xmsg('ftclose' jobid 'failed rc' rc,8)     
  address tso                                                   
  "alloc dd(skelout) da('wj.lib.data1(job"jobnr")') shr reuse" 
  if rc<>0 then exit xmsg('alloc' jobid 'failed rc' rc,8)       
  "repro infile("ztempn") outfile(skelout)"                     
  if rc<>0 then exit xmsg('repro' jobid 'failed rc' rc,8)       
 end                                                           
 address tso "free dd(skelout)"                                 
 exit 0                                                         
XMsg: if arg(1)<>'' then say arg(1);return word(arg(2) 0,1)     
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8619
Location: Back in jolly old England

PostPosted: Fri Dec 01, 2017 2:57 pm    Post subject:
Reply with quote

I may be going mad .............. but

I can recall from the dark and distant past that ISPFILE was always a PS file

icon_eyes.gif

And it's quite easy to use ISPFILE for multiple jobs for submission too.
I always prefer the easy option
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 -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts ISSUE IN copying Sequential file reco... thesumitk JCL & VSAM 2 Wed Dec 13, 2017 3:07 pm
No new posts Looping REXX - unable to interrupt RAVISANKAR07 CLIST & REXX 3 Wed Dec 06, 2017 1:08 pm
No new posts The same REXX program doesnt work for... jackzhang75 CLIST & REXX 5 Wed Dec 06, 2017 2:51 am
No new posts File Tailoring -- Temporary dataset i... samzee71 CLIST & REXX 3 Fri Dec 01, 2017 3:12 am
This topic is locked: you cannot edit posts or make replies. Rexx to Grab ISMF Information. upendrasri All Other Mainframe Topics 16 Sun Nov 26, 2017 12:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us