下载
加入VIP
  • 专属下载特权
  • 现金文档折扣购买
  • VIP免费专区
  • 千万文档免费下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 ALV easy reference

ALV easy reference.pdf

ALV easy reference

sophsong
2011-10-27 0人阅读 举报 0 0 0 暂无简介

简介:本文档为《ALV easy referencepdf》,可适用于IT/计算机领域

AnEasyReferenceforALVGridControlSDNCommunityContribution(ThisisnotanofficialSAPdocument)DisclaimerLiabilityNoticeThisdocumentmaydiscusssamplecodingorotherinformationthatdoesnotincludeSAPofficialinterfacesandthereforeisnotsupportedbySAPChangesmadebasedonthisinformationarenotsupportedandcanbeoverwrittenduringanupgradeSAPwillnotbeheldliableforanydamagescausedbyusingormisusingtheinformation,codeormethodssuggestedinthisdocument,andanyoneusingthesemethodsdoessoathisherownriskSAPoffersnoguaranteesandassumesnoresponsibilityorliabilityofanytypewithrespecttothecontentofthistechnicalarticleorcodesample,includinganyliabilityresultingfromincompatibilitybetweenthecontentwithinthisdocumentandthematerialsandservicesofferedbySAPYouagreethatyouwillnothold,orseektohold,SAPresponsibleorliablewithrespecttothecontentofthisdocument©SAPAGAnEasyReferenceforALVGridControlAppliesTo:ALVGridcontrolcanbeusedasofreleaseCBesidesconsiderthefollowingofficialnotewhileutilizingthiscontrol:SAPdoesnotguaranteethatthemethods,eventsandattributesofthisclassthatarenotpublicwillremainunchangedorwillbeavailableinfuturereleasesThisiswhyyoushouldnotderivetheclasstoaccessprotectedobjectsoftheclassUsingtheseobjectsmakesitmoredifficulttoupgradetosubsequentreleasesSummaryPurposeofthistutorialistoprovideaneasyandquickreferencewhichmaybeusedasaguidewhilecodingtobuildlistsusingALVGridControlActually,thereiseasytoreachinformationaboutimplementingALVGridlistsHowever,itisgenerallyrequiredtofindtheinformationsoughtinaquickerwayThistutorialhandlesthis,beingacondensedsourcewhichcanbeusedasa“guide”ItwillnotdealwiththetechnicalinfrastructureonwhichALVlaysSomeofthetablesaretakenfromtheonlineSAPLibrarywhichisthemosttrustablesourceaboutthetopicShortly,thiswillbeabookletsummarizingmajorcapabilitiesoftheALVGridControlTogetdeepintotheALVGridcontrol,youcanrefertothestandardSAPcourse“BC–ABAPDialogProgrammingUsingEnjoySAPControls”andthebook“ControlsTechnology”AlsoyouhadbetterinspectdemoprogramsBy:SerdarŞİMŞEKLERCompanyandTitle:HavelsanInc,SAPApplicationDeveloperDate:OctUpdatedonJuneUpdatedonAugustPrerequisitesTouseALVGridControlinasimplemanner,itwillbesufficientjusthavingexperienceondialogprogrammingHowever,tomakeuseofmorecapabilities,itisrequiredsomeknowledgeonobjectorientedperspectiveofABAPprogrammingAgeneralknowledgeoncontrolframeworkissupposedtoexist©SAPAGAnEasyReferenceforALVGridControlTableofContentsDISCLAIMERLIABILITYNOTICEAPPLIESTO:SUMMARYPREREQUISITESTABLEOFCONTENTSINTRODUCTIONBUILDINGBLOCKSGENERALSCHEMEBUILDINGFIELDCATALOGSTRUCTUREOFAFIELDCATALOGBUILDINGFIELDCATALOGMANUALLYBUILDINGFIELDCATALOGSEMIAUTOMATICALLYLAYOUTADJUSTMENTSPRINTINGADJUSTMENTSEXCLUDINGUNWANTEDSTANDARDFUNCTIONBUTTONSNONEVENTBASEDADDITIONALFUNCTIONALITIESCHANGINGFIELDCATALOGORLAYOUTAFTERFIRSTDISPLAYSETTINGSORTCONDITIONSFILTERINGMAKINGSELECTIONSRETRIEVINGANDSETTINGSCROLLSTATUSINFOCOLORINGCOLORINGANENTIRECOLUMNCOLORINGANENTIREROWCOLORINGINDIVIDUALCELLSINSERTINGHYPERLINKSMAKINGFIELDSASDROPDOWNLISTSMANAGINGDISPLAYVARIANTS©SAPAGAnEasyReferenceforALVGridControlEVENTBASEDADDITIONALFUNCTIONALITIESGENERALSCHEMEFORTHEEVENTHANDLERCLASSHOTSPOTCLICKINGDOUBLECLICKINGPUSHBUTTONSONTHELISTADDINGYOUROWNFUNCTIONSOVERRIDINGSTANDARDFUNCTIONSCONTEXTMENUSABOUTPRINTINGMAKINGALVGRIDEDITABLECONTROLLINGDATACHANGESLINKINGFHELPTOFIELDSLINKINGFHELPTOFIELDSAPIECEOFTROUBLESHOOTINGAUTHORBIO©SAPAGAnEasyReferenceforALVGridControlIntroductionHereisthedefinitionforALVfromSAPHelp:“TheALVGridcontrolisaflexibletoolfordisplayinglistsThetoolprovidescommonlistoperationsasgenericfunctionsandcanbeenhancedbyselfdefinedoptions”TheALVGridcontrolisusedtobuildnonhierarchical,interactive,andmoderndesignlistsAsacontrol,itisacomponentthatisinstalledonthelocalPCTheALVGridcontrolprovidestypicallistfunctionsassorting,filtering,summing,etcwhilealsogivestheopportunitytodevelopuserfunctionswhereneededItpresentsnumerousinterfaceslikeExcelInplaceandCrystalReportsThewrapperclassimplementedtoencapsulateALVGridfunctionalityis“CLGUIALVGRID”ThereisanotherwaytodisplaylistswithALVutilizing“REUSEALV”functionsHowever,thatwayisnotcomprisedinthistutorialBuildingBlocksWhilepreparingalisttobedisplayedviaanALVgridcontrol,wehavesomebasiccomponentstoprepareTheseareiListdata:Obviously,thisisthedatainaninternaltabletobelistedStandardALVfunctionsexceptsortingmakesjustreadaccesstothelistdataHowever,sortingchangesstateoftheinternaltableTheinternaltableholdinglistdatamaybeofanyflattypeDeeptypesareonlyallowedwhensetforsomefunctionalitiesofALVGridiiFieldCatalog:WeuseanotherinternaltabletodefinespecificationsonhowthefieldsofourlistwillbedisplayedThisinternaltableiscalledthe“fieldcatalog”ThefieldcatalogmustcomprisesometechnicalandadditionalinformationaboutdisplayoptionsforeachcolumntobedisplayedTherearethreeprocedurestogeneratethefieldcatalogas“Automaticgeneration”,“Semiautomaticgeneration”,and“Manualgeneration”Theinternaltableforthefieldcatalogmustbereferencedtothedictionarytype“LVCTFCAT”iiiLayoutStructure:WefillastructuretospecifygenerallayoutoptionsforthegridWiththisstructurewecansetgeneraldisplayoptions,gridcustomizing,totalsoptions,coloradjustmentsetcThelayoutstructuremustbeoftype“LVCSLAYO”ivEventHandler:WeshoulddefineandimplementaneventhandlerclassifwewanttohandleeventstriggeredbytheALVGridinstanceAftercreatingALVGridinstance,wemustregisteraninstanceofthiseventhandlerclasstohandleALVGrideventsvAdditionalData:TotriggersomeadditionalfeaturesofALVGridwecanhavesomeadditionaldatatopassasparametersForexample,initialsortingcriteria,buttonstobedeactivated,etcGeneralSchemeNow,wecanfigureoutaprimitiveschemetoprepareourALVGridAsacontrolobject,ALVGridinstancerequiresacontainertobelinkedtothescreenGenerally,aninstanceoftheclass“clguicustomcontainer”isusedforthispurposeInstancesofsomeothercontainerclassessuchas“clguidockingcontainer”,“clguidialogboxcontainer”mayalsobeusedInourexamplewetakeacustomcontainerTocreateacustomcontainerinstance,weneedacustomcontrolareaonthescreenStepÆAddacustomcontrolonthescreenwhichwillberelatedtothecustomcontainerLet’sgiveitthename‘CCALV’©SAPAGAnEasyReferenceforALVGridControlStepÆDeclareglobalvariablestobeusedforALVGridCionsforALVreferenceFTOclguialvgridcontroladdedonthescreennameTYPEscrfnameVALUE‘CCALV’SHereCSitisndataoSwithcC©*Globaldatadefinit*ALVGridinstanceDATAgralvgridTYPERE*NameofthecustomDATAgccustomcontrolodePart–GlobaldatadefinitionsforALV*CustomcontainerinstancereferenceDATAgrccontainerTYPEREFTOclguicustomcontainer*FieldcatalogtableDATAgtfieldcatTYPElvctfcat*LayoutstructureDATAgslayoutTYPElvcslayotepÆDeclareyourinternaltablewhichissupposedtoholdthelistdataLet’snameit“gtlist”isanexampledeclarationodePart–Declarationoftheinternaltablethatwillholdthelistdata*InternaltableholdinglistdataDATABEGINOFgtlistOCCURSINCLUDESTRUCTURESFLIGHT*Infurthersections,someadditionalfieldswilladdedhere*forsomefunctionalityDATAENDOFgtlisttepÆSomewhereinyourprogrambeforecallinglistdisplay,fillyourlistdataasyouwantHere,otourconcernwhatthedataareWeassumetheinternaltableisfilledreasonablyWewillusetheftableSFLIGHTasourlistdatatepÆCallthescreenwhichcomprisestheALVGridcontrolAtPBOofthisscreenwewilldealreatingtheALVGridinstanceodePart–PBOoftheflowlogicforthescreencontainingALVGridcontrol*PBOPROCESSBEFOREOUTPUTMODULEdisplayalvSAPAGAnEasyReferenceforALVGridControlCodePart–InsidethemoduleMODULEdisplayalvOUTPUTPERFORMdisplayalvENDMODULEStepÆNow,itishightimewewrotesomethingtoplaySo,thispiecewillbetheonewewilldealmainlyWhatwedois,checkingwhetheraninstanceofthecontainer(orALVGrid)existsIfitexists,refreshingit,andifnot,creatingandsettingALVforthefirstdisplayFORMdisplayalvIFgralvgridISINITIAL*CreatingcustomcontainerinstanceCREATEOBJECTgrccontainerEXPORTINGcontainername=gccustomcontrolnameEXCEPTIONScntlerror=cntlsystemerror=createerror=lifetimeerror=lifetimedynprodynprolink=others=IFsysubrc<>*ExceptionhandlingENDIF*CreatingALVGridinstanceCREATEOBJECTgralvgridEXPORTINGiparent=grccontainerEXCEPTIONSerrorcntlcreate=errorcntlinit=errorcntllink=errordpcreate=others=©SAPAGAnEasyReferenceforALVGridControlIFsysubrc<>*ExceptionhandlingENDIF*PreparingfieldcatalogPERFORMpreparefieldcatalogCHANGINGgtfieldcat*PreparinglayoutstructurePERFORMpreparelayoutCHANGINGgslayout*Herewillbeadditionalpreparations*eginitialsortingcriteria,initialfilteringcriteria,excluding*functionsCALLMETHODgralvgrid>settableforfirstdisplayEXPORTING*IBUFFERACTIVE=*ICONSISTENCYCHECK=*ISTRUCTURENAME=*ISVARIANT=*ISAVE=*IDEFAULT='X'islayout=gslayout*ISPRINT=*ITSPECIALGROUPS=*ITTOOLBAREXCLUDING=*ITHYPERLINK=CHANGINGitouttab=gtlistitfieldcatalog=gtfieldcat*ITSORT=*ITFILTER=EXCEPTIONSinvalidparametercombination=programerror=toomanylines=OTHERS=©SAPAGAnEasyReferenceforALVGridControlCce,settingforfirstdisplayandrefresFentwhichinstantiateclassesInthisclguialvgrid”Firstis“setsedAftercreatingtheALVGridinstantable,fieldcatalogtable,layoutstructfromSAPLibraryParameteIBUFFemethodcallisstaticThisiththesamefieldcatalogIndinaspecialbufferThisinparticularISTRUIFsysubrc<>*ExceptionhandlingENDIFELSECALLMETHODgralvgrid>refreshtabledisplay*EXPORTING*ISSTABLE=*ISOFTREFRESH=EXCEPTIONSfinished=OTHERS=©odePart–Formcheckinginstanceexistence,creatinginstanhingromABAPobjects,wearefamiliarwith“CREATEOBJECT”statemsnippetofcode,weusedtwoinstancemethodsof“tableforfirstdisplay”whosenameimpliesforwhatitisucewecallthismethodtomakeourlistdisplayedWepasslistdataureandadditionalinformationHereareparameterdefinitionstakenrMeaningERACTIVEFlagtobesetbytheapplicationifthmeansthemethodisalwayscalledwthiscase,thefieldcatalogcanbehelacceleratesthedisplayofsmalllists,IFsysubrc<>*ExceptionhandlingENDIFENDIFENDFORMCTURENAMENameoftheDDICstructure(forexample,'SFLIGHT')fortheSAPAGAnEasyReferenceforALVGridControldataintheoutputtableIfyouspecifythisparameter,thefieldcatalogisgeneratedautomaticallyISVARIANTDeterminesthelayouttobeusedfordisplayingtheoutputtableIfyouusethisparameter,youmustatleastfillfieldREPORTofthestructureoftypeDISVARIANTISAVEDeterminestheoptionsavailabletotheuserforsavingalayout:'X':globalsavingonly'U':userspecificsavingonly'A':correspondsto'X'and'U'SPACE:nosavingIDEFAULTThisparameterdeterminesiftheuserisallowedtodefinedefaultlayouts:'X':Defaultlayoutsallowed(defaultsetting)SPACE:DefaultlayoutsnotallowedIfdefaultlayoutsareallowedandifsuchalayoutexistsandnootherlayoutisspecifiedinISVARIANT,thedefaultlayoutisautomaticallyloadedwhenthismethodiscalledISLAYOUTDeterminespropertiesofthegridcontrolThelayoutstructurehasnothingtodowiththelayoutforsavingfilter,sort,andcolumnpropertiesISPRINTParameterforprintingonthebackendITSPECIALGROUPSIfinthefieldcatalogthecolumnsweregroupedtogetherwithfieldSPGROUP,youmustpassatablewithtextsforthesegroupsOnthecurrentlayoutwindow,itisthenpossibletousealistboxtorestrictcolumnselectiontooneofthesegroupsITTOOLBAREXCLUDINGThistablecontainsfunctioncodesofthetoolbarthatyouwanttohideforthelifetimeoftheALVGridControlThefunctioncodesareconstantattributesandareprefixedwithMCFCITHYPERLINKThistableassignsahyperlinkaddress(fieldHREFofLVCSHYPE)toeachhandle(fieldHANDLEofLVCSHYPE)Usingthishandle,youcanthenincludehyperlinksinthegridITALVGRAPHICSSettingsfordisplayingtheALVlistasadiagram(forexample,axislabels)Therowtypeofthetablehastwofields(variablesvaluepairs):©SAPAGAnEasyReferenceforALVGridControlPROPID:AssignaconstantattributeoftheclassCLALVGRAPHICSCUwithprefixCOPROPIDtothisfieldtodeterminethechangestobemadetothegraphicUsetheCLALVGRAPHICSCU=>COPROPIDTITLEattribute,forexample,torefertothetitleofthediagramPROPVAL:Thevalueoftherelevanttopic,forexample,'MyTitle'ITOUTTABOutputtablewiththedatatobedisplayedITFIELDCATALOGDeterminesthestructureoftheoutputtableandtheformatofthedatatobedisplayedITSORTTablewithsortpropertiesforcolumnsthataretobesortedinitiallyITFILTERTablewithfilterpropertiesforcolumnsforwhichafilteristobesetinitiallyTable–Interfaceofthemethod“settableforfirstdisplay”Thesecondmethodweusedinourcodesnippetwas“refreshtabledisplay”which,asimpliedfromthenameagain,isusedtorefreshtheALVdisplayWedonotwantourALVGridtobecreatedeverytimethePBOtriggersThefirstpassshouldcreateitandothersshouldjustrefreshHowever,wemayrequiresomechangesabouttheappearance,layout,fieldcatalogetc…Inthatcase,wewilltrytouseotherALVmethodstomakechangesTheparameterdefinitiontableofthismethodisasfollowsParameterMeaningISSTABLEIftheroworcolumnfieldofthisstructureisset,thepositionofthescrollbarfortherowsorcolumnsremainsstableISOFTREFRESHThisparameterisusedonlyinexceptionalcasesIfyousetthisparameter,anytotalscreated,anysortorderdefinedandanyfilterssetforthedatadisplayedremainunchangedwhenthegridcontrolisrefreshedThismakessense,forexample,ifyouhavenotmodifiedthedataofthedatatableandwanttorefreshthegridcontrolonlywithregardtolayoutorfieldcatalogchangesTable–Interfaceofthemethod“refreshtabledisplay”OK!Seeingasimplebutwholepicturewearenowreadytoadvancetobuildourbasiccomponentswhichwejustpointasformcallsinthescheme©SAPAGAnEasyReferenceforALVGridControlBuildingFieldCatalogAsmentionedearlier,therearethreeprocedurestobuildafieldcatalogThesimplestwayappliesifourliststructureissimilartoadictionarytableTodothis,wesimplyeliminatetheformcallandpassthenameofdictionarystructure(inourexample,‘SFLIGHT’)totheparameter‘ISTRUCTURENAME’Beforeexplainingotherprocedures,let’sseewhatafieldcataloghasinitsstructureStructureOfAFieldCatalogTherowstructureofafieldcatalogisofdictionarytype‘LVCSFCAT’TherearemanyfieldsprovidingadjustmentofdisplayoptionsforourlistcolumnsHerearethebasiconesFIELDNAMEYouusethisfieldtoassignafieldnameofyouroutputtabletoarowofthefieldcatalogAllsettingsthatyoumakeinthisrowrefertothecorrespondingcolumnoftheoutputtableREFFIELDYoumustfillthisfieldif:theoutputtablefielddescribedbythecurrententryinthefieldcataloghasacorrespondingfieldintheDataDictionaryandthefieldnameintheoutputtableisnotidenticaltothefieldnameofthefieldintheDataDictionaryIfthefieldnamesareidentical,itissufficienttospecifytheDDICstructureortableinfieldREFTABLEofthefieldcatalogREFTABLEYoumustfillthisfieldonlyiftheoutputtablefielddescribedbythecurrententryinthefieldcataloghasacorrespondingentryintheDataDictionaryUsingthisassignment,theALVGridControlcancopythetextforthecolumnheaderfromtheDictionary,forexampleCHECKBOXOutputtingacheckboxThecheckboxcannotbemodifiedbytheuserCOLPOSRelevantonlyiftherelativecolumnpositionsshouldnotbeidenticaltothesequenceoffieldsinthefieldcatalogwhenthelistisdisplayedforthefirsttimeTheparameterdeterminestherelativecolumnpositionofthefieldforlistoutputTheusercaninteractivelymodifytheorderofthecolumnsIfthisparameterisinitialforeachfieldcatalogentry,theorderofthecolumnscorrespondstothesequenceoffieldsinthefieldcatalogDOSUMIfthisfieldisset,theALVusesthisfieldtocalculatethetotal(thiscorrespondstothegenerictotalsfunctioninthetoolbar)EMPHASIZEIfthefieldissetto'X',theALVusesapredefinedcolorforhighlightingthecolumnIfitissetto'Cxyz'(colorcode),theremainingnumbershavethefollowingmean

用户评价(0)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

评分:

/10

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利