SALV Table 1 : Normal ALV Table Display ᄃ SAP has introduced a new programming model to devleop b!ect riented ALV " ALV# using class $L%SALV &amily class' This class &amily is avaliable in the SAP Netweaver ()' Prior to SAP Netweaver* we have so many di&&erent starting point to start the ALV' The starting point entirly depends o& the &lavour o& ALV "Tabular* Tree* +ierarchical#* Type o& ALV "List or ,rid# etc' -& we want to use the $ontrol &ramewor.* than we need to start the ALV by using the class $L%,/-%ALV%,0-D' oreover to this* we need to ma.e di&&erent calles &or TP232PA,4* 4ND2 32PA,4 etc' To avoid this SAP has developed common model 5 which is entirely based on the ob!ect oriented' These new ALV ob!ect oriented model has many advantages: Simpli&ied design: This odel uses a highly integrated integrated ob!ect oriented design which provides the simplicity to programmers to develop the ALV' /ni&ied b!ect models: This This model has only one main class which will get and set the parameters o& o& entire layout' layout' The main classes &or the di&&erent &lavour o& ALV: ALV Flavour Class Simple 6D table display $L%SALV%TA7L4 +ierarchical ALV display $L%SALV%+-40S48/%TA7L4 Tree ALV using class $L%SALV%T044 All $lasses has static method 3A$T09 which will get bac. the instance o& the ALV' Li.e &or the simple table dispaly we must call the method $L%SALV%TA7L4;3A$T09 to get the instance o& the ALV' ALV' -n this post we will see how we can cretae a simple table output !ust by calling two methods' $ode Snippet to generate ALV using class $L%SALV%TA7L4 - had tried to build the report in the ob!ect oriented &ashion' /L o& that report is as &ollow' This design will give us &le
ᄃ
>?2222222222222222222222222222222222222222222 >?222222222222222222222222222222222222222222222222222222222222222222222 22222222222222222222222222> > >? 0eport @V-NALV(1 >? >?2222222222222222222222222222222222222222222 >?222222222222222222222222222222222222222222222222222222222222222222222 22222222222222222222222222> > >? >? >?2222222222222222222222222222222222222222222 >?222222222222222222222222222222222222222222222222222222222222222222222 22222222222222222222222222> > 04P0T @V-NALV(1'
> >2222222222222222222222222222222222222222222222222222222222222222222222> > $LASS lcl%report D43-N-T-N >2222222222222222222222222222222222222222222222222222222222222222222222> $LASS lcl%report D43-N-T-N' > P/7L-$ S4$T-N' > > 3inal output table T9P4S: 74,-N 3 ty%vba.* vbeln T9P4 vba.2vbeln* erdat T9P4 erdat* auart T9P4 auart* .unnr T9P4 .unnr* 4ND 3 ty%vba.' > DATA: t%vba. T9P4 STANDA0D TA7L4 3 ty%vba.' > > ALV re&erence DATA: o%alv T9P4 043 T cl%salv%table' > 4T+DS: > data selection get%data* > > ,enerating output generate%output' > >>>'''''$D4%ADD%1 2 7egin''''''''''''''''''''''''''''''''''1''>>> > > -n this section we will de&ine the private methods which can > be implemented to set the properties o& the ALV and can be > called in the > >>>'''''$D4%ADD%1 2 4nd''''''''''''''''''''''''''''''''''''1''>>> > 4ND$LASS' Blcl%report D43-N-T-N > > STA0T232S4L4$T-N' DATA: lo%report T9P4 043 T lcl%report' > $04AT4 7C4$T lo%report' > lo%report2;get%data" #' > lo%report2;generate%output" #' > >2222222222222222222222222222222222222222222222222222222222222222222222> > $LASS lcl%report -PL44NTAT-N >2222222222222222222222222222222222222222222222222222222222222222222222> $LASS lcl%report -PL44NTAT-N' >
4T+D get%data' > data selection S4L4$T vbeln erdat auart .unnr -NT TA7L4 t%vba. 30 vba. /P T 1(( 0=S' > 4ND4T+D' Bget%data > >''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 4T+D generate%output' > New ALV instance > =e are calling the static 3actory method which will give bac. > the ALV ob!ect re&erence' > > e >>>'''''$D4%ADD%6 2 7egin''''''''''''''''''''''''''''''''''6''>>> > > -n this area we will call the methods which will set the > di&&erent properties to the ALV > >>>'''''$D4%ADD%6 2 4nd''''''''''''''''''''''''''''''''''''6''>>> > > > Displaying the ALV > +ere we will call the D-SPLA9 method to get the output on the screen o%alv2;display" #' > 4ND4T+D' Bgenerate%output > >>>'''''$D4%ADD% 2 7egin''''''''''''''''''''''''''''''''''''>>> > > -n this area we will implement the methods which are de&ined in > the class de&inition > >>>'''''$D4%ADD% 2 4nd''''''''''''''''''''''''''''''''''''''>>> > > 4ND$LASS' Blcl%report -PL44NTAT-N
SALV Table 6 : Adding De&ault P3 STAT/S in ALV ᄃ
=e have discussed in post SALV odel 1: Normal ALV Table Display ᄃ to generate an ALV using new the SALV odel' -t is a true ob!ect oriented way to generate an ALV' Today* we will see how to add standard P3 Status ",/- Status# in this Standard ALV created using the class $L%SALV%TA7L4' The ob!ect created with re&erence to $L%SALV%TA7L4 contains the method which can be help&ul to add the P32Status in the ALV' +ere is the code Snippet which provides the ADD2N code' This ADD2N code can be replaced with the relevent section &rom this code snippet in the base program' 9ou can &ind the base program code snippet in the post SALV odel 1: Normal ALV Table Display ᄃ' Adding code to base program is li.e adding the code correction &rom the SS Note' The new /L diagram o& our application is li.e: ᄃ
$ode Snippet to add De&ault P3 Status
>>>'''''$D4%ADD%1 2 7egin''''''''''''''''''''''''''''''''''1''>>> > -n this section we will de&ine the private methods which can > be implemented to set the properties o& the ALV and can be > called in the > P0-VAT4 S4$T-N' 4T+DS: set%p&%status $+AN,-N, co%alv T9P4 043 T cl%salv%table' >>>'''''$D4%ADD%1 2 4nd''''''''''''''''''''''''''''''''''''1''>>> > >>>'''''$D4%ADD%6 2 7egin''''''''''''''''''''''''''''''''''6''>>> > -n this area we will call the methods which will set the > di&&erent properties to the ALV $ALL 4T+D set%p&%status $+AN,-N, co%alv o%alv' >>>'''''$D4%ADD%6 2 4nd''''''''''''''''''''''''''''''''''''6''>>> > > >>>'''''$D4%ADD% 2 7egin''''''''''''''''''''''''''''''''''''>>> > > -n this area we will implement the methods which are de&ined in > the class de&inition > 4T+D set%p&%status' > DATA: lo%&unctions T9P4 043 T cl%salv%&unctions%list' > lo%&unctions co%alv2;get%&unctions" #' lo%&unctions2;set%de&ault" abap%true #'
> 4ND4T+D' Bset%p&%status >>>'''''$D4%ADD% 2 4nd''''''''''''''''''''''''''''''''''''''>>>
SALV Table : Adding $ustom P3 STAT/S in ALV ᄃ =e have seen in the previous posts o& this 7log series about the new SALV model to $reate ALV:
SALV odel 1: Normal ALV Table Display ᄃ SALV odel 6: Adding de&ault P3 STAT/S in ALV ᄃ Sometimes we need to create our own P3 Status ",/- Stauts# with more buttons which can provide the users more ways to interact with the ALV' To set our custom P3 status we need to: First create a PF status : =e need to create a P3 status with our own buttons as well as the ALV standard buttons' -& we donEt add the ALV buttons than it would not provide the standard &unctions o& ALVs' n the other hand it is very tedious to add all the ALV buttons in our P3 status manually' So here is the easy way: =e will copy the P32Status using o& any standard SALV%D4 report using the transaction S4)1: enu Painter' A&ter $opying the P32Status we can add our own buttons' Call Method of SALV to display PF: Now we will call this newly created P3 status in our ALV using the method S4T%S$044N%STAT/S o& the re&erence o& the class $L%SALV%TA7L4' +ere is the code snippet to which provides the ADD2N code to our 7ase program' The base program can be &ound in the SALV odel 1: Normal ALV Table Display ᄃ' /L diagram is same as the post SALV odel 6: Adding de&ault P3 STAT/S in ALV ᄃ'
SALV Table ) : Setting up Layout ᄃ Today we will see how easy it is to set up the Layout &or the ALV which was created using the re&erence o& the $L%SALV%TA7L4 calss' All these discussions can be &ound under Tutorials ; SALV Table Display ᄃ' Layouts provides greate &le
>>>'''''$D4%ADD%1 2 7egin''''''''''''''''''''''''''''''''''1''>>> > > -n this section we will de&ine the private methods which can
> be implemented to set the properties o& the ALV and can be > called in the > P0-VAT4 S4$T-N' 4T+DS: set%p&%status $+AN,-N, co%alv T9P4 043 T cl%salv%table' > 4T+DS: set%layout $+AN,-N, co%alv T9P4 043 T cl%salv%table' >>>'''''$D4%ADD%1 2 4nd''''''''''''''''''''''''''''''''''''1''>>> > >>>'''''$D4%ADD%6 2 7egin''''''''''''''''''''''''''''''''''6''>>> > > -n this area we will call the methods which will set the > di&&erent properties to the ALV > > Setting up the P32Status $ALL 4T+D set%p&%status $+AN,-N, co%alv o%alv' > > Setting up the Layout $ALL 4T+D set%layout $+AN,-N, co%alv o%alv' >>>'''''$D4%ADD%6 2 4nd''''''''''''''''''''''''''''''''''''6''>>> > > >>>'''''$D4%ADD% 2 7egin''''''''''''''''''''''''''''''''''''>>> > > -n this area we will implement the methods which are de&ined in > the class de&inition > > 4T+D set%p&%status' > DATA: lo%&unctions T9P4 043 T cl%salv%&unctions%list' > lo%&unctions co%alv2;get%&unctions" #' lo%&unctions2;set%de&ault" abap%true #' > 4ND4T+D' Bset%p&%status > 4T+D set%layout' > DATA: lo%layout T9P4 043 T cl%salv%layout* l&%variant T9P4 slis%vari* ls%.ey T9P4 salv%s%layout%.ey' >
> get layout ob!ect lo%layout co%alv2;get%layout" #' > > set Layout save restriction > 1' Set Layout Hey '' /niGue .ey identi&ies the Di&&erenet ALVs ls%.ey2report sy2repid' lo%layout2;set%.ey" ls%.ey #' > 6' 0emove Save layout the restriction' lo%layout2;set%save%restriction" i&%salv%c%layout;restrict%none #' > > set initial Layout l&%variant ID43A/LTI' lo%layout2;set%initial%layout" l&%variant #' > 4ND4T+D' Bset%layout >>>'''''$D4%ADD% 2 4nd''''''''''''''''''''''''''''''''''''''>>>
SALV Table J 5 Add +eader "Top o& page# ? 3ooter "4nd o& Page#ᄃ Today we will discuss how to add the +eader and 3ooter using the SALV model' -n ALV* header "top2 o&2page# and &ooter "end2o&2page# play important role in presentation o& the data' +eader and &ooter are imortant when we need to print the report and use it &or later decisions' Assume the report which has only columns and no in&ormation' Does it really de&ine K-n&ormationM 5 N' So* letEs get started on how to create +eader and 3ooter' +eader and 3ooter both can be created using the class re&erence CL_SALV_FORM_LAYOU_!R"#$=e will create: 2 A re&erence o& the class $L%SALV%30%LA9/T%,0-D 2 /se methods o& this re&erence to create a Lables ? 3low' 2 Set this re&erence into the main ALV ob!ect "re&erence to $L%SALV%TA7L4#' Labels are use&ul to generate the te
$ode Snippet to generate +eader ? 3ooter
>>>'''''$D4%ADD%1 2 7egin''''''''''''''''''''''''''''''''''1''>>> > -n this section we will de&ine the private methods which can > be implemented to set the properties o& the ALV and can be > called in the >
P0-VAT4 S4$T-N' > De&ault P& Status 4T+DS: set%p&%status $+AN,-N, co%alv T9P4 043 T cl%salv%table' > Set Top o& page 4T+DS: set%top%o&%page $+AN,-N, co%alv T9P4 043 T cl%salv%table' > > Set 4nd o& page 4T+DS: set%end%o&%page $+AN,-N, co%alv T9P4 043 T cl%salv%table' > >>>'''''$D4%ADD%1 2 4nd''''''''''''''''''''''''''''''''''''1''>>> > >>>'''''$D4%ADD%6 2 7egin''''''''''''''''''''''''''''''''''6''>>> > > -n this area we will call the methods which will set the > di&&erent properties to the ALV > > Setting up the de&ault P3 status $ALL 4T+D set%p&%status $+AN,-N, co%alv o%alv' > > $alling the top o& page method $ALL 4T+D me2;set%top%o&%page $+AN,-N, co%alv o%alv' > > $alling the 4nd o& Page method $ALL 4T+D me2;set%end%o&%page $+AN,-N, co%alv o%alv' > >>>'''''$D4%ADD%6 2 4nd''''''''''''''''''''''''''''''''''''6''>>> > >>>'''''$D4%ADD% 2 7egin''''''''''''''''''''''''''''''''''''>>> > > -n this area we will implement the methods which are de&ined in > the class de&inition > 4T+D set%p&%status' > DATA: lo%&unctions T9P4 043 T cl%salv%&unctions%list' > De&ault 3unctions lo%&unctions co%alv2;get%&unctions" #' lo%&unctions2;set%de&ault" abap%true #'
> 4ND4T+D' Bset%p&%status > 4T+D set%top%o&%page' > DATA: lo%header T9P4 043 T cl%salv%&orm%layout%grid* lo%h%label T9P4 043 T cl%salv%&orm%label* lo%h%&low T9P4 043 T cl%salv%&orm%layout%&low' > > header ob!ect $04AT4 7C4$T lo%header' > > To create a Lable or 3low we have to speci&y the target > row and column number where we need to set up the output > te > in&ormation in 7old lo%h%label lo%header2;create%label" row 1 column 1 #' lo%h%label2;set%te > in&ormation in tabular &ormat lo%h%&low lo%header2;create%&low" row 6 column 1 #' lo%h%&low2;create%te lo%h%&low lo%header2;create%&low" row column 1 #' lo%h%&low2;create%te lo%h%&low lo%header2;create%&low" row column 6 #' lo%h%&low2;create%te > set the top o& list using the header &or nline' co%alv2;set%top%o&%list" lo%header #' > > set the top o& list using the header &or Print' co%alv2;set%top%o&%list%print" lo%header #' > 4ND4T+D' Bset%top%o&%page > 4T+D set%end%o&%page' > DATA: lo%&ooter T9P4 043 T cl%salv%&orm%layout%grid* lo%&%label T9P4 043 T cl%salv%&orm%label* lo%&%&low T9P4 043 T cl%salv%&orm%layout%&low' > > &ooter ob!ect $04AT4 7C4$T lo%&ooter' > > in&ormation in bold lo%&%label lo%&ooter2;create%label" row 1 column 1 #' lo%&%label2;set%te > tabular in&ormation lo%&%&low lo%&ooter2;create%&low" row 6 column 1 #'
lo%&%&low2;create%te lo%&%&low lo%&ooter2;create%&low" row column 1 #' lo%&%&low2;create%te lo%&%&low lo%&ooter2;create%&low" row column 6 #' lo%&%&low2;create%te > nline &ooter co%alv2;set%end%o&%list" lo%&ooter #' > > 3ooter in print co%alv2;set%end%o&%list%print" lo%&ooter #' > 4ND4T+D' Bset%end%o&%page > >>>'''''$D4%ADD% 2 4nd''''''''''''''''''''''''''''''''''''''>>> This code will generate output li.e this: ᄃ
=hen you print this output* it will generate a spool li.e: ᄃ
SALV Table 5 Dispaly Settings ᄃ -n the series o& the SALV Simple odel* we will see how we can set the Display Settings to the entire ALV' 9ou can &ind the previous discussions in this blog series at Tutorials ; SALV Table Display ᄃ
To set the display settings* we need to use the re&erence o& the class $L%SALV%D-SPLA9%S4TT-N,S' =e will as. the re&erence o& the Display settings &rom our ALV ob!ect created using the $L%SALV%TA7L4' 7y using the dispaly settings* we can set the @ebra style* Title o& the ALV etc' +ere is the code snippet to which provides the ADD2N code to our 7ase program' The base program can be &ound in the SALV odel 1: Normal ALV Table Display ᄃ' /L diagram &or this e
>>>'''''$D4%ADD%1 2 7egin''''''''''''''''''''''''''''''''''1''>>> > > -n this section we will de&ine the private methods which can > be implemented to set the properties o& the ALV and can be > called in the > P0-VAT4 S4$T-N' 4T+DS: set%display%setting $+AN,-N, co%alv T9P4 043 T cl%salv%table' >>>'''''$D4%ADD%1 2 4nd''''''''''''''''''''''''''''''''''''1''>>> > >>>'''''$D4%ADD%6 2 7egin''''''''''''''''''''''''''''''''''6''>>> > > -n this area we will call the methods which will set the > di&&erent properties to the ALV $ALL 4T+D set%display%setting $+AN,-N, co%alv o%alv' >>>'''''$D4%ADD%6 2 4nd''''''''''''''''''''''''''''''''''''6''>>> > >>>'''''$D4%ADD% 2 7egin''''''''''''''''''''''''''''''''''''>>> > > -n this area we will implement the methods which are de&ined in > the class de&inition > 4T+D set%display%setting' > DATA: lo%display T9P4 043 T cl%salv%display%settings' > > get display ob!ect lo%display o%alv2;get%display%settings" #' > > set @470A pattern lo%display2;set%striped%pattern" IOI #' > > Title to ALV lo%display2;set%list%header" IALV Test &or Display SettingsI #' > 4ND4T+D' BS4T%D-SPLA9%S4TT-N, >>>'''''$D4%ADD% 2 4nd''''''''''''''''''''''''''''''''''''''>>>
ᄃ
SALV Table 5 Add ? +andle +otspot ᄃ -n the series o& the SALV model table display* today we will see how to add the hotspot and a&ter adding* how to handle that hotspot' 9ou can &ind all the previous discussion at Tutorials ; SALV Table Display ᄃ ' +otspot is use&ul in most o& the ALV reports to drill2down &rom the main list' 3or e
$ode Snippet &or +otspot and event handling
>>>'''''$D4%ADD%1 2 7egin''''''''''''''''''''''''''''''''''1''>>> > > -n this section we will de&ine the private methods which can > be implemented to set the properties o& the ALV and can be > called in the > P0-VAT4 S4$T-N' > Set the various column properties 4T+DS: set%hotspot%vbeln $+AN,-N, co%alv T9P4 043 T cl%salv%table co%report T9P4 043 T lcl%report' > > 4vent +andler &or +TSPT event 4T+DS: on%lin.%clic. 30 4V4NT lin.%clic. 3 cl%salv%events%table -P0T-N, row column ' >>>'''''$D4%ADD%1 2 4nd''''''''''''''''''''''''''''''''''''1''>>> > > >>>'''''$D4%ADD%6 2 7egin''''''''''''''''''''''''''''''''''6''>>> > > -n this area we will call the methods which will set the > di&&erent properties to the ALV > > Set /p the +otspot ? 4vent +andler $ALL 4T+D set%hotspot%vbeln $+AN,-N, co%alv o%alv co%report lo%report' >>>'''''$D4%ADD%6 2 4nd''''''''''''''''''''''''''''''''''''6''>>> > > >>>'''''$D4%ADD% 2 7egin''''''''''''''''''''''''''''''''''''>>> > > -n this area we will implement the methods which are de&ined in > the class de&inition > 4T+D set%hotspot%vbeln' > >'''+otSpot DATA: lo%cols%tab T9P4 043 T cl%salv%columns%table* lo%col%tab T9P4 043 T cl%salv%column%table' > > get $olumns ob!ect lo%cols%tab co%alv2;get%columns" #' > > ,et V74LN column T09'
lo%col%tab M lo%cols%tab2;get%column" IV74LNI #' $AT$+ c<%salv%not%&ound' 4NDT09' > > Set the +otSpot &or V74LN $olumn T09' $ALL 4T+D lo%col%tab2;set%cell%type 4OP0T-N, value i&%salv%c%cell%type;hotspot' ' $AT$+ c<%salv%data%error ' 4NDT09' > >'''4vents DATA: lo%events T9P4 043 T cl%salv%events%table' > > all events lo%events o%alv2;get%event" #' > > event handler S4T +ANDL40 co%report2;on%lin.%clic. 30 lo%events' > 4ND4T+D' Bset%hotspot%vbeln > > +andles the /- on the V74LN "+otSpot# 4T+D on%lin.%clic.' > DATA: la%vba. T9P4 ty%vba.' > > ,et the Sales rder number &rom the table 04AD TA7L4 lo%report2;t%vba. -NT la%vba. -ND4O row' -3 la%vba.2vbeln -S NT -N-T-AL' 4SSA,4 iR"((# =-T+ I9ou have selectedI la%vba.2vbeln' 4ND-3' > 4ND4T+D' Bon%lin.%clic. > >>>'''''$D4%ADD% 2 4nd''''''''''''''''''''''''''''''''''''''>>> ᄃ
A&ter event handling o& the +otspot: ᄃ