ALV Popup with checkbox for input help

ALV popup with check-box, ALV input help with checkbox for select-options, input help as ALV

+ -

In the SAP ABAP real-time business applications, we may need to provide an ALV report as a popup for input helps, below lesson explains you how to use ALV report as popup for help request(F4 help) for select-options.

Please refer tutorial ALV popup display and select to know how to use ALV as a popup.

Requirement: Develop an ABAP report to display list of materials for a material type (input) with an ALV report(with check-box) as input help for material type.

Requirement analysis: To provide ALV as input help, we need to use function module REUSE_ALV_POPUP_TO_SELECT under event AT SELECTION-SCREEN ON VALUE-REQUEST , for this requirement, we need to provide checkbox in popup ALV, we need to create field catalog .

Step1: Call ALV popup function module under value request event

Call REUSE_ALV_POPUP_TO_SELECT function module under event SELECTION-SCREEN ON VALUE-REQUEST .

TYPE-POOLS: SLIS.
TABLES: T134.
TYPES: BEGIN OF TY_T134,
       CHECK TYPE CHAR1,
       MTART TYPE T134-MTART,
       END OF TY_T134.
DATA : IT_T134 TYPE TABLE OF TY_T134,
       WA_T134 TYPE TY_T134.
DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
      WA_FCAT LIKE LINE OF IT_FCAT.

SELECT-OPTIONS: S_MTART FOR T134-MTART NO INTERVALS.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MTART-LOW.
  WA_FCAT-COL_POS = 1.
  WA_FCAT-FIELDNAME = 'CHECK'.
  WA_FCAT-SELTEXT_M = 'Select'.
  WA_FCAT-TABNAME = 'IT_T134'.
  APPEND WA_FCAT TO IT_FCAT.
  CLEAR WA_FCAT.
  WA_FCAT-COL_POS = 2.
  WA_FCAT-FIELDNAME = 'MTART'.
  WA_FCAT-SELTEXT_M = 'Material Type'.
  WA_FCAT-TABNAME = 'IT_T134'.
  APPEND WA_FCAT TO IT_FCAT.
  CLEAR WA_FCAT.
  SELECT MTART  FROM T134 INTO CORRESPONDING FIELDS OF TABLE IT_T134.
  CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
    EXPORTING
      I_TITLE              = 'Select Material Type'
      I_CHECKBOX_FIELDNAME = 'CHECK'
      I_TABNAME            = 'IT_T134'
      IT_FIELDCAT          = IT_FCAT
      I_CALLBACK_PROGRAM   = SY-REPID
    TABLES
      T_OUTTAB             = IT_T134
*   EXCEPTIONS
*     PROGRAM_ERROR        = 1
*     OTHERS               = 2
    .
  IF SY-SUBRC <> 0.
* Implement suitable error handling here
  ENDIF.
  LOOP AT IT_T134 INTO WA_T134 WHERE CHECK = 'X'.
    S_MTART-LOW = WA_T134-MTART.
    S_MTART-OPTION = 'EQ'.
    S_MTART-SIGN = 'I'.
    APPEND S_MTART.
  ENDLOOP.

Step2: Display ALV

Display the ALV report based on selection inputs.

DATA: IT_MARA TYPE TABLE OF MARA,
      WA_MARA TYPE MARA.
START-OF-SELECTION.
  SELECT * FROM MARA INTO TABLE IT_MARA UP TO 50 ROWS
     WHERE MTART IN S_MTART .


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM = SY-REPID
      I_STRUCTURE_NAME   = 'MARA'
    TABLES
      T_OUTTAB           = IT_MARA
*     EXCEPTIONS
*     PROGRAM_ERROR      = 1
*     OTHERS             = 2
    .
  IF SY-SUBRC <> 0.
* Implement suitable error handling here
  ENDIF.

Full and final code to display ALV with check-box as popup for input help

REPORT ZSAPN_ALV_POPUP_HELP.
TYPE-POOLS: SLIS.
TABLES: T134.
TYPES: BEGIN OF TY_T134,
       CHECK TYPE CHAR1,
       MTART TYPE T134-MTART,
       END OF TY_T134.
DATA : IT_T134 TYPE TABLE OF TY_T134,
       WA_T134 TYPE TY_T134.
DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
      WA_FCAT LIKE LINE OF IT_FCAT.

DATA: IT_MARA TYPE TABLE OF MARA,
      WA_MARA TYPE MARA.

SELECT-OPTIONS: S_MTART FOR T134-MTART NO INTERVALS.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MTART-LOW.
  WA_FCAT-COL_POS = 1.
  WA_FCAT-FIELDNAME = 'CHECK'.
  WA_FCAT-SELTEXT_M = 'Select'.
  WA_FCAT-TABNAME = 'IT_T134'.
  APPEND WA_FCAT TO IT_FCAT.
  CLEAR WA_FCAT.
  WA_FCAT-COL_POS = 2.
  WA_FCAT-FIELDNAME = 'MTART'.
  WA_FCAT-SELTEXT_M = 'Material Type'.
  WA_FCAT-TABNAME = 'IT_T134'.
  APPEND WA_FCAT TO IT_FCAT.
  CLEAR WA_FCAT.
  SELECT MTART  FROM T134 INTO CORRESPONDING FIELDS OF TABLE IT_T134.
  CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
    EXPORTING
      I_TITLE              = 'Select Material Type'
      I_CHECKBOX_FIELDNAME = 'CHECK'
      I_TABNAME            = 'IT_T134'
      IT_FIELDCAT          = IT_FCAT
      I_CALLBACK_PROGRAM   = SY-REPID
    TABLES
      T_OUTTAB             = IT_T134
*   EXCEPTIONS
*     PROGRAM_ERROR        = 1
*     OTHERS               = 2
    .
  IF SY-SUBRC <> 0.
* Implement suitable error handling here
  ENDIF.
  LOOP AT IT_T134 INTO WA_T134 WHERE CHECK = 'X'.
    S_MTART-LOW = WA_T134-MTART.
    S_MTART-OPTION = 'EQ'.
    S_MTART-SIGN = 'I'.
    APPEND S_MTART.
  ENDLOOP.

START-OF-SELECTION.
  SELECT * FROM MARA INTO TABLE IT_MARA UP TO 50 ROWS
     WHERE MTART IN S_MTART .


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM = SY-REPID
      I_STRUCTURE_NAME   = 'MARA'
    TABLES
      T_OUTTAB           = IT_MARA
*     EXCEPTIONS
*     PROGRAM_ERROR      = 1
*     OTHERS             = 2
    .
  IF SY-SUBRC <> 0.
* Implement suitable error handling here
  ENDIF.

ALV popup with check-box

Learner Questions


No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question

    Was this lesson helpful to you? Yes No 12 People out of 13 think this lesson helpful


    Lesson Navigation

    ←Previous Chapter
    Next Lesson → Sapscripts