Adding Custom Button to ALV Toolbar (Using REUSE_ALV_GRID_DISPLAY_LVC) _ Musicodez

6
5/11/2015 Adding Custom Button to ALV toolbar (using REUSE_ALV_GRID_DISPLAY_LVC) | Musicodez https://musicodez.wordpress.com/2010/09/11/addingcustombuttontoalvtoolbarusingreuse_alv_grid_display_lvc/ 1/6 Musicodez A Personal Notebook of an ABAPer Home Welcome About Type text to search here... Home > ABAP, ALV, SAP > Adding Custom Button to ALV toolbar (using REUSE_ALV_GRID_DISPLAY_LVC) Adding Custom Button to ALV toolbar (using REUSE_ALV_GRID_DISPLAY_LVC) September 11, 2010 marcponty Leave a comment Go to comments FM REUSE_ALV_GRID_DISPLAY_LVC automatically provide ALV toolbars for us. However, sometimes we need to add functionality to add new toolbar button. In example below, we want to add ‘download to pdf’ button for our alv. Here’s the steps. 1. Copy GUI status from other program Go to transaction SE41. Copy status ‘STANDARD_FULLSCREEN’ from program ‘SAPLSLVC_FULLSCREEN’, provide the program name and new GUI STATUS name for the program. There will be a confirmation dialog to define new short text for GUI STATUS object. It’s ok not to define new short text, so just proceed to next step.

description

adding button in alv

Transcript of Adding Custom Button to ALV Toolbar (Using REUSE_ALV_GRID_DISPLAY_LVC) _ Musicodez

  • 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.