Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

OOPS ALV

Former Member
0 Likes
531

Hi,

When user chooses say X then the first data table with its fieldcatalog should be output and when he chooses Y then second data table with its fieldcatalog should be output.

I m transfering my output data table and fieldcatalog to global parameters: <DATA> and it_fieldcatalog, where <DATA> is the fieldsymbol of type table and it_fieldcatalog is of type lvc_t_fcat and then calling the following:

CREATE OBJECT g_container

EXPORTING

container_name = 'C_CONTAINER'.

CREATE OBJECT g_grid

EXPORTING

i_parent = g_container.

CALL METHOD g_grid->set_table_for_first_display

CHANGING

it_outtab = <DATA> it_fieldcatalog = it_fieldcatalog

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

IF sy-subrc 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

The problem i m facing is that when i user chooses X then the first output table's data is displayed in the ALV but when he chooses Y the same data is shown instead of second table's data.

Why the current data is not displayed though respective table and fieldcatalog tables match.

PLZ HELP!

3 REPLIES 3
Read only

Former Member
0 Likes
511

Hi,

How ll de user select X/Y radio buttons?

Read only

Former Member
0 Likes
511

yes X and Y are radiobuttons.

Read only

0 Likes
511

Hi,

Check this code ..........

custom control name = 'CUSTOM'..

TYPES : BEGIN OF tp_display,
        fld1  TYPE char10,
        fld2  TYPE p,
        fld3  TYPE i,
        END   OF tp_display.

DATA : container1   TYPE REF   TO cl_gui_custom_container,
       grid         TYPE REF   TO cl_gui_alv_grid,
       it_display1  TYPE TABLE OF tp_display,
       it_display2  TYPE TABLE OF tp_display,
       it_field_cat TYPE          lvc_t_fcat,
       it_sort      TYPE          lvc_t_sort,
       wa_display   TYPE          tp_display,
       wa_field_cat TYPE LINE  OF lvc_t_fcat,
       wa_sort      TYPE LINE  OF lvc_t_sort.

PARAMETERS : rb1 RADIOBUTTON GROUP rb,
             rb2 RADIOBUTTON GROUP rb.

FIELD-SYMBOLS <it_display> TYPE STANDARD TABLE.

START-OF-SELECTION.

CASE 'X' .
  WHEN rb1.
    ASSIGN it_display1 to <it_display>.
  WHEN rb2.
    ASSIGN it_display2 to <it_display>.
ENDCASE.

  CALL SCREEN 100.



*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'BASIC'.
*  SET TITLEBAR 'xxx'.
  PERFORM build_it_display.
  PERFORM build_it_field_cat.
  PERFORM build_it_sort.
  PERFORM create_objects.


ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE sy-ucomm.
    WHEN 'BACK'.
      CALL METHOD grid->free.
      SET SCREEN 0.
      LEAVE SCREEN.
    WHEN 'EXIT'.
      SET SCREEN 0.
      LEAVE SCREEN.
    WHEN 'CANC'.
      SET SCREEN 0.
      LEAVE SCREEN.
  ENDCASE.

ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Form  build_it_display
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM build_it_display.
  MOVE : 'Hi 1'  TO wa_display-fld1,
         10    TO wa_display-fld2,
         -25   TO wa_display-fld3.

  APPEND wa_display TO it_display1.
  APPEND wa_display TO it_display1.
  APPEND wa_display TO it_display1.
  APPEND wa_display TO it_display1.
  APPEND wa_display TO it_display1.
  MOVE : 'Hello 1' TO wa_display-fld1,
         15      TO wa_display-fld2,
         -5      TO wa_display-fld3.

  APPEND wa_display TO it_display1.
  APPEND wa_display TO it_display1.
  APPEND wa_display TO it_display1.
  APPEND wa_display TO it_display1.
  APPEND wa_display TO it_display1.

    MOVE : 'Hi 2'  TO wa_display-fld1,
         10    TO wa_display-fld2,
         -25   TO wa_display-fld3.

  APPEND wa_display TO it_display2.
  APPEND wa_display TO it_display2.
  APPEND wa_display TO it_display2.
  APPEND wa_display TO it_display2.
  APPEND wa_display TO it_display2.
  MOVE : 'Hello 2' TO wa_display-fld1,
         25      TO wa_display-fld2,
         55      TO wa_display-fld3.

  APPEND wa_display TO it_display2.
  APPEND wa_display TO it_display2.
  APPEND wa_display TO it_display2.
  APPEND wa_display TO it_display2.
  APPEND wa_display TO it_display2.
ENDFORM.                    "build_it_display

*&---------------------------------------------------------------------*
*&      Form  build_it_field_cat
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM build_it_field_cat.
  REFRESH it_field_cat.

  wa_field_cat-fieldname = 'FLD1'.
  wa_field_cat-emphasize = 'X'.
  wa_field_cat-reptext   = 'Character'.
  APPEND wa_field_cat TO it_field_cat.

  wa_field_cat-fieldname = 'FLD2'.
  wa_field_cat-emphasize = ' '.
  wa_field_cat-reptext   = 'Pack integer'.
  wa_field_cat-do_sum    = 'X'.
  APPEND wa_field_cat TO it_field_cat.

  wa_field_cat-fieldname = 'FLD3'.
  wa_field_cat-emphasize = ' '.
  wa_field_cat-reptext   = 'Integer'.
  wa_field_cat-do_sum    = 'X'.
  APPEND wa_field_cat TO it_field_cat.


ENDFORM.                    "build_it_field_cat
*&---------------------------------------------------------------------*
*&      Form  build_it_sort
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build_it_sort .
  wa_sort-fieldname = 'FLD1'.
  wa_sort-up        = ' '.
  wa_sort-down      = 'X'.
  APPEND wa_sort TO it_sort.
ENDFORM.                    " build_it_sort
*&---------------------------------------------------------------------*
*&      Form  create_objects
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM create_objects .


 IF container1 IS INITIAL.
    CREATE OBJECT container1
      EXPORTING
   container_name              = 'CUSTOM'.
    CREATE OBJECT grid
      EXPORTING
         i_shellstyle      = 1
         i_parent          = container1
         i_appl_events     = 'X'.
    CALL METHOD grid->set_table_for_first_display
      CHANGING
        it_outtab       = <it_display>
        it_fieldcatalog = it_field_cat
        it_sort         = it_sort.
  ENDIF.

ENDFORM.                    "create_objects

Cheers,

jose.