Anda di halaman 1dari 3

SAPFI,CO,MM,PP,SD,PM,PS,QM,SM,HR,WF,BW,APO,Basis,ABAP/4,Certification,

Books

AddButtontoALVToolbarwithREUSE_ALV_LIST_DISPLAY
HowtoaddbuttontoALVtoolbarusingREUSE_ALV_LIST_DISPLAY?
IntheprogramwhichcallsALVusingREUSE_ALV_LIST_DISPLAY,
Ihavetoaddanewbutton.
IsawthedemoprogramBCALV_GRID_08,whichiswrittenusingABAPControls.
Inthatexample,thebuttonisaddedusingTOOLBAReventofcl_gui_alv_grid.
CouldyouhelpmetoimplementthesamelogicusingREUSE_ALV_LIST_DISPLAYparameters.

youshouldcopythe'STANDARD'GUIstatusfromprogramSAPLKKBLusingtransactionSE90
>ProgrammingSubObjects>GuiStatus.
Executethistransactiontogettonextscreen.selectstatususingcheckbox.clickonGUIStatus>Copy.
EnteryourZprogramnameandthenameyouwhatforthisstatusyoucankeepitas'STANDARD'to
besimple.
Thenyoucaneditthenewstatustoaddordeletebuttons.ThiswillalsobringinthestandardSAPALV
functionalitysuchassorting/subtotalingetc...
Whenyoucall'REUSE_ALV_GRID_DISPLAY'makesureyoupassitthenewstatusname.
anexampleofoneofmine:
callfunction'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program='ZSDBOLST_REPORT'
i_callback_pf_status_set='STANDARD'<
i_callback_user_command='USER_COMMAND'
i_structure_name='I_BOLACT'
i_grid_title='BOLActionReport'(031)
is_layout=gs_layout
it_fieldcat=gt_fieldcat[]
i_save='A'
is_variant=v_variant
TABLES
t_outtab=i_bolact
EXCEPTIONS
program_error=1
others=2.

Ijusttriedthesameprocedure,butmyentireapplicationtoolbardisappearedandalockiconappears
nexttotheapplicationtoolbarinmycopiedpfstatus.
Couldyouadvicewhatmighthavegonewrong?

AsidentifiedwiththeFM'shelpyoucandothefollowing.
1).UsingSE80(Ithink)youcancopyaGUIstatusfromoneprogramtoanother.Itmentionswhichone
intheFM'shelp.
2).Createaformnamedlikeso:
Code:
*****************************************************************
*FormSet_pf_status
*Notes:CalledbyFMREUSE_ALV_GRID_DISPLAY
*****************************************************************
FORMset_pf_statusUSINGrt_extabTYPEslis_t_extab.
SETPFSTATUS'ZSTANDARD'.
ENDFORM."Set_pf_status

IntheabovecasetheGUIstatuscopiedwasnamedZSTANDARDandadjustedaccordingly,addingand
removingthedesiredbuttons.Abuttonwasaddedcalled'%DELETE'.
3).Createthefollowingreport:
Code:
*****************************************************************
*FormUser_command
*Notes:CalledbyFMREUSE_ALV_GRID_DISPLAY
*Detectswhethertheicon/buttonfor
*'ReturnTagDeletion'hasbeenpressed.Ifithasthen
*detectwhetheranyrowshavebeenhighlightedandthen
*setthedeleteflag.
*****************************************************************
FORMuser_commandUSINGr_ucommLIKEsyucomm
rs_selfieldTYPEslis_selfield.
DATA:li_countTYPEI.
IFr_ucommEQ'%DELETE'.
LOOPAT%g00WHEREmarkEQ'X'.
ADD1TOli_count.
ENDLOOP.
IFli_countGT0.
gc_delete_flag='X'.
r_ucomm='&F03'."Backarraow
ELSE.
MESSAGEW000WITH'Pleasehighlighttherowstobedeleted!'.
ENDIF.
ENDIF.
ENDFORM."User_command

AsI'veaddedanextrabuttontoindicatewhichrecordsshouldbedeletedIneedtoidentifyaformtobe
calledtoprocesswhenthisbuttonischosen.
ThenwhenyoucalltheALVfunctionyoutospecifythefollowingextradetails:

Code:
callfunction'REUSE_ALV_GRID_DISPLAY'
exportingi_callback_program=gc_repid
I_CALLBACK_PF_STATUS_SET='SET_PF_STATUS'
I_CALLBACK_USER_COMMAND='USER_COMMAND'
i_grid_title=lc_grid_title
is_layout=lc_layout
it_fieldcat=gt_fieldcat
it_sort=sort
i_save=l_save
is_reprep_id=l_bbs_id
is_variant=l_variant
tablest_outtab=%g00
exceptionsprogram_error=1
others=2.
Theparametersincapitalsaretheextraonesthatneedtobeadded.
Thatshouldbeit!
MakeyousurethatyoualsoreadthehelpagainsttheALVfunction.
BacktoABAPMenu:
ABAPExampleHintsandTips
Returnto:
SAPABAP/4Programming,BasisAdministration,ConfigurationHintsandTips
(c)www.gotothings.comAllmaterialonthissiteisCopyright.
Everyeffortismadetoensurethecontentintegrity.Informationusedonthissiteisatyourownrisk.
Allproductnamesaretrademarksoftheirrespectivecompanies.Thesitewww.gotothings.comisinnowayaffiliatedwith
SAPAG.
Anyunauthorisedcopyingormirroringisprohibited.