Reuse_alv_grid_display_lvc- Row Selection Function

The REUSE_ALV_GRID_DISPLAY_LVC is used to display alv in the ABAP program. How to realize the line selection function? The method is as follows:

1, in the output internal table, define a C type field to mark which rows are selected, the selected is’X’

2, in LVC_S_LAYO-BOX_FNAME Specify the row selection field defined in 1

share picture

Complete code:

REPORT ztest_alv_lvc_selmode.


TYPES:BEGIN OF gty_ekko,
ebeln
TYPE ekko-ebeln,
verkf
TYPE ekko-verkf,
sel
TYPE c, "The field used to identify the row selection
END OF gty_ekko.
DATA:git_ekko TYPE STANDARD TABLE OF gty_ekko,
gwa_ekko
TYPE gty_ekko.

DATA:git_fcat TYPE lvc_t_fcat,
gwa_fcat
LIKE LINE OF git_fcat,
gwa_layout
TYPE lvc_s_layo.
CONSTANTS: gco_callback_user_command TYPE slis_formname VALUE 'FRM_USER_COMMAND',
gco_callback_status
TYPE slis_formname VALUE 'FRM_USER_STATUS'.

START-OF-SELECTION.

SELECT ebeln
verkf
INTO CORRESPONDING FIELDS OF TABLE git_ekko
FROM ekko
UP
TO 10 ROWS.

PERFORM frm_set_catalog.

gwa_layout
-zebra = 'X'.
gwa_layout
-box_fname = 'SEL'. "Specify row selection fields
gwa_layout-cwidth_opt = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program
= sy-repid
is_layout_lvc
= gwa_layout
it_fieldcat_lvc
= git_fcat
i_callback_pf_status_set
= gco_callback_status
i_callback_user_command
= gco_callback_user_command
TABLES
t_outtab
= git_ekko[]
EXCEPTIONS
program_error
= 1
OTHERS
= 2.
IF sy-subrc = 0.

ENDIF.
*&------------ -------------------------------------------------- -------*
*
& Form FRM_SET_PF_STATUS
*
&---------------------------- -----------------------------------------*
*
text
*
----------------------------- -----------------------------------------*
*
--> p1 text
*
<-- p2 text
*
----------------------------- -----------------------------------------*
FORM frm_user_status USING i_it_extab TYPE slis_t_extab.
SET PF-STATUS 'S0001'.
ENDFORM. " FRM_SET_PF_STATUS

FORM frm_user_command USING i_ucomm TYPE sy-ucomm
i_wa_selfield
TYPE slis_selfield.

DATA:l_count TYPE n,
l_msg
TYPE char100.
CASE i_ucomm.
WHEN
'POP'. "click POP button in application toolbar
LOOP AT git_ekko TRANSPORTING NO FIELDS WHERE sel = 'X'.
l_count
= l_count + 1.
ENDLOOP.
CONCATENATE 'Select'
l_count
'rows'
INTO l_msg
SEPARATED
BY space.
MESSAGE l_msg TYPE 'I'.
WHEN OTHERS.

ENDCASE.

ENDFORM.
*&------------ -------------------------------------------------- -------*
*
& Form FRM_SET_CATALOG
*
&---------------------------- -----------------------------------------*
*
text
*
----------------------------- -----------------------------------------*
*
--> p1 text
*
<-- p2 text
*
----------------------------- -----------------------------------------*
FORM frm_set_catalog.

DATA:l_pos TYPE i VALUE 1.
CLEAR: l_pos.
l_pos
= l_pos + 1.
gwa_fcat
-coltext = 'PO'.
gwa_fcat
-scrtext_l = 'PO'.
gwa_fcat
-scrtext_m = 'PO'.
gwa_fcat
-scrtext_s = 'PO'.
gwa_fcat
-fieldname = 'EBELN'.
gwa_fcat
-col_pos = l_pos.
gwa_fcat
-outputlen = '10'.
APPEND gwa_fcat TO git_fcat.
l_pos
= l_pos + 1.
gwa_fcat
-coltext = 'PO item'.
gwa_fcat
-scrtext_l = 'PO item'.
gwa_fcat
-scrtext_m = 'PO item'.
gwa_fcat
-scrtext_s = 'PO item'.
gwa_fcat
-fieldname = 'VERKF'.
gwa_fcat
-col_pos = l_pos.
gwa_fcat
-outputlen = '20'.
APPEND gwa_fcat TO git_fcat.

ENDFORM.

Create a status for the program and add a custom on it Button POPUP

share picture

Operation effect:

share picture

Above.

REPORT ztest_alv_lvc_selmode.


TYPES:BEGIN OF gty_ekko,
ebeln
TYPE ekko-ebeln,
verkf
TYPE ekko-verkf,
sel
TYPE c, "The field used to identify the row selection
END OF gty_ekko.
DATA:git_ekko TYPE STANDARD TABLE OF gty_ekko,
gwa_ekko
TYPE gty_ekko.

DATA:git_fcat TYPE lvc_t_fcat,
gwa_fcat
LIKE LINE OF git_fcat,
gwa_layout
TYPE lvc_s_layo.
CONSTANTS: gco_callback_user_command TYPE slis_formname VALUE 'FRM_USER_COMMAND',
gco_callback_status
TYPE slis_formname VALUE 'FRM_USER_STATUS'.

START-OF-SELECTION.

SELECT ebeln
verkf
INTO CORRESPONDING FIELDS OF TABLE git_ekko
FROM ekko
UP
TO 10 ROWS.

PERFORM frm_set_catalog.

gwa_layout
-zebra = 'X'.
gwa_layout
-box_fname = 'SEL'. "Specify row selection fields
gwa_layout-cwidth_opt = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program
= sy-repid
is_layout_lvc
= gwa_layout
it_fieldcat_lvc
= git_fcat
i_callback_pf_status_set
= gco_callback_status
i_callback_user_command
= gco_callback_user_command
TABLES
t_outtab
= git_ekko[]
EXCEPTIONS
program_error
= 1
OTHERS
= 2.
IF sy-subrc = 0.

ENDIF.
*&------------ -------------------------------------------------- -------*
*
& Form FRM_SET_PF_STATUS
*
&---------------------------- -----------------------------------------*
*
text
*
----------------------------- -----------------------------------------*
*
--> p1 text
*
<-- p2 text
*
----------------------------- -----------------------------------------*
FORM frm_user_status USING i_it_extab TYPE slis_t_extab.
SET PF-STATUS 'S0001'.
ENDFORM. " FRM_SET_PF_STATUS

FORM frm_user_command USING i_ucomm TYPE sy-ucomm
i_wa_selfield
TYPE slis_selfield.

DATA:l_count TYPE n,
l_msg
TYPE char100.
CASE i_ucomm.
WHEN
'POP'. "click POP button in application toolbar
LOOP AT git_ekko TRANSPORTING NO FIELDS WHERE sel = 'X'.
l_count
= l_count + 1.
ENDLOOP.
CONCATENATE 'Select'
l_count
'rows'
INTO l_msg
SEPARATED
BY space.
MESSAGE l_msg TYPE 'I'.
WHEN OTHERS.

ENDCASE.

ENDFORM.
*&------------ -------------------------------------------------- -------*
*
& Form FRM_SET_CATALOG
*
&---------------------------- -----------------------------------------*
*
text
*
----------------------------- -----------------------------------------*
*
--> p1 text
*
<-- p2 text
*
----------------------------- -----------------------------------------*
FORM frm_set_catalog.

DATA:l_pos TYPE i VALUE 1.
CLEAR: l_pos.
l_pos
= l_pos + 1.
gwa_fcat
-coltext = 'PO'.
gwa_fcat
-scrtext_l = 'PO'.
gwa_fcat
-scrtext_m = 'PO'.
gwa_fcat
-scrtext_s = 'PO'.
gwa_fcat
-fieldname = 'EBELN'.
gwa_fcat
-col_pos = l_pos.
gwa_fcat
-outputlen = '10'.
APPEND gwa_fcat TO git_fcat.
l_pos
= l_pos + 1.
gwa_fcat
-coltext = 'PO item'.
gwa_fcat
-scrtext_l = 'PO item'.
gwa_fcat
-scrtext_m = 'PO item'.
gwa_fcat
-scrtext_s = 'PO item'.
gwa_fcat
-fieldname = 'VERKF'.
gwa_fcat
-col_pos = l_pos.
gwa_fcat
-outputlen = '20'.
APPEND gwa_fcat TO git_fcat.

ENDFORM.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5718 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.