Ü
STRSDA:
Create a Message subfile record format using record type SFLMSG
Message subfile
·
Message subfile
as the name signifies is a subfile of messages. It is a special subfile
specially designed to hold messages.
·
Message subfile loads
itself automatically at runtime loads with the messages from program message
queue to display it on the screen.
·
To load the
subfile we simply fill the message queue with the messages and link the subfile
with that message queue.
·
Similarly to
clear the subfile, we clear the message queue.
·
Message subfile
can be used in a case we want to display multiple error/information messages at
the same time on the screen or other way it can be used to display additional
information for a particular error message like what should be done in a case
it appears. More precisely we can say that by using this we can display 2nd
level messages by programming with great ease.
·
How many
messages we want to display on the screen, it depends on SFLPAG value.
Steps to create Message subfile
ü
Step (1)
Create message file that
will store all the messages having all the messages required.
CRTMSGF
AMIT/AM_MSGF
ADDMSGD
MSGID(MSG0001) MSGF(AMIT/AM_MSGF) MSG('THE ACCOUNT NUMBER IS NOT VALID')
Like this we add all the messages to the message file AM_MSGF.
Finally all the added messages can be
seen with the command as below:
DSPMSGD RANGE(*FIRST *LAST)
MSGF(AMIT/AM_MSGF) DETAIL(*BASIC)
Display Message Descriptions
System: USALID09
Message file: AM_MSGF Library: AMIT
Position to . . . . . . . Message ID
Type options, press Enter.
5=Display details 6=Print
Opt Message ID Severity Message Text
MSG0001 1 ORG CODE CAN NOT BE BLANK
MSG0002 0 THE ACCOUNT NUMBER CAN NOT BE BLANK
MSG0003 0 THE ACCOUNT CURRENCY CAN NOT BE BLANK
MSG0004 0 THE PARTY NUMBER CAN NOT BE BLANK
MSG0011 0 THE ORGANISATION CODE SHOULD BE EITHER 190 191 192
MSG0012 0 THE ACCOUNT NUMBER SHOULD BE PREFIXED WITH A
MSG0013 0 THE CURRENCY CAN BE THEREE CHARACTER CODE e.g. EUR,
MSG0014 0 THE PARTY NUMBER SHOULD START WITH PREFIX 'P'
MSG0015 0 THE CURRENCY CAN BE'THREE'CHARACTER CODE e.g. EUR
MSG0099 0 ORGANISATION CODE, ACCOUNT NUMBER , CURRENCY AND PA
Bottom
F3=Exit F5=Refresh F12=Cancel
ü Step
(2)
·
Type STRSDA on command line and
open SCREEN DESIGN AID.
Screen Design Aid (SDA)
Select one of the following:
1. Design screens
2. Design menus
3. Test display files
Selection or command
===> 1___________________________________________________________________
_________________________________________________________________________
F1=Help F3=Exit F4=Prompt F9=Retrieve F12=Cancel
·
Take option-1
Design Screens
Type choices, press Enter.
Source file . . . . . . . . QRPGLESRC Name, F4 for list
Library . . . . . . . . . AMIT Name, *LIBL, *CURLIB
Member . . . . . . . . . . ACC_DSPFC Name, F4 for list
F3=Exit F4=Prompt F12=Cancel
·
Press ENTER
Work with Display Records
File . . . . . . : QRPGLESRC Member . . . . . . : ACC_DSPFC
Library . . . . : AMIT 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
(No records in file)
Bottom
F3=Exit F12=Cancel F14=File-level keywords
F15=File-level comments F17=Subset F24=More keys
·
Enter the display file name.
Here it is ACC_DSPF.
Add New Record
File . . . . . . : QRPGLESRC Member . . . . . . : ACC_DSPFC
Library . . . . : AMIT Source type . . . : DSPF
Type choices, press Enter.
New record . . . . . . . . . . . . . . . HEADER Name
Type . . . . . . . . . . . . . . . . . . RECORD RECORD, USRDFN
SFL, SFLMSG
WINDOW, WDWSFL
PULDWN, PDNSFL
MNUBAR
F3=Exit F5=Refresh F12=Cancel
·
Design HEADER record.
ACCOUNT ENTRY DISPLAY
ORG 999-
ACC BBBBBBBBBBBB
CCY BBB
PARTY BBBBBBBBBBBB
·
Add new record FOOTER.
Add New Record
File . . . . . . : QRPGLESRC Member . . . . . . : ACC_DSPFC
Library . . . . : AMIT Source type . . . : DSPF
Type choices, press Enter.
New record . . . . . . . . . . . . . . . FOOTER Name
Type . . . . . . . . . . . . . . . . . . RECORD RECORD, USRDFN
SFL, SFLMSG
WINDOW, WDWSFL
PULDWN, PDNSFL
MNUBAR
F3=Exit F5=Refresh F12=Cancel
·
Below we can see the two
records have been created.
Work with Display Records
File . . . . . . : QRPGLESRC Member . . . . . . : ACC_DSPFC
Library . . . . : AMIT 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 HEADER RECORD 07/06/12
20 FOOTER RECORD 05/18/12
Bottom
F3=Exit F12=Cancel F14=File-level keywords
F15=File-level comments F17=Subset F24=More keys
·
Now add a record of type
SFLMSG. It will ask for Subfile and control record format. Here ACCSFL and
ACCCTL names have been given for this.
Add New Record
File . . . . . . : QRPGLESRC Member . . . . . . : ACC_DSPFC
Library . . . . : AMIT Source type . . . : DSPF
Type choices, press Enter.
New record . . . . . . . . . . . . . . . ACCSFL Name
Type . . . . . . . . . . . . . . . . . . SFLMSG RECORD, USRDFN
SFL, SFLMSG
WINDOW, WDWSFL
PULDWN, PDNSFL
MNUBAR
Subfile control record . . . . . . . . . ACCCTL Name
F3=Exit F5=Refresh F12=Cancel
·
When
we press ENTER, it will ask for below parameters:
Ø SFLMSGRCD (subfile message
record)
This
keyword is used to give the row number where the message will be displayed on
the display screen.
Ø SFLMSGKEY (subfile message key)
All the
messages in the program message queue is associated with a unique message key.
Hence, we can display only specific messages using this subfile message key.
Ø SFLPGMQ (subfile program queue)
It
specifies the program message queue from where the messages are fetched.
Define Message Record
Subfile record . . . . . . . : ACCSFL
Type choices, press Enter.
Keyword
Line number for first message . . . . SFLMSGRCD 24 1-27
Message ID field . . . . . . . . . . SFLMSGKEY MSGKEY Name
(if program message queue is built
one message at a time)
Program message queue field . . . . . SFLPGMQ MSGQ Name
Generate a 276 byte field . . . . . Y=Yes
F3=Exit
·
After
Entering all above parameters, we select General Keywords.
Select Subfile Control Keywords
Subfile control record . . . . . . . . . : ACCCTL
Type choices, press Enter.
Y=Yes
General keywords . . . . . . . . Y
Subfile display layout . . . . .
Subfile messages . . . . . . . .
Select record keywords . . . . .
TEXT keyword . . . . . . . . . .
F3=Exit F4=Display Selected Keywords F12=Cancel
·
Make
the selection of the keywords as below.
Define General Keywords
Subfile control record . . . . . . . . . : ACCCTL
Type choices, press Enter. Keyword
Related subfile record . . . . . . . SFLCTL ACCSFL Name
Subfile cursor relative record . . . SFLCSRRRN Name
Subfile mode . . . . . . . . . . . . SFLMODE Name
Program message queue field . . . . SFLPGMQ 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 N03
Indicate more records . . . . . . . SFLEND 45
SFLEND parameter . . . . . . . . *MORE Y
SFLEND parameter . . . . . . . . *SCRBAR *MORE ...
Record not active . . . . . . . . . SFLRNA
More...
F3=Exit F12=Cancel
·
After
Entering all above parameters, we select Subfile display layout.
Select Subfile Control Keywords
Subfile control record . . . . . . . . . : ACCCTL
Type choices, press Enter.
Y=Yes
General keywords . . . . . . . .
Subfile display layout . . . . . Y
Subfile messages . . . . . . . .
Select record keywords . . . . .
TEXT keyword . . . . . . . . . .
F3=Exit F4=Display Selected Keywords F12=Cancel
·
Now
we provide the display layout parameter.
Ø SFLPAG=How many message at a time
will be displayed on the screen.
Ø SFLSIZ=What will be the buffer
size that will hold all the messages from message queue.
Define Display Layout
Subfile control record . . . . . . . . . : ACCCTL
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
·
Now
we select record keywords.
Select Subfile Control Keywords
Subfile control record . . . . . . . . . : ACCCTL
Type choices, press Enter.
Y=Yes
General keywords . . . . . . . .
Subfile display layout . . . . .
Subfile messages . . . . . . . .
Select record keywords . . . . . Y
TEXT keyword . . . . . . . . . .
F3=Exit F4=Display Selected Keywords F12=Cancel
·
Select OVERLAY keyword as
‘YES’.
Select Record Keywords
Record . . . : ACCCTL
Type choices, press Enter.
Y=Yes
General keywords . . . . . . . .
Indicator keywords . . . . . . .
Application help . . . . . . . .
Help keywords . . . . . . . . . .
Output keywords . . . . . . . . .
Input keywords . . . . . . . . .
Overlay keywords . . . . . . . . Y
Print keywords . . . . . . . . .
ALTNAME keyword . . . . . . . . .
TEXT keyword . . . . . . . . . .
F3=Exit F4=Display Selected Keywords F12=Cancel
·
Select OVERLAY keyword as
‘YES’.
Select Overlay Keywords
Record . . . : ACCCTL
Type choices, press Enter.
Keyword Y=Yes Indicators/+ Roll
Overlay without erasing . . . . . . OVERLAY Y
Retain data on re-display . . . . . PUTRETAIN
Protect all input fields . . . . . . PROTECT
Activate OVRDTA and OVRATR . . . . . PUTOVR
Override Data . . . . . . . . . . . OVRDTA
Override Attribute . . . . . . . . . OVRATR
Initialize input fields . . . . . . INZINP
Reset all modified data tags . . . . MDTOFF
MDTOFF parameter . . . . . . . . . *UNPR
*ALL
Erase all input fields . . . . . . . ERASEINP
ERASEINP parameter . . . . . . . . *MDTON
*ALL
Erase all records below . . . . . . ERASE
F3=Exit F12=Cancel
·
Finally just save the display
file.
Work with Display Records
File . . . . . . : QRPGLESRC Member . . . . . . : ACC_DSPFC
Library . . . . : AMIT 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 HEADER RECORD 07/06/12
20 FOOTER RECORD 02/13/13
30 ACCSFL SFLMSG 02/13/13
40 ACCCTL SFLCTL ACCSFL 02/13/13
Bottom
F3=Exit F12=Cancel F14=File-level keywords
F15=File-level comments F17=Subset F24=More keys
Record ACCSFL added to member ACC_DSPFC.
·
Below is the DDS of the
display file created.
Columns . . . : 1 80 Browse AMIT/QRPGLESRC
SEU==> ACC_DSPFC
FMT DP .....AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+++++++++++++++++++++++++++
*************** Beginning of data *********************************************************
0001.00 A DSPSIZ(24 80 *DS3)
0002.00 A CA03(03 'EXIT')
0003.00 A CA12(12 'PREVIOUS')
0004.00 A R HEADER
0005.00 A 1 30'ACCOUNT ENTRY DISPLAY'
0006.00 A DSPATR(HI)
0007.00 A COLOR(BLU)
0008.00 A 4 25'ORG'
0009.00 A DSPATR(HI)
0010.00 A COLOR(BLU)
0011.00 A S_ORG 3S 0B 4 35
0012.00 A FLDCSRPRG(S_ACC)
0013.00 A 50 DSPATR(RI)
0014.00 A 5 25'ACC'
0015.00 A DSPATR(HI)
0016.00 A COLOR(BLU)
0017.00 A S_ACC 12A B 5 35
0018.00 A FLDCSRPRG(S_CCY)
0019.00 A 51 DSPATR(RI)
0020.00 A 6 25'CCY'
0021.00 A DSPATR(HI)
0022.00 A COLOR(BLU)
0023.00 A S_CCY 3A B 6 35
0024.00 A FLDCSRPRG(S_PARTY)
0025.00 A 52 DSPATR(RI)
0026.00 A 7 25'PARTY'
0027.00 A DSPATR(HI)
0028.00 A COLOR(BLU)
0029.00 A S_PARTY 12A B 7 35
0030.00 A 53 DSPATR(RI)
0031.00 A R FOOTER
0032.00 A OVERLAY
0033.00 A 22 5'F3 = EXIT'
0034.00 A DSPATR(HI)
0035.00 A COLOR(BLU)
0036.00 A 22 20'F12 = CANCEL'
0037.00 A DSPATR(HI)
0038.00 A COLOR(BLU)
0039.00 A R ACCSFL SFL
0040.00 A SFLMSGRCD(23)
0041.00 A MSGKEY SFLMSGKEY
0042.00 A PGMQ SFLPGMQ(10)
0043.00 A R ACCCTL SFLCTL(ACCSFL)
0044.00 A OVERLAY
0045.00 A SFLDSP
0046.00 A SFLDSPCTL
0047.00 A SFLINZ
0048.00 A N03 SFLEND(*PLUS)
0049.00 A SFLSIZ(0003)
0050.00 A SFLPAG(0002)
0051.00 A PGMQ SFLPGMQ(10)
****************** End of data ************************************************************
ü
Step (3)
Write a program
to demonstrate message subfile
Columns . . . : 6 80 Browse AMIT/QRPGLESRC
SEU==> ACC_RPGLEC
FMT H HKeywords++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*************** Beginning of data ****************************************************
0001.00 HOPTION(*NODEBUGIO)
0002.00 H DEBUG(*YES)
0003.00 FACC_DSPFC CF E WORKSTN
0004.00 FACCOUNT UF A E K DISK
0005.00 DS_MSG S 30A
0006.00 Dtime_is S z
0007.00 Dtime_isO S 20
0008.00 *
0009.00 DCURTIMSTP DS
0010.00 DCURTIMDATE 1 16S 0
0011.00 DCURRYEAR 1 4S 0
0012.00 DCURRMONTH 5 6S 0
0013.00 DCURRDAY 7 8S 0
0014.00 DCURRHRS 9 10S 0
0015.00 DCURRMINS 11 12S 0
0016.00 DCURRSECS 13 16S 0
0017.00 C DOW *IN03=*OFF
0018.00 C 03 LEAVE
0019.00 C EXSR VALIDATE
0020.00 * IF S_MSG IS BLANK , THEN WRITE THE DATA TO PF
0021.00 C IF S_MSG=*BLANKS
0022.00 C EXSR WRITEDATA
0023.00 C ELSE
0024.00 C MOVEL 'MSG0099' S_MSG
0025.00 C EXSR SHOWMSG
0026.00 C ENDIF
0027.00 C WRITE HEADER
0028.00 C WRITE FOOTER
0029.00 C WRITE ACCCTL
0030.00 C READ HEADER
0031.00 C EXSR CLRMSGQ
0032.00 C ENDDO
0033.00 C SETON LR
0034.00 *_____________________________________________________________________
0035.00 *
0036.00 C VALIDATE BEGSR
0037.00 C SETOFF 505152
0038.00 C SETOFF 53
0039.00 C IF S_ORG=*ZEROS
0040.00 C SETON 50
0041.00 C MOVEL 'MSG0001' S_MSG
0042.00 C EXSR SHOWMSG
0043.00 C MOVEL 'MSG0014' S_MSG
0044.00 C EXSR SHOWMSG
0045.00 C ELSEIF S_ACC=*BLANKS
0046.00 C SETON 51
0047.00 C MOVEL 'MSG0002' S_MSG
0048.00 C EXSR SHOWMSG
0049.00 C MOVEL 'MSG0012' S_MSG
0050.00 C EXSR SHOWMSG
0051.00 C ELSEIF S_CCY=*BLANKS
0052.00 C SETON 52
0053.00 C MOVEL 'MSG0003' S_MSG
0054.00 C EXSR SHOWMSG
0055.00 C MOVEL 'MSG0013' S_MSG
0056.00 C EXSR SHOWMSG
0057.00 C ELSEIF S_PARTY=*BLANKS
0058.00 C SETON 53
0059.00 C MOVEL 'MSG0004' S_MSG
0060.00 C EXSR SHOWMSG
0061.00 C MOVEL 'MSG0014' S_MSG
0062.00 C EXSR SHOWMSG
0063.00 C ELSE
0064.00 C MOVEL *BLANKS S_MSG
0065.00 C SETOFF 505152
0066.00 C SETOFF 53
0067.00 C ENDIF
0068.00 C ENDSR
0069.00 *____________________________________________________________________
0070.00 *
0071.00 C WRITEDATA BEGSR
0072.00 C EVAL ORG=S_ORG
0073.00 C EVAL ACC=S_ACC
0074.00 C EVAL CCY=S_CCY
0075.00 C EVAL PARTY=S_PARTY
0076.00 C EVAL ACCSTS=2
0077.00 C EVAL ENTSTS=1
0078.00 C EVAL VERSTS=1
0079.00 C EVAL AUTSTS=1
0080.00 C EVAL RECSTS=2
0081.00 * CALCULATE THE TIME FOR THE CURRENT SYSTEM DATE
0082.00 C EVAL TIMESTP=%TIMESTAMP()
0083.00 C EVAL TIME_IS=%TIMESTAMP()
0084.00 C EVAL TIME_ISO=%char(TIME_IS:*iso0)
0085.00 C EVAL CURRYEAR=%dec(%SUBST(TIMe_ISo:1:4):4:0)
0086.00 C EVAL CURRMONTH=%dec(%SUBST(TIMe_ISo:5:2):2:0)
0087.00 C EVAL CURRDAY=%dec(%SUBST(TIMe_ISo:7:2):2:0)
0088.00 C EVAL CURRHRS=%dec(%SUBST(TIMe_ISo:9:2):2:0)
0089.00 C EVAL CURRMINS=%dec(%SUBST(TIMe_ISo:11:2):2:0)
0090.00 C EVAL CURRSECS=%dec(%SUBST(TIMe_ISo:13:4):4:0)
0091.00 C EVAL OPENDT=%DEC(%editc(CURRYEAR:'X')+
0092.00 C %editc(CURRMONTH:'X')+
0093.00 C %editc(CURRDAY:'X'):10:0)
0094.00 C WRITE REC1
0095.00 C EVAL S_ORG =*ZEROS
0096.00 C EVAL S_ACC=*BLANKS
0097.00 C EVAL S_CCY=*BLANKS
0098.00 C EVAL S_PARTY=*BLANKS
0099.00 C ENDSR
0100.00 *____________________________________________________________________
0101.00 *
0102.00 C SHOWMSG BEGSR
0103.00 * SEND MSG0001 FROM MESSAGE FILE CPF9898 TO PROGRAM MESSAGE QUEUE
0104.00 C MOVEL S_MSG MSGID
0105.00 C MOVEL 'AM_MSGF' MSGF
0106.00 C MOVE 'I' MSGOPT
0107.00 C EXSR SEND
0108.00 C ENDSR
0109.00 * - - - - - - - - - - - - - - - -- - - - - - - - -
0110.00 C CLRMSGQ BEGSR
0111.00 C MOVE 'C' MSGOPT
0112.00 C EXSR SEND
0113.00 C ENDSR
0114.00 * - - - - - - - - - - - - - - - - - - - - - - - - -
0115.00 C SEND BEGSR
0116.00 C CALL 'MSGSFLCL'
0117.00 C PARM MSGID 7
0118.00 C PARM MSGF 10
0119.00 C PARM MSGOPT 1
0120.00 C ENDSR
0121.00 *____________________________________________________________________
0122.00 C *INZSR BEGSR
0123.00 C EVAL PGMQ='ACC_RPGLEC'
0124.00 C WRITE HEADER
0125.00 C WRITE FOOTER
0126.00 C READ HEADER
0127.00 C ENDSR
****************** End of data *******************************************************
ð Below is the
called program MSGSFLCL.
Columns . . . : 1 80 Browse AMIT/QRPGLESRC
SEU==> MSGSFLCL
FMT ** ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+...
*************** Beginning of data ****************************************************
0001.01 PGM PARM(&MSGID &MSGF &MSGOPT)
0002.00 DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
0003.00 DCL VAR(&MSGF) TYPE(*CHAR) LEN(10)
0004.00 DCL VAR(&MSGOPT) TYPE(*CHAR) LEN(1)
0006.00
0007.00
0008.00 IF COND(&MSGOPT *EQ 'I') THEN(SNDPGMMSG +
0009.00 MSGID(&MSGID) MSGF(&MSGF))
0010.00
0011.00 IF COND(&MSGOPT *EQ 'C') THEN(RMVMSG PGMQ(*PRV +
0012.00 (*)) CLEAR(*ALL))
0013.00 ENDPGM
****************** End of data *******************************************************
OUTPUT
Run the program ACC_RPGLEC
Below is the first screen that we see.
ACCOUNT ENTRY DISPLAY
ORG ___
ACC ____________
CCY ___
PARTY ____________
F3 = EXIT F12 = CANCEL
Now without entering anything on this screen just press
Enter. This will result into:
(a)
The first field ORG will be
highlighted (RI) in reverse image.
(b)
Error message will display at
the bottom with 2 additional messages.
(c)
Initially we can see only 2
message at the bottom as SFLPAG = 2
(d)
But when we put the cursor at
PLUS sign at the bottom and press PAGE DOWN key, we see the 3rd
message.
ACCOUNT ENTRY DISPLAY
ORG ___
ACC ____________
CCY ___
PARTY ____________
F3 = EXIT F12 = CANCEL
ORG CODE CAN NOT BE BLANK
THE PARTY NUMBER SHOULD START WITH PREFIX 'P'
ACCOUNT ENTRY DISPLAY
ORG ___
ACC ____________
CCY ___
PARTY ____________
F3 = EXIT F12 = CANCEL
ORGANISATION CODE, ACCOUNT NUMBER , CURRENCY AND PARTY NUMBER ARE MANDATORY
Now we enter the organization code in ORG field and then
press Enter which result into:
(a)
The 2nd field ACC will be highlighted(RI) in reverse
image.
(b)
Error message will display at
the bottom with 2 additional messages.
(c)
Initially we can see only 2
message at the bottom as SFLPAG = 2
(d)
But when we put the cursor at
PLUS sign at the bottom and press PAGE DOWN key, we see the 3rd
message.
ACCOUNT ENTRY DISPLAY
ORG 190
ACC ____________
CCY ___
PARTY ____________
F3 = EXIT F12 = CANCEL
THE ACCOUNT NUMBER CAN NOT BE BLANK
THE ACCOUNT NUMBER SHOULD BE PREFIXED WITH A +
ACCOUNT ENTRY DISPLAY
ORG 190
ACC ____________
CCY ___
PARTY ____________
F3 = EXIT F12 = CANCEL
ORGANISATION CODE, ACCOUNT NUMBER , CURRENCY AND PARTY NUMBER ARE MANDATORY