PML For Create Reports
Published on January 11, 2016
Mansyur Usman FollowingUnfollow
AVEVA PDMS / E3D ADMINISTRATOR / PML DEVELOPER DEVELOPER26 articles
20
Like
Comment
1
2
Write an article
------------------------------------------------------------------------------------------------------------------- Copyright (c) UNSRI 2016 -- File: MANSYURGRIDREPORT.pmlfrm -- Author: Mansyur Usman (
[email protected]),Sriwijaya University (UNSRI) Palembang Indonesia -- Created: Bandung, Jan 11 2016 -- Description: To create and display Report for PDMS and Aveva E3D -- Note : change Aveva.Pdms.Presentation to Aveva.core.Presentation if you used Aveva E3D 2.1 and above -- Semoga bermanfaat -----------------------------------------------------------------------------------------------------------------KILL!!MANSYURGRIDREPORT import 'PMLFileBrowser' handle (1000,0) endhandle import 'GridControl' handle (1000,0) endhandle using namespace 'Aveva.Pdms.Present 'Aveva.Pdms.Presentation' ation' setup form !!MANSYURGRIDREPORT size 60 12 !this.formTitle = 'Reports Form for PDMS & Aveva E3D' !this.iconTitle !this.iconTitle = 'Report' !this.initcall !this.initcall = '!this.initialise()' '!this.initialise()' !CTIME = OBJECT DATETIME() hdist 1 halign centre path right vdist 0.5 frame .frmScope 'PDMS & Aveva E3D Reports' at x0 y0 anchor T+L+R width 60 button.bt '0.' backg white callback callback '!this.pilih()' '!this.pilih()' at x0 x0 y0 text .bt1 '' at 6 0 width 15 is string button.bn 'Create 'Create Report for for CE' linklabel linklabel callback callback '!this.create()' '!this.create()' at x0 y1.5 y1.5 button.DIS 'Dismiss' Dismiss' linklabel linklabel callback callback 'kill!!MANSYUR 'kill!!MANSYURGRIDRE GRIDREPORT' PORT' at x0 y2.5 paragraph .p1 AT AT 26 0 text 'By By : Mansyur Usman Usman (mansyur.usm@gma (
[email protected])' il.com)' width width 33 lines 1 paragraph .p2 AT AT 26 1 text 'Bandung, Bandung, 11 January January 2016' width width 20 lines 1 exit path down frame .frmselected 'Selected Elements' at x0 y6 width 60 height 10 container .conSelected nobox PMLNetCONTROL 'NET' at xmin dock fill exit menu .mnupopup popup !this.mnupopup.add( 'CALLBACK', 'Add to 3D view','!this.addToView()', 'ADD3DVIEW' ) !this.mnupopup.add( 'SEPARATOR' ) !this.mnupopup.add( 'CALLBACK', 'Remove selected list in Grid','!this.removeFromList()', 'REMOVE') !this.mnupopup.add( 'CALLBACK', 'Remove all list in Grid','!this.ngcSelected.clearGrid()', 'REMOVEALL') !this.mnupopup.add( 'SEPARATOR' ) !this.mnupopup.add( 'CALLBACK', 'Export to Excel...','!this.exportToExcel()', 'EXCEL' ) !this.mnupopup.add( 'CALLBACK', 'Print Preview...','!this.printList()', 'PRINT' ) !this.mnupopup.add( 'CALLBACK', 'Go to Element...','!this.GoToElement()', 'elemen' ) member .ngcSelected is NETGRIDCONTROL member .headings is ARRAY member .debug is BOOLEAN member .sftgrid is SFTGRIDDATA exit define method .pilih() !CENAM = !!CE.NAME !VISI = !THIS.bt.TAG
IF !VISI.EQ( '0.' ) THEN !THIS.BT1.VAL = 'EQUIPMENT' !THIS.bt.TAG = '1.' !THIS.bt.background = 5 ELSEIF !VISI.EQ( '1.' ) THEN !THIS.BT1.VAL = 'PIPING' !THIS.bt.TAG = '2.' !THIS.bt.background = 7 ELSEIF !VISI.EQ( '2.' ) THEN !THIS.BT1.VAL = 'STRUCTURE' !THIS.bt.TAG = '3.' !THIS.bt.background = 6 else !THIS.BT1.VAL = 'Select' !THIS.bt.TAG = '0.' !THIS.bt.background = 10 ENDIF endmethod define method .MANSYURGRIDREPORT() !this.headings.append('NAME') !this.headings.append('DESCRIPTION') !this.headings.append('FUNCTION') using namespace 'Aveva.Pdms.Presentation' !this.ngcSelected = object NETGRIDCONTROL() !this.conSelected.control = !this.ngcSelected.handle() !this.ngcSelected.addeventhandler('OnPopup', !this, 'PopupHandler') !this.conSelected.popup = !this.mnupopup endmethod define method .initialise() !THIS.BT1.VAL = 'Select' !THIS.bt.TAG = '0.' !THIS.bt.background = 10 !this.debug = FALSE if (defined(!!debug) ) then !this.debug = TRUE endif using namespace 'Aveva.Pdms.Presentation' !t = true !f = false !this.ngcSelected.columnExcelFilter(!t) !this.ngcSelected.outlookGroupStyle(!f) !this.ngcSelected.fixedHeaders(!f) !this.ngcSelected.fixedRows(!f) !this.ngcSelected.editableGrid(!f) !this.ngcSelected.singlerowselection(!f) !this.ngcSelected.headerSort(!t) !this.ngcSelected.columnsummaries(!t) !this.ngcSelected.setalternaterowcolor('RED') !this.ngcSelected.clearGrid() endmethod define method .create() if !THIS.BT1.VAL eq 'EQUIPMENT' then !Tolarray = Object Array() var !equiarray append coll all equi for ce !Tolarray.Appendarray(!equiarray) !I = 1 do !mem values !Tolarray !equiname = name of $!mem $!mem !equi = !attarray[!i].dbref() Handle any Elsehandle none endhandle !I = !I + 1 enddo !judul = ARRAY() !judul[1] = 'NAME' !judul[2] = 'DESCRIPTION'
!judul[3] = 'EAST' !judul[4] = 'NORTH' !judul[5] = 'UP' !headings = ARRAY() !headings[1] = 'Namn of equi' !headings[2] = 'description' !headings[3] = 'E' !headings[4] = 'N' !headings[5] = 'U' import 'PMLFileBrowser' Handle Any Endhandle using namespace 'Aveva.Pdms.Presentation' !this.ngcSelected.clearGrid() !nds = object NetDataSource('Grid Control Example', !headings, !judul, !equiarray) !this.ngcSelected.BindToDataSource(!nds) !t = true !f = false !this.ngcSelected.columnExcelFilter(!t) !this.ngcSelected.outlookGroupStyle(!f) !this.ngcSelected.fixedHeaders(!f) !this.ngcSelected.fixedRows(!f) !this.ngcSelected.editableGrid(!f) !this.ngcSelected.singlerowselection(!f) !this.ngcSelected.headerSort(!t) !this.ngcSelected.columnsummaries(!t) !this.ngcSelected.setalternaterowcolor('GREEN') elseif !THIS.BT1.VAL eq 'PIPING' then !Tolarray = Object Array() var !piparray append coll all pipe for ce !Tolarray.Appendarray(!piparray) !I = 1 do !mem values !Tolarray !pipename = name of $!mem $!mem !pipe = !attarray[!i].dbref() Handle any Elsehandle none endhandle !I = !I + 1 enddo !judul = ARRAY() !judul[1] = 'NAME' !judul[2] = 'DESCRIPTION' !judul[3] = 'FUNCTION' !judul[4] = 'SPEC' !judul[5] = 'BORE' !headings = ARRAY() !headings[1] = 'Namn of pipe' !headings[2] = 'description' !headings[3] = 'function' !headings[4] = 'Pspec' !headings[5] = 'Bore' import 'PMLFileBrowser' Handle Any Endhandle using namespace 'Aveva.Pdms.Presentation' !this.ngcSelected.clearGrid() !nds = object NetDataSource('Grid Control Example', !headings, !judul, !piparray) !this.ngcSelected.BindToDataSource(!nds) !t = true !f = false !this.ngcSelected.columnExcelFilter(!t) !this.ngcSelected.outlookGroupStyle(!f) !this.ngcSelected.fixedHeaders(!f) !this.ngcSelected.fixedRows(!f) !this.ngcSelected.editableGrid(!f) !this.ngcSelected.singlerowselection(!f) !this.ngcSelected.headerSort(!t) !this.ngcSelected.columnsummaries(!t) !this.ngcSelected.setalternaterowcolor('pink')
elseif !THIS.BT1.VAL eq 'STRUCTURE' then !Tolarray = Object Array() var !struarray append coll all stru for ce !Tolarray.Appendarray(!struarray) !I = 1 do !mem values !Tolarray !struname = name of $!mem $!mem !equi = !attarray[!i].dbref() Handle any Elsehandle none endhandle !I = !I + 1 enddo !judul = ARRAY() !judul[1] = 'NAME' !judul[2] = 'DESCRIPTION' !judul[3] = 'EAST' !judul[4] = 'NORTH' !judul[5] = 'UP' !headings = ARRAY() !headings[1] = 'Namn of stru' !headings[2] = 'description' !headings[3] = 'E' !headings[4] = 'N' !headings[5] = 'U' import 'PMLFileBrowser' Handle Any Endhandle using namespace 'Aveva.Pdms.Presentation' !this.ngcSelected.clearGrid() !nds = object NetDataSource('Grid Control Example', !headings, !judul, !struarray) !this.ngcSelected.BindToDataSource(!nds) !t = true !f = false !this.ngcSelected.columnExcelFilter(!t) !this.ngcSelected.outlookGroupStyle(!f) !this.ngcSelected.fixedHeaders(!f) !this.ngcSelected.fixedRows(!f) !this.ngcSelected.editableGrid(!f) !this.ngcSelected.singlerowselection(!f) !this.ngcSelected.headerSort(!t) !this.ngcSelected.columnsummaries(!t) !this.ngcSelected.setalternaterowcolor('blue') else endif endmethod define method .removeFromList() !this.ngcSelected.deleteSelectedRows() endmethod define method .updateDisplayedList(!arrData is ARRAY) if (!this.debug) then WRITE |Running MANSYURGRIDREPORT.updateDisplayedList()| endif using namespace 'Aveva.Pdms.Presentation' do !index indices !this.headings skip if(!this.headings[!index].match('AREA') eq 0) !testArea = 1 sq mm !this.headings[!index] = 'AREA (' + !testArea.units().unitQualifier() + ')' break enddo !nds = object NETDATASOURCE('Selected elements', !this.headings, !arrData) !this.ngcSelected.bindToDataSource(!nds) endmethod define method .popupHandler(!data is ARRAY) !active = (!this.ngcSelected.getRows().size() neq 0) !this.mnupopup.setFieldProperty('ADD3DVIEW', 'active', !active ) !this.mnupopup.setFieldProperty('REMOVE', 'active', !active ) !this.mnupopup.setFieldProperty('REMOVEALL', 'active', !active ) !this.mnupopup.setFieldProperty('EXCEL', 'active', !active )
!this.mnupopup.setFieldProperty('PRINT', 'active', !active ) !this.conSelected.showPopup(!data[0], !data[1]) endmethod define method .printList() if (!this.ngcSelected.getNumberRows().neq(0)) then !this.ngcSelected.printPreview() else !!alert.error('No data to print') endif endmethod define method .exportToExcel() if (!this.ngcSelected.getNumberRows().eq(0)) then !!alert.error('No data to save') return endif using namespace 'AVEVA.PDMS.Presentation' !browser = object PMLFILEBROWSER('SAVE') !directory = 'C:\temp' !seedFile = 'Report' !title = 'PDMS - E3D Report' !existFlag = FALSE !filter = 'Microsoft Excel Files (*.xls)|*.xls' !filterIndex = 1 !browser.show(!directory, !seedFile, !title, !existFlag, !filter, !filterIndex) !saveFile = object FILE( !browser.file() ) if ( !saveFile.set() ) then !this.ngcSelected.saveGridToExcel(!saveFile.string()) handle (1000,0) !!alert.error('Could not write file: ' + !saveFile.string() + ' - ' + !!error.text ) elsehandle none !!alert.message('File saved: ' + !saveFile.string() ) endhandle endif endmethod define method .checkValidation(!dbref is DBREF) is BOOLEAN if (!this.debug) then WRITE |Running MANSYURGRIDREPORT.checkValidation()| endif if (!dbref.type eq 'WORL') then return FALSE else return TRUE endif endmethod define method .closeCallback() if (!this.debug) then WRITE |Running MANSYURGRIDREPORT.closeCallback()| endif !this.sftgrid.unset() kill !!MANSYURGRIDREPORT endmethod define method .addToView() !sele = !this.ngcSelected.GetSelectedRowTags() !navi = !sele[1] $!navi add ce auto ce endmethod define method .GoToElement() using namespace 'Aveva.Pdms.Presentation' !sele = !this.ngcSelected.GetSelectedRowTags() !navi = !sele[1] $!navi endmethod