Skip to Content
author's profile photo Former Member
Former Member

why this code is not working for alv

Dear

Regards,

i have implemented the same program for ALV which i have used earlier in the reports. but now it is showing no output:

*&---------------------------------------------------------------------*
*& Report  ZTCT1_ALV2                                                  *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ztct1_alv2                              .

CLASS lcl_event_receiver DEFINITION DEFERRED.
*-------------------------------------------------------------------------
* INCLUDING TABLES.
*-------------------------------------------------------------------------
TABLES: vbrk,
        vbrp,
        kna1,
        t001w,
        makt.

*-------------------------------------------------------------------------
* DECLARATION OF INTERNAL TABLES.
*-------------------------------------------------------------------------
DATA: BEGIN OF itab OCCURS 0,  "Including the fields of VBRK and VBRP
        kunag LIKE vbrk-kunag, "Customer Code
        name1 LIKE kna1-name1, "Customer Name
        vbeln LIKE vbrk-vbeln, "Invoice #
        fkdat LIKE vbrk-fkdat, "Invoice Date
        werks LIKE vbrp-werks, "Plant
        name2 LIKE t001w-name1,"Plant Description
        matnr LIKE vbrp-matnr, "Material #
        maktx LIKE makt-maktx, "Material Description
        meins LIKE vbrp-meins, "Unit of Measure
        fklmg LIKE vbrp-fklmg, "Quantity
        netwr LIKE vbrp-netwr, "Amount
      END OF itab,

      BEGIN OF itnm OCCURS 0,  "Including the fields of VBRK and KNA1
        kunag LIKE vbrk-kunag, "Customer Code
        name1 LIKE kna1-name1, "Customer Name
      END OF itnm,

      BEGIN OF itpt OCCURS 0,  "Including the fields of VBRP and T001W
        werks LIKE vbrp-werks, "Plant
        name1 LIKE t001w-name1,"Plant Description
      END OF itpt,

      BEGIN OF itmt OCCURS 0,  "Including the fields of VBRP and MAKT
        matnr LIKE vbrp-matnr, "Material #
        maktx LIKE makt-maktx, "Material description
      END OF itmt,
      BEGIN OF itsm OCCURS 0,
        kunag LIKE kna1-kunnr,
        name1 LIKE kna1-name1,
        fklmg LIKE vbrp-fklmg,
        netwr LIKE vbrp-netwr,
      END OF itsm,

      ok_code            LIKE sy-ucomm,
      save_ok            LIKE sy-ucomm,
      g_max              TYPE i VALUE 100,
      g_repid            LIKE sy-repid,
      gs_layout          TYPE lvc_s_layo,
      g_container        TYPE scrfname VALUE 'CUST_CONT',
      grid1              TYPE REF TO cl_gui_alv_grid,
      g_custom_container TYPE REF TO cl_gui_custom_container,
      grid2              TYPE REF TO cl_gui_alv_grid,
      gt_sort            TYPE lvc_t_sort,
      gt_fieldcatalog    TYPE lvc_t_fcat,
      w_tot_qty          LIKE vbrp-fklmg,
      w_tot_amt          LIKE vbrp-netwr,
* Reference to Dialogbox Container.
      dialogbox_container TYPE REF TO cl_gui_dialogbox_container,
* Reference to local class that handles events of GRID1 and
* DIALOGBOX_CONTAINER
      event_receiver TYPE REF TO lcl_event_receiver.

*-------------------------------------------------------------------------
* SELECT-OPTIONS
*-------------------------------------------------------------------------
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK input WITH FRAME TITLE text-000.
SELECT-OPTIONS: s_werks FOR vbrp-werks, "Plant
                s_kunag FOR vbrk-kunag, "Customer
                s_matnr FOR vbrp-matnr, "Material Number
                s_fkdat FOR vbrk-fkdat. "Invoice Date
SELECTION-SCREEN END OF BLOCK input .
SELECTION-SCREEN SKIP 1.

*-------------------------------------------------------------------------
* START-OF-SELECTION
*-------------------------------------------------------------------------
START-OF-SELECTION.

  SET SCREEN 100.
*-------------------------------------------------------------------------
* CLEARING INTERNAL TABLES.
*-------------------------------------------------------------------------
  CLEAR: itab,
         itnm,
         itmt,
         itpt.

*-------------------------------------------------------------------------
* QUERY FOR JOINING TABLES VBRK AND VBRP
*-------------------------------------------------------------------------
  SELECT vbrk~kunag
         vbrk~vbeln
         vbrk~fkdat
         vbrp~werks
         vbrp~matnr
         vbrp~meins
         vbrp~fklmg
         vbrp~netwr
         INTO CORRESPONDING FIELDS OF TABLE itab
         FROM vbrk
         INNER JOIN vbrp
             ON vbrk~vbeln = vbrp~vbeln
         WHERE vbrk~kunag IN s_kunag
           AND vbrk~fkdat IN s_fkdat
           AND vbrp~matnr IN s_matnr
           AND vbrp~werks IN s_werks.

*-------------------------------------------------------------------------
* QUERY FOR JOINING TABLES VBRK AND KNA1
*-------------------------------------------------------------------------
  SELECT kna1~kunnr AS kunag
         kna1~name1
         INTO TABLE itnm
         FROM kna1
         WHERE kna1~kunnr IN s_kunag.

*-------------------------------------------------------------------------
* QUERY FOR JOINING TABLES VBRP AND T001W
*-------------------------------------------------------------------------
  SELECT t001w~werks
         t001w~name1
         INTO TABLE itpt
         FROM t001w
         WHERE t001w~werks IN s_werks.

*-------------------------------------------------------------------------
* QUERY FOR JOINING TABLES VBRP AND MAKT
*-------------------------------------------------------------------------
  SELECT makt~matnr
         makt~maktx
         INTO TABLE itmt
         FROM makt
         WHERE makt~matnr IN s_matnr.

*-------------------------------------------------------------------------
* SORTING INTERNAL TABLES.
*-------------------------------------------------------------------------
  SORT itab BY kunag.

*    LOOP AT itab.
*      CLEAR: itmt, itnm, itpt.
*      READ TABLE itnm WITH KEY kunag = itab-kunag.
*      READ TABLE itmt WITH KEY matnr = itab-matnr.
*      READ TABLE itpt WITH KEY werks = itab-werks.
*      itab-name1 = itnm-name1.
*      itab-maktx = itmt-maktx.
*      itab-name2 = itpt-name1.
*      MODIFY itab.
*    ENDLOOP.
*
*    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'KUNAG' 'C' 'Customer Code'.
*    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NAME1' 'C' 'Customer Name'.
*    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'VBELN' 'C' 'Invoice #'.
*    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'FKDAT' 'DATS' 'Invoice Date'.
*    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'WERKS' 'C' 'Plant'.
*    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NAME2' 'C' 'Plant Description'.
*    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'MATNR' 'C' 'Material #'.
*    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'MAKTX' 'C' 'Material Description'.
*    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'MEINS' 'C' 'UoM'.
*    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'FKLMG' 'QUAN' 'Quantity'.
*    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NETWR' 'CURR' 'Amount'.
    LOOP AT itab.
      CLEAR itsm.
      READ TABLE itnm WITH KEY kunag = itab-kunag.
      itsm-kunag = itab-kunag.
      itsm-name1 = itnm-name1.
      itsm-fklmg = itab-fklmg.
      itsm-netwr = itab-netwr.
      COLLECT itsm.
    ENDLOOP.

    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'KUNAG' 'C' 'Customer Code'.
    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NAME1' 'C' 'Customer Name'.
    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'FKLMG' 'QUAN' 'Quantity'.
    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NETWR' 'CURR' 'Amount'.
  PERFORM sort_build USING gt_sort[].
  PERFORM layout_init USING gs_layout.

******************************************************************
*   LOCAL CLASSES: Definition
******************************************************************
CLASS lcl_event_receiver DEFINITION.

  PUBLIC SECTION.
    METHODS:

    handle_double_click
        FOR EVENT double_click OF cl_gui_alv_grid
            IMPORTING e_row e_column,
    handle_close
        FOR EVENT close OF cl_gui_dialogbox_container
            IMPORTING sender.

  PRIVATE SECTION.
    DATA: dialogbox_status TYPE c.  "'X': does exist, SPACE: does not ex.

ENDCLASS.                    "lcl_event_receiver DEFINITION

******************************************************************
*   LOCAL CLASSES: Implementation
******************************************************************
CLASS lcl_event_receiver IMPLEMENTATION.

*   §3.At doubleclick(1): The event DOUBLE_CLICK provides
*      parameters of the clicked row and column.
*      Use row parameter to select a line of the
*      corresponding internal table.
  METHOD handle_double_click.
    DATA: ls_sm LIKE LINE OF itsm,
          wa_itab LIKE ITAB.

*   read selected row from internal table gt_sflight
    READ TABLE itsm INDEX e_row-index INTO ls_sm.

*   §4.At Doubleclick(2): Select booking data
*    READ TABLE ITAB WITH KEY KUNAG = LS_SM-KUNAG.    .
    READ TABLE ITAB INTO WA_ITAB WITH KEY KUNAG = LS_SM-KUNAG.

*   §5.At doubleclick(3): Create dialogbox to show detail list
*     (if not already existent)
    IF dialogbox_status IS INITIAL.
      dialogbox_status = 'X'.
      PERFORM create_detail_list.
    ELSE.
      CALL METHOD dialogbox_container->set_visible
        EXPORTING
          visible = 'X'.
      CALL METHOD grid2->refresh_table_display.
    ENDIF.
  ENDMETHOD.                    "handle_double_click
*----------------------------------------------------------*
  METHOD handle_close.
*   §6.Handle the CLOSE-button of the dialogbox

*   set dialogbox invisible
*   (the dialogbox is destroyed outomatically when the user
*   switches to another dynpro).
    CALL METHOD sender->set_visible
      EXPORTING
        visible = space.
*   In this example closing the dialogbox leads
*   to make it invisible. It is also conceivable to destroy it
*   and recreate it if the user doubleclicks a line again.
*   Displaying a great amount of data has a greater impact on performance.
  ENDMETHOD.                    "handle_close

ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
*
*   lcl_event_receiver (Implementation)
*=====================================================================

*---------------------------------------------------------------------*
*       FORM EXIT_PROGRAM                                             *
*---------------------------------------------------------------------*
FORM exit_program.
  CALL METHOD g_custom_container->free.
  CALL METHOD cl_gui_cfw=>flush.
  IF sy-subrc NE 0.
* add your handling, for example
    CALL FUNCTION 'POPUP_TO_INFORM'
      EXPORTING
        titel = g_repid
        txt2  = sy-subrc
        txt1  = 'Error in FLush'(500).
  ENDIF.
  LEAVE TO SCREEN 0.
ENDFORM.                    "exit_program

*---------------------------------------------------------------------*
*  MODULE PBO_ALV OUTPUT
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
MODULE pbo_alv OUTPUT.
  SET PF-STATUS 'MAIN'.
  SET TITLEBAR 'MAIN100'.
  g_repid = sy-repid.
  IF g_custom_container IS INITIAL.
    READ TABLE itsm.
    CREATE OBJECT g_custom_container
      EXPORTING
        container_name = g_container
      EXCEPTIONS
        cntl_error = 1
        cntl_system_error = 2
        create_error = 3
        lifetime_error = 4
        lifetime_dynpro_dynpro_link = 5.

    IF sy-subrc NE 0.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = g_repid
          txt2  = sy-subrc
          txt1  = 'The control could not be created'(510).
    ENDIF.

    CREATE OBJECT grid1
      EXPORTING
        i_parent = g_custom_container.
    gs_layout-grid_title = 'Invoice Summary'.

    CALL METHOD grid1->set_table_for_first_display
      EXPORTING
        is_layout       = gs_layout
      CHANGING
        it_outtab       = itsm[]
        it_fieldcatalog = gt_fieldcatalog
        it_sort         = gt_sort.

    CREATE OBJECT event_receiver.
    SET HANDLER event_receiver->handle_double_click FOR grid1.
  ENDIF.

  CALL METHOD cl_gui_control=>set_focus
    EXPORTING
      control = grid1.

ENDMODULE.                    "PBO_ALV OUTPUT

*---------------------------------------------------------------------*
*  MODULE PAI_ALV INPUT
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
MODULE pai_alv INPUT.
  CALL METHOD cl_gui_cfw=>dispatch.

  CASE sy-ucomm.
    WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
      LEAVE TO SCREEN 0.
  ENDCASE.
ENDMODULE.                    "PAI_ALV INPUT

*&--------------------------------------------------------------------*
*&      Form  fieldcatalog_init
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
*      -->LT_FIELDCATtext
*      -->VALUE(FIELDtextE)
*      -->VALUE(FIELDtextE)
*      -->VALUE(FIELDtextT)
*---------------------------------------------------------------------*
FORM fieldcatalog_init USING lt_fieldcatalog TYPE lvc_t_fcat
                       value(field_name) value(field_type) value(field_text).
  DATA: ls_fieldcatalog TYPE lvc_s_fcat.

  CLEAR ls_fieldcatalog.
  ls_fieldcatalog-fieldname = field_name.
  ls_fieldcatalog-datatype  = field_type.
  ls_fieldcatalog-reptext   = field_text.
  ls_fieldcatalog-coltext  =  field_text.
  ls_fieldcatalog-seltext  =  field_text.
  ls_fieldcatalog-tooltip  =  field_text.

  APPEND ls_fieldcatalog TO lt_fieldcatalog.
ENDFORM.                    "fieldcatalog_init

*&--------------------------------------------------------------------*
*&      Form  sort_build
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
*      -->LT_SORT    text
*---------------------------------------------------------------------*
FORM sort_build USING lt_sort TYPE lvc_t_sort.
  DATA: ls_sort TYPE lvc_s_sort.

  ls_sort-fieldname = 'KUNAG'.    "Fieldname on which to sort
  ls_sort-up        = 'X'.        "Sort Ascending
  APPEND ls_sort TO lt_sort.

  ls_sort-fieldname = 'NAME1'.    "Fieldname on which to sort
  ls_sort-up        = 'X'.        "Sort Ascending
  APPEND ls_sort TO lt_sort.

ENDFORM.                    "sort_build

*&--------------------------------------------------------------------*
*&      Form  layout_init
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
*      -->LS_LAYOUT  text
*---------------------------------------------------------------------*
FORM layout_init USING ls_layout TYPE lvc_s_layo.
  ls_layout-zebra      = 'X'.
  ls_layout-grid_title = 'Customer Details'.
  ls_layout-sel_mode   = 'A'.
  ls_layout-cwidth_opt = 'X'.
ENDFORM.                    "layout_init

*&---------------------------------------------------------------------*
*&      Form  create_detail_list
*&---------------------------------------------------------------------*
*         text
*------------------------------------------------------------------------*
*    -->  p1        text
*    <--  p2        text
*------------------------------------------------------------------------*
FORM create_detail_list.
*   create dialogbox container as dynpro-instance
*   When the user switches to another screen, it is
*   destroyed by lifetime mangagement of CFW
  CREATE OBJECT dialogbox_container
      EXPORTING
        top = 150
        left = 150
        lifetime = cntl_lifetime_dynpro
        caption = 'INVOICE DETAILS'(200)
        width = 800
        height = 200.
  CREATE OBJECT grid2
      EXPORTING i_parent = dialogbox_container.
*   Register ABAP OO event 'CLOSE'. It is not necessary to register this
*   event at the frontend (this is done during creation).
  SET HANDLER event_receiver->handle_close FOR dialogbox_container.

*   display data
  gs_layout-grid_title = 'Invoice Details'(100).
  CALL METHOD grid2->set_table_for_first_display
    EXPORTING
      i_structure_name = 'itab'
      is_layout        = gs_layout
    CHANGING
      it_outtab        = itab[]
      it_fieldcatalog  = gt_fieldcatalog
      it_sort          = gt_sort.


  CALL METHOD cl_gui_control=>set_focus
    EXPORTING
      control = grid2.

ENDFORM.                    " create_detail_list[code][/

code]

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Oct 06, 2005 at 05:35 AM

    Hi,

    Did you checked your itab after this select statement in debugging?If itab is empty,then you won't output.Kindly reward points by clciking the star on the left of reply,if it helps.

    SELECT vbrk~kunag

    vbrk~vbeln

    vbrk~fkdat

    vbrp~werks

    vbrp~matnr

    vbrp~meins

    vbrp~fklmg

    vbrp~netwr

    INTO CORRESPONDING FIELDS OF TABLE itab

    FROM vbrk

    INNER JOIN vbrp

    ON vbrkvbeln = vbrpvbeln

    WHERE vbrk~kunag IN s_kunag

    AND vbrk~fkdat IN s_fkdat

    AND vbrp~matnr IN s_matnr

    AND vbrp~werks IN s_werks.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 06, 2005 at 05:41 AM

    i have seen the itab it is getting data properly

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 06, 2005 at 05:48 AM

    Hi,

    Sorted out ur problem, the problem is in module, while <b>calling screen</b> just got to the flowlogic double <b>click on PBO and PAI module</b> and then create dont copy paste.

    That is the problem y it didnt work.

    I tried copy and pasting ur code it didnt work first, then if u go and <b>double click on the module in flowlogic it will ask whether u need to create it</b>. So this means that u haven't created properly.

    No other problem in ur logic and program its working fine.

    Remember to reward poinst and close the thread.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 06, 2005 at 05:51 AM

    i have made the PBO AND PAI by double clicking only

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      I also copied and pasted the same code check once again by copying this code and create screens by double clicking on 100.

      ************************************************************************
      CLASS lcl_event_receiver DEFINITION DEFERRED.
      *-----------------------------------------------------------------------
      * INCLUDING TABLES.
      *-----------------------------------------------------------------------
      
      TABLES: vbrk,
              vbrp,
              kna1,
              t001w,
              makt.
      
      *-----------------------------------------------------------------------
      * DECLARATION OF INTERNAL TABLES.
      *-----------------------------------------------------------------------
      
      DATA: BEGIN OF itab OCCURS 0,  "Including the fields of VBRK and VBRP
              kunag LIKE vbrk-kunag, "Customer Code
              name1 LIKE kna1-name1, "Customer Name
              vbeln LIKE vbrk-vbeln, "Invoice #
              fkdat LIKE vbrk-fkdat, "Invoice Date
              werks LIKE vbrp-werks, "Plant
              name2 LIKE t001w-name1,"Plant Description
              matnr LIKE vbrp-matnr, "Material #
              maktx LIKE makt-maktx, "Material Description
              meins LIKE vbrp-meins, "Unit of Measure
              fklmg LIKE vbrp-fklmg, "Quantity
              netwr LIKE vbrp-netwr, "Amount
            END OF itab,
      
            BEGIN OF itnm OCCURS 0,  "Including the fields of VBRK and KNA1
              kunag LIKE vbrk-kunag, "Customer Code
              name1 LIKE kna1-name1, "Customer Name
            END OF itnm,
      
            BEGIN OF itpt OCCURS 0,  "Including the fields of VBRP and T001W
              werks LIKE vbrp-werks, "Plant
              name1 LIKE t001w-name1,"Plant Description
            END OF itpt,
      
            BEGIN OF itmt OCCURS 0,  "Including the fields of VBRP and MAKT
              matnr LIKE vbrp-matnr, "Material #
              maktx LIKE makt-maktx, "Material description
            END OF itmt,
            BEGIN OF itsm OCCURS 0,
              kunag LIKE kna1-kunnr,
              name1 LIKE kna1-name1,
              fklmg LIKE vbrp-fklmg,
              netwr LIKE vbrp-netwr,
            END OF itsm,
      
            ok_code            LIKE sy-ucomm,
            save_ok            LIKE sy-ucomm,
            g_max              TYPE i VALUE 100,
            g_repid            LIKE sy-repid,
            gs_layout          TYPE lvc_s_layo,
            g_container        TYPE scrfname VALUE 'CUST_CONT',
            grid1              TYPE REF TO cl_gui_alv_grid,
            g_custom_container TYPE REF TO cl_gui_custom_container,
            grid2              TYPE REF TO cl_gui_alv_grid,
            gt_sort            TYPE lvc_t_sort,
            gt_fieldcatalog    TYPE lvc_t_fcat,
            w_tot_qty          LIKE vbrp-fklmg,
            w_tot_amt          LIKE vbrp-netwr,
      * Reference to Dialogbox Container.
            dialogbox_container TYPE REF TO cl_gui_dialogbox_container,
      * Reference to local class that handles events of GRID1 and
      * DIALOGBOX_CONTAINER
            event_receiver TYPE REF TO lcl_event_receiver.
      
      *-----------------------------------------------------------------------
      
      * SELECT-OPTIONS
      *-----------------------------------------------------------------------
      
      SELECTION-SCREEN SKIP 1.
      SELECTION-SCREEN BEGIN OF BLOCK input WITH FRAME TITLE text-000.
      SELECT-OPTIONS: s_werks FOR vbrp-werks, "Plant
                      s_kunag FOR vbrk-kunag, "Customer
                      s_matnr FOR vbrp-matnr, "Material Number
                      s_fkdat FOR vbrk-fkdat. "Invoice Date
      SELECTION-SCREEN END OF BLOCK input .
      SELECTION-SCREEN SKIP 1.
      
      *-----------------------------------------------------------------------
      
      * START-OF-SELECTION
      *-----------------------------------------------------------------------
      
      START-OF-SELECTION.
      SET SCREEN 100.
      *-----------------------------------------------------------------------
      
      * CLEARING INTERNAL TABLES.
      *-----------------------------------------------------------------------
      
        CLEAR: itab,
               itnm,
               itmt,
               itpt.
      
      *-----------------------------------------------------------------------
      
      * QUERY FOR JOINING TABLES VBRK AND VBRP
      *-----------------------------------------------------------------------
        SELECT vbrk~kunag
               vbrk~vbeln
               vbrk~fkdat
               vbrp~werks
               vbrp~matnr
               vbrp~meins
               vbrp~fklmg
               vbrp~netwr
               INTO CORRESPONDING FIELDS OF TABLE itab
               FROM vbrk
               INNER JOIN vbrp
                   ON vbrk~vbeln = vbrp~vbeln
               WHERE vbrk~kunag IN s_kunag
                 AND vbrk~fkdat IN s_fkdat
                 AND vbrp~matnr IN s_matnr
                 AND vbrp~werks IN s_werks.
      
      *-----------------------------------------------------------------------
      * QUERY FOR JOINING TABLES VBRK AND KNA1
      *-----------------------------------------------------------------------
        SELECT kna1~kunnr AS kunag
               kna1~name1
               INTO TABLE itnm
               FROM kna1
               WHERE kna1~kunnr IN s_kunag.
      
      *-----------------------------------------------------------------------
      * QUERY FOR JOINING TABLES VBRP AND T001W
      *-----------------------------------------------------------------------
        SELECT t001w~werks
               t001w~name1
               INTO TABLE itpt
               FROM t001w
               WHERE t001w~werks IN s_werks.
      
      *-----------------------------------------------------------------------
      * QUERY FOR JOINING TABLES VBRP AND MAKT
      *-----------------------------------------------------------------------
        SELECT makt~matnr
               makt~maktx
               INTO TABLE itmt
               FROM makt
               WHERE makt~matnr IN s_matnr.
      
      *-----------------------------------------------------------------------
      * SORTING INTERNAL TABLES.
      *-----------------------------------------------------------------------
        SORT itab BY kunag.
      
          LOOP AT itab.
            CLEAR itsm.
            READ TABLE itnm WITH KEY kunag = itab-kunag.
            itsm-kunag = itab-kunag.
            itsm-name1 = itnm-name1.
            itsm-fklmg = itab-fklmg.
            itsm-netwr = itab-netwr.
            COLLECT itsm.
          ENDLOOP.
      * END-OF-SELECTION.
      *
      * If not itsm[] is initial.
      *    CALL SCREEN 100.
      * endif.
      
      ******************************************************************
      *   LOCAL CLASSES: Definition
      ******************************************************************
      CLASS lcl_event_receiver DEFINITION.
      
        PUBLIC SECTION.
          METHODS:
      
          handle_double_click
              FOR EVENT double_click OF cl_gui_alv_grid
                  IMPORTING e_row e_column,
          handle_close
              FOR EVENT close OF cl_gui_dialogbox_container
                  IMPORTING sender.
      
        PRIVATE SECTION.
          DATA: dialogbox_status TYPE c.  "'X': does exist, SPACE: does not ex
      .
      
      ENDCLASS.                    "lcl_event_receiver DEFINITION
      
      ******************************************************************
      *   LOCAL CLASSES: Implementation
      ******************************************************************
      CLASS lcl_event_receiver IMPLEMENTATION.
      
      *   §3.At doubleclick(1): The event DOUBLE_CLICK provides
      *      parameters of the clicked row and column.
      *      Use row parameter to select a line of the
      *      corresponding internal table.
        METHOD handle_double_click.
          DATA: ls_sm LIKE LINE OF itsm,
                wa_itab LIKE ITAB.
      
      *   read selected row from internal table gt_sflight
          READ TABLE itsm INDEX e_row-index INTO ls_sm.
      
      *   §4.At Doubleclick(2): Select booking data
      *    READ TABLE ITAB WITH KEY KUNAG = LS_SM-KUNAG.    .
          READ TABLE ITAB INTO WA_ITAB WITH KEY KUNAG = LS_SM-KUNAG.
      
      *   §5.At doubleclick(3): Create dialogbox to show detail list
      *     (if not already existent)
          IF dialogbox_status IS INITIAL.
            dialogbox_status = 'X'.
            PERFORM create_detail_list.
          ELSE.
            CALL METHOD dialogbox_container->set_visible
              EXPORTING
                visible = 'X'.
            CALL METHOD grid2->refresh_table_display.
          ENDIF.
        ENDMETHOD.                    "handle_double_click
      *----------------------------------------------------------*
        METHOD handle_close.
      *   §6.Handle the CLOSE-button of the dialogbox
      
      *   set dialogbox invisible
      *   (the dialogbox is destroyed outomatically when the user
      *   switches to another dynpro).
          CALL METHOD sender->set_visible
            EXPORTING
              visible = space.
      *   In this example closing the dialogbox leads
      *   to make it invisible. It is also conceivable to destroy it
      *   and recreate it if the user doubleclicks a line again.
      *   Displaying a great amount of data has a greater impact on
      *performance.
        ENDMETHOD.                    "handle_close
      
      ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
      *
      *   lcl_event_receiver (Implementation)
      *=====================================================================
      
      *---------------------------------------------------------------------*
      *       FORM EXIT_PROGRAM                                             *
      *---------------------------------------------------------------------*
      FORM exit_program.
        CALL METHOD g_custom_container->free.
        CALL METHOD cl_gui_cfw=>flush.
        IF sy-subrc NE 0.
      * add your handling, for example
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = g_repid
              txt2  = sy-subrc
              txt1  = 'Error in FLush'(500).
        ENDIF.
        LEAVE TO SCREEN 0.
      ENDFORM.                    "exit_program
      
      *&---------------------------------------------------------------------*
      *&      Module  STATUS_0100  OUTPUT
      *&---------------------------------------------------------------------*
      *       text
      *----------------------------------------------------------------------*
      module STATUS_0100 output.
        SET PF-STATUS 'MAIN'.
        SET TITLEBAR 'MAIN100'.
        g_repid = sy-repid.
        IF g_custom_container IS INITIAL.
          READ TABLE itsm.
          CREATE OBJECT g_custom_container
            EXPORTING
              container_name = g_container
            EXCEPTIONS
              cntl_error = 1
              cntl_system_error = 2
              create_error = 3
              lifetime_error = 4
              lifetime_dynpro_dynpro_link = 5.
      
          IF sy-subrc NE 0.
            CALL FUNCTION 'POPUP_TO_INFORM'
              EXPORTING
                titel = g_repid
                txt2  = sy-subrc
                txt1  = 'The control could not be created'(510).
          ENDIF.
      
          CREATE OBJECT grid1
            EXPORTING
              i_parent = g_custom_container.
          gs_layout-grid_title = 'Invoice Summary'.
      
       PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'KUNAG' 'C'
      'Customer Code'.
          PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NAME1' 'C'
      'Customer Name'.
          PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'FKLMG' 'QUAN'
      'Quantity'.
          PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NETWR' 'CURR'
      'Amount'.
        PERFORM sort_build USING gt_sort[].
        PERFORM layout_init USING gs_layout.
      
          CALL METHOD grid1->set_table_for_first_display
            EXPORTING
              is_layout       = gs_layout
            CHANGING
              it_outtab       = itsm[]
              it_fieldcatalog = gt_fieldcatalog
              it_sort         = gt_sort.
      
          CREATE OBJECT event_receiver.
          SET HANDLER event_receiver->handle_double_click FOR grid1.
        ENDIF.
      
        CALL METHOD cl_gui_control=>set_focus
          EXPORTING
            control = grid1.
      
      endmodule.                 " STATUS_0100  OUTPUT
      
      *---------------------------------------------------------------------*
      *  MODULE PAI_ALV INPUT
      *---------------------------------------------------------------------*
      *
      *---------------------------------------------------------------------*
       MODULE USER_COMMAND_0100.
       CALL METHOD cl_gui_cfw=>dispatch.
      
        CASE sy-ucomm.
          WHEN 'BACK' OR 'EXIT' OR 'CANC'.
            LEAVE TO SCREEN 0.
        ENDCASE.
      ENDMODULE.                    "PAI_ALV INPUT
      
      *&--------------------------------------------------------------------*
      *&      Form  fieldcatalog_init
      *&--------------------------------------------------------------------*
      *       text
      *---------------------------------------------------------------------*
      *      -->LT_FIELDCATtext
      *      -->VALUE(FIELDtextE)
      *      -->VALUE(FIELDtextE)
      *      -->VALUE(FIELDtextT)
      *---------------------------------------------------------------------*
      FORM fieldcatalog_init USING lt_fieldcatalog TYPE lvc_t_fcat
                             value(field_name) value(field_type)
      value(field_text).
        DATA: ls_fieldcatalog TYPE lvc_s_fcat.
      
        CLEAR ls_fieldcatalog.
        ls_fieldcatalog-fieldname = field_name.
        ls_fieldcatalog-datatype  = field_type.
        ls_fieldcatalog-reptext   = field_text.
        ls_fieldcatalog-coltext  =  field_text.
        ls_fieldcatalog-seltext  =  field_text.
        ls_fieldcatalog-tooltip  =  field_text.
      
        APPEND ls_fieldcatalog TO lt_fieldcatalog.
      ENDFORM.                    "fieldcatalog_init
      
      *&--------------------------------------------------------------------*
      *&      Form  sort_build
      *&--------------------------------------------------------------------*
      *       text
      *---------------------------------------------------------------------*
      *      -->LT_SORT    text
      *---------------------------------------------------------------------*
      FORM sort_build USING lt_sort TYPE lvc_t_sort.
        DATA: ls_sort TYPE lvc_s_sort.
      
        ls_sort-fieldname = 'KUNAG'.    "Fieldname on which to sort
        ls_sort-up        = 'X'.        "Sort Ascending
        APPEND ls_sort TO lt_sort.
      
        ls_sort-fieldname = 'NAME1'.    "Fieldname on which to sort
        ls_sort-up        = 'X'.        "Sort Ascending
        APPEND ls_sort TO lt_sort.
      
      ENDFORM.                    "sort_build
      
      *&--------------------------------------------------------------------*
      *&      Form  layout_init
      *&--------------------------------------------------------------------*
      *       text
      *---------------------------------------------------------------------*
      *      -->LS_LAYOUT  text
      *---------------------------------------------------------------------*
      FORM layout_init USING ls_layout TYPE lvc_s_layo.
        ls_layout-zebra      = 'X'.
        ls_layout-grid_title = 'Customer Details'.
        ls_layout-sel_mode   = 'A'.
        ls_layout-cwidth_opt = 'X'.
      ENDFORM.                    "layout_init
      
      *&---------------------------------------------------------------------*
      *&      Form  create_detail_list
      *&---------------------------------------------------------------------*
      *         text
      *-----------------------------------------------------------------------
      *    -->  p1        text
      *    <--  p2        text
      *-----------------------------------------------------------------------
      FORM create_detail_list.
      *   create dialogbox container as dynpro-instance
      *   When the user switches to another screen, it is
      *   destroyed by lifetime mangagement of CFW
        CREATE OBJECT dialogbox_container
            EXPORTING
              top = 150
              left = 150
              lifetime = cntl_lifetime_dynpro
              caption = 'INVOICE DETAILS'(200)
              width = 800
              height = 200.
        CREATE OBJECT grid2
            EXPORTING i_parent = dialogbox_container.
      *   Register ABAP OO event 'CLOSE'. It is not necessary to register this
      *   event at the frontend (this is done during creation).
        SET HANDLER event_receiver->handle_close FOR dialogbox_container.
      
      *   display data
        gs_layout-grid_title = 'Invoice Details'(100).
        CALL METHOD grid2->set_table_for_first_display
          EXPORTING
            i_structure_name = 'itab'
            is_layout        = gs_layout
          CHANGING
            it_outtab        = itab[]
            it_fieldcatalog  = gt_fieldcatalog
            it_sort          = gt_sort.
      
      
        CALL METHOD cl_gui_control=>set_focus
          EXPORTING
            control = grid2.
      
      ENDFORM.                    " create_detail_list

      Nothing wrong in the code i am able to see the output with five records and the pop-up screen on double clicking a value.

      Kindly close the thread or revert back

  • Posted on Oct 11, 2005 at 05:20 AM

    Hi Siddarth,

    Will u please close this thread rewarding points we r spending time in solving ur problem, but u r not giving any response?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.