File manager batch using a Rexx procedure

File-AID from Compuware and File Manager from IBM.
Previous topicNext topic
User avatar

Topic Author
misi01
Registered Member
Posts: 11
Joined: Tue Aug 23, 2016 7:34 pm

File manager batch using a Rexx procedure

Post by misi01 » Wed Aug 24, 2016 1:42 pm

The trouble for me, based on what I'm trying to do, is that I can't find any examples related to what I'm trying to do (and, yes, I could be going at it the wrong way, but that's simply due to my fumbling in the dark).

Okay, here's what I'm trying to do. I want to run FM in batch so that it produces my output for the first x columns only. Neither do I want any IBM boiler plate at the top of the file. Here's an example of what I've tried

Code: Select all

//EXAMPLE    EXEC FILEMNGR                            
//FMNEXEC  DD  DISP=SHR,DSN=MISI01.PRIVATE.CODE       
//SYSPRINT DD  SYSOUT=*                               
//DDIN     DD  DISP=SHR,DSN=MISI01.FOHA.Q265001       
//FMOUT     DD DSN=MISI01.FMAN.TEST,DISP=(,CATLG),    
//             RECFM=FB,LRECL=132                     
//SYSIN    DD  *                                      
ÅÅFILEM DSP INPUT=DDIN,MEMBER=BATCH,PROC=MSFILEMN     
ÅÅFILEM DSP FORMAT=TABL,                              
ÅÅFILEM TCIN=xxx.yyy.zzz(HAFOP348)                   
The Rexx code looks like this (I'm conversant with Rexx). Remember, the code here is my fumbling, trying to understand what ends up where.

Code: Select all

rname = 'MSFILENM'                                
say "Record "substr(inrec,14,11)' '               
record.0 = 1                                      
record.1 = substr(inrec,14,11)                    
address TSO "execio 1 diskw FMOUT (stem record."  
These are my results

Code: Select all

Record 00402147391                                                    
REC   10    DATA   165       01333214191560040214739120160822SE0000709
                                                                      
Record 00000000000                                                    
IBM File Manager for z/OS                                             
REC   11    DATA   165       01333214191560000000000020160822SE0000500
                                                                      
Record 00402147391                                                    
REC   12    DATA   165       01333214191560040214739120160822SE0001192
                                                                      
                                                                      
FMNBE082 12 record(s) printed                                         
ÅÅFILEM DSP FORMAT=TABL,                                              
ÅÅFILEM TCIN=SHB.PR2.COPY(HAFOP348)                                   
IBM File Manager for z/OS                                             
* * * * Device 350A, 3390, VOLSER=SMS109                      Data Set
* *     DSORG  PS, RECFM FB, LRECL 165 BLKSIZE 27885                  
Length P348-TYP-POST-HAFO P348-PERS-ORG-SHB-NR-SEKEL P348-AVKASTNKTONR
                   ZD 1:2                    ZD 3:11          ZD 14:11
                      <->               <---+----1->      <---+----1->
000165                  1                33321419123                 0
000165                  1                33321419131         402147731
000165                  1                33321419131         402147731
The quote above can be divided into the following "groups":-
Record 00402147391 (the say from my Rexx)
REC 10 DATA 165 (something printed from FM ????)
IBM File Manager for z/OS (the IBM boiler plate that I don't want)
Length P348-TYP-POST-HAFO P348-PERS-ORG-SHB-NR-SEKEL (to the end, the actual FM TABL formatting of the input file).

What I don't get from the manual (feel free to point me at the page) is how I define an output file to receive the data starting with
Length P348-TYP-POST-HAFO P348-PERS-ORG-SHB-NR-SEKEL as well as how I can "chop" the output results (the template has a large filler field at the back-end which is also printed, and that I DON'T want in the output).

So basically, I want to run the TABL command in batch using a Rexx procedure (if needed) so that only the first 100 columns are printed.



User avatar

Topic Author
misi01
Registered Member
Posts: 11
Joined: Tue Aug 23, 2016 7:34 pm

Re: File manager batch using a Rexx procedure

Post by misi01 » Wed Aug 24, 2016 2:29 pm

A follow-on to this append. I note that the manual talks about the FILEM. Rexx stem variable that can be created.
I tried this using Rexx as the output option via 0.1 and then using 3.2 to print the file I'm after.
After printing (no Rexx script specified in the Use Proc field), I pressed PF1 to see the long message and I saw this
12 record(s) stored in REXX variables
.
Based on the manual, I understand this to mean that the results are stored in FILEM., but what the manual doesn't seem to do is tell you HOW you're supposed to use these results from within FM (rather than batch). There's another catch there as well, inasmuch as the Rexx variables obviously only contain the raw (formatted) data; no headers or anything else.




Anjali Chopra
Website Team
Website Team
Posts: 93
Joined: Sun May 12, 2013 12:33 am
Zodiac: Leo

Re: File manager batch using a Rexx procedure

Post by Anjali Chopra » Wed Aug 24, 2016 3:36 pm



Regards,
Anjali

User avatar

Topic Author
misi01
Registered Member
Posts: 11
Joined: Tue Aug 23, 2016 7:34 pm

Re: File manager batch using a Rexx procedure

Post by misi01 » Wed Aug 24, 2016 3:58 pm

Anjali Chopra wrote: Use OFFSET parameters:

https://www.ibm.com/support/knowledgece ... #offsetcmd
Sorry Anjali, did I miss something there? That doesn't have anything to do with Rexx and Batch, does it?




Anjali Chopra
Website Team
Website Team
Posts: 93
Joined: Sun May 12, 2013 12:33 am
Zodiac: Leo

Re: File manager batch using a Rexx procedure

Post by Anjali Chopra » Wed Aug 24, 2016 4:18 pm

misi01 wrote: REC 10 DATA 165 (something printed from FM ????)
OFFSET can help you in removing these characters.


Regards,
Anjali

User avatar

Topic Author
misi01
Registered Member
Posts: 11
Joined: Tue Aug 23, 2016 7:34 pm

Re: File manager batch using a Rexx procedure

Post by misi01 » Wed Aug 24, 2016 5:11 pm

I'm really after some sort of help or an example as to HOW to get the example described above working. For example, where is the REC 10 DATA 165 coming from and can it be directed somewhere else using a DD-name



User avatar

Topic Author
misi01
Registered Member
Posts: 11
Joined: Tue Aug 23, 2016 7:34 pm

Re: File manager batch using a Rexx procedure

Post by misi01 » Fri Aug 26, 2016 3:34 pm

Okay, after some experimenting, the following works for me (granted, it's a far more complicated solution than the problem required, but I've almost learnt something useful for the future).

IF you do use this as a basis for your experiments, remember to change the the Å characters to $ (being In Sweden, we use the Å).
I think the main thing to remember is the differnece in what ends up in the Rexx variable FILEM. as opposed to the SP. one.

Code: Select all

/* rexx */                                                             
/*                                                                     
  An example of how to call File Manager in "batch" and catch          
  and process the formatted results                                    
                                                                       
*/                                                                     
rname = 'FMANBAT'                                                      
                                                                       
address TSO                                                            
alloc_print = "ALLOC DD(SYSPRINT) NEW LRECL(32756) RECFM(F B)",        
              "DSORG(PS) REUSE SPACE(1 1) CYL"                         
alloc_print                                                            
                                                                       
"ALLOC DD(SYSIN) NEW LRECL(80) RECFM(F B) DSORG(PS) REUSE SPACE(1) TRA"
                                                                       
i = 1                                                                  
/* The commands sent to FM. We want the results written to the         
   REXX stem variable FILEM. (filem. is hard-coded in FM */            
parm.i = "ÅÅFILEM SET PRINTOUT=REXX"  ; i=i+1                          
/* The input file we want "formatted" as well as HOW we want it done */
parm.i = "ÅÅFILEM DSP DSNIN='MISI01.FOHA.Q265001',FORMAT=TABL,"; i=i+1 
/* The copybook describing the format layout */                        
parm.i = "ÅÅFILEM TCIN=xxx.xxx.xxx(HAFOP348)"   ; i=i+1               
                                                                    
parm.0 = i - 1                                                      
                                                                    
/* Write the commands to SYSIN */                                   
"EXECIO * DISKW SYSIN (STEM parm. FINIS"                            
"CALL *(FMNMAIN) '/BATCH'"                                          
if rc <> 0 then                                                     
  do                                                                
    SAY 'Rc from call to FMAN 'rc                                   
    return 1                                                        
  end                                                               
                                                                    
/* After this, SP. will contain all the "garbage" generated by FM */
"EXECIO * DISKR SYSPRINT (STEM SP. FINIS"                           
/* do ms = 1 to sp.0; say ms left(sp.ms,70); end */                 
                                                                    
i = 1                                                               
                                                                    
/* -CLNR is the last "real" column we're interested in. After this, 
   HAFOP348 contains a field P348-FILLER OCCURS 76 TIMES PIC X.     
   whereupon FM then creates 76 columns of data for each index      
   in the filler field (not really what we're after). */            
sw_length = 0 ; o = 0; last_field = '-CLNR '                        
                                                                    
DO I = 1 TO filem.0                                                 
  select                                                            
    when sw_length = 0 & left(filem.i,7) == 'Length ' then          
      do                                                            
        /* The first row of "real" data; the column headers.        
           Look for the position of the last field we're interested 
           in .... */                                               
        y = pos(last_field,filem.i)                                 
        y = (y + length(last_field)) - 8                            
        o = o + 1                                                   
        /* Throw away the junk at the start ... */                  
        temp = substr(filem.i,8)                                    
        /* ... and the filler fields after -CLNR */                 
        output.o = substr(temp,1,y)                                 
        sw_length = 1                                               
      end                                                           
    when left(filem.i,8) == 'FMNBE082' then                         
      nop   /* Not of interest */                                   
    when sw_length = 1 then                                         
      do                                                            
        o = o + 1                                                   
        temp = substr(filem.i,8)                                    
        output.o = substr(temp,1,y)                                 
      end                                                           
    otherwise                                                       
      nop                                                           
  end                                                               
END                                                                 
output.0 = o                                                      
/* trace ?a */                                                    
if o > 0 then                                                     
  do                                                              
    /* Nothing failed, and output. contains the formatted file */ 
    fman_file = "FMAN.LIST"                                       
    X = OUTTRAP('TEMP.')                                          
    x = LISTDSI(fman_file)                                        
    if x = 0 then                                                 
      do                                                          
        "delete "fman_file                                        
        if rc <> 0 then                                           
          do                                                      
            rc = file_busy(fman_file)                             
            return 1                                              
          end                                                     
      end                                                         
    /* Allocate th eoutput file and write the data to it */       
    alloc_fmanout = "ALLOC DD(FMANOUT) da("fman_file")",          
                    "NEW LRECL("length(output.1)") RECFM(F B)",   
                    "REUSE SPACE(1 1) CYL"                        
    alloc_fmanout                                                 
    "EXECIO "o" DISKW FMANOUT (STEM output. FINIS"                
    "FREE DD(FMANOUT)"                                            
        X = OUTTRAP('OFF')                                                 
    rc = file_written(o, fman_file)                                    
  end                                                                  
                                                                       
"FREE DD(SYSIN SYSPRINT)"                                              
                                                                       
return 0                                                               
/**********************************************************************
                                                                       
**********************************************************************/
file_written:                                                          
arg nr_records, filename                                               
zedsmsg = nr_records' records written'                                 
zedlmsg = nr_records' records were written to 'filename                
address ispexec 'SETMSG MSG(ISRZ001)'                                  
return 0                                                               
/********************************************************************** 
                                                                        
**********************************************************************/ 
file_busy:                                                              
arg filename                                                            
zedsmsg = ''                                                            
zedlmsg = 'Could not delete 'filename' - do you have it',               
          'open for edit in another window?'                            
signal exit2                                                            
return 0                                                                
/********************************************************************** 
                                                                        
**********************************************************************/ 
exit2:                                                                  
/* say 'In exit2 in 'rname ; trace ?a */                                
Address ISREDIT                          /* Pass all cmd to EDIT      */
                                                                        
address ispexec                                                         
'SETMSG MSG(ISRZ001)'                                                   
x = MSG("OFF")                                                          
address TSO "FREE DD(DDIN SYSIN SYSPRINT)"                              
a = MSG(x)        /* reset message value */                             
                                                                        
exit 1                                                                  



User avatar

Anuj Dhawan
Founder
Posts: 2611
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Zodiac: Sagittarius

Re: File manager batch using a Rexx procedure

Post by Anuj Dhawan » Fri Aug 26, 2016 6:26 pm

Thanks for posting what has worked for you [username|#8040BF|bold|2848]misi01[/username]. This is an excellent gesture. Appreciate your efforts! :good:


Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.

Previous topicNext topic

Return to “File-AID and IBM File Manager.”