Sei sulla pagina 1di 6

5/11/2015

AddingCustomButtontoALVtoolbar(usingREUSE_ALV_GRID_DISPLAY_LVC)| Musicodez

Musicodez
APersonalNotebookofanABAPer
Home
Welcome
About

Home>ABAP,ALV,SAP>AddingCustomButtontoALVtoolbar(using
REUSE_ALV_GRID_DISPLAY_LVC)
Typetexttosearchhere...

AddingCustomButtontoALVtoolbar(using
REUSE_ALV_GRID_DISPLAY_LVC)
September11,2010marcpontyLeaveacommentGotocomments

FMREUSE_ALV_GRID_DISPLAY_LVCautomaticallyprovideALVtoolbarsforus.However,
sometimesweneedtoaddfunctionalitytoaddnewtoolbarbutton.Inexamplebelow,wewanttoadd
downloadtopdfbuttonforouralv.Heresthesteps.
1.CopyGUIstatusfromotherprogram
GototransactionSE41.CopystatusSTANDARD_FULLSCREENfromprogram
SAPLSLVC_FULLSCREEN,providetheprogramnameandnewGUISTATUSnamefortheprogram.
TherewillbeaconfirmationdialogtodefinenewshorttextforGUISTATUSobject.Itsoknottodefine
newshorttext,sojustproceedtonextstep.

https://musicodez.wordpress.com/2010/09/11/addingcustombuttontoalvtoolbarusingreuse_alv_grid_display_lvc/

1/6

5/11/2015

AddingCustomButtontoALVtoolbar(usingREUSE_ALV_GRID_DISPLAY_LVC)| Musicodez

2.AddnewbuttontonewlycreatedGUISTATUS
a.GotoSE38>Edit>DisplayObjectList.InlefttoolbaryoullseeGUIStatusfolder.Contractthe
folderandclickonthenewGUISTATUS.
b.Placethecursorwhereyouwanttoputthenewtoolbar,thenclickInsertEntrybutton.

c.EnternewOKCode(functioncode)foryourstatus.Onceyoupressenter,adialogboxwillappear.
Choosestatictextaswearenottocreatearuntimedefinedicon.

https://musicodez.wordpress.com/2010/09/11/addingcustombuttontoalvtoolbarusingreuse_alv_grid_display_lvc/

2/6

5/11/2015

AddingCustomButtontoALVtoolbar(usingREUSE_ALV_GRID_DISPLAY_LVC)| Musicodez

d.ProvideinformationoftheFunctionText.
Functiontext:Name/identifierofthefunctiontext.
Iconname:Nameoftheiconthatwillbeshown.JustpressF4toseelistoftheicon.
Info.text:Informationthatwillbeshownwhenhoveringthroughtheicon.
e.Assignafunctionkey(shortcut)foryournewfunctionkey.Justpickfromoneofthelist.
f.Yournewiconwillbedisplayedontheiconlist.Youcanclicktheiconagaintoprovideotherparameter,
forexampletodefinetheiconfunctionaltype,ortoprovideicontextsothatacustomtextwillbedisplayed
sidebysidewiththeicon.

3.AttachtheGUIStatustotheALV
a.Createasubroutine,forexampleSET_PF_STATUS,andputbelowcode:
FORMset_pf_statusUSINGrt_extabTYPEslis_t_extab."#ECCALLED
DESCRIBETABLErt_extab."AvoidExtendedCheckWarning
SETPFSTATUS'STANDARD_FULLSCREEN'.
ENDFORM."Set_pf_status

b.WhilecallingtheFMREUSE_ALV_GRID_DISPLAY_LVC,providethesubroutinenametoexporting
parameteri_callback_pf_status_set.
CALLFUNCTION'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program=syrepid
i_callback_pf_status_set='SET_PF_STATUS'
i_callback_user_command='USER_COMMAND'
it_fieldcat_lvc=li_fcat
...
https://musicodez.wordpress.com/2010/09/11/addingcustombuttontoalvtoolbarusingreuse_alv_grid_display_lvc/

3/6

5/11/2015

AddingCustomButtontoALVtoolbar(usingREUSE_ALV_GRID_DISPLAY_LVC)| Musicodez

(note:theparameterrt_extabishavetobeprovidedtoavoidshortdumpwhiletheFMtrytocallthe
subroutine.ThisparameterisfilledwiththelistoffunctioncodethatcomeswithdefaultpfstatusoftheALV.
4.Addingfunctionalitytothenewicon
Now,whileweexecutetheprogram,theALVshouldhavethenewicondisplayed.However,weneedto
addfunctionalitytothenewicon.
a.Createnewsubroutinewithanyname,forexampleUSER_COMMAND.
FORMuser_commandUSINGr_ucommLIKEsyucomm"#ECCALLED
rs_selfieldTYPEslis_selfield.
DATAlv_fileTYPEstring.
IFr_ucommEQ'%PDF'.Addthefunctioncodeofyouricon
Callsubroutine/processingcodehere
ENDIF.
ENDFORM."User_command

Thissubroutineshouldhavetwoparameterswithtypesyucommandslis_selfield.Thefirstparameterisused
Follow
torecognizewhichfunctionkeyisaccesed,whichwillreturntheokcode(functioncode)ofthefunctionkey.
Thesecondparameterwillreturntheinformationaboutwhichcellisselectedinthealv,whichwillbeusefulif
Follow
youwanttocreatehotspotintheALVoutputdata.Thesecondparameterwontbemuchuseforourcase
rightnow.
Musicodez
Get every new post delivered
b.WhilecallingtheFMREUSE_ALV_GRID_DISPLAY_LVC,providethesubroutinenametoexporting
to your Inbox.
parameteri_callback_user_command.
i_callback_user_command='USER_COMMAND'
Enteryouremailaddress

Now,youshouldalreadyhavethenewiconintheALVwithfullyfunctionality.OthericoninthecustomGUI
Signmeup
Statusthatcomesbydefaultwillhaveitsfunctionrunningautomatically.
Build a website with WordPress.com

Like

About these ads

Bethefirsttolikethis.

Categories:ABAP,ALV,SAP
Comments(1)Trackbacks(0)LeaveacommentTrackback
1.
RamShanker
May19,2011at4:01pm
Reply
THanks..Itisreallynice.
Ram
1. Notrackbacksyet.
https://musicodez.wordpress.com/2010/09/11/addingcustombuttontoalvtoolbarusingreuse_alv_grid_display_lvc/

4/6

5/11/2015

AddingCustomButtontoALVtoolbar(usingREUSE_ALV_GRID_DISPLAY_LVC)| Musicodez

LeaveaReply
Enteryourcommenthere...

RaisingClassExceptionCausedbyFMException
RSSfeed

It'sablog,sharingtipsandtrickbasedonexperiencedand'howtodo'tutorials,aboutSAP,especially
ABAPprogramminglanguage.

RecentPosts
UploadLongTextintoCustomTextObject
DynamicFieldSelection
CustomValidationonTableMaintenanceGenerator(SM30)
DownloadALVGridReporttoPDF
DatabaseInconsistenciesWhenAddingUserDefinedField

Categories
SelectCategory

Archives
September2010(7)
September2010
M T W T F S S

1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30


Top
https://musicodez.wordpress.com/2010/09/11/addingcustombuttontoalvtoolbarusingreuse_alv_grid_display_lvc/

5/6

5/11/2015

AddingCustomButtontoALVtoolbar(usingREUSE_ALV_GRID_DISPLAY_LVC)| Musicodez

BlogatWordPress.com.TheINoveTheme.

https://musicodez.wordpress.com/2010/09/11/addingcustombuttontoalvtoolbarusingreuse_alv_grid_display_lvc/

6/6

Potrebbero piacerti anche