Message Subfile:
Overview:
This module enables the student to understand the concept of Message Subfile.
Outline:
Topics covered,
·
Kew
words used for Message Subfile.
- How
to design Message subfile
- CL
commands related to message subfile
- Code for message subfile
Objective:
By the end of this module, the student should be
able to:
·
Understand
the concept of Kew words used for Message Subfile.
- Understand
how to design Message subfile
- Understand
CL commands related to message subfile
- Understand
code for message subfile
Introduction:
Message subfiles, are one of the most powerful, yet simple, forms
of forms of displaying multiple detail messages.
Message subfiles allow you to easily
display multiple error conditions to a display station operator so that all
error conditions can be corrected the first time. Contrast this situation to
displaying only one message at a time, correcting the error, pressing Enter,
and receiving a different error condition, which can be very aggravating.
Message subfiles are similar to regular
subfiles in that they make it much easier to display multiple messages, just
like how regular subfiles make it easier to display multiple lines of data.
However, message subfiles are defined differently in DDS and are structurally
different from the regular subfiles.
Difference
between Message Subfile and Regular Subfile
The biggest difference between message
subfiles versus the other subfiles that you have looked at is that you won’t
clear and load the message subfile in the typical manner. Message subfiles
utilize a program queue. A program message queue is a queue to which you can
send messages. Clearing a message subfile is accomplished by removing all the
messages out of a program message queue to which the subfile is linked. Loading
a message subfile can be performed automatically. If there are messages in the
program message queue when you display the subfile, they are loaded. You do not
have to have a “LOAD” routine coded in the program for a message subfile like
you do for the regular subfiles. When you display a message subfile, it can
know to automatically load itself with the records from the program message
queue to which it is linked.
How to create a Message Subfile:-
Message subfile name : MSGDSP
Source type : DSPF
Subfile Record Name : S1
Subfile Control Format : C1
The
Message Subfile Format
The message subfile needs a few different
keywords than the ones used for the regular subfiles
Creating of message subfile is similar to
normal subfile
Keywords related to message subfile
record:
- SFLMSGRCD:
Type a number between 1 and 27 to
indicate where the first message is to appear on the subfile record
display. The SFLMSGRCD keyword specifies that this subfile
will contain messages from a program message queue.
- SFLMSGKEY(message ID field):
Type the name of a hidden field
that contains the four-character message ID field. The SFLMSGKEY keyword specifies that the
program message queue is built only one message at a time.
- SFLPGMQ(program message queue field):
Type the name of the field that
contains the name of the program message queue. The system uses this message
queue to build the message subfile.
Type Y (Yes) in
the Generate a 276-byte field prompt to use 276 as the value for the
SFLPGMQ keyword. If this prompt is blank, the default
parameter for SFLPGMQ is 10.
1) Create DSPF having name ‘MSGSFL’
Work with
Members Using PDM
S653278B
File .
. . . . . MYDDS
Library . . . . PB01U01D Position to . . . . .
Type options, press Enter.
2=Edit 3=Copy 4=Delete 5=Display 6=Print 7=Rename
8=Display description 9=Save 13=Change text 14=Compile
15=Create module...
Opt
Member Type Text
17 MSGDSP
DSPF Window Subfile
Bottom
Parameters
or command
===>
F3=Exit F4=Prompt F5=Refresh F6=Create
F9=Retrieve
F10=Command entry F23=More options F24=More keys
Press enter after providing option 17 in
option button.
Work with Display
Records
File .
. . . . . : MYDDS Member . . . . . . : WINSFL
Library . . . . :
PB01U01D 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
DDS Error
1 S1
(No records in file)
Bottom
F3=Exit F12=Cancel F14=File-level keywords
F15=File-level comments F17=Subset F24=More keys
(C)
COPYRIGHT IBM CORP. 1981, 2002.
Hit
enter and change type as ‘SFLMSG’ and press enter and write name of
control format:
Add New
Record
File .
. . . . . : MYDDS Member . . . . . . : MSGDSP
Library . . . . :
PB01U01D Source
type . . . : DSPF
Type choices, press Enter.
New record . . . . . . . . . . .
. . . . S1 Name
Type . . . . . . . . . . . . . .
. . . . SFLMSG RECORD, USRDFN
SFL, SFLMSG
WINDOW, WDWSFL
PULDWN, PDNSFL
MNUBAR
Subfile control record . . . . .
. . . . C1 Name
F3=Exit
F5=Refresh F12=Cancel
Hit enter and fill subfile message record
keywords as shown below and as discussed above:
The starting message line for the subfile
has been set to be line 24, as described on the SFLMSGRCD keyword. The
message key field will be referenced inside the RPG program as KEY1, and
the program message queue will be referenced as PQ.
Define Message
Record
Subfile record . . . . . . . : S1
Type choices, press Enter.
Keyword
Line number for first message . . . .
SFLMSGRCD 24 1-27
Message ID field . . . . . . . .
. . SFLMSGKEY KEY1 Name
(if program message queue is built
one message at a time)
Program message queue field . . . . .
SFLPGMQ PQ Name
Generate a 276 byte field . . . . . Y=Yes
F3=Exit
Hit enter until the following screen
‘Select Subfile Control Keywords’ is not get display and write ‘Y’ for each
option:
The SFLDSP, SFLDSPCTL, and SFLINZ keywords
must be specified without conditioning indicators.
Select Subfile Control
Keywords
Subfile control record . . . . . . . . .
: C1
Type choices, press Enter.
Y=Yes
General keywords . . . . . . . . Y
Subfile display layout . . . .
. Y
Subfile messages . . . . . . .
. Y
Select record keywords . . . .
. Y
TEXT keyword . . . . . . . . .
.
F3=Exit
F4=Display Selected Keywords
F12=Cancel
Hit enter to ‘Define General Keyword’
screen:
Define General
Keywords
Subfile control record . . . . . . . . .
: C1
Type choices, press Enter. Keyword
Related subfile record . . . . . . .
SFLCTL S1 Name
Subfile cursor relative record . . .
SFLCSRRRN Name
Subfile mode . . . . . . . . . . . .
SFLMODE Name
Program message queue field . . .
. SFLPGMQ PQ Name
Generate a 276 byte field . . .
. Y=Yes
Y=Yes Indicators/+
Display subfile records . . . . .
. SFLDSP Y
Display control record . . . . . . .
SFLDSPCTL Y
Initialize
subfile fields . . . . . SFLINZ
Y
Delete subfile area . . . . . . .
. SFLDLT
Clear subfile records . . . . . .
. SFLCLR
Indicate more records . . . . . .
. SFLEND
SFLEND parameter . . . . . . .
. *MORE
SFLEND parameter . . . . . . .
. *SCRBAR *MORE ...
Record not active . . . . . . . .
. SFLRNA
More...
F3=Exit
F12=Cancel
Press enter to ‘Define Display Layout’ keywords
Define Display
Layout
Subfile
control record . . . . . . . . . :
C1
Type values, press Enter.
Keyword Number
Records in subfile . . . . . . . . . .
SFLSIZ 2
Program-to-system field . . . . .
.
Records per display . . . . . . .
. . SFLPAG 1
Spaces between records . . . . . . . .
SFLLIN
F3=Exit
F12=Cancel
Press enter until following screen is get
displayed:
Work with Display
Records
File .
. . . . . : MYDDS Member . . . . . . : MSGDSP
Library . . . . :
PB01U01D 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
DDS Error
10 S1 SFLMSG 03/28/05
20 C1 SFLCTL S1 03/28/05
Bottom
F3=Exit F12=Cancel F14=File-level keywords
F15=File-level comments F17=Subset F24=More keys
Record S1 added to member MSGSFL.
+
Now insert simple record having name ‘REC1’
by using option ‘1=Add’ as shown below,
Work with Display
Records
File .
. . . . . : MYDDS Member . . . . . . : MSGDSP
Library . . . . :
PB01U01D 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
DDS Error
1 REC1
10 S1 SFLMSG 03/28/05
20 C1 SFLCTL S1 03/28/05
Bottom
F3=Exit F12=Cancel F14=File-level keywords
F15=File-level comments F17=Subset F24=More keys
Record S1 added to member MSGSFL. +
Press enter 2 times to get a blank display
screen and design simple screen as shown below
Simple Message Subfile
Program
Name: BBBBBBBBBBBBBBBBBBBB
Address: BBBBBBBBBBBBBBBBBBBB
F3 : Exit
Press F3 and Compile above screen.
DDS code for above screen:
Columns . . . : 1
71 Edit PB01U01D/MYDDS
SEU==>
MSGDSP
FMT
A* .....A*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
*************** Beginning of data *************************************
0000.10 A*%%TS
SD 20050328 175621
PB01U01 REL-V5R2M0 5722-WDS
0000.20 A*%%EC
0000.30 A DSPSIZ(24
80 *DS3)
0000.40 A
R S1
SFL
0000.50 A*%%TS
SD 20050328 165505
PB01U01 REL-V5R2M0 5722-WDS
0000.60 A
SFLMSGRCD(24)
0000.70 A KEY1 SFLMSGKEY
0000.80 A PQ SFLPGMQ(10)
0000.90 A
R C1 SFLCTL(S1)
0001.00 A*%%TS
SD 20050328 165505
PB01U01 REL-V5R2M0 5722-WDS
0001.10 A CF03(03
'exit')
0001.20 A OVERLAY
0001.30 A
SFLDSP
0001.40 A
SFLDSPCTL
0001.50 A SFLINZ
0001.60 A
SFLSIZ(0002)
0001.70 A
SFLPAG(0001)
0001.80 A PQ SFLPGMQ(10)
0001.90 A
R REC1
0002.00 A*%%TS
SD 20050328 175621
PB01U01 REL-V5R2M0 5722-WDS
0002.10 A CF03(03
'exit')
0002.20 A
OVERLAY
0002.30 A 5 26'Simple
Message Subfile Pro
0002.40 A 9
19'Name:'
0002.50 A
10
19'Address:'
0002.60 A NAME 20A
B 9 32
0002.70 A ADD 20A
B 10 32
0002.80 A 18 27'F3 : Exit'
****************** End of data ****************************************
F3=Exit
F4=Prompt F5=Refresh F9=Retrieve
F10=Cursor F11=Toggle
F16=Repeat find F17=Repeat change F24=More keys
(C)
COPYRIGHT IBM CORP. 1981, 2002.
For above screen we put validations to
check that both the screen fields Name and Address are not blank.
Now following are some ‘CL’ commands must
used with above message subfile:
COMMAND
NAME
|
DESCRIPTION
|
COMMAND
ATTRIBUTES
|
CRTMSGF
|
CREATE MESSAGE FILE
|
FILE NAME, LIBRARY
|
ADDMSGD
|
ADD MESSAGE DESCRIPTION
|
MESSAGEID, MESSAGE FILE NAME, LIBRARY,
MESSAGE TEXT.
|
WRKMSGF
|
WORK WITH MESSAGE FILE
|
MESSAGE
FILE AME, LIBRARY
|
RMVMSG
|
REMOVE MESSAGE
|
MESSAGE
REALTIONSHIP, CLEAR
|
SNDPGMMSG
|
SEND PROGRAM MESSAGE
|
MESSAGE
IDENTIFIER, MESSAGE FILE, LIBRARY
|
From above commands some commands are running with CL
program such as RMVMSG, SNDPGMMSG to send message and remove message
from program queue.
In next step we will create a message file using command CRTMSGF
on command line as shown below,
Work with Members
Using PDM S653278B
File .
. . . . . MYDDS
Library . . . . PB01U01D Position to . . . . .
Type options, press Enter.
2=Edit 3=Copy 4=Delete 5=Display 6=Print 7=Rename
8=Display description 9=Save 13=Change text 14=Compile
15=Create module...
Opt
Member Type Text
STUD1 PF
STUDENT DETAILS
STUD1 PF
STUDENT DETAILS
CORS PF COURSE DETAILS
EMP PF EMPLOYEE DETAILS
EMPMST PF EMPDETAILS
More...
Parameters or command
===> CRTMSGF
F3=Exit F4=Prompt F5=Refresh F6=Create
F9=Retrieve F10=Command entry F23=More options F24=More keys
Type the command and press F4 and fill the attribute,
Create Message File
(CRTMSGF)
Type choices, press Enter.
Message file . . . . . . . . . . MSGF Name
Library . . . . . . . . . .
. PB01U01O Name, *CURLIB
Text 'description' . . . . . . . FIRST MESSAGE FILE
Bottom
F3=Exit
F4=Prompt F5=Refresh F10=Additional parameters F12=Cancel
F13=How to use this display F24=More keys
press enter to create message file ‘MSGF’ in library PB01U01O
and add message using ADDMSGD command on command line.
Work with Members Using PDM S653278B
File .
. . . . . MYDDS
Library . . . . PB01U01D Position to . . . . .
Type options, press Enter.
2=Edit 3=Copy 4=Delete 5=Display 6=Print 7=Rename
8=Display description 9=Save 13=Change text 14=Compile
15=Create module...
Opt
Member Type Text
STUD1 PF
STUDENT DETAILS
STUD1 PF
STUDENT DETAILS
CORS PF COURSE DETAILS
EMP PF EMPLOYEE DETAILS
EMPMST PF EMPDETAILS
More...
Parameters or command
===> ADDMSGD
F3=Exit F4=Prompt F5=Refresh F6=Create
F9=Retrieve F10=Command entry F23=More options F24=More keys
Press F4 to fill information,
Add Message Description
(ADDMSGD)
Type choices, press Enter.
Message identifier . . . . . . . MSG0001 Name
Message file . . . . . . . . . . MSGF Name
Library . . . . . . . . . .
. PB01U01O Name, *LIBL, *CURLIB
First-level message text . . . . 'NAME MUST ENTER'
Second-level message text . . .
*NONE
...
Severity code
. . . . . . . . . 00 0-99
More...
F3=Exit
F4=Prompt F5=Refresh F10=Additional parameters F12=Cancel
F13=How to use this display F24=More keys
Hit enter to add message in MSGF, at one
time user can add one message in file using ADDMSGD command. To add more
messages run the same command again and again.
In next step write a CL program ‘MSGCL’ where you have to
remove and send message in message queue using parameter as shown below,
Columns . . . : 1
71 Edit PB01U01S/MYCLP
SEU==> MSGCL
*************** Beginning of data *************************************
0001.00
PGM PARM(&MSGID)
0001.01 DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
0001.02 IF COND(&MSGID *EQ 'MSG0000')
THEN(DO)
0001.03 RMVMSG PGMQ(*PRV)
CLEAR(*ALL)
0001.04 RETURN
0001.05 ENDDO
0002.00 RMVMSG PGMQ(*PRV) CLEAR(*ALL)
0003.00 SNDPGMMSG MSGID(&MSGID) MSGF(PB01U01O/MSGF)
0004.00
ENDPGM
****************** End of data ****************************************
(C) COPYRIGHT IBM CORP. 1981, 2002.
Save and compile above program.
In last step pass above parameter in RPG
program and write RPG program having name ‘MSGPM’ as shown below.
Columns . . . : 1
71 Edit PB01U01S/MYRPG
SEU==>
MSGPM
*************** Beginning of data *************************************
0001.00 FMSGDSP
CF E WORKSTN
0002.00 **** MOVING RPG PROGRAM IN QUEUE
******
0003.00 C MOVEL'MSGPM' PQ
0003.01 C WRITEC1
0003.02 C
EXFMTREC1
0004.00 C *IN03 DOWEQ*OFF
0007.00 C NAME IFEQ *BLANKS
0008.00 C MOVE 'MSG0001' MSGID 7
0008.01 **** CALL CL PROGRAM TO MOVE AND CLEAR
MESSAGE ******
0009.00 C CALL 'MSGCL'
0009.01 **** PASS PARAMETER ******
0009.02 C PARM MSGID
0009.02 C WRITEC1
0009.03 C EXFMTREC1
0011.00 C ELSE
0012.00 C MOVE 'MSG0000' MSGID 7
0013.00 C CALL 'MSGCL'
0013.01
C PARM MSGID
0013.03 C WRITEC1
0013.04 C EXFMTREC1
0014.00 C ENDIF
0015.00 C ENDDO
0016.00 C SETON LR
****************** End of data ****************************************
(C)
COPYRIGHT IBM CORP. 1981, 2002.
Above RPG program send message to check
validation for NAME field only. If you want to put validation for both address
and name filed do the changes in the CL program and RPG program.
Columns . .
. : 1
71 Edit PB01U01S/MYCLP
SEU==> MSGCL1
*************** Beginning of data
*************************************
0001.00 PGM PARM(&MSGID1 &MSGID2)
0002.00 DCL VAR(&MSGID1) TYPE(*CHAR) LEN(7)
0003.00 DCL VAR(&MSGID2) TYPE(*CHAR)
LEN(7)
0004.00 IF COND(&MSGID1 *EQ 'MSG0000')
THEN(DO)
0005.00 IF COND(&MSGID2 *EQ 'MSG0000')
THEN(DO)
0006.00 RMVMSG PGMQ(*PRV) CLEAR(*ALL)
0007.00 RETURN
0008.00 ENDDO
0009.00 ENDDO
0010.00 IF COND(&MSGID1 *EQ 'MSG0001')
THEN(DO)
0011.00 IF COND(&MSGID2 *EQ 'MSG0002')
THEN(DO)
0012.00 RMVMSG
PGMQ(*PRV) CLEAR(*ALL)
0013.00 SNDPGMMSG MSGID(&MSGID1) MSGF(PB01U01S/MSGF)
0014.00 SNDPGMMSG MSGID(&MSGID2) MSGF(PB01U01S/MSGF)
0015.00 ENDDO
0016.00 ENDDO
0017.00 IF COND(&MSGID1 *EQ 'MSG0001')
THEN(DO)
0018.00 IF COND(&MSGID2 *EQ 'MSG0000')
THEN(DO)
0019.00 RMVMSG PGMQ(*PRV) CLEAR(*ALL)
0020.00 SNDPGMMSG MSGID(&MSGID1) MSGF(PB01U01S/MSGF)
0020.00 SNDPGMMSG MSGID(&MSGID1) MSGF(PB01U01S/MSGF)
0021.00 ENDDO
0022.00 ENDDO
0023.00 IF COND(&MSGID1 *EQ 'MSG0000')
THEN(DO)
0024.00 IF COND(&MSGID2 *EQ 'MSG0002')
THEN(DO)
0025.00 RMVMSG PGMQ(*PRV) CLEAR(*ALL)
0026.00 SNDPGMMSG MSGID(&MSGID2) MSGF(PB01U01S/MSGF)
0027.00 ENDDO
0028.00 ENDDO
0029.00 ENDPGM
****************** End of data
****************************************
Now
write the RPG program to pass multiple messages at a time.
Columns . . . : 1
71 Edit PB01U01S/MYRPG
SEU==>
MSGPM1
*************** Beginning of data *************************************
0001.00 FMSGDSP
CF E WORKSTN
0002.00 C MOVEL'MSGPM1' PGMQ
0003.00 C *IN03 DOWEQ*OFF
0004.00 C WRITEC1
0005.00 C EXFMTPROMPT
0006.00 C NAME IFEQ *BLANK
0007.00 C ADDR ANDEQ*BLANK
0008.00 C MOVE 'MSG0001' MSGID1 7
0009.00 C MOVE 'MSG0002' MSGID2 7
0010.00 C CALL 'MSGCL1'
0011.00
C PARM MSGID1
0012.00 C PARM MSGID2
0013.00 C ITER
0014.00 C
ENDIF
0015.00 C NAME IFEQ *BLANK
0016.00 C ADDR ANDNE*BLANK
0017.00 C MOVE 'MSG0001' MSGID1 7
0018.00 C MOVE 'MSG0000' MSGID2 7
0019.00 C CALL 'MSGCL1'
0020.00 C PARM MSGID1
0021.00 C PARM MSGID2
0022.00 C ITER
0023.00 C ENDIF
0024.00 C NAME IFNE *BLANK
0025.00 C ADDR ANDEQ*BLANK
0026.00 C MOVE 'MSG0000' MSGID1 7
0027.00
C MOVE 'MSG0002' MSGID2 7
0028.00 C CALL 'MSGCL1'
0029.00 C PARM MSGID1
0030.00 C PARM MSGID2
0031.00 C ITER
0032.00 C ENDIF
0033.00 C NAME IFNE *BLANK
0034.00 C ADDR ANDNE*BLANK
0035.00 C MOVE 'MSG0000' MSGID1 7
0036.00 C MOVE 'MSG0000' MSGID2 7
0037.00 C CALL 'MSGCL1'
0038.00 C PARM MSGID1
0039.00 C PARM MSGID2
0040.00 C ITER
0041.00 C ENDIF
0042.00 C ENDDO
0043.00 C SETON LR
****************** Endofdata****************
No comments:
Post a Comment