Friday, June 5, 2020

REXX: How to set RC/MAXCC from REXX?

When you run your REXX in batch using ISPSTART, even if your program crashes, the job return code/MAXCC would be zero. This is not the result you want as you might have the following steps which would depend on this RC.

So, how to set the return code from REXX?

We need to make use of the system variable ZISPFRC.

if sysvar("SYSISPF") = "ACTIVE" then do         
   zispfrc = 16                                 
   address "ISPEXEC" "VPUT (ZISPFRC) SHARED"    
end                                             
exit                                            

This piece of code would set the return code of the batch to 16.

REXX: Print SDSF Spool output using REXX

The below code helps to print the spool out to the dataset. 
FILTER command is used to uniquely select the job output when the job names are same.
FILTER works only together with AFD REFRESH command. 
The program ISFAFD is the batch support for SDSF.

This REXX takes three inputs:
  • JOBNAME
  • JOBID
  • OUTPUT Dataset Name

ARG JOBNAME JOBID TEMPFILE                                              
ADDRESS TSO                                                             
"ALLOC F(ISFIN) TRACKS SPACE(1) REU" /* USED BY SDSF */                 
"ALLOC F(ISFOUT) NEW DELETE REU " , /* USED BY SDSF */                  
"TRACKS SPACE(100,100) LRECL(133) RECFM(F,B,A) DSORG(PS)"               
"ALLOC F(TEMPPRT) DA('"TEMPFILE"("JOBID")')                             
      SHR  REUSE"                                                       
DROPBUF 0                                                               
QUEUE "PRE " JOBNAME  /* SDSF COMMANDS IN BATCH*/                       
QUEUE "H"                                                               
QUEUE "FILTER JobID EQ "JOBID                                           
QUEUE "AFD REFRESH"                                                     
QUEUE "SELECT "STRIP(JOBNAME) STRIP(JOBID)                              
QUEUE "++S"                                                             
QUEUE "PRINT FILE TEMPPRT" /* PRINT TO TEMP DATASET */                  
QUEUE "PRINT 1 999999"                                                  
QUEUE "PRINT CLOSE"                                                     
QUEUE "END"                                                             
"EXECIO" QUEUED()" DISKW ISFIN (FINIS" /* INPUT TO SDSF BATCH */        
ADDRESS ISPEXEC "SELECT PGM(ISFAFD) PARM('++32,1000')"/* INVOKE SDSF */ 
"FREE FI(ISFIN)"                                                        
"FREE FI(ISFOUT)"                                                       
"FREE FI(TEMPPRT)"                                                      
RETURN 0                                                                

Wednesday, April 8, 2020

JCL: Abend S013 SYSTEM COMPLETION CODE=013 REASON CODE=00000018

Abend S013 SYSTEM COMPLETION CODE=013  REASON CODE=00000018

AN OPEN WAS ISSUED FOR A PARTITIONED DATASET. THE SPECIFIED MEMBER NAME WAS NOT FOUND IN THE DATASET. S013 1C - AN OPEN MACRO WAS ISSUED FOR A PARTITIONED DATASET, BUT AN I/O WAS ENCOUNTERED SEARCHING THE DIRECTORY.

A mentioned PDS member in the jcl is not found during execution. The DDNAME and the dataset name could be found with this information IEC141I.

Monday, April 6, 2020

Windows 10: User Startup folder location

Windows 10 Startup Folder Location

If you want to add a program, URL or document to startup you should place its shortcut to user startup folder. By default it is located in:
C:\Users\Username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Thursday, March 5, 2020

REXX: Reading the dataset name of a DDNAME

/* REXX */
ddinfo = LISTDSI("DDNAME" "FILE")   
Say "Dataset Name: "SYSDSNAME     
Say "RC : " ddinfo
Exit

To run this REXX in background mode, use IKJEFT01 utility. Also, note LISTDSI works well with IKJEFT01 utility.

An incorrect ddname would lead to RC 16.

If the keyword "FILE" is ignored, LISTDSI would assume that the given value is a dataset name.

If you'd like to know the sysexec dataset of your profile, try "SYSEXEC" in place of the ddname. This can be run in foreground mode.

Wednesday, February 5, 2020

REXX: How to execute IMS region commands?

I have the requirement to restart the IMS region by issuing command

/STO REG <region no>

and then

/STA REG <Region Name>

How to achieve this in REXX?


Solution:

ADDRESS LINK  'CSLULXSB'                           
ADDRESS IMSSPOC                                   
"DIS SUBSYS ALL"                                   
"IMS <IMSPlex>"                     
"ROUTE <IMSPlex member>"                     
"CART DISTRAN"                                     
"/STOP REGION "REGION_NO                           
STOP_RC = CSLULGTS('STOINFO.','DISTRAN',"59")     
DO J=1 TO STOINFO.0                               
   Say STOINFO.J                                   
END                         


<IMSPlex> - Your system programmer would know it.
<IMSPlex member> - The region where your command would be executed.

Very important: You need to add your steplib for this REXX to work.

"STEPLIB ADD DA('SYSC.IMSDBCN.SDFSRESL.<IMSPlex member>') NOMSG"                    

In this library, you will find the member CSLULXSB. This is to ensure that you are adding the correct library.

Friday, January 17, 2020

REXX: Removing Junk Character in dataset using REXX

/* REXX */           
ADDRESS ISREDIT      
"MACRO"              
"C ALL P'.' ' '"     



Save this rexx under remjunk and run it over a dataset to replace all junk characters with spaces.

REXX: Reading JOB Status using REXX

/* REXX */                                                              
X = OUTTRAP('SLINE.')                                                   
"STATUS <JOBNAME> <JOBID>"                                                       
D = OUTTRAP("OFF")                                                      
count = 0                                                               
DO I = 1 TO SLINE.0                                                     
   SAY SLINE.I                                                          
     PARSE VAR SLINE.I JOBHOLDER NAME MESSAGE                           
      STRT_POS     =  POS("(",NAME,1)                                   
      END_POS      =  POS(")",NAME,1)                                   
      LENG_NAM     =  STRT_POS - 1                                      
      STRT_POSID   =  STRT_POS + 1                                      
      LENG_JOBID   =  END_POS - STRT_POSID                              
      JOBNAM       =  SUBSTR(NAME,1,LENG_NAM)                           
      JOBID        =  SUBSTR(NAME,STRT_POSID,LENG_JOBID)                
      IF MESSAGE = "EXECUTING" THEN                                     
          DO                                                            
            SAY " ONLY JOBS ON OUTPUT CAN BE BROWSED "JOBID" "MESSAGE   
          END                                                           
      IF MESSAGE = "ON OUTPUT QUEUE"   THEN                             
          DO                                                            
            COUNT = COUNT + 1                                           
          END                                                           
      IF MESSAGE = "NO JOBS FOUND" THEN                
          DO              
            SAY MESSAGE   
            RETURN        
          END             
END                       

EXIT                      

                 
Note: Replace JOBNAME and JOBID in the rexx and execute to see the results.

You may also ignore JOBID to get the list of all jobs with that job. 

"STATUS <JOBNAME>"

REXX: Setting dataset profile using REXX MACRO

/* REXX */                            
ADDRESS ISREDIT                       
"MACRO (PARM)"                        
PARM = TRANSLATE(PARM)                
IF PARM = "COBOL" ! PARM = "" THEN    
DO                                    
   "HI COBOL"                         
   "STATS ON"                         
   "CAPS OFF"                         
END                                   
IF PARM = "REXX" THEN                 
DO                                    
   "HI REXX"                          
   "STATS ON"                         
   "CAPS OFF"                         
END                                   
IF PARM = "JCL" THEN                  
DO                                    
   "HI JCL"                           
   "STATS ON"                         
   "CAPS OFF"                         
END     
EXIT               

Save this REXX macro as SETPROF.

Examples:

To set the profile for JCL :  TSO SETPROF JCL
To set the profile for REXX : TSO SETPROF REXX
To set the profile for COBOL : TSO SETPROF (or) TSO SETPROF COBOL

Executing this macro without any parameters would set the profile for COBOL. 

Thursday, October 10, 2019

REXX: Delayed-Access Columns in SDSF


To create variables for the alternate field list including delayed access columns, the below ADDRESS SDSF command should be issued.

isfprefix = "your prefix *"
rc=isfcalls('on')
address sdsf "isfexec st (alternate delayed)"
do index=1 to jobid.ix
     say timer.index
     say dater.index
end

timer and dater are alternate field variables. They are introduced into your macro by the command (alternate delayed).

 Entire list of columns in ST panel is available at List of Columns in ST Panel.


Related topics: Accessing SDSF using REXX

Thursday, May 23, 2019

Debugging REXX - Trace Instruction

The TRACE instruction has several options for tracing, two of them are "commands" or "c" and "error" or "e".

TRACE C

When "trace c"  is specified in an exec, any command that follows is traced before it is executed, then it is executed, and the return code from the command is displayed.

For example, 

/*REXX*/                     
trace c                      
"listds 'dummy.ser.ds'"      
exit                         

This example results in the following error message.

     3 *-* "listds 'dummy.ser.ds'"         
       >>>   "listds 'dummy.ser.ds'"       
DUMMY.SER.DS                               
DATA SET 'DUMMY.SER.DS' NOT IN CATALOG     
       +++ RC(8) +++                       

TRACE E

When "trace e" is specified in an exec, any host command that results in a nonzero return code is traced after it executes and the return code from the command is displayed.

If an exec includes "trace e", the exec displays error messages, the line number and the command, and the return code from the command, as follows:

DUMMY.SER.DS                             
DATA SET 'DUMMY.SER.DS' NOT IN CATALOG   
     3 *-* "listds 'dummy.ser.ds'"       
       +++ RC(8) +++                     
***                                      

Saturday, May 18, 2019

Abend 878000 hex occurred processing command 'EXEC '.

"Abend 878000 hex occurred processing command 'EXEC '." This error message occurs while executing REXX when there is insufficient virtual storage.

Possible solutions:

  • Check if you are using EXECIO * DISKR. In this case, the input data might be too large which may cause allocation error. 

          To avoid this error, execute the same REXX in background mode using JCL with maxium                    REGION parameter value. 

  • Try logging out of the session, login again and execute the REXX again.

Friday, May 17, 2019

REXX: External Functions

In addition to in built functions, REXX provides external functions to do specific tasks

SYSDSN:

This function returns OK if the specified data set exists; otherwise, it returns an appropriate error message.

The input for this function is a dataset name.

Example:

if SYSDSN(" ' Your Dataset ' ") /= 'OK' then do       
    say "Dataset doesn't exist. ' 
end

SYSVAR:

This function uses specific argument values to return information about the user, terminal, language, exec, system, and console session.

Example:

userid = SYSVAR(SYSUID)
say userid

This would return the userid who is logged in.

SETLANG:

This function is used to determine the currently language being used and also it allows us to change the language.

Example:

 curlang=SETLANG()
 say curlang 

OUTTRAP:

This function puts lines of command output into a series of numbered variables, each with the same prefix. These variables save the command output and allow an exec to process the output. Specify the variable name in parentheses following the function call.

Example:
x = OUTTRAP('att')
"LISTC"

att0 - will contain the no. of lines stored.
att1 - will contain the first line
att2 - will contain the second line and so on

you can also use STEM variables as parameter.

Example:

x = OUTTRAP('out.')
"LISTC"

out.0 - will contain the no. of lines stored.
out.1 - will contain the first line
out.2 - will contain the second line and so on

LISTDSI:

This function lists the dataset information.

Example:

x = LISTDSI(" ' Your Dataset ' ")

This statement will populate many system variables.

for ex:
SYSDSNAME
SYSRECFM 
SYSLRECL 
SYSBLKSIZE
SYSKEYLEN
SYSALLOC
SYSUSED
SYSUSEDPAGES
SYSPRIMARY
SYSSECONDS
SYSUNITS
SYSEXTENTS
SYSCREATE

Thursday, May 16, 2019

How to get the ZOS DB2 Version in mainframe?

Go to QMF or Spufi.

Execute the below query.

SELECT GETVARIABLE('SYSIBM.VERSION') FROM SYSIBM.SYSDUMMY1

The result would be of format pppvvrrm.

ppp - product string
vv  - Version
rr - Release number
m - Modification level

Example: DSN11015 means DB2 Version 11 in new-function mode.

DSN - DB2 for z/OS
11 - DB2 Verison 11
5 - modification level 5 means New-function mode.

How to get the ZOS Version in mainframes?

Enter the command TSO ISPVCALL STATUS from the console.

Output should be written to userid.ISPVCALL.TRACE.

Result would be:


The marked text is the ZOS version.

Tuesday, May 14, 2019

Integrating SceneBuilder with Eclipse

Pre-requisites:

You must download:

  • Scene Builder from gluonhq
  • Eclipse IDE must be already installed

Install SceneBuilder.exe from Gluon website


In Eclipse IDE, goto Windows à Preference à JavaFX.

Then provide the SceneBuilder.exe’s absolute path in the JavaFx preference.


Click Apply and Close.

Installing JavaFX in Eclipse

Pre-requisites:

You must download

  • JDK from Oracle
  • Java Eclipse IDE from Eclipse


In the Eclipse IDE, goto Help-> Install New Software

Use this site address : http://download.eclipse.org/efxclipse/updates-released/1.2.0/site/

Use this filter text: e(FX)clipse




Click à Next à Next à Accept license agreement à Finish

Friday, May 3, 2019

Setting last logged in User ID as default login id in windows

To set last logged in User ID as default login in windows, couple of windows registry key values must be updated.

Copy the below content and store it with extension .reg and double click it to execute it.


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"dontdisplaylockeduserid"=dword:00000001
"DontDisplayLastUserName"=dword:00000000


Once this is set, when you lock the computer or reboot the computer, the logon id would be populated with the last logged in user id.


Tuesday, April 23, 2019

GIT Command fails in VPN - fatal: unable to access

Git users may face the below issue while connecting to git while they are in VPN


fatal: unable to access 'https://github.com/user/MyProject.git/'


In order to over come this issue, the git config must be updated with proxy which is used in your VPN.

Open command prompt and enter the following command

git config --global http.proxy #ProxyServer:8080

#ProxyServer must be replaced with the IP or the full name of the proxy server.

Do not enter proxy server with https:\\ or http:\\

To ensure that you have configured correctly.

git config -l

This would list down all your configuration. In that list, you would find the value for http.proxy

http.proxy=#ProxyServer:8080


Try using the git command after configuring the proxy settings. This time, it must work.

To unset the proxy setting, use the following command

git config --global --unset http.proxy

Happy Learning!

Tuesday, December 18, 2018

Input ID and Password Text Boxes using Java Swing

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;


public class getIdAndPassword {

public String[] getUserDetails() {
String[] getUserDetails = new String[3];
JTextField userId = new JTextField(15);
JPasswordField password = new JPasswordField(15);
password.setEchoChar('*');

//the below piece of code ensures that the user cannot enter greater than 15 characters

userId.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
if (userId.getText().length() >= 15) {
e.consume();
JOptionPane.showMessageDialog(null, "Maximum characters: 15 ", "Max Limit Reached", JOptionPane.WARNING_MESSAGE);

}
}
});

//the below piece of code ensures that the user cannot enter greater than 15 characters
password.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
if (password.getPassword().length >= 15) {
e.consume();
JOptionPane.showMessageDialog(null, "Maximum characters: 15 ", "Max Limit Reached", JOptionPane.WARNING_MESSAGE);
}
}
});
JPanel myPanel = new JPanel();
myPanel.add(new JLabel("User-ID:"));
myPanel.add(userId);
myPanel.add(Box.createHorizontalStrut(15)); // a spacer
myPanel.add(new JLabel("Password:"));
myPanel.add(password);

//set your own image. Default image is "?".
//Remove the image code if you would like to use default image

ImageIcon icon = new ImageIcon("myImage.jpg");
Image image = icon.getImage();
Image newimg = image.getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH);
icon = new ImageIcon(newimg);
int result = JOptionPane.showConfirmDialog(null, myPanel, "Please Enter User-ID and Password",
JOptionPane.OK_CANCEL_OPTION,JOptionPane.NO_OPTION,icon);
if (result == JOptionPane.OK_OPTION) {
getUserDetails[0] = userId.getText();
getUserDetails[1] = String.valueOf(password.getPassword());
}
if (result == JOptionPane.CANCEL_OPTION) {
getUserDetails[0] = " ";
getUserDetails[1] = " ";
getUserDetails[2] = "CANCELLED";
System.out.println("Operation Cancelled");
}
if (result==JOptionPane.CLOSED_OPTION) {
getUserDetails[0] = " ";
getUserDetails[1] = " ";
getUserDetails[2] = "CANCELLED";
System.out.println("Operation Cancelled");
}
return getUserDetails;
}

}


This class will return the string array "getUserDetails".

Create a java main class to test the above class. Copy and paste the below code into your main method and test.

  getIdAndPassword ip=new getIdAndPassword();
  String userDetails[]=ip.getUserDetails();
  if (userDetails[0].trim().isEmpty() || userDetails[1].trim().isEmpty() || userDetails[2]=="CANCELLED")
  {
   if(userDetails[2]=="CANCELLED")
   {
    JOptionPane.showMessageDialog(null, "Aborting application ", "Abort", JOptionPane.WARNING_MESSAGE); 
    return;
   }
   else
   {
    JOptionPane.showMessageDialog(null, "Either User-ID or Password is not provided", "Insuffient Input", JOptionPane.WARNING_MESSAGE);
    return;
   }
  }
  System.out.println("User-ID  : "+userDetails[0]);
  System.out.println("Password : "+userDetails[1]);


The result would be as follows:


Input ID and Password Text Boxes using Java Swing

Featured Post

REXX Skeleton: Submitting jobs through Rexx

Submitting jobs through REXX and reading the spool through REXX gives us immense potential to automate many manual activities in mainframes....