In the past couple of week I have been asked by several people how to condition whether a display file is shown in *DS3 (24 rows x 80 columns) or *DS4 (27 x 132) format. Rather than writing the same message to each one, I have decided to write this post so I can direct them to it.

These days I doubt if any of us IBM i developers are still using "dumb" workstations, we are all using PCs. In the settings of our 5250 emulator there is a configuration setting so we can set our emulated session to have a screen size of either 24x80 or 27x132. Personally I always configure my sessions to be 27x132.

You can see, and change, this setting depending on the emulator application you use.

Application Steps ACS Communication > Configure... > Change value in "Screen Size" Client Access Communication > Configure... > Change the value in "Size"

In a previous post I gave an example of how to tell whether a session was configured as *DS3 or *DS4 . In this post I am going to show what code you can insert into your display file and RPG program to control which format the user sees.

In these examples I am going to want to show the screen record format as *DS4 as my default. This I can set in the record level keywords of my display file:

AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+++++++++ A DSPSIZ(27 132 *DS4 A 24 80 *DS3)

The only reason I have broken this out into two lines is so I can show it in the space offered by the web editor. I could have equally well enter what is shown below.

Functions+++++++++++++++++++++ DSPSIZ(27 132 *DS4 24 80 *DS3)

In that previous post I showed how to use SDA to add the *DS3 and *DS4 to a display file.

Below is a simple display file that can be used in either size format.

AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+++++++++ 01 A DSPSIZ(27 132 *DS4 02 A 24 80 *DS3) 03 A INDARA *------------------------------------------------------- 04 A R SCREEN1 05 A 1 90'SCREEN1' 06 A *DS3 4 3 *------------------------------------------------------- 07 A R SCREEN2 08 A 99 DSPMOD(*DS3) 09 A 1 3'DS3 indicator .' 10 A ZINDICATOR 1A 1 20 11 A 3 3'SCREEN2'

Line 1 and 2: The default display size is *DS4 . If, due to the PC's configuration, *DS4 cannot be used the display will use *DS3 .

Kline 3: The INDARA keyword is needed as I always use the indicator data structure in my RPG programs.

Lines 4 – 6: In this record format the text "SCREEN1" will be display on the first row and in the 90th column, which is outside of the display range of *DS3 . Line 6 will ensure that if the display is being used in *DS3 "SCREEN1" will be displayed on the fourth row and in the third column.

Lines 7 – 11: The second record format, SCREEN2, can be displayed in both *DS3 and *DS4 on a *DS4 compatible session.

Line 8: If indicator 99 is on the record format will be displayed as *DS3 due to the value in the DSPMOD keyword. If 99 is off then the record format will be displayed in whatever the session's default size format is. I do not have to condition this keyword with an indicator. If the indicator was absent then the record format would always be displayed as *DS3 .

Lines 9 and 10: Is used to display the value of indicator 99.

I am only going to show snippets of the RPG code.

01 dcl-f DSPFILE1 workstn indds(Dspf) ; 02 dcl-ds Dspf qualified ; 03 ScreenSize ind pos(99) ; 04 end-ds ;

Line 1: The display file is defined to use the indicator data structure.

Lines 2 – 4: The indicator data structure just contains one indicator, 99, which corresponds to the indicator used for the DSPMOD .

The line below, 5, displays the first record format.

05 exfmt SCREEN1 ;

Depending upon which screen size format my display looks like:



Click on image to see a larger version

The session on the right, black, is configured at 27x132 ( *DS4 ), therefore, the text, "SCREEN1", is shown in the 90th column. While the display on the left, blue, is configured at 24x80 ( *DS3 ), and shows "SCREEN1" at the location given on line 5 of the display file, fourth column and third row.

In the second display record format the screen size is conditioned by the indicator 99, or Dspf.ScreenSize in the RPG program. If I always wanted this one record format to display at *DS3 regardless of my configuration I would still use the DSPMOD(*DS3) , but without the conditioning indicator.

06 Dspf.ScreenSize = *off ; 07 ZINDICATOR = Dspf.ScreenSize ; 08 exfmt SCREEN2 ;

When 99, Dspf.ScreenSize , is off the record format is displayed with my display's default record format.



Click on image to see a larger version

As the display on the left is configured as 24x80 it displays the record format as *DS3 . The right is configured as 27x132 and displays the record format as *DS4 .

In this next example I have turned 99, Dspf.ScreenSize , on.

09 Dspf.ScreenSize = *on ; 10 ZINDICATOR = Dspf.ScreenSize ; 11 exfmt SCREEN2 ;

Both sessions show the display as *DS3 .



Click on image to see a larger version

The people who asked me about this also asked how they could position fields in different places on the display depending on the screen size, and have different size fields displayed. I advised them to try to do both their *DS3 and *DS4 in the same record format would lead to a mess, and make it hard to maintain.

What I advised was to have two record formats, one for each configuration. If I determine the screen size I can then display one record format or another. If I used the same function key indicators and field names on both record formats, unless the fields are different sizes, most of the validation and processing would be the same.

01 dcl-f DSPFILE workstn infds(InfDs) ; 02 dcl-ds InfDs qualified ; 03 Rows int(5) pos(152) ; 04 Columns int(5) pos(154) ; 05 end-ds ; 06 dcl-s SmallScreen ind ; 07 if (InfDs.Rows = 24) ; //*DS3 24x80 08 SmallScreen = *on ; 09 endif ; 10 if (SmallScreen) ; 11 exfmt SCREEN1 ; 12 else ; 13 exfmt SCREEN2 ; 14 endif ;

Line 1: The definition for the display includes the definition for the file information data structure, INFDS .

Lines 2 – 5: I am only concerned with two subfields of the file information data structure, the ones that return the size of the configured display.

Line 6: I am going to use this indicator variable to flag which size display is configured.

Lines 7 – 9: If the display is configured to *DS3 , 24 rows x 80 columns, I set on to the indicator SmallScreen .

Lines 10 – 14: I can then use this indicator to condition which record format is displayed. SCREEN1 is designed for *DS3 , and SCREEN2 for *DS4 .

In conclusion it is possible to create a display file that will work well for both screen size configurations. You just have to be careful and take your time not to create a mess by stuffing everything into one record format.

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