Wednesday, May 24, 2017

Determining the screen size

determine screen size if it is *ds3 24x80 or *ds4 27x132

Most of us are aware that TN5250 sessions (displays) on the IBM i can be configured in two sizes:

  • 24 x 80 commonly known as *DS3
  • 27 x 132 commonly known as *DS4

Most of the time IBM i operating system handles this for us, only displaying "wide" screens when my session is *DS4 and the information to be displayed is wider than 80 columns.


SEU of RPG source using *DS4 (27 x 132)

 


SEU of RPG source using *DS3 (24 x 80)

I was creating several subfile programs where I only wanted to show the data in the wider format, as the necessary columns would not fit in 80 columns. How can I detect which configuration the current session has?

The display size of the screen is dictated by the DSPSIZ keyword in the display file. This can be specified at the file and/or record level. The example below shows how I would set my display file to show in *DS4 if my session is configured to the wider size, or the narrowed *DS3 if it is not.

01 A                                      DSPSIZ(27 132 *DS4 +
02 A                                             24 80 *DS3)

If I only configure my display file with DSPSIZ(27 132 *DS4) and try execute the display on a session configured with the narrow size I receive this error message:

                     Additional Message Information

 Message ID . . . . :   CPF4169       Severity . . . . . :   40
 Message type . . . :   Escape

 Message . . . . :   The device file does not contain an entry
                     for screen size.
 Cause . . . . . :   The file TESTDSPF in library MYLIB display
                     size (DSPSIZ) parameter value is not the 
                     screen size of the device QPADEV0001.
 Recovery  . . . :   Close the file.  Change the DSPSIZ parameter
                     value. Create the file again, and then try
                     the command again.

Fortunately there are two fields in the Information Data Structure for display files that will tell me the maximum number of rows and columns for the file. Therefore, I can retrieve these numbers and determine if the session is *DS4 or *DS3.

I need just a very simple display file:

01 A                                      DSPSIZ(27 132 *DS4 +
02 A                                             24 80 *DS3)

03 A          R SCREEN
04 A                                  2  2'X'

Lines 1 and 2: The screen size dimensions.

Line 3: All display files must have a record format.

Line 4: And this record format just has a constant 'X' displayed in it.

The RPG code is also very simple:

01  *free
02  dcl-f TESTDSPF workstn infds(ScreenSize) ;

03  dcl-ds ScreenSize qualified ;
04    Rows int(5) pos(152) ;
05    Columns int(5) pos(154) ;
06  end-ds ;

07  dsply ('Rows=' + %char(ScreenSize.Rows) +
           '  Columns=' + %char(ScreenSize.Columns)) ;

08  *inlr = *on ;

line 1: Well, I am using an IBM i with version 7.3 so I am going to use totally free form RPG.

Line 2: This is the definition for the display file. The INFDS keyword gives the name I have decided to call the Information Data Structure.

Lines 3 – 6: This is the data structure's definition. It has two subfields, the first for the value of the maximum number of rows that can be displayed by this display file, line 4, and the second for maximum number of columns, line 5.

I do not have to display the record format, to get the information I need. As long as the file has been opened, which it is by the way RPG opens files at program initialization, unless it has the USROPN keyword, I have the data I need in the Information Data Structure.

Line 7: As this program is just for demonstration purposes I am just going to display the values for the number of rows and columns.

When this program is run in a session that is configured for *DS4 I see:

DSPLY  Rows=27  Columns=132

If I use another session configured for the smaller *DS3 I see:

DSPLY  Rows=24  Columns=80

My example program can easily be changed to return a parameter to a calling program to flag what size the session is configured for.

How do you change the settings for the screen size? I can explain how to do it if you are using IBM's Client Access.

  • If you are signed on to your session, signoff.
     
  • At the top of the screen in the tool bar select: "Communication"
     
  • In the drop down menu select: "Configure"
     
  • About half way down the "Configure PC5250" window there is "Size". Select the value you want. Click the "OK" button.
     
  • "PCSCC041" message window is displayed. Click the "OK" button.
     
  • The signon screen will blink away and come back as the settings for the session are changed. This is why I told you to signoff in step 1.

If you are using some other TN5250 emulation software you will have to work it out for yourself.

I have to admit if I had to I edit the DSPSIZ I would use SEU rather than SDA. But if I was going to change a display file to use only *DS4 using SDA I would need to do the following:

1. Start SDA. This option 17 in PDM.

2. At the "Work with Display Records" screen press F14 for the file level keywords.

                      Work with Display Records

 File  . . . . . . :   DEVSRC            Member . . . . . . :   TESTDSPF
   Library . . . . :     MYLIB           Source type  . . . :   DSPF

 Type options, press Enter.
   1=Add             2=Edit comments          3=Copy          4=Delete
   7=Rename          8=Select keywords       12=Design image

 Opt  Order    Record        Type      Related Subfile   Date
                        
        10    SCREEN1       RECORD                       DD/DD/DD


                                                                  Bottom
 F3=Exit                     F12=Cancel      F14=File-level keywords
 F15=File-level comments     F17=Subset      F24=More keys

3. On the "Select File Keywords" screen select "Display sizes".

                        Select File Keywords

 Member . . . :   TESTDSPF

 Type choices, press Enter.
                                     Y=Yes
   General keywords  . . . . . . . .    
   Indicator keywords  . . . . . . .    
   Print keywords  . . . . . . . . .    
   Help keywords . . . . . . . . . .    
   Display sizes . . . . . . . . . .   Y
   Alternate keywords  . . . . . . .    
   DBCS conversion . . . . . . . . .    
   Window Borders  . . . . . . . . .    
   Menu-bar keywords . . . . . . . .    


 F3=Exit   F4=Display Selected Keywords   F12=Cancel

4. If I just want to display file to open as *DS4 I just select it with a "1". If I want to display *DS4 as my first choice, and *DS3 as the second then I would put a "2" next to the *DS3 as well.

                        Select Display Sizes

 Member . . . :   TESTDSPF

 Type order (1-4) to select display sizes, press Enter.
                     DSPSIZ         MSGLOC

 Order   Size     Display Name   Message Line
   1     27x132     *DS4              28      1-28
         24x80      *DS3              25      1-25


 F3=Exit   F12=Cancel

 

My finished programs display the subfile with 132 columns. As I can now determine the session's screen size if I call the program with a session configured as *DS3 I will present a screen that tells me I need to change my configuration.

 

You can learn more about this from the IBM website:

 

This article was written for IBM i 7.3, and should work for earlier releases too.

3 comments:

  1. Might be a little simpler to set up a subproc that uses the QsnQryModSup API. That can retrieve a lot of information about the device that is connected. There's a good example from Douglas Handy in this thread on Midrange.com https://archive.midrange.com/rpg400-l/200011/msg00361.html

    ReplyDelete
  2. We use screens that may be displayed either *DS3 or *DS4. Here's how we handle it:
    A DSPSIZ(24 80 *DS3
    A 27 132 *DS4)
    A *DS3 MSGLOC(24)
    A *DS4 MSGLOC(27)
    A PRINT
    A R RTVACD01 SFL
    A SEL 1Y 0H SFLCHCCTL
    A ACCODE R H REFFLD(ADJCODE/ACCODE ADJCODE)
    A ACDESC R O 5 5REFFLD(ADJCODE/ACDESC ADJCODE)
    A R RTVACD02 SFLCTL(RTVACD01)
    A 50 DSPMOD(*DS4)
    A *DS3 SFLSIZ(0195)
    A *DS4 SFLSIZ(0195)
    A *DS3 SFLPAG(0008)
    A *DS4 SFLPAG(0008)
    A *DS3 WINDOW(RTVACD03)
    A *DS4 WINDOW(RTVACD03)
    A OVERLAY
    A 91 SFLDSP
    A SFLDSPCTL

    In this case the default is *DS3 unless the calling program passes a value that will set the DSPMOD keyword to *DS4. This allows the window screen to be displayed over any size full screen without removing the background screen.

    ReplyDelete
    Replies
    1. How do stop users from viewing the screen in *DS3 and make them see it in *DS4?

      Delete

To prevent "comment spam" all comments are moderated.
Learn about this website's comments policy here.

Some people have reported that they cannot post a comment using certain computers and browsers. If this is you feel free to use the Contact Form to send me the comment and I will post it for you, please include the title of the post so I know which one to post the comment to.