Upload
ashish-mohapatra
View
262
Download
13
Embed Size (px)
DESCRIPTION
adding button in alv
Citation preview
5/11/2015 AddingCustomButtontoALVtoolbar(usingREUSE_ALV_GRID_DISPLAY_LVC)| Musicodez
https://musicodez.wordpress.com/2010/09/11/addingcustombuttontoalvtoolbarusingreuse_alv_grid_display_lvc/ 1/6
MusicodezAPersonalNotebookofanABAPer
HomeWelcomeAbout
Typetexttosearchhere... Home>ABAP,ALV,SAP>AddingCustomButtontoALVtoolbar(usingREUSE_ALV_GRID_DISPLAY_LVC)
AddingCustomButtontoALVtoolbar(usingREUSE_ALV_GRID_DISPLAY_LVC)
September11,2010marcpontyLeaveacommentGotocomments
FMREUSE_ALV_GRID_DISPLAY_LVCautomaticallyprovideALVtoolbarsforus.However,sometimesweneedtoaddfunctionalitytoaddnewtoolbarbutton.Inexamplebelow,wewanttoadddownloadtopdfbuttonforouralv.Heresthesteps.
1.CopyGUIstatusfromotherprogramGototransactionSE41.CopystatusSTANDARD_FULLSCREENfromprogramSAPLSLVC_FULLSCREEN,providetheprogramnameandnewGUISTATUSnamefortheprogram.TherewillbeaconfirmationdialogtodefinenewshorttextforGUISTATUSobject.Itsoknottodefinenewshorttext,sojustproceedtonextstep.
5/11/2015 AddingCustomButtontoALVtoolbar(usingREUSE_ALV_GRID_DISPLAY_LVC)| Musicodez
https://musicodez.wordpress.com/2010/09/11/addingcustombuttontoalvtoolbarusingreuse_alv_grid_display_lvc/ 2/6
2.AddnewbuttontonewlycreatedGUISTATUSa.GotoSE38>Edit>DisplayObjectList.InlefttoolbaryoullseeGUIStatusfolder.ContractthefolderandclickonthenewGUISTATUS.
b.Placethecursorwhereyouwanttoputthenewtoolbar,thenclickInsertEntrybutton.
c.EnternewOKCode(functioncode)foryourstatus.Onceyoupressenter,adialogboxwillappear.Choosestatictextaswearenottocreatearuntimedefinedicon.
5/11/2015 AddingCustomButtontoALVtoolbar(usingREUSE_ALV_GRID_DISPLAY_LVC)| Musicodez
https://musicodez.wordpress.com/2010/09/11/addingcustombuttontoalvtoolbarusingreuse_alv_grid_display_lvc/ 3/6
d.ProvideinformationoftheFunctionText.Functiontext:Name/identifierofthefunctiontext.Iconname:Nameoftheiconthatwillbeshown.JustpressF4toseelistoftheicon.Info.text:Informationthatwillbeshownwhenhoveringthroughtheicon.
e.Assignafunctionkey(shortcut)foryournewfunctionkey.Justpickfromoneofthelist.
f.Yournewiconwillbedisplayedontheiconlist.Youcanclicktheiconagaintoprovideotherparameter,forexampletodefinetheiconfunctionaltype,ortoprovideicontextsothatacustomtextwillbedisplayedsidebysidewiththeicon.
3.AttachtheGUIStatustotheALV
a.Createasubroutine,forexampleSET_PF_STATUS,andputbelowcode:
FORMset_pf_statusUSINGrt_extabTYPEslis_t_extab."#ECCALLEDDESCRIBETABLErt_extab."AvoidExtendedCheckWarningSETPFSTATUS'STANDARD_FULLSCREEN'.ENDFORM."Set_pf_status
b.WhilecallingtheFMREUSE_ALV_GRID_DISPLAY_LVC,providethesubroutinenametoexportingparameteri_callback_pf_status_set.
CALLFUNCTION'REUSE_ALV_GRID_DISPLAY_LVC'EXPORTINGi_callback_program=syrepidi_callback_pf_status_set='SET_PF_STATUS'i_callback_user_command='USER_COMMAND'it_fieldcat_lvc=li_fcat...
5/11/2015 AddingCustomButtontoALVtoolbar(usingREUSE_ALV_GRID_DISPLAY_LVC)| Musicodez
https://musicodez.wordpress.com/2010/09/11/addingcustombuttontoalvtoolbarusingreuse_alv_grid_display_lvc/ 4/6
(note:theparameterrt_extabishavetobeprovidedtoavoidshortdumpwhiletheFMtrytocallthesubroutine.ThisparameterisfilledwiththelistoffunctioncodethatcomeswithdefaultpfstatusoftheALV.
4.Addingfunctionalitytothenewicon
Now,whileweexecutetheprogram,theALVshouldhavethenewicondisplayed.However,weneedtoaddfunctionalitytothenewicon.
a.Createnewsubroutinewithanyname,forexampleUSER_COMMAND.
FORMuser_commandUSINGr_ucommLIKEsyucomm"#ECCALLEDrs_selfieldTYPEslis_selfield.DATAlv_fileTYPEstring.IFr_ucommEQ'%PDF'.AddthefunctioncodeofyouriconCallsubroutine/processingcodehereENDIF.ENDFORM."User_command
Thissubroutineshouldhavetwoparameterswithtypesyucommandslis_selfield.Thefirstparameterisusedtorecognizewhichfunctionkeyisaccesed,whichwillreturntheokcode(functioncode)ofthefunctionkey.Thesecondparameterwillreturntheinformationaboutwhichcellisselectedinthealv,whichwillbeusefulifyouwanttocreatehotspotintheALVoutputdata.Thesecondparameterwontbemuchuseforourcaserightnow.
b.WhilecallingtheFMREUSE_ALV_GRID_DISPLAY_LVC,providethesubroutinenametoexportingparameteri_callback_user_command.
i_callback_user_command='USER_COMMAND'
Now,youshouldalreadyhavethenewiconintheALVwithfullyfunctionality.OthericoninthecustomGUIStatusthatcomesbydefaultwillhaveitsfunctionrunningautomatically.
Categories:ABAP,ALV,SAPComments(1)Trackbacks(0)LeaveacommentTrackback
1.RamShankerMay19,2011at4:01pmReply
THanks..Itisreallynice.
Ram
1. Notrackbacksyet.
About these adsLike
Bethef irsttolikethis.
Follow
FollowMusicodezGet every new post deliveredto your Inbox.
Enteryouremailaddress
Signmeup
Build a website with WordPress.com
5/11/2015 AddingCustomButtontoALVtoolbar(usingREUSE_ALV_GRID_DISPLAY_LVC)| Musicodez
https://musicodez.wordpress.com/2010/09/11/addingcustombuttontoalvtoolbarusingreuse_alv_grid_display_lvc/ 5/6
LeaveaReply
RaisingClassExceptionCausedbyFMExceptionRSSfeed
It'sablog,sharingtipsandtrickbasedonexperiencedand'howtodo'tutorials,aboutSAP,especiallyABAPprogramminglanguage.
RecentPosts
UploadLongTextintoCustomTextObjectDynamicFieldSelectionCustomValidationonTableMaintenanceGenerator(SM30)DownloadALVGridReporttoPDFDatabaseInconsistenciesWhenAddingUserDefinedField
Categories
SelectCategory
Archives
September2010(7)
September2010M T W T F S S
1 2 3 4 56 7 8 9 10 11 1213 14 15 16 17 18 1920 21 22 23 24 25 2627 28 29 30
Top
Enteryourcommenthere...
5/11/2015 AddingCustomButtontoALVtoolbar(usingREUSE_ALV_GRID_DISPLAY_LVC)| Musicodez
https://musicodez.wordpress.com/2010/09/11/addingcustombuttontoalvtoolbarusingreuse_alv_grid_display_lvc/ 6/6
BlogatWordPress.com.TheINoveTheme.