RE: ALV Grid – Popup

      I have written a basic program to display SFLIGHT data in an ALV Grid.

      I would like to add the functionality to double-click on a row in the ALV Grid to launch a popup showing all of the data from that row. I have looked at programs with this functionality built in but find them too complicated to understand.

      Would be grateful for any help.

      Thanks

      Steven

      Hi Steven, here is the fully working version:   REPORT  Z_ALV_POPUP. TYPE-POOLS: slis.  " SLIS contains all the ALV data types *&---------------------------------------------------------------------* *& Data Declaration *&---------------------------------------------------------------------* DATA: it_sflight   TYPE TABLE OF sflight,       it_fieldcat  TYPE slis_t_fieldcat_alv,       wa_fieldcat  TYPE slis_fieldcat_alv. *&---------------------------------------------------------------------* *& START-OF-SELECTION *&---------------------------------------------------------------------* START-OF-SELECTION. *Fetch data from the database   SELECT * FROM sflight  INTO TABLE it_sflight. *Build field catalog   wa_fieldcat-fieldname  = 'CARRID'.    " Fieldname in the data table   wa_fieldcat-seltext_m  = 'Airline Code'.   " Column description in the output   APPEND wa_fieldcat TO it_fieldcat.   wa_fieldcat-fieldname  = 'CONNID'.   wa_fieldcat-seltext_m  = 'Con. No.'.   APPEND wa_fieldcat TO…

      User Rating: Be the first one !
      Daniel Sobral Vice Professor Asked on November 2, 2016 in user interface-development.
      Add Comment
      1 Answers

        Hi Steven,

        here is the fully working version:

         

        REPORT  Z_ALV_POPUP. TYPE-POOLS: slis” SLIS contains all the ALV data types *&———————————————————————* *& Data Declaration *&———————————————————————* DATA: it_sflight   TYPE TABLE OF sflight,       it_fieldcat  TYPE slis_t_fieldcat_alv,       wa_fieldcat  TYPE slis_fieldcat_alv. *&———————————————————————* *& START-OF-SELECTION *&———————————————————————* START-OF-SELECTION. *Fetch data from the database   SELECT * FROM sflight  INTO TABLE it_sflight. *Build field catalog   wa_fieldcatfieldname  = ‘CARRID’.    ” Fieldname in the data table   wa_fieldcatseltext_m  = ‘Airline Code’.   ” Column description in the output   APPEND wa_fieldcat TO it_fieldcat.   wa_fieldcatfieldname  = ‘CONNID’.   wa_fieldcatseltext_m  = ‘Con. No.’.   APPEND wa_fieldcat TO it_fieldcat.   wa_fieldcatfieldname  = ‘FLDATE’.   wa_fieldcatseltext_m  = ‘Date’.   APPEND wa_fieldcat TO it_fieldcat.   wa_fieldcatfieldname  = ‘PLANETYPE’.   wa_fieldcatseltext_m  = ‘Aircraft Type’.   APPEND wa_fieldcat TO it_fieldcat.   wa_fieldcatfieldname  = ‘SEATSMAX’.   wa_fieldcatseltext_m  = ‘Maximum Capacity Economy’.   APPEND wa_fieldcat TO it_fieldcat.   wa_fieldcatfieldname  = ‘SEATSOCC’.   wa_fieldcatseltext_m  = ‘Occuppied Seats Economy’.   APPEND wa_fieldcat TO it_fieldcat.   wa_fieldcatfieldname  = ‘PAYMENTSUM’.   wa_fieldcatseltext_m  = ‘Total of current bookings’.   APPEND wa_fieldcat TO it_fieldcat.   wa_fieldcatfieldname  = ‘SEATSMAX_B’.   wa_fieldcatseltext_m  = ‘Maximum Capacity Business’.   APPEND wa_fieldcat TO it_fieldcat.   wa_fieldcatfieldname  = ‘SEATSOCC_B’.   wa_fieldcatseltext_m  = ‘Occuppied Seats Business’.   APPEND wa_fieldcat TO it_fieldcat.   wa_fieldcatfieldname  = ‘SEATSMAX_F’.   wa_fieldcatseltext_m  = ‘Maximum Capacity First Classy’.   APPEND wa_fieldcat TO it_fieldcat.   wa_fieldcatfieldname  = ‘SEATSOCC_F’.   wa_fieldcatseltext_m  = ‘Occuppied Seats First Class’.   APPEND wa_fieldcat TO it_fieldcat. *Pass data and field catalog to ALV function module to display ALV list   CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’     EXPORTING       it_fieldcat             = it_fieldcat       i_callback_program      = syrepid       i_callback_user_command = ‘USER_COMMAND’     TABLES       t_outtab                = it_sflight     EXCEPTIONS       program_error           = 1       OTHERS                  = 2. *&———————————————————————* *&      Form  user_command *&———————————————————————* *       text *———————————————————————-* *      –>W_UCOMM      text *      –>LS_SELFIELD  text *———————————————————————-* FORM user_command USING w_ucomm LIKE syucomm                 ls_selfield TYPE slis_selfield.   DATA: wa_example LIKE LINE OF it_sflight. “wa_example is current line of table it_sflight   CASE w_ucomm. * Double Click Event     WHEN ‘&IC1’.       IF ls_selfieldtabindex > 0 AND ls_selfieldsumindex LE 0.         READ TABLE it_sflight INTO wa_example INDEX ls_selfieldtabindex.         IF sysubrc = 0.           DATA:             lt_fcat TYPE lvc_t_fcat,             ls_layout TYPE lvc_s_layo.           ls_layoutno_toolbar = ‘X’.           ls_layoutcwidth_opt = ‘X’.           CALL FUNCTION ‘LVC_FIELDCATALOG_MERGE’             EXPORTING               i_structure_name = ‘SFLIGHT’             CHANGING               ct_fieldcat      = lt_fcat.           DATA:             ls_detail TYPE lvc_s_deta,             lt_detail TYPE lvc_t_deta.           FIELD-SYMBOLS:             <s_fcat> LIKE LINE OF lt_fcat,             <field> TYPE ANY.           LOOP AT lt_fcat ASSIGNING <s_fcat>.             CHECK <s_fcat>tech IS INITIAL.             MOVE <s_fcat>reptext TO ls_detailcolumntext.             ASSIGN COMPONENT <s_fcat>fieldname OF STRUCTURE wa_example TO <field>.             CHECK sysubrc = 0.             MOVE <field> TO ls_detailvalue.             APPEND ls_detail TO lt_detail.           ENDLOOP.           DATA: lt_det TYPE lvc_t_detm,                 ls_det TYPE lvc_s_detm.           MOVE  lt_detail TO ls_detdetailtab.           APPEND ls_det TO lt_det.           REFRESH lt_fcat.           DATA: ls_fcat LIKE LINE OF lt_fcat.           ls_fcatfieldname = ‘COLUMNTEXT’.           ls_fcattabname   = ‘LVC_S_DETA’.           ls_fcatrollname  = ‘LANGUAGE’.           ls_fcatoutputlen 4.           ls_fcatkey       = ‘X’.           APPEND ls_fcat TO lt_fcat.           ls_fcatfieldname = ‘VALUE’.           ls_fcattabname   = ‘LVC_S_DETA’.           ls_fcatrollname  = ‘CGSTXT_M’.           ls_fcatoutputlen 20.           ls_fcatkey       = ‘X’.           APPEND ls_fcat TO lt_fcat.           CALL FUNCTION ‘LVC_ITEM_DETAIL’             EXPORTING               i_title               = ‘Details’               i_screen_start_column = 50               i_screen_start_line   = 10               i_screen_end_column   = 100               i_screen_end_line     = 20               it_fieldcatalog       = lt_fcat               is_layout             = ls_layout             TABLES               t_outtab              = lt_det.         ENDIF.       ENDIF.   ENDCASE. ENDFORM.                    “user_command

        Add Comment

        Your Answer

        By posting your answer, you agree to the privacy policy and terms of service.