Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

re : alv

Former Member
0 Kudos

hai friends

can anybody tellme how to create push button in alv.

thanks

by

geetha

1 ACCEPTED SOLUTION

Former Member
0 Kudos

In that case you can re-write the behavior of the ADDLINE button.

1) Add button to ALV toolbar

METHOD handle_toolbar_event. "FOR EVENT toolbar OF cl_gui_alv_grid

" IMPORTING e_object e_interactive,

DATA: ls_toolbar TYPE stb_button.

CLEAR ls_toolbar.

MOVE 'ADDLINE' TO ls_toolbar-function. " This will be your

e_ucomm

MOVE icon_insert_row TO ls_toolbar-icon.

MOVE 'Add Line' TO ls_toolbar-quickinfo.

MOVE gc_false TO ls_toolbar-disabled.

APPEND ls_toolbar TO e_object->mt_toolbar.

ENDMETHOD. "

2)Now handle this toolbar event in the local class

METHOD handle_user_command . "FOR EVENT user_command OF cl_gui_alv_grid

" IMPORTING e_ucomm,

IF e_ucomm EQ 'ADDLINE'.

" CALL METHOD cl_gui_cfw=>set_new_ok_code

" EXPORTING

" new_code = e_ucomm.

"You can write your code here for adding a line and added functionality

Endif.

ENDMETHOD. "

3) Also, in the PBO, exclude the standard ADD button

DATA: exclude_tab TYPE TABLE OF ui_func.

Data: ls_exclude type ui_func.

ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.

APPEND ls_exclude TO exclude_tab.

CALL METHOD my_alv_grid->set_table_for_first_display

EXPORTING

it_toolbar_excluding = exclude_tab.

OR

try this

For example. see in this call we are passing the SET_PF_STATUS_SDO to the i_callback_pf_status-set as well as the REPID to the i_callback_program. This tells the alv to comeback to this program to set the status.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = repid

i_callback_pf_status_set = 'SET_PF_STATUS_SDO'

i_callback_user_command = 'HANDLE_USER_COMMAND_SDO'

is_layout = ilayout

it_fieldcat = ifc

it_sort = isort

i_grid_title = xgrid_title

tables

t_outtab = ialv_sdo

exceptions

program_error = 1

others = 2.

Then you need to have the FORM routine in this program.

form set_pf_status_sdo using rt_extab type slis_t_extab.

set pf-status 'STANDARD'.

endform.

check these ones:

Standard Buttons:

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/webDynproABAP-ALVControllingStandard+Buttons&

alv-pfstatus:

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_pfstatus.htm

then how to capture that button click.

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_ucomm.htm

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_rowsel.htm

-


Add User command functionality to ALVgrid report

In order modify PF_STATUS of ALV grid report you need to perform the following steps:

1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include:

i_callback_pf_status_set = 'SET_PF_STATUS' statement.

2. Create 'SET_PF_STATUS' FORM

3. Create pf_status (i.e. 'ZNEWSTATUS').

- It is recommend that you copy standard status'STANDARD' from function group SALV

and modify it accordingly. ALV standard function codes always start with '&'.

please copy the below code and just copy and pfstatus and see ..

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

i_callback_top_of_page = 'TOP-OF-PAGE'

i_callback_pf_status_set = 'SET_PF_STATUS' "see FORM

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

i_save = 'X'

tables

t_outtab = it_ekko

exceptions

program_error = 1

others = 2.

FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'ZNEWSTATUS'.

"Copy of 'STANDARD' pf_status from fgroup SALV

ENDFORM.

-


An Interactive ALV Report

&----


*& Report ZZ_22038_22098_002 *

*& *

&----


*& This is an Interactive ALV report, where on line slection we can see

*& the secondry list

*&

*& *

&----


REPORT ZZ_22038_22098_002 NO STANDARD PAGE HEADING LINE-SIZE 650

MESSAGE-ID ZZ_9838 .

TYPE-POOLS: SLIS.

*type declaration for values from ekko

TYPES: BEGIN OF I_EKKO,

EBELN LIKE EKKO-EBELN,

AEDAT LIKE EKKO-AEDAT,

BUKRS LIKE EKKO-BUKRS,

BSART LIKE EKKO-BSART,

LIFNR LIKE EKKO-LIFNR,

END OF I_EKKO.

DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,

WA_EKKO TYPE I_EKKO.

*type declaration for values from ekpo

TYPES: BEGIN OF I_EKPO,

EBELN LIKE EKPO-EBELN,

EBELP LIKE EKPO-EBELP,

MATNR LIKE EKPO-MATNR,

MENGE LIKE EKPO-MENGE,

MEINS LIKE EKPO-MEINS,

NETPR LIKE EKPO-NETPR,

END OF I_EKPO.

DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,

WA_EKPO TYPE I_EKPO .

*variable for Report ID

DATA: V_REPID LIKE SY-REPID .

*declaration for fieldcatalog

DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.

  • declaration for events table where user comand or set PF status will

  • be defined

DATA: V_EVENTS TYPE SLIS_T_EVENT,

WA_EVENT TYPE SLIS_ALV_EVENT.

  • declartion for layout

DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.

  • declaration for variant(type of display we want)

DATA: I_VARIANT TYPE DISVARIANT,

I_VARIANT1 TYPE DISVARIANT,

I_SAVE(1) TYPE C.

*PARAMETERS : p_var TYPE disvariant-variant.

*Title displayed when the alv list is displayed

DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.

DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.

INITIALIZATION.

V_REPID = SY-REPID.

PERFORM BUILD_FIELDCATLOG.

PERFORM EVENT_CALL.

PERFORM POPULATE_EVENT.

START-OF-SELECTION.

PERFORM DATA_RETRIEVAL.

PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.

PERFORM DISPLAY_ALV_REPORT.

&----


*& Form BUILD_FIELDCATLOG

&----


  • Fieldcatalog has all the field details from ekko

----


FORM BUILD_FIELDCATLOG.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-FIELDNAME = 'EBELN'.

WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-FIELDNAME = 'AEDAT'.

WA_FIELDCAT-SELTEXT_M = 'DATE.'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-FIELDNAME = 'BUKRS'.

WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-FIELDNAME = 'BUKRS'.

WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-FIELDNAME = 'LIFNR'.

WA_FIELDCAT-NO_OUT = 'X'.

WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

ENDFORM. "BUILD_FIELDCATLOG

&----


*& Form EVENT_CALL

&----


  • we get all events - TOP OF PAGE or USER COMMAND in table v_events

----


FORM EVENT_CALL.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = V_EVENTS

  • EXCEPTIONS

  • LIST_TYPE_WRONG = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. "EVENT_CALL

&----


*& Form POPULATE_EVENT

&----


  • Events populated for TOP OF PAGE & USER COMAND

----


FORM POPULATE_EVENT.

READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.

IF SY-SUBRC EQ 0.

WA_EVENT-FORM = 'TOP_OF_PAGE'.

MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

WA_EVENT-FORM.

ENDIF.

READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.

IF SY-SUBRC EQ 0.

WA_EVENT-FORM = 'USER_COMMAND'.

MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

WA_EVENT-NAME.

ENDIF.

ENDFORM. "POPULATE_EVENT

&----


*& Form data_retrieval

&----


  • retreiving values from the database table ekko

----


FORM DATA_RETRIEVAL.

SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.

ENDFORM. "data_retrieval

&----


*& Form bUild_listheader

&----


  • text

----


  • -->I_LISTHEADEtext

----


FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.

DATA HLINE TYPE SLIS_LISTHEADER.

HLINE-INFO = 'this is my first alv pgm'.

HLINE-TYP = 'H'.

ENDFORM. "build_listheader

&----


*& Form display_alv_report

&----


  • text

----


FORM DISPLAY_ALV_REPORT.

V_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = V_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

I_GRID_TITLE = I_TITLE_EKKO

  • I_GRID_SETTINGS =

  • IS_LAYOUT = ALV_LAYOUT

IT_FIELDCAT = I_FIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • i_default = 'ZLAY1'

I_SAVE = 'A'

  • is_variant = i_variant

IT_EVENTS = V_EVENTS

TABLES

T_OUTTAB = IT_EKKO

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. "display_alv_report

&----


*& Form TOP_OF_PAGE

&----


  • text

----


FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = IT_LISTHEADER

  • i_logo =

  • I_END_OF_LIST_GRID =

.

ENDFORM. "TOP_OF_PAGE

&----


*& Form USER_COMMAND

&----


  • text

----


  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

----


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

CASE R_UCOMM.

WHEN '&IC1'.

READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.

PERFORM BUILD_FIELDCATLOG_EKPO.

PERFORM EVENT_CALL_EKPO.

PERFORM POPULATE_EVENT_EKPO.

PERFORM DATA_RETRIEVAL_EKPO.

PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.

PERFORM DISPLAY_ALV_EKPO.

ENDCASE.

ENDFORM. "user command

&----


*& Form BUILD_FIELDCATLOG_EKPO

&----


  • text

----


FORM BUILD_FIELDCATLOG_EKPO.

WA_FIELDCAT-TABNAME = 'IT_EKPO'.

WA_FIELDCAT-FIELDNAME = 'EBELN'.

WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_EKPO'.

WA_FIELDCAT-FIELDNAME = 'EBELP'.

WA_FIELDCAT-SELTEXT_M = 'LINE NO'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'I_EKPO'.

WA_FIELDCAT-FIELDNAME = 'MATNR'.

WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'I_EKPO'.

WA_FIELDCAT-FIELDNAME = 'MENGE'.

WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'I_EKPO'.

WA_FIELDCAT-FIELDNAME = 'MEINS'.

WA_FIELDCAT-SELTEXT_M = 'UOM'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'I_EKPO'.

WA_FIELDCAT-FIELDNAME = 'NETPR'.

WA_FIELDCAT-SELTEXT_M = 'PRICE'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

ENDFORM. "BUILD_FIELDCATLOG_EKPO

&----


*& Form event_call_ekpo

&----


  • we get all events - TOP OF PAGE or USER COMMAND in table v_events

----


FORM EVENT_CALL_EKPO.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = V_EVENTS

  • EXCEPTIONS

  • LIST_TYPE_WRONG = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. "event_call_ekpo

&----


*& Form POPULATE_EVENT

&----


  • Events populated for TOP OF PAGE & USER COMAND

----


FORM POPULATE_EVENT_EKPO.

READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.

IF SY-SUBRC EQ 0.

WA_EVENT-FORM = 'TOP_OF_PAGE'.

MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

WA_EVENT-FORM.

ENDIF.

ENDFORM. "POPULATE_EVENT

&----


*& Form TOP_OF_PAGE

&----


  • text

----


FORM F_TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = IT_LISTHEADER

  • i_logo =

  • I_END_OF_LIST_GRID =

.

ENDFORM. "TOP_OF_PAGE

&----


*& Form USER_COMMAND

&----


  • text

----


  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

----


*retreiving values from the database table ekko

FORM DATA_RETRIEVAL_EKPO.

SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.

ENDFORM.

FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.

DATA: HLINE1 TYPE SLIS_LISTHEADER.

HLINE1-TYP = 'H'.

HLINE1-INFO = 'CHECKING PGM'.

ENDFORM.

FORM DISPLAY_ALV_EKPO.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = V_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = I_TITLE_EKPO

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

IT_FIELDCAT = I_FIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT =

I_SAVE = 'A'

  • IS_VARIANT =

IT_EVENTS = V_EVENTS

TABLES

T_OUTTAB = IT_EKPO

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM.

-


what u have done is perfectly right!! should be some minor problem...

jus check if you have done the following....

-> copy GUI status from the standard program of the alv... i think the program name is SAPLSLVC_FULLSCREEN into your program say 'zstandard' as in ur case.

-> create form as below...

FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'ZSTANDARD'.

ENDFORM.

-> Add a button to the copied pf-status and assin a function code to it...

-> Add the following form to catch the click event..

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

IF r_ucomm EQ '<function code of the button u added>'.

(whatever you wanted to do)

ENDIF.

ENDFORM.

-> Now call reuse alv with the following params:

call function 'REUSE_ALV_GRID_DISPLAY'

exporting i_callback_program = <your prog name>

I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

i_grid_title = lc_grid_title <Title text of the alv grid>

is_layout = lc_layout <Layout options to optimize the display>

it_fieldcat = gt_fieldcat <field catalog setting form name>

tables t_outtab = <name of the table u want to pass to alv>

exceptions program_error = 1

others = 2.

This should work fine!

Or you should be having problems with the call to the second list...

-


Let me explain you in detail...

-> Go to the Gui status that you have copied from the standard program.

-> Click on expand icon next to the Applicaion toolbar displayed.

-> You will see a display something like this...

-


items 1-7 | <icon name1> | <icon name2> |

-


items 8-14 | <icon name3> | <icon name4> |

-


-> you would have added your icon in the last...

-> remove that cut and paste in the <icon name1> position and move that to the last.

-> your icon will be the first now!!! in the application toolbar...

regards,

Prabhu

reward if ti is helpful.

7 REPLIES 7

Former Member
0 Kudos

In that case you can re-write the behavior of the ADDLINE button.

1) Add button to ALV toolbar

METHOD handle_toolbar_event. "FOR EVENT toolbar OF cl_gui_alv_grid

" IMPORTING e_object e_interactive,

DATA: ls_toolbar TYPE stb_button.

CLEAR ls_toolbar.

MOVE 'ADDLINE' TO ls_toolbar-function. " This will be your

e_ucomm

MOVE icon_insert_row TO ls_toolbar-icon.

MOVE 'Add Line' TO ls_toolbar-quickinfo.

MOVE gc_false TO ls_toolbar-disabled.

APPEND ls_toolbar TO e_object->mt_toolbar.

ENDMETHOD. "

2)Now handle this toolbar event in the local class

METHOD handle_user_command . "FOR EVENT user_command OF cl_gui_alv_grid

" IMPORTING e_ucomm,

IF e_ucomm EQ 'ADDLINE'.

" CALL METHOD cl_gui_cfw=>set_new_ok_code

" EXPORTING

" new_code = e_ucomm.

"You can write your code here for adding a line and added functionality

Endif.

ENDMETHOD. "

3) Also, in the PBO, exclude the standard ADD button

DATA: exclude_tab TYPE TABLE OF ui_func.

Data: ls_exclude type ui_func.

ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.

APPEND ls_exclude TO exclude_tab.

CALL METHOD my_alv_grid->set_table_for_first_display

EXPORTING

it_toolbar_excluding = exclude_tab.

OR

try this

For example. see in this call we are passing the SET_PF_STATUS_SDO to the i_callback_pf_status-set as well as the REPID to the i_callback_program. This tells the alv to comeback to this program to set the status.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = repid

i_callback_pf_status_set = 'SET_PF_STATUS_SDO'

i_callback_user_command = 'HANDLE_USER_COMMAND_SDO'

is_layout = ilayout

it_fieldcat = ifc

it_sort = isort

i_grid_title = xgrid_title

tables

t_outtab = ialv_sdo

exceptions

program_error = 1

others = 2.

Then you need to have the FORM routine in this program.

form set_pf_status_sdo using rt_extab type slis_t_extab.

set pf-status 'STANDARD'.

endform.

check these ones:

Standard Buttons:

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/webDynproABAP-ALVControllingStandard+Buttons&

alv-pfstatus:

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_pfstatus.htm

then how to capture that button click.

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_ucomm.htm

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_rowsel.htm

-


Add User command functionality to ALVgrid report

In order modify PF_STATUS of ALV grid report you need to perform the following steps:

1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include:

i_callback_pf_status_set = 'SET_PF_STATUS' statement.

2. Create 'SET_PF_STATUS' FORM

3. Create pf_status (i.e. 'ZNEWSTATUS').

- It is recommend that you copy standard status'STANDARD' from function group SALV

and modify it accordingly. ALV standard function codes always start with '&'.

please copy the below code and just copy and pfstatus and see ..

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

i_callback_top_of_page = 'TOP-OF-PAGE'

i_callback_pf_status_set = 'SET_PF_STATUS' "see FORM

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

i_save = 'X'

tables

t_outtab = it_ekko

exceptions

program_error = 1

others = 2.

FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'ZNEWSTATUS'.

"Copy of 'STANDARD' pf_status from fgroup SALV

ENDFORM.

-


An Interactive ALV Report

&----


*& Report ZZ_22038_22098_002 *

*& *

&----


*& This is an Interactive ALV report, where on line slection we can see

*& the secondry list

*&

*& *

&----


REPORT ZZ_22038_22098_002 NO STANDARD PAGE HEADING LINE-SIZE 650

MESSAGE-ID ZZ_9838 .

TYPE-POOLS: SLIS.

*type declaration for values from ekko

TYPES: BEGIN OF I_EKKO,

EBELN LIKE EKKO-EBELN,

AEDAT LIKE EKKO-AEDAT,

BUKRS LIKE EKKO-BUKRS,

BSART LIKE EKKO-BSART,

LIFNR LIKE EKKO-LIFNR,

END OF I_EKKO.

DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,

WA_EKKO TYPE I_EKKO.

*type declaration for values from ekpo

TYPES: BEGIN OF I_EKPO,

EBELN LIKE EKPO-EBELN,

EBELP LIKE EKPO-EBELP,

MATNR LIKE EKPO-MATNR,

MENGE LIKE EKPO-MENGE,

MEINS LIKE EKPO-MEINS,

NETPR LIKE EKPO-NETPR,

END OF I_EKPO.

DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,

WA_EKPO TYPE I_EKPO .

*variable for Report ID

DATA: V_REPID LIKE SY-REPID .

*declaration for fieldcatalog

DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.

  • declaration for events table where user comand or set PF status will

  • be defined

DATA: V_EVENTS TYPE SLIS_T_EVENT,

WA_EVENT TYPE SLIS_ALV_EVENT.

  • declartion for layout

DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.

  • declaration for variant(type of display we want)

DATA: I_VARIANT TYPE DISVARIANT,

I_VARIANT1 TYPE DISVARIANT,

I_SAVE(1) TYPE C.

*PARAMETERS : p_var TYPE disvariant-variant.

*Title displayed when the alv list is displayed

DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.

DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.

INITIALIZATION.

V_REPID = SY-REPID.

PERFORM BUILD_FIELDCATLOG.

PERFORM EVENT_CALL.

PERFORM POPULATE_EVENT.

START-OF-SELECTION.

PERFORM DATA_RETRIEVAL.

PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.

PERFORM DISPLAY_ALV_REPORT.

&----


*& Form BUILD_FIELDCATLOG

&----


  • Fieldcatalog has all the field details from ekko

----


FORM BUILD_FIELDCATLOG.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-FIELDNAME = 'EBELN'.

WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-FIELDNAME = 'AEDAT'.

WA_FIELDCAT-SELTEXT_M = 'DATE.'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-FIELDNAME = 'BUKRS'.

WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-FIELDNAME = 'BUKRS'.

WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-FIELDNAME = 'LIFNR'.

WA_FIELDCAT-NO_OUT = 'X'.

WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

ENDFORM. "BUILD_FIELDCATLOG

&----


*& Form EVENT_CALL

&----


  • we get all events - TOP OF PAGE or USER COMMAND in table v_events

----


FORM EVENT_CALL.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = V_EVENTS

  • EXCEPTIONS

  • LIST_TYPE_WRONG = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. "EVENT_CALL

&----


*& Form POPULATE_EVENT

&----


  • Events populated for TOP OF PAGE & USER COMAND

----


FORM POPULATE_EVENT.

READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.

IF SY-SUBRC EQ 0.

WA_EVENT-FORM = 'TOP_OF_PAGE'.

MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

WA_EVENT-FORM.

ENDIF.

READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.

IF SY-SUBRC EQ 0.

WA_EVENT-FORM = 'USER_COMMAND'.

MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

WA_EVENT-NAME.

ENDIF.

ENDFORM. "POPULATE_EVENT

&----


*& Form data_retrieval

&----


  • retreiving values from the database table ekko

----


FORM DATA_RETRIEVAL.

SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.

ENDFORM. "data_retrieval

&----


*& Form bUild_listheader

&----


  • text

----


  • -->I_LISTHEADEtext

----


FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.

DATA HLINE TYPE SLIS_LISTHEADER.

HLINE-INFO = 'this is my first alv pgm'.

HLINE-TYP = 'H'.

ENDFORM. "build_listheader

&----


*& Form display_alv_report

&----


  • text

----


FORM DISPLAY_ALV_REPORT.

V_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = V_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

I_GRID_TITLE = I_TITLE_EKKO

  • I_GRID_SETTINGS =

  • IS_LAYOUT = ALV_LAYOUT

IT_FIELDCAT = I_FIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • i_default = 'ZLAY1'

I_SAVE = 'A'

  • is_variant = i_variant

IT_EVENTS = V_EVENTS

TABLES

T_OUTTAB = IT_EKKO

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. "display_alv_report

&----


*& Form TOP_OF_PAGE

&----


  • text

----


FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = IT_LISTHEADER

  • i_logo =

  • I_END_OF_LIST_GRID =

.

ENDFORM. "TOP_OF_PAGE

&----


*& Form USER_COMMAND

&----


  • text

----


  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

----


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

CASE R_UCOMM.

WHEN '&IC1'.

READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.

PERFORM BUILD_FIELDCATLOG_EKPO.

PERFORM EVENT_CALL_EKPO.

PERFORM POPULATE_EVENT_EKPO.

PERFORM DATA_RETRIEVAL_EKPO.

PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.

PERFORM DISPLAY_ALV_EKPO.

ENDCASE.

ENDFORM. "user command

&----


*& Form BUILD_FIELDCATLOG_EKPO

&----


  • text

----


FORM BUILD_FIELDCATLOG_EKPO.

WA_FIELDCAT-TABNAME = 'IT_EKPO'.

WA_FIELDCAT-FIELDNAME = 'EBELN'.

WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_EKPO'.

WA_FIELDCAT-FIELDNAME = 'EBELP'.

WA_FIELDCAT-SELTEXT_M = 'LINE NO'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'I_EKPO'.

WA_FIELDCAT-FIELDNAME = 'MATNR'.

WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'I_EKPO'.

WA_FIELDCAT-FIELDNAME = 'MENGE'.

WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'I_EKPO'.

WA_FIELDCAT-FIELDNAME = 'MEINS'.

WA_FIELDCAT-SELTEXT_M = 'UOM'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'I_EKPO'.

WA_FIELDCAT-FIELDNAME = 'NETPR'.

WA_FIELDCAT-SELTEXT_M = 'PRICE'.

APPEND WA_FIELDCAT TO I_FIELDCAT.

CLEAR WA_FIELDCAT.

ENDFORM. "BUILD_FIELDCATLOG_EKPO

&----


*& Form event_call_ekpo

&----


  • we get all events - TOP OF PAGE or USER COMMAND in table v_events

----


FORM EVENT_CALL_EKPO.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = V_EVENTS

  • EXCEPTIONS

  • LIST_TYPE_WRONG = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. "event_call_ekpo

&----


*& Form POPULATE_EVENT

&----


  • Events populated for TOP OF PAGE & USER COMAND

----


FORM POPULATE_EVENT_EKPO.

READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.

IF SY-SUBRC EQ 0.

WA_EVENT-FORM = 'TOP_OF_PAGE'.

MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

WA_EVENT-FORM.

ENDIF.

ENDFORM. "POPULATE_EVENT

&----


*& Form TOP_OF_PAGE

&----


  • text

----


FORM F_TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = IT_LISTHEADER

  • i_logo =

  • I_END_OF_LIST_GRID =

.

ENDFORM. "TOP_OF_PAGE

&----


*& Form USER_COMMAND

&----


  • text

----


  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

----


*retreiving values from the database table ekko

FORM DATA_RETRIEVAL_EKPO.

SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.

ENDFORM.

FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.

DATA: HLINE1 TYPE SLIS_LISTHEADER.

HLINE1-TYP = 'H'.

HLINE1-INFO = 'CHECKING PGM'.

ENDFORM.

FORM DISPLAY_ALV_EKPO.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = V_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = I_TITLE_EKPO

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

IT_FIELDCAT = I_FIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT =

I_SAVE = 'A'

  • IS_VARIANT =

IT_EVENTS = V_EVENTS

TABLES

T_OUTTAB = IT_EKPO

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM.

-


what u have done is perfectly right!! should be some minor problem...

jus check if you have done the following....

-> copy GUI status from the standard program of the alv... i think the program name is SAPLSLVC_FULLSCREEN into your program say 'zstandard' as in ur case.

-> create form as below...

FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'ZSTANDARD'.

ENDFORM.

-> Add a button to the copied pf-status and assin a function code to it...

-> Add the following form to catch the click event..

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

IF r_ucomm EQ '<function code of the button u added>'.

(whatever you wanted to do)

ENDIF.

ENDFORM.

-> Now call reuse alv with the following params:

call function 'REUSE_ALV_GRID_DISPLAY'

exporting i_callback_program = <your prog name>

I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

i_grid_title = lc_grid_title <Title text of the alv grid>

is_layout = lc_layout <Layout options to optimize the display>

it_fieldcat = gt_fieldcat <field catalog setting form name>

tables t_outtab = <name of the table u want to pass to alv>

exceptions program_error = 1

others = 2.

This should work fine!

Or you should be having problems with the call to the second list...

-


Let me explain you in detail...

-> Go to the Gui status that you have copied from the standard program.

-> Click on expand icon next to the Applicaion toolbar displayed.

-> You will see a display something like this...

-


items 1-7 | <icon name1> | <icon name2> |

-


items 8-14 | <icon name3> | <icon name4> |

-


-> you would have added your icon in the last...

-> remove that cut and paste in the <icon name1> position and move that to the last.

-> your icon will be the first now!!! in the application toolbar...

regards,

Prabhu

reward if ti is helpful.

Former Member
0 Kudos

Hi Geetha rani,

Check out these threads,

hope this helps.

Former Member
0 Kudos

Hi,

1.Pushbutton

a>

Build events table with these events

w_events-form = 'PF_STATUS_SET'.

w_events-name = 'PF_STATUS_SET'.

APPEND w_events TO i_events.

CLEAR w_events.

w_events-form = 'USER_COMMAND'.

w_events-name = 'USER_COMMAND'.

APPEND w_events TO i_events.

CLEAR w_events.

b>.

Call back subroutine for 'PF_STATUS_SET,'USER_COMMAND are like this

FORM PF_STATUS_SET USING extab TYPE slis_t_extab.

SET PF-STATUS 'VENKAT' EXCLUDING extab.

ENDFORM. "set_pf_status

FORM user_command USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield .

ENDFORM. "user_command

2.Checkbox

a>.

Define one variable in ur final table

checkbox TYPE c .

b>.

While building fieldcatalog Itab.

Fill up this info for Checkbox .

w_field-fieldname = 'CHECKBOX'.

w_field-tabname = 'I_MARD'.

w_field-checkbox = 'X'.

w_field-input = 'X'.

w_field-seltext_m = 'Checkbox'.

APPEND w_field TO i_field.

CLEAR w_field.

3.

Have a look at this example program.

&----


*& Report ZORAY1234 *

*& *

&----


REPORT zoray1234 .

TABLES :mard .

TYPE-POOLS :slis.

DATA: BEGIN OF i_mard OCCURS 0,

checkbox TYPE c ,

matnr TYPE mard-matnr,

werks TYPE mard-werks,

lgort TYPE mard-lgort,

labst TYPE mard-labst,

END OF i_mard.

DATA :i_field TYPE slis_t_fieldcat_alv,

w_field LIKE LINE OF i_field,

i_events TYPE slis_t_event,

w_events LIKE LINE OF i_events.

START-OF-SELECTION.

PERFORM get_data.

PERFORM build_field.

PERFORM build_events.

PERFORM display_data.

&----


*& Form get_data

&----


FORM get_data .

SELECT matnr werks lgort labst

FROM mard

INTO CORRESPONDING FIELDS OF TABLE i_mard

WHERE werks = 'NB4'.

ENDFORM. " get_data

&----


*& Form build_field

&----


FORM build_field .

CLEAR w_field.

CLEAR i_field.

w_field-fieldname = 'CHECKBOX'.

w_field-tabname = 'I_MARD'.

w_field-checkbox = 'X'.

w_field-input = 'X'.

w_field-seltext_m = 'Checkbox'.

APPEND w_field TO i_field.

CLEAR w_field.

w_field-fieldname = 'MATNR'.

w_field-tabname = 'I_MARD'.

w_field-seltext_m = 'Matnr'.

APPEND w_field TO i_field.

CLEAR w_field.

w_field-fieldname = 'WERKS'.

w_field-tabname = 'I_MARD'.

w_field-seltext_m = 'Werks'.

APPEND w_field TO i_field.

CLEAR w_field.

w_field-fieldname = 'LGORT'.

w_field-tabname = 'I_MARD'.

w_field-seltext_m = 'Lgort'.

APPEND w_field TO i_field.

CLEAR w_field.

w_field-fieldname = 'LABST'.

w_field-tabname = 'I_MARD'.

w_field-seltext_m = 'Labst'.

APPEND w_field TO i_field.

CLEAR w_field.

ENDFORM. " build_field

&----


*& Form display_data

&----


FORM display_data .

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

i_callback_program = 'ZORAY1234'

    • i_callback_pf_status_set = 'SET_PF_STATUS'

  • i_callback_user_command = 'USER_COMMAND'

  • I_STRUCTURE_NAME =

  • IS_LAYOUT =

it_fieldcat = i_field

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

it_events = i_events

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = i_mard

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " display_data

&----


*& Form set_pf_status

&----


FORM PF_STATUS_SET USING extab TYPE slis_t_extab.

SET PF-STATUS 'VENKAT' EXCLUDING extab.

ENDFORM. "set_pf_status

&----


*& Form user_command

&----


  • text

----


FORM user_command USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield .

CASE ucomm.

WHEN 'BUTTON' .

LOOP AT i_mard WHERE checkbox = 'X'.

WRITE 😕 i_mard-matnr,

i_mard-werks,

i_mard-lgort,

i_mard-labst.

ENDLOOP.

WHEN 'BUTTON1'.

LOOP AT i_mard WHERE checkbox = 'X'.

WRITE 😕 i_mard-matnr,

i_mard-werks,

i_mard-lgort,

i_mard-labst.

ENDLOOP.

ENDCASE.

ENDFORM. "user_command

&----


*& Form build_events

&----


FORM build_events .

CLEAR i_events.

CLEAR i_events.

w_events-form = 'PF_STATUS_SET'.

w_events-name = 'PF_STATUS_SET'.

APPEND w_events TO i_events.

CLEAR w_events.

w_events-form = 'USER_COMMAND'.

w_events-name = 'USER_COMMAND'.

APPEND w_events TO i_events.

CLEAR w_events.

ENDFORM. " build_events

Regards,

Priyanka.

Former Member
0 Kudos

Simple ALV report

http://www.sapgenie.com/abap/controls/alvgrid.htm

http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox

ALV

1. Please give me general info on ALV.

http://www.sapfans.com/forums/viewtopic.php?t=58286

http://www.sapfans.com/forums/viewtopic.php?t=76490

http://www.sapfans.com/forums/viewtopic.php?t=20591

http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.

2. How do I program double click in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=11601

http://www.sapfans.com/forums/viewtopic.php?t=23010

3. How do I add subtotals (I have problem to add them)...

http://www.sapfans.com/forums/viewtopic.php?t=20386

http://www.sapfans.com/forums/viewtopic.php?t=85191

http://www.sapfans.com/forums/viewtopic.php?t=88401

http://www.sapfans.com/forums/viewtopic.php?t=17335

4. How to add list heading like top-of-page in ABAP lists?

http://www.sapfans.com/forums/viewtopic.php?t=58775

http://www.sapfans.com/forums/viewtopic.php?t=60550

http://www.sapfans.com/forums/viewtopic.php?t=16629

5. How to print page number / total number of pages X/XX in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)

6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.

http://www.sapfans.com/forums/viewtopic.php?t=64320

http://www.sapfans.com/forums/viewtopic.php?t=44477

7. How can I set the cell color in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=52107

8. How do I print a logo/graphics in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=81149

http://www.sapfans.com/forums/viewtopic.php?t=35498

http://www.sapfans.com/forums/viewtopic.php?t=5013

9. How do I create and use input-enabled fields in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=84933

http://www.sapfans.com/forums/viewtopic.php?t=69878

10. How can I use ALV for reports that are going to be run in background?

http://www.sapfans.com/forums/viewtopic.php?t=83243

http://www.sapfans.com/forums/viewtopic.php?t=19224

11. How can I display an icon in ALV? (Common requirement is traffic light icon).

http://www.sapfans.com/forums/viewtopic.php?t=79424

http://www.sapfans.com/forums/viewtopic.php?t=24512

12. How can I display a checkbox in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=88376

http://www.sapfans.com/forums/viewtopic.php?t=40968

http://www.sapfans.com/forums/viewtopic.php?t=6919

Go thru these programs they may help u to try on some hands on

ALV Demo program

BCALV_DEMO_HTML

BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode

BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode

BCALV_GRID_DEMO Simple ALV Control Call Demo Program

BCALV_TREE_DEMO Demo for ALV tree control

BCALV_TREE_SIMPLE_DEMO

BC_ALV_DEMO_HTML_D0100

Former Member
0 Kudos

Hi Geetha,

Check this link,

<b>

<b>Regards,.

Jackie.</b>

Former Member
0 Kudos

thanks to all

Former Member
0 Kudos

hi

In se41 set the pf status and in application toolbar

you can create the button there.