ALV文挡.docx
《ALV文挡.docx》由会员分享,可在线阅读,更多相关《ALV文挡.docx(47页珍藏版)》请在冰豆网上搜索。
![ALV文挡.docx](https://file1.bdocx.com/fileroot1/2022-11/23/0a8dcbba-3c17-44fe-8682-284aa956e792/0a8dcbba-3c17-44fe-8682-284aa956e7921.gif)
ALV文挡
ALV(ABAPLISTVIEWER)
SapprovidesasetofALV(ABAPLISTVIEWER)functionmodules,whichcanbeputintousetoembellishtheoutputofareport.ThissetofALVfunctionsisusedtoenhancethereadabilityandfunctionalityofanyreportoutput.Casesariseinsapwhentheoutputofareportcontainscolumnsextendingmorethan255charactersinlength.Insuchcases,thissetofALVfunctionscanhelpchooseselectedcolumnsandarrangethedifferentcolumnsfromareportoutputandalsosavedifferentvariantsforreportdisplay.Thisisaveryefficienttoolfordynamicallysortingandarrangingthecolumnsfromareportoutput.Thereportoutputcancontainupto90columnsinthedisplaywiththewidearrayofdisplayoptions.
ThecommonlyusedALVfunctionsusedforthispurposeare;
1.REUSE_ALV_VARIANT_DEFAULT_GET
2.REUSE_ALV_VARIANT_F4
3.REUSE_ALV_VARIANT_EXISTENCE
4.REUSE_ALV_EVENTS_GET
5.REUSE_ALV_COMMENTARY_WRITE
6.REUSE_ALV_FIELDCATALOG_MERGE
7.REUSE_ALV_LIST_DISPLAY
8.REUSE_ALV_GRID_DISPLAY
9.REUSE_ALV_POPUP_TO_SELECT
Thedifferentstepsusedforgettingtheabovefunctionmodulesintouseare:
Step1
DATADECLARATION
Sapstandardtypepools:
SLIS,KKBLO.
Sapstandardtablestypestakenfromthetypepoolsare:
SLIS_LAYOUT_ALV,
SLIS_T_FIELDCAT_ALV,
SLIS_T_LISTHEADER,
SLIS_T_EVENT,
SLIS_SELFIELD.
Internaltablestousedintheprogramdeclaredbasedontheabovetabletypes
DATA:
I_LAYOUTTYPESLIS_LAYOUT_ALV,
I_FIELDTABTYPESLIS_T_FIELDCAT_ALV,
I_HEADINGTYPESLIS_T_LISTHEADER,
I_EVENTSTYPESLIS_T_EVENT.
TYPES:
KKBLO_SELFIELDTYPESLIS_SELFIELD.
Step2(Optional)
SELECTINGTHEVARIANTSFORINITIALLISTDISPLAY(DEFAULTVARIANT)
Thevariantsinthelistdisplaycanbebothuser-specificandgeneral.Theusercanprogrammaticallysettheinitial(default)variantforlistdisplay.
Thedefaultvariantcanbefoundusingthefunctionmodule'REUSE_ALV_VARIANT_DEFAULT_GET'.
Samplecode:
CALLFUNCTION'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save=variantsavecondition(A=all,U=user-specific)
CHANGING
cs_variant=internaltablecontainingtheprogramname(andthedefaultvariant---optional)
EXCEPTIONS
not_found=2.
Theusercanalsochoosefromthelistofexistingvariantsusingthefunctionmodule‘REUSE_ALV_VARIANT_F4’.
Step3
DEFINININGOUTPUTCHARACTERISTICS:
PREPARINGDISPLAYFIELDSCATALOG
Afieldcatalogispreparedusingtheinternaltable(I_FIELDCAT)oftypeSLIS_T_FIELDCAT_ALV.Fieldcatalogcontainingdescriptionsofthelistoutputfields(usuallyasubsetoftheinternaloutputtablefields).
AfieldcatalogisrequiredforeveryALVlistoutputtoadddesiredfunctionality(i.e.Key,Hotspot,Specificheadings,Justify,Col.positionetc)tocertainfieldsoftheoutput.Ifnotmentionedspecifically,thenthedefaultsaretaken.Thepossiblevaluesanddefaultsarelistedbelow.
Thefieldcatalogfortheoutputtableisbuilt-upinthecaller'scoding.Thebuild-upcanbecompletelyorpartiallyautomatedbycallingtheREUSE_ALV_FIELDCATALOG_MERGEmodule.
Theminimalfieldcatalogisdocumentedbelow.Thiscanbedoneinaroutineusingalocalvariable.Theusercanusetheotheroptionalparameterstoassignoutputattributestodifferentfieldsintheoutput,whichdifferfromthedefault.
Afieldcatalogneednotbebuilt-upandpassedexplicitlyonlyunderthefollowingconditions:
1.TheinternaltabletobeoutputhasthesamestructureasaDataDictionarystructurewhichisreferredtointheinternaltabledeclarationusingLIKEorINCLUDESTRUCTURE.Inthiscasetheattributesofthedifferentfieldsistakendirectlyfromthetableandtheattributes(keyfields,length,textsetc)needtostateexplicitly.
2.allfieldsinthisstructurearetobeoutput
3.ThestructurenameispassedtoALVintheparameterI_STRUCTURE_NAMEofthefunctionmoduleREUSE_ALV_LIST_DISPLAY.
AllthevaluesenteredinthecatalogisspecifictotheparticularfieldwhosenameisenteredinthefieldnameFIELDNAMEofthefieldcatstructure.Thenameofthetableisalsoenteredinthecorr.FieldnameTABNAMEofthestructure.
Thedifferentpossibleattributesare:
∙Row_pos(rowposition):
Onlyrelevantifthelistoutputistobemulti-line(twoorthreelines)bydefault.So,thisattributecanbeusedmaintaincertainlevelofalignmentintheoutput.
Valueset:
0,1–3
∙Col_pos(columnposition):
Thisparameterisrelevantwhenthefieldsintheoutputaretobedifferentfromthesequenceofthefieldsintheinternaltableusedfordisplay.Theparameterspecifiestherelativecolumnpositionofthefieldinthelistoutput.Thecolumnordercanbechangedinteractivelybytheuser.Ifthisparameterisinitialforallfieldcatalogentries,columnsappearintheinternaltablefieldsequence.
Valueset:
0,1–60
∙Fieldname(fieldname):
Thisisthenameoftheinternaltablefieldforwhichtheparametersarepassedinthecatalog.
Valueset:
internaloutputtablefieldname(requiredparameter)
∙Tabname(internaloutputtable):
NameoftheinternaloutputtablethatcontainsthefieldFIELDCAT-FIELDNAMEabove.
Valueset:
SPACE,internaloutputtablename.
∙Ref_fieldname(referencefieldname):
NameoftheDataDictionaryfieldreferredto.ThisparameterisonlyusedwhentheinternaloutputtablefielddescribedbythecurrentfieldcatalogentryhasareferencetotheDataDictionary(notaprogramfield),andthefieldnameintheinternaloutputtableisdifferentfromthenameofthefieldintheDataDictionary.Ifthefieldnamesareidentical,namingtheDataDictionarystructureortableintheFIELDCAT-REF_TABNAMEparameterissufficient.
Valueset:
SPACE,DataDictionaryfieldname.
∙Ref_tabname(referencetable/structurefieldname):
StructureortablenameofthereferredDataDictionaryfield.ThisparameterisonlyusedwhentheinternaloutputtablefielddescribedbythecurrentfieldcatalogentryhasaDataDictionaryreference(notaprogramfield).
Valueset:
SPACE,nameofaDataDictionarystructureortable
Linktocurrencyunit
∙Cfieldname(currencyunitfieldname):
Thisisusedforcurrencyfieldsthathaveareferencetoanyunitfield.Thisisonlyrelevantforamountcolumnswithassociatedunit.ThisparametercontainstheNameoftheinternaloutputtablefieldcontainingthecurrencyunitassociatedwiththeamountfieldFIELDCAT-FIELDNAME.ThefieldinFIELDCAT-CFIELDNAMEmusthaveitsownfieldcatalogentry.
Valueset:
SPACE,outputtablefieldname
∙Ctabname(internalcurrencyunitfieldoutputtable):
NameoftheinternaloutputtablecontainingtheFIELDCAT-CFIELDNAMEfield.
Valueset:
SPACE,outputtablefieldname.
Linktomeasurementunit
∙Qfieldname(measurementunitfieldname):
Onlyrelevantforquantitycolumnswithunitlink.NameoftheinternaloutputtablefieldcontainingthemeasurementunitassociatedwiththequantityfieldFIELDCAT-FIELDNAME.ThefieldinFIELDCAT-QFIELDNAMEmusthaveitsownfieldcatalogentry.
Valueset:
SPACE,outputtablefieldname.
∙Qtabname(internalmeasurementunitfieldoutputtable):
NameoftheinternaloutputtablecontainingtheFIELDCAT-QFIELDNAMEfield.
Valueset:
SPACE,outputtablefieldname.
∙Outputlen(columnwidth):
Thisparameterisusedifthedesiredoutputlengthforafieldisdesiredtobedifferentfromtheinternaloutputtablefield.ForfieldswithaDataDictionarylinkthisparametercanbeleftinitial.ForfieldswithoutaDataDictionarylink(programfield)theparametermustbegiventhevalueofthedesiredfieldlistoutputlength(columnwidth).
Initial=columnwidthistheoutputlengthofthereferredDataDictionaryfield(domain).
N=columnwidthisncharacters.
Valueset:
0(initial),n.
∙Key(keycolumn):
Bydefault,thesystemmakessomefieldsintheoutputaskeyfields,providedthefieldsarekeyfieldsintheirreferencingtable.Usingthisparameter,fieldsotherthankeyfieldsofthereferencingtablecanbemadekeyfield.Thisparameterismostimportantiftheoutputneedstocontainsomefieldwhicharenotscrollableorcannotbehidden.
Iftheinternaloutputtablecontainsfieldsthatarekeyfieldsfromdifferenttables,thenallthosefieldsinthereportoutputbecomesunscrollableandcannotbehidden.So,thefieldsintheoutputinternaltableshouldnotbereferencedfromtablesinwhichtheyarekeyfields.Instead,theyshouldbereferencedtothetablesinwhichtheyarenotkeyfields,incasetheyarenotdesiredaskeyfieldintheoutput.
'X'=keyfield(keyfieldoutputincolor)andKeyfieldscannotbeinteractivelyhidden.ParameterFIELDCAT-NO_OUTmustbeleftinitial.
Valueset:
SPACE,'X'.
∙Key_sel(hideablekeycolumn):
ThisparameterisonlyrelevantforthefieldswhicharemadekeyfieldsusingFIELDCAT-KEY='X'.UsingthisparametertheKeyfieldcanbehiddeninteractively.
Thekeycolumnsequencecannotbechangedinteractivelybytheuser.TheoutputiscontrolledbytheFIELDCAT-NO_OUTparameteranalogouslytonon-keyfields.
Valueset:
SPACE,'X'.
∙No_out(fieldinfieldlist):
Thisparameterisusedtoremovecertainfieldsfromtheoutputduringinitialdisplay.Theusercanhoweverinteractivelychoosethefieldforoutputfromthefieldlistinthedisplayvariant.
'X'=fieldisnotdisplayedinthecurrentlist.
Valueset:
SPACE,'X'.
∙Tech(technicalfield):
Thisparameterisusedtomakecertainfielddisplayonlyinthefieldcatalog.Thefieldswiththisparametersetcannotbeoutputinthelistnorcantheybedisplayedinteractivelyfromthecatalog.
'X'=technicalfield.
Valueset:
SPACE,'X'.
∙Emphasize(highlightcolumnsincolor):
Asnamesuggests,thisfieldparameterisusedtohighlightcertai