Application Development and Automation 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: 
Read only

ALV

Former Member
0 Likes
770

Hi,

I am new to ALV. While displaying the output of ALV,as u all know a small toolbar appears above the grid which contains icons like sigma etc. How to control the actions on those icons.

i.e., for eg., if i click any icon like details icon or sigma icon,i want to display a message instead of normal funtions like giving summation for sigma icon.

Please help me to know how to do it...

Points wil be rewarded for helpful answers.

Regards,

Akshaya

6 REPLIES 6
Read only

Former Member
0 Likes
747

Hi

Hope this code will help you.

Reward if help.

REPORT YMS_CHECKBOXALV.

TYPE-POOLS: slis.

DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.

DATA: s_fieldcatalog TYPE slis_fieldcat_alv.

DATA: s_layout TYPE slis_layout_alv.

DATA: BEGIN OF itab OCCURS 0,

icon TYPE icon-id,

vbeln TYPE vbeln,

kunnr TYPE kunnr,

erdat TYPE erdat,

box TYPE c,

END OF itab.

DATA: v_repid TYPE syrepid.

START-OF-SELECTION.

  • Get the data.

SELECT vbeln kunnr erdat UP TO 100 ROWS

FROM vbak

INTO CORRESPONDING FIELDS OF TABLE itab.

IF sy-subrc <> 0.

MESSAGE s208(00) WITH 'No data found'.

LEAVE LIST-PROCESSING.

ENDIF.

  • Modify the record with red light.

itab-icon = '@0A@'.

MODIFY itab TRANSPORTING icon WHERE NOT vbeln IS initial.

v_repid = sy-repid.

  • Get the field catalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '1'.

s_fieldcatalog-fieldname = 'ICON'.

s_fieldcatalog-tabname = 'ITAB'.

s_fieldcatalog-seltext_l = 'Status'.

s_fieldcatalog-icon = 'X'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '2'.

s_fieldcatalog-fieldname = 'VBELN'.

s_fieldcatalog-tabname = 'ITAB'.

s_fieldcatalog-rollname = 'VBELN'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '3'.

s_fieldcatalog-fieldname = 'KUNNR'.

s_fieldcatalog-tabname = 'ITAB'.

s_fieldcatalog-rollname = 'KUNNR'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '4'.

s_fieldcatalog-fieldname = 'ERDAT'.

s_fieldcatalog-tabname = 'ITAB'.

s_fieldcatalog-rollname = 'ERDAT'.

APPEND s_fieldcatalog TO t_fieldcatalog.

  • Set the layout.

s_layout-box_fieldname = 'BOX'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = v_repid

is_layout = s_layout

i_callback_pf_status_set = 'SET_PF_STATUS'

i_callback_user_command = 'USER_COMMAND'

it_fieldcat = t_fieldcatalog[]

TABLES

t_outtab = itab.

----


  • FORM SET_PF_STATUS *

----


  • ........ *

----


  • --> EXTAB *

----


FORM set_pf_status USING extab TYPE slis_t_extab.

SET PF-STATUS 'TEST2'.

ENDFORM.

----


  • FORM user_command *

----


  • ........ *

----


  • --> UCOMM *

  • --> SELFIELD *

----


FORM user_command USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

  • Check the ucomm.

IF ucomm = 'DETAIL'.

LOOP AT itab WHERE box = 'X'.

itab-icon = '@08@'.

MODIFY itab TRANSPORTING icon.

ENDLOOP.

ENDIF.

selfield-refresh = 'X'.

ENDFORM.

Read only

pradeep_nellore
Participant
0 Likes
747

Hi,

For this you need to use user defined PF status for ALV much like our screen painter.

Thanks

--Pradeep

Read only

Former Member
0 Likes
747

Hi,

To meet your requirement,you need to use PF-STATUS in ALV

reports.

Have a look on the following code.

THIS IS THE GRID DISPLAY BY USING “PF-STATUS”.

REPORT ZCS_PRG14.

TYPE-POOLS: SLIS.

TYPES: BEGIN OF I_MARA,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

MEINS LIKE MARA-MEINS,

GROES LIKE MARA-GROES,

VOLUM LIKE MARA-VOLUM,

END OF I_MARA.

DATA: IT_MARA TYPE STANDARD TABLE OF I_MARA INITIAL SIZE 0.

DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

REPID TYPE SY-REPID,

GD_LAYOUT TYPE SLIS_LAYOUT_ALV.

DATA: I_TITLE_MARA TYPE LVC_TITLE VALUE 'GRID DISPLAY'.

START-OF-SELECTION.

PERFORM DATA_RETRIEVAL.

PERFORM BLD_FLDCAT.

PERFORM BLD_LAYOUT.

PERFORM DISPLAY_ALV_REPORT.

FORM BLD_FLDCAT.

FLDCAT-FIELDNAME = 'MATNR'.

FLDCAT-SELTEXT_M = 'MATERIAL NUMBER'.

FLDCAT-COL_POS = 0.

FLDCAT-KEY = 'X'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'MTART'.

FLDCAT-SELTEXT_M = 'MATERIAL TYPE'.

FLDCAT-COL_POS = 1.

FLDCAT-KEY = 'X'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'MEINS'.

FLDCAT-SELTEXT_M = 'UNIT OF MEASURE'.

FLDCAT-COL_POS = 2.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'GROES'.

FLDCAT-SELTEXT_M = 'SIZE'.

FLDCAT-COL_POS = 3.

FLDCAT-KEY = 'X'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'VOLUM'.

FLDCAT-SELTEXT_M = 'VOLUME'.

FLDCAT-COL_POS = 4.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

ENDFORM.

FORM BLD_LAYOUT.

GD_LAYOUT-NO_INPUT = 'X'.

GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

GD_LAYOUT-ZEBRA = 'X'.

GD_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'.

ENDFORM.

FORM DISPLAY_ALV_REPORT.

REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = REPID

I_CALLBACK_PF_STATUS_SET = 'STANDARD'

I_CALLBACK_USER_COMMAND = '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_MARA

  • I_GRID_SETTINGS =

IS_LAYOUT = GD_LAYOUT

IT_FIELDCAT = FLDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

I_SAVE = 'X'

  • IS_VARIANT =

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

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = IT_MARA

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

FORM DATA_RETRIEVAL.

SELECT MATNR MTART MEINS GROES VOLUM

INTO TABLE IT_MARA FROM MARA

UP TO 40 ROWS.

ENDFORM.

FORM TOP_OF_PAGE.

DATA: T_HEADER TYPE SLIS_T_LISTHEADER,

WA_HEADER TYPE SLIS_LISTHEADER.

WA_HEADER-TYP = 'H'.

WA_HEADER-INFO = 'THIS IS MY FIRST ALV'.

APPEND WA_HEADER TO T_HEADER.

WA_HEADER-TYP = 'S'.

WA_HEADER-INFO = 'THIS IS SECOND'.

APPEND WA_HEADER TO T_HEADER.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = T_HEADER

  • I_LOGO =

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

ENDFORM.

FORM STANDARD USING EXTAB TYPE SLIS_T_EXTAB.

SET PF-STATUS 'STANDA02' EXCLUDING EXTAB.

ENDFORM.

FORM USER-COMMAND USING R_COMM TYPE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

CASE R_COMM.

WHEN 'F3'.

LEAVE PROGRAM.

ENDCASE.

ENDFORM.

Double click on “STANDA02”, it opens new screen(menu painter),there u can add menu bars, application tool bars etc.

Regards,

Chandu

Read only

Former Member
0 Likes
747

HI

u need to set the pf status for this.

if u want to copy the standard tool bar the go to se80...in FUNCTION GROUP give SALV and in that select the gui status ..STANDARD right click and copy and then it wil ask the target name...u can give u r program name..and gui status......

now goto se41 and there u edit the functionalities .

Edited by: Jyothsna M on Apr 1, 2008 6:59 AM

Read only

Former Member
0 Likes
747

Hi,

for this u have to

1.first go to SE41.

2.Give the program name as SAPLKKBL

3.In Staus Give Standard.

4.Then Press Copy Status Button.

5.Give your Program Name and Status Name and Press Ok.

6.Then press change.

7.Go to Application toolBar

8.Click on the Icon U want to change.

9.Change The function Code give your own function Code and in Program

write when sy-ucomm = <Your Function Code> Display The message

Regards

Sandipan

Read only

Former Member
0 Likes
747

Hi guys,

Thanks for your reply.

You all have answered as setting PF-STATUS. But actually my requirement is not to control functions of icons of gui_status.

While displaying the grid,some icons wil be displayed attached with grid itself like sigma,filter and display icon and i want to control functions of those icons only and not gui status.

Please help me...

Points wil be rewarded for helpful answers.

Regards,

kamalapriya