0% found this document useful (0 votes)
4K views6 pages

Adding Custom Button To ALV Toolbar (Using REUSE - ALV - GRID - DISPLAY - LVC) - Musicodez

The document describes how to add a custom button to the ALV toolbar when using the function module REUSE_ALV_GRID_DISPLAY_LVC. It involves copying an existing GUI status, adding a new button to it, and attaching the status to the ALV grid. The new button's function can then be defined by programming a callback subroutine to handle the user command.

Uploaded by

Ashish Mohapatra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4K views6 pages

Adding Custom Button To ALV Toolbar (Using REUSE - ALV - GRID - DISPLAY - LVC) - Musicodez

The document describes how to add a custom button to the ALV toolbar when using the function module REUSE_ALV_GRID_DISPLAY_LVC. It involves copying an existing GUI status, adding a new button to it, and attaching the status to the ALV grid. The new button's function can then be defined by programming a callback subroutine to handle the user command.

Uploaded by

Ashish Mohapatra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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

You might also like