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

calling ucomm in ALV_Grid

Hi experts,

I am trying to do some thing but I have some difficulties. I would appreciate if some one tells me how to achieve this.

I am trying to invoke the ucomm and CALL SELECTION-SCREEN 500 STARTING AT 10 10 WHEN the field 'CITYFROM' is pressed.

Could some body tells me what I need to do in my coding? Below is my coding. Thank you all in advance.

*&---------------------------------------------------------------------*
*& Report  ZSPFLI

REPORT  zspfli.

TYPE-POOLS: slis.
TABLES: sflight, spfli.

DATA: gt_sflight TYPE STANDARD TABLE OF sflight,
      gw_sflight TYPE sflight.

DATA: gt_spfli TYPE STANDARD TABLE OF spfli,
      gw_spfli TYPE spfli.

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001. " .
SELECTION-SCREEN SKIP.
PARAMETERS: p_carr LIKE spfli-carrid.
SELECTION-SCREEN SKIP.

SELECTION-SCREEN END OF BLOCK blk1.

SELECTION-SCREEN BEGIN OF SCREEN 500 TITLE title
                                     AS WINDOW.
PARAMETERS name TYPE sy-uname.
SELECTION-SCREEN END OF SCREEN 500.
title = 'Input name'.
*CALL SELECTION-SCREEN 500 STARTING AT 10 10.

START-OF-SELECTION.

  PERFORM data_selection.

END-OF-SELECTION.

  PERFORM alv_output.
*&---------------------------------------------------------------------*
*&      Form  data_selection
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM data_selection .

  SELECT * FROM spfli INTO TABLE gt_spfli
            WHERE carrid = p_carr.
*            AND   connid = so_con.

ENDFORM.                    " data_selection
*&---------------------------------------------------------------------*
*&      Form  alv_output
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM alv_output .

  DATA:
    l_variant          TYPE disvariant,
    l_str_layout       TYPE slis_layout_alv.

* Make column width as small as possible.
  l_str_layout-colwidth_optimize = 'X'.
* Give the name of the report so that the user can save individual
* configuration of the ALV-Grid Display
  l_variant-report = sy-repid.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
*   I_CALLBACK_PROGRAM                = ' '
*   I_CALLBACK_PF_STATUS_SET          = ' '
     i_callback_user_command           = 'USER_COMMAND'
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
     i_structure_name                  = 'SPFLI'
*   I_BACKGROUND_ID                   = ' '
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
   is_layout                         = l_str_layout
*   IT_FIELDCAT                       =
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
*   I_SAVE                            = ' '
   is_variant                        = l_variant
*   IT_EVENTS                         =
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   IR_SALV_FULLSCREEN_ADAPTER        =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
    TABLES
      t_outtab                          = gt_spfli
   EXCEPTIONS
     program_error                     = 1
     OTHERS                            = 2
            .
  ENDFORM.                    " alv_output

*&---------------------------------------------------------------------*
*&      Form  user_command
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
                  rs_selfield   TYPE slis_selfield.

  DATA: lt_spfli TYPE spfli.

  CASE r_ucomm.
    WHEN '&IC1'.                       "Doppelklick
      READ TABLE gt_spfli INTO lt_spfli INDEX rs_selfield-tabindex.
      IF sy-subrc = 0.

        CASE rs_selfield-fieldname.

          WHEN 'CITYFROM'.
            CALL SELECTION-SCREEN 500 STARTING AT 10 10.
        ENDCASE.
      ENDIF.
  ENDCASE.

ENDFORM.                    "user_command

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 09:28 PM

    I have done some changes in ur code (marked in bold)

    REPORT ZSPFLI.

    &----


    *& Report ZSPFLI

    TYPE-POOLS: slis.

    TABLES: sflight, spfli.

    DATA: gt_sflight TYPE STANDARD TABLE OF sflight,

    gw_sflight TYPE sflight.

    DATA: gt_spfli TYPE STANDARD TABLE OF spfli,

    gw_spfli TYPE spfli.

    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001. " .

    SELECTION-SCREEN SKIP.

    PARAMETERS: p_carr LIKE spfli-carrid.

    SELECTION-SCREEN SKIP.

    SELECTION-SCREEN END OF BLOCK blk1.

    SELECTION-SCREEN BEGIN OF SCREEN 500 TITLE title

    AS WINDOW.

    PARAMETERS name TYPE sy-uname.

    SELECTION-SCREEN END OF SCREEN 500.

    title = 'Input name'.

    *CALL SELECTION-SCREEN 500 STARTING AT 10 10.

    START-OF-SELECTION.

    PERFORM data_selection.

    END-OF-SELECTION.

    PERFORM alv_output.

    &----


    *& Form data_selection

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM data_selection .

    SELECT * FROM spfli INTO TABLE gt_spfli

    WHERE carrid = p_carr.

    • AND connid = so_con.

    ENDFORM. " data_selection

    &----


    *& Form alv_output

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM alv_output .

    DATA:

    l_variant TYPE disvariant,

    l_str_layout TYPE slis_layout_alv,

    l_syrepid type syrepid.

    l_syrepid = sy-repid.

    • Make column width as small as possible.

    l_str_layout-colwidth_optimize = 'X'.

    • Give the name of the report so that the user can save individual

    • configuration of the ALV-Grid Display

    l_variant-report = sy-repid.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = l_syrepid

    • I_CALLBACK_PF_STATUS_SET = ' '

    i_callback_user_command = 'USER_COMMAND'

    • I_CALLBACK_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    i_structure_name = 'SPFLI'

    • I_BACKGROUND_ID = ' '

    • I_GRID_TITLE =

    • I_GRID_SETTINGS =

    is_layout = l_str_layout

    • IT_FIELDCAT =

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    is_variant = l_variant

    • IT_EVENTS =

    • IT_EVENT_EXIT =

    • IS_PRINT =

    • IS_REPREP_ID =

    • IT_ALV_GRAPHICS =

    • IT_HYPERLINK =

    • IT_ADD_FIELDCAT =

    • IT_EXCEPT_QINFO =

    • IR_SALV_FULLSCREEN_ADAPTER =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    t_outtab = gt_spfli

    EXCEPTIONS

    program_error = 1

    OTHERS = 2

    .

    ENDFORM. " alv_output

    &----


    *& Form user_command

    &----


    • text

    ----


    FORM user_command USING r_ucomm LIKE sy-ucomm

    rs_selfield TYPE slis_selfield.

    DATA: lt_spfli TYPE spfli.

    CASE r_ucomm.

    WHEN '&IC1'. "Doppelklick

    READ TABLE gt_spfli INTO lt_spfli INDEX rs_selfield-tabindex.

    IF sy-subrc = 0.

    CASE rs_selfield-fieldname.

    WHEN 'CITYFROM'.

    CALL SELECTION-SCREEN 500 STARTING AT 10 10.

    ENDCASE.

    ENDIF.

    ENDCASE.

    ENDFORM. "user_command

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 17, 2008 at 09:14 PM

    Hi looks like you are not maintaining any pf status for ur field or the button CITY* , you need create a PF status and assign a function code to that.. and then write your condition on sy-ucomm.

    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.