How to Invoke a substitutional macro-name
search cancel

How to Invoke a substitutional macro-name

book

Article ID: 221487

calendar_today

Updated On:

Products

Easytrieve Report Generator

Issue/Introduction

Is it possible to Invoke a macro-name using a substitutional macro-name parameter instead of

hard coding the macro-name within Easytrieve code?

 

Environment

Release : 11.6

Component : CA EASYTRIEVE REPORT GEN

Resolution

There is no option in Easytrieve to choose between the macros dynamically 
during the execution of a program. 
Easytrieve doesn't facilitate applying logic for the File statements 
to choose them dynamically. 


Some workarounds which may be useful 

Method 1: Using JCL symbols to dynamically change the macro name in the Easytrieve program. 
This can work only when the Easytrieve program is inline with the JCL.

Example:

// EXPORT SYMLIST=(MACNAME)                              
// SET    MACNAME=MACRO1                                
//COMP     EXEC PGM=EZTPA00                              
//STEPLIB  DD DISP=SHR,DSN=<>
//INPUT    DD DSN=<>,DISP=SHR    
//EZOPTBL  DD DSN=<>,DISP=SHR      
//MACDD    DD DISP=SHR,DSN=<>             
//SYSPRINT DD SYSOUT=*                                  
//SYSOUT DD SYSOUT=*                                    
//SYSIN DD *,SYMBOLS=JCLONLY                            
FILE INPUT                                              
%&MACNAME                                                
*                                                        
JOB INPUT INPUT                                          
DISPLAY FIRST-NAME                                      
/*                                                       

In this JCL, the variable &MACNAME would be substituted with "MACRO1"(or any name equated).


Method 2: In case there are multiple macros with the same layout, a master 
layout macro can be created which can fit in all the other sub-layouts. 

Macro1(master layout)
MACRO                                  
FIRST-NAME    1 6 A                    
SECOND-NAME   8 8 A                    
EMPLOYEE-NUM 17 8 A                    
SALARY       31 3 P MASK    '99999K'  
JOB-CAT      35 2 N                    

Macro2(sub-layout 1)
MACRO                  
FIRST-NAME2   1 6 A    
SECOND-NAME2  8 8 A    

macro3(sub-layout 3)
MACRO                
FIRST-NAME3   1 6 A  
SECOND-NAME3  8 8 A  
EMPL-NUM3    17 8 A  

Easytrieve program with all three layouts referring to the same file. 
Just that the variable names have to be different in the macros even though they map to the same field.
FILE INPUT                
%MACRO1                    
%MACRO2                    
%MACRO3                    
*                          
JOB INPUT INPUT            
DISPLAY FIRST-NAME        
DISPLAY FIRST-NAME2        
DISPLAY FIRST-NAME3        

The three DISPLAY statements here display the same data. The same would happen for storing data to these fields.

This Easytrieve program will expand to this and would point to the same file and map to similar fields.
FILE INPUT                            
%MACRO1                                
MACRO                                  
FIRST-NAME    1 6 A                    
SECOND-NAME   8 8 A                    
EMPLOYEE-NUM 17 8 A                    
SALARY       31 3 P MASK    '99999K'  
JOB-CAT      35 2 N                    
%MACRO2                                
MACRO                                  
FIRST-NAME2   1 6 A                    
SECOND-NAME2  8 8 A                    
%MACRO3                                
MACRO                                  
FIRST-NAME3   1 6 A                    
SECOND-NAME3  8 8 A                    
EMPL-NUM3    17 8 A                    
*                                      
JOB INPUT INPUT                        
DISPLAY FIRST-NAME                    
DISPLAY FIRST-NAME2                    
DISPLAY FIRST-NAME3