Example 3: Show the System i Disk Usage

RAMP-NL

Example 3: Show the System i Disk Usage


A screen wrapper can pick values out of hidden 5250 screen(s) and present it in completely different ways. This example shows the disk usage of a System i graphically:

To access the work with disk status screen type wrkdsksts in the command line. The name given to the Work with Disk Status screen in this example is "DiskStatus".

When in the disk status screen, read the %Use column of the subfile and feed the data to the graph.

*

*

* COMPONENT: STD_PANL

*

*

Function Options(*DIRECT)

Begin_Com Role(*EXTENDS #VF_AC010) Height(559) Hint(*MTXTDF_DET1) Layoutmanager(#ATLM_1) Width(557)

Define_Com Class(#PRIM_GRID) Name(#DiskSts) Displayposition(1) Height(150) Left(109) Parent(#PANL_2) Rowheight(19) Tabposition(1) Top(15) Width(212)

Define_Com Class(#PRIM_GDCL) Name(#GDCL_1) Caption('Disk Unit') Captiontype(Caption) Displayposition(1) Parent(#DiskSts) Source(#VF_ELTYPE) Width(29)

Define_Com Class(#PRIM_GDCL) Name(#GDCL_2) Caption('% Use') Captiontype(Caption) Displayposition(2) Parent(#DiskSts) Readonly(False) Source(#VF_ELTXTS) Width(30) Widthtype(Remainder)

Define_Com Class(#PRIM_GRPH) Name(#GRPH_1) Displayposition(1) Height(370) Left(0) Parent(#PANL_3) Scatterstyle(SymbolAtPoints+Solid) Surfacestyle(ConnectLinesInBlack) Tabposition(1) Top(0) Width(557) Xcaption('Disk Units') Ycaption('% Use')

Define_Com Class(#PRIM_GRCL) Name(#GRCL_1) Columnrole(Label) Displayposition(1) Parent(#GRPH_1) Source(#VF_ELTYPE)

Define_Com Class(#PRIM_GRCL) Name(#GRCL_2) Columnsymbol(HollowUpTriangle) Displayposition(2) Parent(#GRPH_1) Source(#VF_ELWIDP)

Define_Com Class(#vf_sy122) Name(#myscreen_wrapper) Displayposition(3) Height(513) Left(144) Parent(#PANL_1) Top(24) Visible(False) Width(593)

Define_Com Class(#PRIM_PANL) Name(#PANL_1) Displayposition(1) Height(559) Layoutmanager(#SPLM_1) Left(0) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(0) Width(557)

Define_Com Class(#PRIM_ATLM) Name(#ATLM_1)

Define_Com Class(#PRIM_ATLI) Name(#ATLI_1) Attachment(Center) Manage(#PANL_1) Parent(#ATLM_1)

Define_Com Class(#PRIM_SPLM) Name(#SPLM_1)

Define_Com Class(#PRIM_PANL) Name(#PANL_2) Displayposition(1) Height(185) Layoutmanager(#FWLM_1) Left(0) Parent(#PANL_1) Tabposition(2) Tabstop(False) Top(0) Width(557)

Define_Com Class(#PRIM_PANL) Name(#PANL_3) Displayposition(2) Height(370) Layoutmanager(#ATLM_2) Left(0) Parent(#PANL_1) Tabposition(3) Tabstop(False) Top(189) Width(557)

Define_Com Class(#PRIM_SPLI) Name(#SPLI_1) Manage(#PANL_2) Parent(#SPLM_1) Weight(1)

Define_Com Class(#PRIM_SPLI) Name(#SPLI_2) Manage(#PANL_3) Parent(#SPLM_1)

Define_Com Class(#PRIM_ATLM) Name(#ATLM_2)

Define_Com Class(#PRIM_ATLI) Name(#ATLI_2) Attachment(Center) Manage(#GRPH_1) Parent(#ATLM_2)

Define_Com Class(#PRIM_FWLM) Name(#FWLM_1) Direction(TopToBottom) Flowoperation(Center) Margintop(15) Spacingitems(2)

Define_Com Class(#PRIM_FWLI) Name(#FWLI_3) Manage(#DiskSts) Parent(#FWLM_1)

Define_Com Class(#PRIM_PHBN) Name(#PHBN_1) Caption('Refresh Statistics') Displayposition(2) Left(331) Parent(#PANL_2) Tabposition(2) Top(15) Width(117)

Define_Com Class(#PRIM_FWLI) Name(#FWLI_6) Manage(#PHBN_1) Parent(#FWLM_1)

Mthroutine Name(uInitialize) Options(*REDEFINE)

* Do any initialization defined in the ancestor

Invoke Method(#Com_Ancestor.uInitialize)

Set Com(#grph_1) Graphtype(Bar)

Set Com(#myscreen_wrapper) Ucommand(#com_owner)

Endroutine

Mthroutine Name(uExecute) Options(*REDEFINE)

* Do any execution logic defined in the ancestor

Invoke Method(#Com_Ancestor.uExecute)

Invoke Method(#myscreen_wrapper.MakeRampAvailable) Foraction(ShowDiskStatus)

Endroutine

Evtroutine Handling(#myscreen_wrapper.RampAvailable) Foraction(#ForAction)

* Get the employee number of the employee whose details are to be displayed.

Case (#ForAction)

When Value_Is('= ShowDiskStatus')

#myscreen_wrapper.current_form Name(#vf_eltxtl)

If (#vf_eltxtl *NE 'DiskStatus')

Invoke Method(#myscreen_wrapper.navigatetoscreen) Name('DiskStatus') Returnscreen(#vf_eltxtl)

Endif

If (#vf_eltxtl = 'DiskStatus')

#myscreen_wrapper.sendkey Key(#myscreen_wrapper.KeyF10)

#myscreen_wrapper.sendkey Key(#myscreen_wrapper.KeyF5)

#com_owner.uGetDiskStatus Gridname('uDiskStatus')

Endif

Otherwise

Use Builtin(message_box_show) With_Args(ok ok info *component ('Incorrect ForAction>>' + #ForAction.Value + '<<'))

Endcase

Endroutine

Mthroutine Name(uGetDiskStatus)

Define_Map For(*input) Class(#vf_eltxtl) Name(#GridName)

Define_Map For(*input) Class(#vf_eltxtl) Name(#nxtpage) Mandatory('+')

Define Field(#colcount) Type(*dec) Length(2) Decimals(0)

Define Field(#rowcount) Type(*dec) Length(4) Decimals(0)

Define Field(#column) Type(*dec) Length(2) Decimals(0) Default(0)

Define Field(#row) Type(*dec) Length(2) Decimals(0) Default(0)

Define Field(#colname) Type(*char) Length(50)

Define Field(#headrows) Type(*dec) Length(2) Decimals(0) Default(0)

Clr_List Named(#DiskSts)

Clr_List Named(#grph_1)

Dowhile ((#nxtpage *NE '') And (#nxtpage *NE 'Bottom'))

#myscreen_wrapper.getvalue From(#GridName.value + ".RowCount") Value(#rowcount)

#myscreen_wrapper.getvalue From(#GridName.value + ".HeadRows") Value(#headrows)

* Subtract one because the row collection is zero based.

#rowcount -= 1

Begin_Loop Using(#row) From(#headrows) To(#rowcount)

#myscreen_wrapper.getvalue From(#GridName.value + ".Columns.Count") Value(#colcount)

Begin_Loop Using(#column) To(#colcount)

#com_owner.uGetColName Ugridname(#GridName.value) Ucolnumber(#column) Ucolname(#colname)

Case (#colname)

When Value_Is(= 'Unit')

#com_owner.uGetCellValue Ugridname(#GridName.value) Ucolnumber(#column) Urownumber(#row) Ucellvalue(#vf_eltype)

When Value_Is(= 'Used')

#com_owner.uGetCellValue Ugridname(#GridName.value) Ucolnumber(#column) Urownumber(#row) Ucellvalue(#vf_eltxts)

#VF_ELWIDP := #vf_eltxts.trim.asnumber

Endcase

End_Loop

Add_Entry To_List(#DiskSts)

Add_Entry To_List(#grph_1)

End_Loop

#myscreen_wrapper.getvalue From(#GridName.value + ".Marker") Value(#nxtpage.value)

If ((#nxtpage.value *NE '') And (#nxtpage.value *NE 'Bottom'))

#myscreen_wrapper.sendkey Key(#myscreen_wrapper.KeyPageDown)

Endif

Endwhile

Endroutine

Mthroutine Name(uGetColName)

Define_Map For(*input) Class(#vf_eltxtl) Name(#uGridName)

Define_Map For(*input) Class(#vf_elnum) Name(#uColNumber)

Define_Map For(*output) Class(#vf_eltxtl) Name(#uColName)

#ucolnumber -= 1

#myscreen_wrapper.getvalue From(#uGridName.value + ".Columns(" + #uColNumber.asstring + ").Name") Value(#ucolname.value)

Endroutine

Mthroutine Name(uGetCellValue)

Define_Map For(*input) Class(#vf_eltxtl) Name(#uGridName)

Define_Map For(*input) Class(#vf_elnum) Name(#uColNumber)

Define_Map For(*input) Class(#vf_elnum) Name(#uRowNumber)

Define_Map For(*output) Class(#vf_eltxtl) Name(#uCellvalue)

#ucolnumber -= 1

#myscreen_wrapper.getvalue From(#uGridName.value + ".Columns(" + #uColNumber.asstring + ").Cells(" + #uRowNumber.asstring + ").Text") Value(#ucellvalue.value)

Endroutine

Mthroutine Name(uTerminate) Options(*REDEFINE)

* Clean up the colelction of fields on the panel

* Do any termination defined in the ancestor

Invoke Method(#Com_Ancestor.uTerminate)

Endroutine

Evtroutine Handling(#PHBN_1.Click)

Invoke Method(#myscreen_wrapper.MakeRampAvailable) Foraction(ShowDiskStatus)

Endroutine

End_Com