Saturday, December 18, 2010
Use function module REUSE_ALV_POPUP_TO_SELECT to be able to display in ALV in popup.

REPORT  zovh_alv_popup.
** Types
TYPES:
    BEGIN OF t_p0001,
      checkbox TYPE c,
      pernr    TYPE p0001-pernr,
      ename    TYPE p0001-ename,
    END OF t_p0001.
** Work Areas
DATA:
    w_p0001 TYPE t_p0001.
* Internal tables
DATA:
    i_p0001 TYPE STANDARD TABLE OF t_p0001.
PARAMETERS:p_pernr TYPE pernr-pernr.
*&---------------------------------------------------------------------*
* ALV Declarations
*----------------------------------------------------------------------*
* Types Pools
TYPE-POOLS:
    slis.
* Types
TYPES:
    t_fieldcat         TYPE slis_fieldcat_alv,
    t_events           TYPE slis_alv_event,
    t_layout           TYPE slis_layout_alv.
* Workareas
DATA:
    w_fieldcat         TYPE t_fieldcat,
    w_events           TYPE t_events,
    w_layout           TYPE t_layout.
* Internal Tables
DATA:
    i_fieldcat         TYPE STANDARD TABLE OF t_fieldcat,
    i_events           TYPE STANDARD TABLE OF t_events.

START-OF-SELECTION.
  PERFORM get_data.

END-OF-SELECTION.
  PERFORM display_data.
*&---------------------------------------------------------------------*
*&      Form  get_data
*&---------------------------------------------------------------------*
FORM get_data .
  SELECT pernr ename
  FROM pa0001
  INTO CORRESPONDING FIELDS OF TABLE i_p0001 UP TO 10 ROWS.
ENDFORM.                    " get_data
*&---------------------------------------------------------------------*
*&      Form  display_data
*&---------------------------------------------------------------------*
FORM display_data .
  PERFORM build_fieldcatalog.
  PERFORM display_data_alv.
ENDFORM.                    " display_data
*&---------------------------------------------------------------------*
*&      Form  display_data_alv
*&---------------------------------------------------------------------*
FORM display_data_alv .
  DATA:
  l_program TYPE sy-repid.
  l_program = sy-repid.
  CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
    EXPORTING
      i_title              = 'XYZ'
      i_tabname            = 'I_P0001'
      i_checkbox_fieldname = 'CHECKBOX'
      it_fieldcat          = i_fieldcat
      i_callback_program   = l_program
    TABLES
      t_outtab             = i_p0001.
  IF sy-subrc =  0.

    DATA:i_pa0002 TYPE TABLE OF pa0002.

    DELETE i_p0001 WHERE checkbox NE 'X'.
    SELECT *
    FROM pa0002
    INTO TABLE i_pa0002
    FOR ALL ENTRIES IN i_p0001
    WHERE pernr = i_p0001-pernr.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program = l_program
        i_structure_name   = 'PA0002'
      TABLES
        t_outtab           = i_pa0002.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.


  ELSE.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDFORM.                    " display_data_alv
*&---------------------------------------------------------------------*
*&      Form  build_fieldcatalog
*&---------------------------------------------------------------------*
FORM build_fieldcatalog .
  CLEAR: w_fieldcat,
  i_fieldcat[].
  w_fieldcat-fieldname = 'PERNR'.
  w_fieldcat-tabname   = 'I_P0001'.
  w_fieldcat-seltext_m = 'Emp No'.
  APPEND w_fieldcat TO i_fieldcat.
  CLEAR w_fieldcat.
  w_fieldcat-fieldname = 'ENAME'.
  w_fieldcat-tabname   = 'I_P0001'.
  w_fieldcat-seltext_m = 'Name'.
  APPEND w_fieldcat TO i_fieldcat.
  CLEAR w_fieldcat.
ENDFORM.                    " build_fieldcatalog

1 comment:

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.