Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

ALV F8 event + Checkbox?

Hi,

1. How to catch F8 event in an ALV?

2. How to determine witch checkbox is checked.

tnx!

Simple ALV example:

TYPE-POOLS: slis.

DATA: g_repid LIKE sy-repid,
gs_print            TYPE slis_print_alv,
gt_list_top_of_page TYPE slis_t_listheader,
gt_events           TYPE slis_t_event,
gt_sort             TYPE slis_t_sortinfo_alv,
gs_layout           TYPE slis_layout_alv,
gt_fieldcat         TYPE slis_t_fieldcat_alv,
fieldcat_ln LIKE LINE OF gt_fieldcat,
col_pos TYPE i.

DATA: BEGIN OF itab,
sel,
  field1(5) TYPE c,
  field2(5) TYPE c,
  field3(5) TYPE p DECIMALS 2,
END OF itab.

DATA: BEGIN OF itab1 OCCURS 0.
        INCLUDE STRUCTURE itab.
DATA: END OF itab1.

DATA: BEGIN OF itab_fieldcat OCCURS 0.
        INCLUDE STRUCTURE itab.
DATA: END OF itab_fieldcat.


INITIALIZATION.
  g_repid = sy-repid.
 " PERFORM print_build    USING gs_print.      "Print PARAMETERS
  gs_layout-box_fieldname = 'SEL'.

START-OF-SELECTION.
* TEST DATA
  MOVE 'TEST1' TO itab1-field1.
  MOVE 'TEST1' TO itab1-field2.
  MOVE '10.00' TO itab1-field3.
  APPEND itab1.

  MOVE 'TEST2' TO itab1-field1.
  MOVE 'TEST2' TO itab1-field2.
  MOVE '20.00' TO itab1-field3.
  APPEND itab1.

  DO 5 TIMES.
    APPEND itab1.
  ENDDO.

END-OF-SELECTION.

  PERFORM build.
  PERFORM call_alv.

*&---------------------------------------------------------------------*
*&      Form  BUILD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM build.
* DATA FIELD CATALOG
* Explain Field Description to ALV
  DATA: fieldcat_in TYPE slis_fieldcat_alv.

  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'FIELD1'.
  fieldcat_ln-tabname   = 'ITAB1'.
*FIELDCAT_LN-NO_OUT    = 'X'.  "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
  fieldcat_ln-key       = ' '.   "SUBTOTAL KEY
  fieldcat_ln-no_out    = ' '.
  fieldcat_ln-seltext_l = 'HEAD1'.
  APPEND fieldcat_ln TO gt_fieldcat.

  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'FIELD2'.
  fieldcat_ln-tabname   = 'ITAB1'.
  fieldcat_ln-no_out    = 'X'.
  fieldcat_ln-seltext_l = 'HEAD2'.
  APPEND fieldcat_ln TO gt_fieldcat.

  CLEAR fieldcat_in.
  fieldcat_ln-fieldname     = 'FIELD3'.
  fieldcat_ln-tabname       = 'ITAB1'.
  fieldcat_ln-ref_fieldname = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
  fieldcat_ln-ref_tabname   = 'MSEG'.  "<- REF TABLE IN THE DICTIONNARY
  fieldcat_ln-no_out        = ' '.
  fieldcat_ln-do_sum        = 'X'.   "SUM UPON DISPLAY
  APPEND fieldcat_ln TO gt_fieldcat.

* DATA SORTING AND SUBTOTAL
  DATA: gs_sort TYPE slis_sortinfo_alv.

  CLEAR gs_sort.
  gs_sort-fieldname = 'FIELD1'.
  gs_sort-spos      = 1.
  gs_sort-up        = 'X'.
  gs_sort-subtot    = 'X'.
  APPEND gs_sort TO gt_sort.

  CLEAR gs_sort.
  gs_sort-fieldname = 'FIELD2'.
  gs_sort-spos      = 2.
  gs_sort-up        = 'X'.
*GS_SORT-SUBTOT    = 'X'.
  APPEND gs_sort TO gt_sort.

ENDFORM.                    "BUILD

*&---------------------------------------------------------------------*
*&      Form  CALL_ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM call_alv.
* ABAP List Viewer
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
  EXPORTING
  i_callback_program = g_repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
  i_structure_name = 'ITAB1'
  is_layout =  gs_layout
  it_fieldcat = gt_fieldcat[]
    it_sort = gt_sort[]
    it_events = gt_events[]
    is_print = gs_print
  TABLES
  t_outtab = itab1
  EXCEPTIONS
  program_error = 1
  OTHERS = 2.
ENDFORM.                    "CALL_ALV

Tags:
Former Member
Former Member replied

FORM call_alv.

  • ABAP List Viewer

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = g_repid

I_CALLBACK_PF_STATUS_SET = 'PF-STATUS' '

i_callback_user_command = 'FORM_USER'

i_structure_name = 'ITAB1'

is_layout = GS_STATUS

it_fieldcat = gt_fieldcat[]

it_sort = gt_sort[]

it_events = gt_events[]

is_print = gs_print

TABLES

t_outtab = itab1

EXCEPTIONS

program_error = 1

OTHERS = 2.

ENDFORM. "CALL_ALV

&----


*& Form form_user

&----


  • text

----


FORM pf_status USING rt_ext TYPE slis_t_extab.

SET PF-STATUS 'ZSG_STATUS4'.

ENDFORM.

FORM form_user USING p_ucomm TYPE sy-ucomm

ps_selfield TYPE slis_selfield.

ps_selfield-fieldname = <lt2_vbak-vbeln fielname>.

CASE p_ucomm.

WHEN 'ENTER' OR 'SPACE'. " for F8

***do coding

ENDCASE.

ENDFORM. "form_user

CREATE A PF STATUS IN SE41

PLEASE WRITE EACH PARAMETERS IN CAPITAL LETTER IN ALV FM

Edited by: swati gupta on Sep 18, 2008 11:07 AM

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question