100% found this document useful (1 vote)
1K views8 pages

Subfiles in As/400 For Programmers

This document discusses subfiles in AS/400 and provides examples of using message subfiles. It explains the three types of subfiles - Load All, Load on Demand [SIZ>PAG], and Load on Demand [SIZ=PAG]. It also provides examples of DDS keywords used to define subfile and control records like SFLCTL, SFLMSG, SFLPGMQ, SFLSIZ, SFLPAG. The document shows how to create a message file and add error messages to display in a message subfile within an RPG program using keywords like SFLMSGRCD and SFLPGMQ.

Uploaded by

JohnJaneson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views8 pages

Subfiles in As/400 For Programmers

This document discusses subfiles in AS/400 and provides examples of using message subfiles. It explains the three types of subfiles - Load All, Load on Demand [SIZ>PAG], and Load on Demand [SIZ=PAG]. It also provides examples of DDS keywords used to define subfile and control records like SFLCTL, SFLMSG, SFLPGMQ, SFLSIZ, SFLPAG. The document shows how to create a message file and add error messages to display in a message subfile within an RPG program using keywords like SFLMSGRCD and SFLPGMQ.

Uploaded by

JohnJaneson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

3/26/2015

ISeriesAs400Bloggertime:Subfile
0

More NextBlog

CreateBlog SignIn

ISeriesAs400Bloggertime

ShowingpostswithlabelSubfile. Showallposts
SATURDAY,1JUNE2013

BLOGARCHIVE

LABELS

2013(64)

AS400 (14)

June(18)
DDS(Data
Descriptio
n
Specificati
ons.)

SubfileTypes

Explain about sub files in AS/400.


Ifwewanttoaccessmultiplerecords,thenwehavetogosubfiles.Therearethreetypesofsubfiles.
i. Loadallbythismethodwehavetoloadonly9999records.Herethepageupand

pagedownhasbeencontrolbysystem.Inthismethodsubfilesizeisgreaterthan
subfilepage.
ii. Loadondemand[SIZ>PAG]bythismethodwecanloadonly9999records.Here

thepageupcontrolcanbecontrolledbysystemandusercontrolsthepagedown.In
thismethodsubfilesizeisgreaterthansubfilepage.
1. iii.Loadondemand[SIZ=PAG]bythemethodwecanloadunlimitedrecords.
2. HereusercontrolsbothofthePageupandPagedown.Inthismethodsubfilesizeis
3. equaltosubfilepage.Thistypeismoreadvantage
Postedbysivarazzmat08:21

Nocomments:

Recommend this on Google

Labels:Subfile

Subfilekeywords

DB2
Keywords
RPGIII,IV
OPCODE
REFERAN
CES

As400 Interview
Questions (5) CL

Programs

(8)

RPGLE
Programs
(17) Sub file
(9)

Sub Procedures

(3)

DB2/400
Keywords
As/400
Numbers
As400
Questions
and
answers
byusers
AS/400
System
O.S
(Operating
System/40
0)
DDS(Data
Descriptio
n
Specificati
ons.)
DataAreas
CL/400
Interview
Questions

Explain all Subfile keywords.

Data
Structure

SFLENTERThisrecordlevelkeywordusedtoassignasarollupkey.Youcandefineanotherkeyfor
enterpurpose.

Exception/Err
or
Handling

SFLINZThisrecordlevelkeywordisusedtoinitializetheSubfile.

Arrays
concepts

SFLLINThisrecord level keyword is used to define how many spaces are to be inserted between
Subfilerecords.
SFLMSGThisrecordlevelkeyword,whichidentifiesthesubfile,isaMessageSubfile.
SFLMSGIDThisrecordlevelkeywordisusedaslikeasSFLMSG.Hereyoujustputthe
messageIDinsteadofhardcodingthemessagetext.
SFLMSGKEYThisrecordlevelkeywordisusedtospecifythefieldusedasmessagekey.

OpenQuery
File
Subfile
Types

Hist

Subfile
keywords
Checkyour
subfile
skills
May(46)

SFLMSGRCDThisrecordlevelkeywordisusedtospecifywhatline#,wherethemessagehastobe
displayed.
SFLPGMQThiskeywordspecifiestheprogrammessagequeuethatconfirmstheSubfilerecordsfor

http://as400error.blogspot.in/search/label/Sub%20file

1/8

3/26/2015

ISeriesAs400Bloggertime:Subfile
amessageSubfile.
SFLNXTCHGThisrecordlevelkeywordisusedtomarktheSubfilerecordsasbeingchanged.
SFLPAG This record level keyword is used to determine how many Subfile records to show per
displayscreen.
SFLROLVALThisrecordlevelkeywordidentifiestheno.recordstoroll,wheneverarollup/rolldown
keyispressed.
SFLSIZThisrecordlevelkeywordisusedtosettheinitialsizeofSubfile
SFLDROP This record level keyword. The program first displays the Subfile in truncated mode
[displayinonelineform].Whentheuserpressestheassociatedkey,itwilldisplayfoldedform.
SFLFOLDThisrecordlevelkeyword.TheprogramfirstdisplaystheSubfileinfoldedmode[displayin
multiplelineform].Whentheuserpressestheassociatedkey,itwilldisplaytruncatedform.
SFLMODEThisrecordlevelkeywordisusedtotellwhethertheSubfileisindropmodeorfoldmode.
Ifthemode=1meansDropmodeandthemodeis0meansFoldmode.
SFLENDControlsthedisplayofplussign.
SFLRCDNBRControlswhatSubfilepageisdisplayedandwherecursorgoes.
SFLRNARecordnotactiveusedtomakethefileinactive.

Postedbysivarazzmat08:19

Nocomments:

Recommend this on Google

Labels:Subfile

Checkyoursubfileskills

WHY SUBFILES IN AS400


1.ExplainSubfile.
Toaccessmultiplerecordsatatime,wecanusesubfiles.Itmakeseasytheusertaskthathecan
workwithgroupofrecord.Ithastworecordformats.
1.SubfileRecord
2.SubfileControlRecord
2.WhatisaSubfilecontrolrecord?
Therecordthatcontrolsthedisplayoftherecordformatandtextinformation
3.WhatisaSubfilerecordformat?
Therecordthatcontainsthedisplayabledata.
4.WhatmustfollowtheSFLCTLkeywordintheSubfilecontrolrecord?
ThenameoftheSubfileRecordFormat.

5.WhatarethemandatorykeywordsfordeclareSubfile.
SFL,SFLCTL,SFLDSP,SFLSIZandSFLPAG
SFL
ItdefinestherecordisSubfilerecord.
SFLCTL
Itdefinestherecordisacontrolrecord.
SFLDSP
Itistodisplaythedataisthedisplayscreen.
SFLSIZ
ItidentifiestheSubfilesize.ThemaxsizeforLoadallis9999.
SFLPAG
Itidentifiestheno.ofrecordtobedisplayedatatime.ForloadallitshouldbelessthanSFLSIZ
6.WhatisRelativeRecordNumber[RRN]?
RelativeRecordNumber[RRN]isauniquenumeralvalueusedtopositionrecordsinSubfile.

http://as400error.blogspot.in/search/label/Sub%20file

2/8

3/26/2015

ISeriesAs400Bloggertime:Subfile

7.WhatDDSkeywordsarerequiredwhendefiningacontrolrecordformat?
SFLCTL,SFLDSPCTL,SFLPAG,SFLSIZ.
8.Whatarethe3typesofsubfiles?
Singlepage,expandableandloadall.
9.WhichtypeofSubfilehasthebetterperformance?
Singlepage.
10.WhatisaSubfilerecordnumber?
TheinternalvalueassociatedwiththeeachSubfilerecord.
11.WhatdoesO.S400controllingofSubfilemean?
In Load All Subfile if we press the Page Up or Page Down key the controlwill not go to the
programandtheO.S.400willtakethecontrolandredisplaytheprecedingorsucceedingrecords.
ThissimplifiesthecodingandifthebeginningorendofSubfilereachedthentheO.S400will
automaticallydisplaythemessagelikeEndOfFileReached.
12.WhywouldonetakecontroloverrollingofSubfilerecord?
Itwillreducethetimetakentoredisplaytherecordsifthereislargerecords.Ifwedefinetheroll key
thenthecontrolwillreturntoprogramwhiletherollkeyispressed.Theprogramthenaddsnewrecords
anddisplay.
13.HowwillyougetaPlussigninSubfile?
ByspecifyingtheSFLENDkeyword.Ifwespecify*MorewithSFLENDthenthewordMORE
willbeatlowerrightcornerwhichindicatesmorerecordsarethereinSubfilethandisplayingandifend
offilereachedthenitwilldisplayBOTTOM.
14.HowdoesCLRLwork?CompareitwithOVERLAY.
ThiskeywordisusedtoClearandControlspecificnumberoflinesfromthescreen.Italsohelps
to overlap two record formats without the first format is being cleared completely. Only those lines
clearedfromthefirstformataredeleted,allotherlineswillremaininthescreen.
If we specify CLRL (*NO) for a format then no line will be cleared. So if a record format is
overlayedthenthelinesofthepreviousformatwillnotbedeletedbutjustoverlayed.
It is not in case of OVERLAY. If any line in the first format in the overlaps then the complete
formatwillbedeletedbeforenextformatdisplay.
15.WhatdoyoumeanbySFLRCDNBR?
ItmeansSubfilerecordnumber.Thisisusedinloadalltype.
SupposewearelivinginthirdpageandifwepressEnterkey,thenthecontrolwill go to first
page.Soifwemovethepositionof378to379oftheFileInformationDataStructuretoahiddenfield
thentheRRNvalueandSubfileRecordNumberwillbesame.Sothecontrolwillbeinthelivingpage.
WecannotuseSFLRCDNBRandSFLROLVALsimultaneously.
16.WhatdoestheSFLNXTCHGkeywordmean?
ItmeansSubfileNextChange.ItactivatestheREADCoperationandmarkrecordsaschanged
records.
Suppose the READC operation reads fifth or sixth changed record and if modify a second or
firstrecordthenREADCwontreadthatrecord.ForthisweactivatetheSFLNXTCHGkeywordwithan
indicator.SoifwechangearecordthatindicatorwillsetonandREADCwillreadallchangedrecord.
Postedbysivarazzmat08:15

Nocomments:

Recommend this on Google

Labels:Subfile

FRIDAY,31MAY2013

MESSAGESubfiles

MESSAGESubfiles
Createthemessagefileandtheerrormessages.Issuethefollowingcommands:
MESSAGESUBFILE:

http://as400error.blogspot.in/search/label/Sub%20file

3/8

3/26/2015

ISeriesAs400Bloggertime:Subfile

CRTMSGFMSGF(MYLIB/TSTMSGF)
ADDMSGDMSGID(ERR0001)MSGF(MYLIB/TSTMSGF)MSG('Exampleoferrormessage')

DISPLAYFILE:
MessageSubfile:
ARMSGSFLSFL
ASFLMSGRCD(24)
AM@MSGKSFLMSGKEY
AM@PGMQSFLPGMQ(10)
MessageSubfileControl:
ARMSGCTLSFLCTL(MSGSFL)
A41SFLDSP
A43SFLDSPCTL
A40SFLCLR
A42SFLEND
ASFLSIZ(0010)
ASFLPAG(0001)

RPGPROGRAM:
InitializeMessageSubfileinExtendedFSpecificationasbelow
FSFILE(MSGSFL:W$RRN1)
SubroutineClearMessageSubfile
C#CLRMGBegSr
*
CSetOn40
CSetOff414243
CWriteMsgCtl
CSetOff4041
CSetOn4243
CZAdd*ZEROW$RRN1
*
CEndSr
ClearSubroutine:
SetoffSFLDSP,SFLDSPCTL
SetonSFLCLR
SetoffSFLEND
ClearMSGCTL
SetoffSFLDSP,SFLCLR
SetonSFLDSPCTL,SFLEND
SubroutineWriteMessageSubfile
C#SDMSGBegSr
*
CSetOn41
CCall'SSM720C1'
CParmP$MGID7
CParm'CCCMSGF'P$MSGF10
CParmP$MGVL80
CParmP$MSGK4
CParmP$CSTS1
*
CEvalM@MSGK=P$MSGK
CAdd1W$RRN1
CWriteMsgSfl

http://as400error.blogspot.in/search/label/Sub%20file

4/8

3/26/2015

ISeriesAs400Bloggertime:Subfile

*
CEvalP$MGVL=*BLANK
*
CEndSr
CLPROGRAM:
PGMPARM(&MSGID&MSGF&MSGVAL&MSGKEY&CMPSTS)
DCLVAR(&MSGID)TYPE(*CHAR)LEN(7)
DCLVAR(&MSGF)TYPE(*CHAR)LEN(10)
DCLVAR(&MSGVAL)TYPE(*CHAR)LEN(80)
DCLVAR(&MSGKEY)TYPE(*CHAR)LEN(4)
DCLVAR(&CMPSTS)TYPE(*CHAR)LEN(1)
CHGVARVAR(&CMPSTS)VALUE('0')
SNDPGMMSGMSGID(&MSGID)MSGF(*LIBL/&MSGF)+
MSGDTA(&MSGVAL)KEYVAR(&MSGKEY)
MONMSGMSGID(CPF0000)EXEC(CHGVARVAR(&CMPSTS)+
VALUE('1'))
EXIT:ENDPGM

UsingRRNtoChaintoSubfiles
WecanuseRRNtochaintosubfiletoreadallrecords(thismightbeparticularlyusefulinEDITABLE
subfilessincewemayhavetoreadallrecords)
Rrn=1
DoWhileRrn<=SubfileRrn
RrnChainSubfile

(.xxx.)
UpdateSubfile
Rrn=Rrn+1
EndDo
(Updatethesubfileifyouwanterrorstobehighlighted)

AllrecordscanalsobereadfromasubfilebymakingSFLNXTCHG=ONandthendoingaREADC.

Postedbysivarazzmat22:26

Nocomments:

Recommend this on Google

Labels:Subfile

THURSDAY,30MAY2013

CheckingRecordLocksWhileUpdatingPFinSubfiles

CheckingRecordLocksWhileUpdatingPFinSubfiles

RPGLE
Checkfor%STATUSafterdoingaCHAIN(E)tofile.
If%STATUS=01218,thenrecordislocked.
RPG
Checkforstatuscode01218inthefileinformationdatastructure(INFDS).

http://as400error.blogspot.in/search/label/Sub%20file

5/8

3/26/2015

ISeriesAs400Bloggertime:Subfile

DeclareINFDStoFspecificationinKeywordscolumnINFDSFILEDS
Now,declareFILEDSasbelow
IFIELDSDS
I*STATUSSTAT
Now,inprogram,afterCHAIN,checkforSTAT=01218

Postedbysivarazzmat10:49

Nocomments:

Recommend this on Google

Labels:Subfile

MESSAGESubfiles

MESSAGESubfiles
Createthemessagefileandtheerrormessages.Issuethefollowingcommands:
MESSAGESUBFILE:
CRTMSGFMSGF(MYLIB/TSTMSGF)
ADDMSGDMSGID(ERR0001)MSGF(MYLIB/TSTMSGF)MSG('Exampleoferrormessage')

DISPLAYFILE:
MessageSubfile:
ARMSGSFLSFL
ASFLMSGRCD(24)
AM@MSGKSFLMSGKEY
AM@PGMQSFLPGMQ(10)
MessageSubfileControl:
ARMSGCTLSFLCTL(MSGSFL)
A41SFLDSP
A43SFLDSPCTL
A40SFLCLR
A42SFLEND
ASFLSIZ(0010)
ASFLPAG(0001)

RPGPROGRAM:
InitializeMessageSubfileinExtendedFSpecificationasbelow
FSFILE(MSGSFL:W$RRN1)
SubroutineClearMessageSubfile
C#CLRMGBegSr
*
CSetOn40
CSetOff414243
CWriteMsgCtl
CSetOff4041
CSetOn4243

http://as400error.blogspot.in/search/label/Sub%20file

6/8

3/26/2015

ISeriesAs400Bloggertime:Subfile

CZAdd*ZEROW$RRN1
*
CEndSr
ClearSubroutine:
SetoffSFLDSP,SFLDSPCTL
SetonSFLCLR
SetoffSFLEND
ClearMSGCTL
SetoffSFLDSP,SFLCLR
SetonSFLDSPCTL,SFLEND
SubroutineWriteMessageSubfile
C#SDMSGBegSr
*
CSetOn41
CCall'SSM720C1'
CParmP$MGID7
CParm'CCCMSGF'P$MSGF10
CParmP$MGVL80
CParmP$MSGK4
CParmP$CSTS1
*
CEvalM@MSGK=P$MSGK
CAdd1W$RRN1
CWriteMsgSfl
*
CEvalP$MGVL=*BLANK
*
CEndSr
CLPROGRAM:
PGMPARM(&MSGID&MSGF&MSGVAL&MSGKEY&CMPSTS)
DCLVAR(&MSGID)TYPE(*CHAR)LEN(7)
DCLVAR(&MSGF)TYPE(*CHAR)LEN(10)
DCLVAR(&MSGVAL)TYPE(*CHAR)LEN(80)
DCLVAR(&MSGKEY)TYPE(*CHAR)LEN(4)
DCLVAR(&CMPSTS)TYPE(*CHAR)LEN(1)
CHGVARVAR(&CMPSTS)VALUE('0')
SNDPGMMSGMSGID(&MSGID)MSGF(*LIBL/&MSGF)+
MSGDTA(&MSGVAL)KEYVAR(&MSGKEY)
MONMSGMSGID(CPF0000)EXEC(CHGVARVAR(&CMPSTS)+
VALUE('1'))
EXIT:ENDPGM

UsingRRNtoChaintoSubfiles
WecanuseRRNtochaintosubfiletoreadallrecords(thismightbeparticularly
usefulinEDITABLEsubfilessincewemayhavetoreadallrecords)
Rrn=1
DoWhileRrn<=SubfileRrn
RrnChainSubfile

(.xxx.)
UpdateSubfile
Rrn=Rrn+1
EndDo
(Updatethesubfileifyouwanterrorstobehighlighted)

AllrecordscanalsobereadfromasubfilebymakingSFLNXTCHG=ONandthendoinga
READC.

http://as400error.blogspot.in/search/label/Sub%20file

7/8

3/26/2015

ISeriesAs400Bloggertime:Subfile

Postedbysivarazzmat10:47

Nocomments:

Recommend this on Google

Labels:Subfile

Home

OlderPosts

Subscribeto:Posts(Atom)

PictureWindowtemplate.PoweredbyBlogger.

http://as400error.blogspot.in/search/label/Sub%20file

8/8

You might also like