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

reuse_alv_popup_to_select

Former Member
0 Kudos
2,303

Hi experts,

can anybody please let me know how to use reuse_alv_popup_to_select.

thanks,

sudheer

1 ACCEPTED SOLUTION
Read only

Former Member
0 Kudos
913

Hi,

Have a look on the following simple code.

  • Declaration of Data Base table

TABLES: VBAK.

  • Declaration of Internal table

DATA: ITAB TYPE VBAK OCCURS 0.

  • POPULATING DATA INTO THE INTERNAL TABLE

SELECT * FROM VBAK INTO TABLE ITAB.

  • Calling the function module and passing the internal table to it

CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

EXPORTING

  • I_TITLE =

  • I_SELECTION = 'X'

  • I_ALLOW_NO_SELECTION =

  • I_ZEBRA = ' '

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_CHECKBOX_FIELDNAME =

  • I_LINEMARK_FIELDNAME =

  • I_SCROLL_TO_SEL_LINE = 'X'

I_TABNAME = 'ITAB'

I_STRUCTURE_NAME = 'VBAK'

  • IT_FIELDCAT =

  • IT_EXCLUDING =

  • I_CALLBACK_PROGRAM =

  • I_CALLBACK_USER_COMMAND =

  • IS_PRIVATE =

  • IMPORTING

  • ES_SELFIELD =

  • E_EXIT =

TABLES

T_OUTTAB = ITAB

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

Regards,

Chandu

5 REPLIES 5
Read only

Former Member
0 Kudos
913

if u want to use this in selection screen use it in at seletion-screen on value request event .

pass the required parameters into that fm.

Read only

former_member705122
Active Contributor
0 Kudos
913
Read only

Former Member
0 Kudos
913

Please check the sample code.

REPORT ztest_alv_check MESSAGE-ID zz .
 
TYPE-POOLS: slis.
DATA: x_fieldcat TYPE slis_fieldcat_alv,
it_fieldcat TYPE slis_t_fieldcat_alv,
l_layout TYPE slis_layout_alv,
x_events TYPE slis_alv_event,
it_events TYPE slis_t_event.
 
DATA: BEGIN OF itab OCCURS 0,
vbeln LIKE vbak-vbeln,
posnr LIKE vbap-posnr,
chk(1),
color(4),
END OF itab.
 
SELECT vbeln
posnr
FROM vbap
UP TO 20 ROWS
INTO TABLE itab.
 
x_fieldcat-fieldname = 'CHK'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 1.
x_fieldcat-input = 'X'.
x_fieldcat-edit = 'X'.
x_fieldcat-checkbox = 'X'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
 
x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-seltext_l = 'VBELN'.
x_fieldcat-hotspot = 'X'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 2.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
 
x_fieldcat-fieldname = 'POSNR'.
x_fieldcat-seltext_l = 'POSNR'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 3.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
 
 
DATA selfield TYPE  slis_selfield.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
  EXPORTING
    i_title                 = 'Select Data'
    i_selection             = 'X'
    i_zebra                 = 'X'
    i_screen_start_column   = 5
    i_screen_start_line     = 5
    i_screen_end_column     = 50
    i_screen_end_line       = 10
    i_checkbox_fieldname    = 'CHK'
    i_tabname               = 'ITAB'
    i_scroll_to_sel_line    = 'X'
    it_fieldcat             = it_fieldcat
    i_callback_program      = sy-repid
    i_callback_user_command = 'USER_COMMAND'
  IMPORTING
    es_selfield             = selfield
  TABLES
    t_outtab                = itab
  EXCEPTIONS
    program_error           = 1.
 
*&---------------------------------------------------------------------*
*&      Form  STATUS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_EXTAB    text
*----------------------------------------------------------------------*
FORM status USING p_extab TYPE slis_t_extab.
 
  SET PF-STATUS 'STATUS'.
ENDFORM. " STATUS
 
*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
 
  DATA: gd_repid LIKE sy-repid, "Exists
  ref_grid TYPE REF TO cl_gui_alv_grid.
  IF ref_grid IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      IMPORTING
        e_grid = ref_grid.
  ENDIF.
  IF NOT ref_grid IS INITIAL.
    CALL METHOD ref_grid->check_changed_data .
  ENDIF.
 
  LOOP AT itab WHERE chk = 'X'.
    itab-color = 'C300'.
    MODIFY itab INDEX sy-tabix TRANSPORTING color.
  ENDLOOP.
  rs_selfield-refresh = 'X'.
  BREAK-POINT.
 
ENDFORM. "USER_COMMAND

Regards

Vijay Babu Dudla

Read only

0 Kudos
913

Hi Vijay,

I have tried your code and need to do process on USER_COMMAND routine, any how control is not moving to USER_COMMAD on selecting records on output.. can you please advice how can get control in user_command routine. I want to put some error if non of the rows are selected..

Thanks & Regards,

Rajesh

Read only

Former Member
0 Kudos
914

Hi,

Have a look on the following simple code.

  • Declaration of Data Base table

TABLES: VBAK.

  • Declaration of Internal table

DATA: ITAB TYPE VBAK OCCURS 0.

  • POPULATING DATA INTO THE INTERNAL TABLE

SELECT * FROM VBAK INTO TABLE ITAB.

  • Calling the function module and passing the internal table to it

CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

EXPORTING

  • I_TITLE =

  • I_SELECTION = 'X'

  • I_ALLOW_NO_SELECTION =

  • I_ZEBRA = ' '

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_CHECKBOX_FIELDNAME =

  • I_LINEMARK_FIELDNAME =

  • I_SCROLL_TO_SEL_LINE = 'X'

I_TABNAME = 'ITAB'

I_STRUCTURE_NAME = 'VBAK'

  • IT_FIELDCAT =

  • IT_EXCLUDING =

  • I_CALLBACK_PROGRAM =

  • I_CALLBACK_USER_COMMAND =

  • IS_PRIVATE =

  • IMPORTING

  • ES_SELFIELD =

  • E_EXIT =

TABLES

T_OUTTAB = ITAB

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

Regards,

Chandu