Display any user's screen

This tip allows you to view any user's screen right from where you are sitting.

This Content Component encountered an error

This tip allows you to view any user's screen right from where you are sitting. It works on screen sizes of 24x80 and 27x132 and automatically adjusts as required.

A typical day in a typical user support scenario: The phone rings and a confused user says that they can't do certain things on the system. You proceed to ask them for the screen ID and what they see on the screen. After an exhaustive list of questions, you finally decide to pay them a visit to see for yourself what is on their screen. You take the lift two floors down and finally make your way to their seating place. Ahah, you finally see the screen and understand what was the bother. Your simple reply, "You should use option "B", instead of "D" to perform agent enquiries".

I don't know if that sounds familiar to you, but I have certainly found it very useful if I can immediately view their screen right from where I was sitting. It would save the hassle of finding my way to another department just to look at their screen. Well, this is what this tip is all about.

It consists of four main parts :

1. Two display files named SCREEN and SCREEN2.
2. DSPSCRN command.
3. DSPSCRNCL, which is the CPP for the command.
4. GETDSPCL, which reads the screen and sends it to a data queue.


Display file SCREEN

 
 *                                                                         
 *  Member .....: SCREEN                                                   
 *  Type .......: DSPF                                                     
 *  Compile ....: CRTDSPF FILE(QGPL/SCREEN) +                              
 *                  SRCFILE(YOURLIB/QDDSSRC)                               
 *                                                                         
A                                      DSPSIZ(27 132 *DS4                 -
A                                             24  80 *DS3)                 
A          R SCREEN                                                        
A                                      KEEP                                
A                                      DSPMOD(*DS3)                        
A            LINES       3564A  H                                          
A          R SCREEN80                                                      
A                                      DSPMOD(*DS3)                        
A            LINES80     1917A  O  1  2                                    
A          R SCREEN132                                                     
A                                      DSPMOD(*DS4)                        
A            LINES132    3561A  O  1  2



Display file SCREEN2
 *                                            
 *  Member .....: SCREEN2                     
 *  Type .......: DSPF                        
 *  Compile ....: CRTDSPF FILE(QGPL/SCREEN2) +
 *                  SRCFILE(YOURLIB/QDDSSRC)  
 *                                            
A          R DUMMY                            
A                                      KEEP   
A            LINES       3564A  H             
A          R SCREEN                    USRDFN 
A                                      KEEP



Command DSPSCRN. This command accepts a qualified job name which specifies the screen to capture. The qualified job must be an interactive job otherwise an exception is issued.
/*                                                            */ 
/*  Member .....: DSPSCRN                                     */ 
/*  Member type : CMD                                         */ 
/*  Compile ....: CRTCMD CMD(QGPL/DSPSCRN) PGM(QGPL/DSPSCRNCL)*/ 
/*                  SRCFILE(YOURLIB/QCMDSRC)                  */ 
/*                                                            */ 
        CMD        PROMPT('Display User Screen')                 
        PARM       KWD(JOBNAME) TYPE(*NAME) LEN(10) MIN(1) +     
                     CHOICE('Name') PROMPT('Job name')           
        PARM       KWD(JOBUSER) TYPE(*NAME) LEN(10) MIN(1) +     
                     CHOICE('Name') PROMPT('Job user')           
        PARM       KWD(JOBNUMBER) TYPE(*CHAR) LEN(6) +           
                     RANGE('000000' '999999') MIN(1) +           
                     CHOICE('000000 - 999999') PROMPT('Job +     
                     number')



CL Program DSPSCRNCL which is the CPP for DSPSCRN. Note that SCREEN and SCREEN2 display files must be compiled first.
/*                                                            */ 
/*  Member .....: DSPSCRNCL                                   */ 
/*  Member type : CLP                                         */ 
/*  Description : CPP for DSPSCRN                             */ 
/*  Compile ....: CRTCLPGM PGM(QGPL/DSPSCRNCL) +              */ 
/*                  SRCFILE(YOURLIB/QCLSRC)                   */ 
/*                                                            */ 
        PGM        PARM(&JOBNAME &USER &JOBNO)                   
        DCL        VAR(&JOBNAME) TYPE(*CHAR) LEN(10)             
        DCL        VAR(&USER)    TYPE(*CHAR) LEN(10)             
        DCL        VAR(&JOBNO)   TYPE(*CHAR) LEN(06)             
                                                                 
        DCL        VAR(&DTAQA)   TYPE(*CHAR) LEN(10)             
        DCL        VAR(&DTAQB)   TYPE(*CHAR) LEN(10)             
        DCL        VAR(&LEN)     TYPE(*DEC)  LEN(5 0) VALUE(1)   
        DCL        VAR(&WAIT)    TYPE(*DEC)  LEN(5 0) VALUE(30)  
        DCLF       FILE(SCREEN)                                  
        MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR))       
                                                                 
        CHGVAR     VAR(&DTAQA) VALUE('DSP' || &JOBNO)            
        CHGVAR     VAR(&DTAQB) VALUE('STS' || &JOBNO)            
                                                                 
/* If DTAQ doesn't exist, then create it.                     */
        CHKOBJ     OBJ(QGPL/&DTAQA) OBJTYPE(*DTAQ)                
        MONMSG     MSGID(CPF9801) EXEC(DO)                        
        CRTDTAQ    DTAQ(QGPL/&DTAQA) MAXLEN(3564)                 
        CRTDTAQ    DTAQ(QGPL/&DTAQB) MAXLEN(1)                    
        ENDDO                                                     
                                                                  
/* Clears the DTAQ, then sends a request to capture screen    */  
        CALL       PGM(QCLRDTAQ) PARM(&DTAQA 'QGPL')              
        CALL       PGM(QCLRDTAQ) PARM(&DTAQB 'QGPL')              
        CALL       PGM(QSNDDTAQ) PARM(&DTAQB 'QGPL' &LEN '*')     
                                                                  
        STRSRVJOB  JOB(&JOBNO/&USER/&JOBNAME)                     
        TRCJOB     MAXSTG(1024) EXITPGM(QGPL/GETDSPCL)            
                                                                  
        CALL       PGM(QRCVDTAQ) PARM(&DTAQA 'QGPL' &LEN &LINES + 
                     &WAIT)                                       
                                                                  
        DLYJOB     DLY(2)                                         
        TRCJOB     SET(*END) MAXSTG(1024)                         
        ENDSRVJOB                                                 
                                                                  
/* The captured screen image is returned in &LINES            */  
/* &LEN of 1920=24x80; otherwise it is 27x132 screen size      */ 
        IF         COND(&LEN *EQ 1920) THEN(DO)
            CHGVAR     VAR(&LINES80) VALUE(&LINES)                   
            SNDRCVF    RCDFMT(SCREEN80)                              
            ENDDO                                                    
            ELSE       CMD(DO)                                       
            CHGVAR     VAR(&LINES132) VALUE(&LINES)                  
            SNDRCVF    RCDFMT(SCREEN132)                             
            ENDDO                                                    
                                                                     
            GOTO       CMDLBL(FINISH)                                
                                                                     
ERROR:      SNDPGMMSG  MSG('Errors occurred in command. Display job +
                         log for more details.')                     
                                                                     
FINISH:     DLTDTAQ    DTAQ(QGPL/&DTAQA)                             
            MONMSG     MSGID(CPF0000)                                
            DLTDTAQ    DTAQ(QGPL/&DTAQB)                             
            MONMSG     MSGID(CPF0000)                                
                                                                     
            ENDPGM 

CL Program GETDSPCL, which will read the screen and send it to a data queue. Note that SCREEN and SCREEN2 display files must be compiled first.

 
     /*                                                            */ 
     /*  Member .....: GETDSPCL                                    */ 
     /*  Member type : CLP                                         */ 
     /*  Description : Reads the screen and sends it to a DTAQ     */ 
     /*  Compile ....: CRTCLPGM PGM(QGPL/GETDSPCL)  +              */ 
     /*                  SRCFILE(YOURLIB/QCLSRC)                   */ 
     /*                                                            */ 
             PGM        PARM(&NOTUSED)                                
             DCL        VAR(&NOTUSED) TYPE(*CHAR) LEN(100)            
             DCL        VAR(&DTAQA)   TYPE(*CHAR) LEN(10)             
             DCL        VAR(&DTAQB)   TYPE(*CHAR) LEN(10)             
             DCL        VAR(&LEN)     TYPE(*DEC)  LEN(5 0)            
             DCL        VAR(&WAIT)    TYPE(*DEC)  LEN(5 0) VALUE(0)   
             DCL        VAR(&JOBNO)   TYPE(*CHAR) LEN(06)             
             DCLF       FILE(SCREEN)                                  
                                                                      
             RTVJOBA    NBR(&JOBNO)                                   
             CHGVAR     VAR(&DTAQA) VALUE('DSP' || &JOBNO)            
             CHGVAR     VAR(&DTAQB) VALUE('STS' || &JOBNO)            
                                                                      
             CALL       PGM(QRCVDTAQ) PARM(&DTAQB 'QGPL' &LEN &LINES +
                          &WAIT)                                      
             IF         COND(&LEN *EQ 0) THEN(GOTO CMDLBL(FINISH))

     /* This part reads the screen contents and puts it into &LINES  */
             OVRDSPF    FILE(SCREEN) TOFILE(QGPL/SCREEN2) +            
                          LVLCHK(*NO)                                  
             CHGVAR     VAR(&LINES) VALUE(X'00021000730462')           
             SNDRCVF    RCDFMT(SCREEN)                                 
                                                                       
     /* Determines the display size:- 1920=24x80; 3564=27x132        */
             CHGVAR     VAR(&LEN) VALUE(3564)                          
             CHGVAR     VAR(&LINES) VALUE(%SST(&LINES 2 3563))         
             IF         COND(%SST(&LINES 1921 1643) *EQ ' ') +         
                          THEN(CHGVAR VAR(&LEN) VALUE(1920))           
             CALL       PGM(QSNDDTAQ) PARM(&DTAQA 'QGPL' &LEN &LINES)  
                                                                       
 FINISH:     ENDPGM 

This was first published in May 2002

Dig deeper on iSeries CL programming

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close