Application Development 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: 

led light in alv grid

Former Member
0 Kudos
2,544

Hi Everyone,

This is the sample code where in i display the alv grid in this the green led light is not coming up.

In perfrom get table i have hardcoded, the values for icon name as led green . but in the alv it displays the values @5d,

what could be the problem do i have to change here in the alv display something or what else could be done to get the led in the grid.

MODULE status_0130 OUTPUT.

  • * Create objects

IF go_custom_container IS INITIAL.

CREATE OBJECT go_custom_container

EXPORTING container_name = 'TABLE'.

CREATE OBJECT go_grid

EXPORTING

i_parent = go_custom_container.

PERFORM data

ENDIF.

ENDMODULE.

FORM data

DATA: gs_layout TYPE lvc_s_layo.

PERFORM get table

USING

table_info

CHANGING

itab.

  • Set grid title

gs_layout-grid_title = 'Table Data.

gs_layout-smalltitle = 'X'.

gs_layout-cwidth_opt = 'X'.

CALL METHOD go_grid->set_table_for_first_display

EXPORTING

i_structure_name = 'struct_table'

is_layout = gs_layout

CHANGING

it_outtab = itab.

ENDFORM.

Thanks in advance,

Any help will be of great use to me.

Prabs.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
540

Hi,

Check this demo program BALVSD01

Regards,

Vijay

21 REPLIES 21

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
540

The field needs to be at least 4 characters big. ALso, please make sure that when filling field catalog, to set the ICON field to "X".

fieldcat-ICON = 'X'.

Regards,

Rich Heilman

0 Kudos
540

Here is a sample program. Pay close attention to the parts in BOLD.



report zrich_0006.

tables: mara.

<b>type-pools: slis, icon.</b>

* Internal Tables
data: begin of ialv occurs 0,
<b>      stats(4) type c,</b>
      matnr type mara-matnr,
      maktx type makt-maktx,
      end of ialv .

data: alv_container type ref to cl_gui_custom_container,
       alv_grid type ref to cl_gui_alv_grid,
      fieldcat type lvc_t_fcat.

select-options: s_matnr for mara-matnr.

start-of-selection.

  perform get_data.

  call screen 100.

************************************************************************
*      Module  status_0100  OUTPUT
************************************************************************
module status_0100 output.
  set pf-status '0100'.
  set titlebar '0100'.

* Create Controls
  create object alv_container
         exporting container_name = 'ALV_CONTAINER'.

  create object alv_grid
         exporting  i_parent =  alv_container.

*  Populate Field Catalog
  perform get_fieldcatalog.


  call method alv_grid->set_table_for_first_display
      exporting
           i_structure_name       = 'IALV'
      changing
           it_outtab       = ialv[]
           it_fieldcatalog = fieldcat[].



endmodule.

************************************************************************
*      Module  USER_COMMAND_0100  INPUT
************************************************************************
module user_command_0100 input.

  case sy-ucomm.

    when 'BACK' or 'CANC'.
      if sy-subrc = 0.
        set screen 0.
        leave screen.
      else.
        leave program.
      endif.

    when 'EXIT'.
      leave program.

  endcase.

endmodule.


*********************************************************************
*       FORM GET_DATA.
*********************************************************************
form get_data.

  select mara~matnr makt~maktx
             into corresponding fields of table ialv
                 from mara
                      inner join makt
                         on mara~matnr = makt~matnr
                                where mara~matnr in s_matnr
                                  and makt~spras = sy-langu.

  sort ialv ascending by matnr.

  loop at ialv.
<b>    write icon_green_light as icon to ialv-stats.</b>
    modify ialv.
  endloop.

endform.



************************************************************************
*      Form  Get_Fieldcatalog - Set Up Columns/Headers
************************************************************************
form get_fieldcatalog.

  data: ls_fcat type lvc_s_fcat.
  data: columnno(3) type n value '0'.
  refresh: fieldcat.



<b>  clear: ls_fcat.
  ls_fcat-reptext    = 'Status'.
  ls_fcat-coltext    = 'Status'.
  ls_fcat-fieldname  = 'STATS'.
  ls_fcat-ref_table  = 'IALV'.
  ls_fcat-outputlen  = '4'.
  ls_fcat-icon       = 'X'.
  ls_fcat-col_pos    = 1.
  append ls_fcat to fieldcat.</b>

  clear: ls_fcat.
  ls_fcat-reptext    = 'Material Number'.
  ls_fcat-coltext    = 'Material Number'.
  ls_fcat-fieldname  = 'MATNR'.
  ls_fcat-ref_table  = 'IALV'.
  ls_fcat-outputlen  = '18'.
  ls_fcat-col_pos    = 1.
  append ls_fcat to fieldcat.

  clear: ls_fcat.
  ls_fcat-reptext    = 'Material Description'.
  ls_fcat-coltext    = 'Material Description'.
  ls_fcat-fieldname  = 'MATKX'.
  ls_fcat-ref_table  = 'IALV'.
  ls_fcat-outputlen  = '40'.
  ls_fcat-col_pos    = 2.
  append ls_fcat to fieldcat.

endform.

Regards,

Rich Heilman

0 Kudos
540

Thanks Rich,

so i have to use this field catalog form in my pgm.

thank you,

Prabs.

0 Kudos
540

Do you have some field in your structure_name that is (4) characters that you can use as your LED Light field? If so, then I guess you could use it.

The <b>Fieldcat-icon = 'X'</b> code will only "centerize" the icon in the field. If you don't do this, the icon will be Left justified in the ALV field, and hence look a little funny. I would suggest using a field catalog.

Regards,

Rich Heilman

0 Kudos
540

Hi,

I think I'm making some mistake somewhere, I did not get the LED icon in the grid.

Anymore suggestions will be greatly appreciated.

Thanks,

Prabs.

Former Member
0 Kudos
540

Hi prabakar,

I'm following this method and i'm getting lights. This will work for sure.

In data declaration along with your alv display structure as a field named lights(any name).

DATA : BEGIN OF wa_srr,

vbeln LIKE vbak-vbeln, "Sales Order number

posnr LIKE vbap-posnr, "Item nunmber

matnr LIKE makt-matnr, "Material number Desc

maktx LIKE makt-maktx, "Material Description

gbstk LIKE vbuk-gbstk, "Completion status

bukrs LIKE knb1-bukrs, "Company Code

butxt LIKE t001-butxt, "Company Code description

vkorg LIKE vbak-vkorg, "Sales organization

vtext LIKE tvkot-vtext, "Sales Org description

vtweg LIKE vbak-vtweg, "Distribution Channel

dtext LIKE tvtwt-vtext, "Dist Channel description

spart LIKE vbak-spart, "Division

dvtxt LIKE tspat-vtext, "Division Description

kunnr LIKE vbak-kunnr, "Customer Number

name1 LIKE kna1-name1, "Customer Name

land1 LIKE kna1-land1, "Country

regio LIKE kna1-regio, "State

ort01 LIKE kna1-ort01, "City

erdat LIKE vbak-erdat, "Creation Date

vdatu LIKE vbak-vdatu, "Due date

kwmeng LIKE vbap-kwmeng, "Material Quantity

netpr LIKE vbap-netpr, "unit net price

netwr LIKE vbap-netwr, "Price

wavwr LIKE vbap-wavwr, "Cost price

bzirk LIKE vbkd-bzirk, "Sales District

bztxt LIKE t171t-bztxt, "Sales District Discription

lights, "Diplaying Status

END OF wa_srr.

While you are building the field cat do as follows

FORM build_layout CHANGING l_wa_layout TYPE slis_layout_alv.

l_wa_layout-zebra = cb_zebr. "Set alterante colored line

l_wa_layout-colwidth_optimize = cb_colop. "Optimize column width

l_wa_layout-no_vline = cb_novli. "No vertical line

l_wa_layout-no_colhead = cb_nocol. "no column Header

l_wa_layout-lights_fieldname = 'LIGHTS'. "Set light field

(assigning the field u have added in ur structure here as light field in alv report)

ENDFORM. " BUILD_LAYOUT

Then as per the logic, u make green, yellow or red light

Example,

FORM build_light .

LOOP AT it_srr INTO wa_srr. "for all entries in the table

IF wa_srr-gbstk = 'C'. "If status is 'completed',

wa_srr-lights = '3'. "Show green signal light

ELSEIF wa_srr-gbstk = 'B'. "If status is 'Partial'

wa_srr-lights = '2'. "Show yellow signal light

ELSE. "If status is 'incomplete'

wa_srr-lights = '1'. "Show red signal light

ENDIF.

MODIFY it_srr FROM wa_srr. "Update to table

ENDLOOP.

ENDFORM. " build_light

Lemme know whther this solved ur problem by rewardin the points.

0 Kudos
540

Hi prabakar,

U dont need to use <ICON>, if u r using the code i've given. I havent used any <ICON> symbols.

With regards,

praveen.

0 Kudos
540

Thanks Praveen,

I have a quick question. In the form build layout, after building the layout structure l_wa_layout what should I do with it. Should I pass it to some function module. I don't see it being used anywhere in your code.

My field catalog code looks like this:

loop at pt_fieldcat into wa_fcat.

if wa_fcat-fieldname EQ 'STATUS'.

wa_fcat-reptext = 'Status'.

wa_fcat-coltext = 'Status'.

wa_fcat-outputlen = '3'.

wa_fcat-icon = 'X'.

wa_fcat-col_pos = 0.

modify pt_fieldcat from wa_fcat.

endif.

if wa_fcat-fieldname EQ 'DEPTID'.

wa_fcat-no_out = 'X'.

modify pt_fieldcat from wa_fcat.

endif.

endloop.

Regards,

Prabs.

0 Kudos
540

Hi,

FORM f1003_display_data.

* You can put your conditions here. Based upon the conditions you can 
* display the lights as Red, Yellow or Green

  w_output-light = '1'.                     “ Red
  w_output-matnr = '000123456'.
  w_output-msgty = '1'.
  APPEND w_output TO i_output.

  w_output-light = '2'.                     “ Yellow
  w_output-matnr = '000123457'.
  w_output-msgty = '1'.
  APPEND w_output TO i_output.

  w_output-light = '3'.                     “ Green
  w_output-matnr = '000123458'.
  w_output-msgty = '1'.
  APPEND w_output TO i_output.

ENDFORM.                    " f1003_display_data

FORM f9400_layout USING    value(ptitle)
                     value(pzebra)
                     value(pmode)
                     value(pwidth)
                     value(pvariant).

  w_layout-grid_title = ptitle.
  w_layout-zebra      = pzebra.
  w_layout-sel_mode   = pmode.
  w_layout-cwidth_opt = pwidth.
  w_variant-handle    = pvariant.
  w_variant-report    = sy-repid.
<b>  w_layout-excp_fname = 'LIGHT'.</b>                      " To display Light

ENDFORM.                    " f9400_layout

Create a structure: ZLIGHT_STRUC
*Build field catalog
    PERFORM f9200_build_field_cat TABLES i_fieldcat
                             USING 'ZLIGHT_STRUC'.

Components:
           <b>LIGHT Component Type LIGHT DataType INT2</b>
           MATNR           MSGTY

Message was edited by: Judith Jessie Selvi

0 Kudos
540

hi praba,

I'm sorry for this late reply. just went out for my lunch.

dude after building ur layout, Pass it to ur alv function module like this.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_top_of_page = 'TOP_OF_PAGE'

i_background_id = 'ALV_BACKGROUND'

i_grid_title = text-011

pass ur layout structure here********

is_layout = wa_layout

****************************************

it_fieldcat = it_fcat

it_sort = it_sort

i_save = v_save

is_variant = wa_variant

is_print = wa_print

TABLES

t_outtab = it_srr

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE i001. "List cannot be displayed

ENDIF.

0 Kudos
540

hi,

If u r still not clear, leave me ur mail id, I shall send u a sample program.

with regards,

praveen.

0 Kudos
540

Sorry for another reply,

>loop at pt_fieldcat into wa_fcat.

>if wa_fcat-fieldname EQ 'STATUS'.

>wa_fcat-reptext = 'Status'.

>wa_fcat-coltext = 'Status'.

wa_fcat-outputlen = '3'.

wa_fcat-icon = 'X'.

>wa_fcat-col_pos = 0.

>modify pt_fieldcat from wa_fcat.

endif.

>if wa_fcat-fieldname EQ 'DEPTID'.

>wa_fcat-no_out = 'X'.

>modify pt_fieldcat from wa_fcat.

>endif.

>endloop.

You dont need to do this like this. This is how i've built my field catalg

DATA l_fcat TYPE slis_fieldcat_alv. "Work area for field catalog

***BUILD FIELD CATALOG

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'WA_SRR'

i_client_never_display = 'X'

i_inclname = sy-repid

CHANGING

ct_fieldcat = l_it_fcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE w004. "Building field catalog failed

ENDIF.

and wat all i did to add light is,

1) adding an extra field in the main structure.

2)create internal table with this structure as data table for alv report

3) add 'field name' field in layout

4) I have passed values(3, 2, 1) for green, yellow and red light resp, to the field(LIGHTS) in the internal table that is passed to alv function module.(Based on some condition)

5) pass the layout structure layout to alv function module

Thats it. If u do all this teps, u r done with it.

with regards,

praveen.

0 Kudos
540

Hi,

One quick clarification...

What is the component type u gave for LIGHT, while creating the structure?

The component type of that field should be "LIGHT".

Regards,

Anjali.

Send me ur mail id, i shall send u a simple code

Message was edited by: Anjali Devi

0 Kudos
540

Hi anjali,

U dont have to give any component type while creating a structure. that means its a character type of lenght 1. I'm using it for all my reports specs. Its working damn good.

with regards,

praveen.

0 Kudos
540

Hi,

In table type

types: begin of slis_layout_alv_spec1,

*        Exceptions
         lights_fieldname type slis_fieldname," fieldname for exception
         lights_tabname type slis_tabname, " fieldname for exception
         lights_rollname like dfies-rollname," rollname f. exceptiondocu
         lights_condense(1) type c,    " fieldname for exception

If u r using <b>SLIS</b> type then u have to specify exceptions as above, so try to use that.

Hope this helps.

0 Kudos
540

Hi,

Just do as Praveen and do the following modifications.

Declare a field light along with the fields of the output.

eg: begin of it_outtab occurs 0,

ebeln...

ebelp...

.

.

<b>light type c</b>,

end of it_outtab.

just before using method set_table_for_first_display declare the layout it_layout:

it_layout-grid_title = 'Output'.

<b>it_layout-excp_fname = w_light</b>.

declare the field w_light:

data : w_light type lvc_cifnm value 'LIGHT'.

And based on your condition pass '1' or '2' or '3' to it_outtab-light while filling data into table it_outtab.

just by doing this, the traffic lights will appear along with the records in the output

Former Member
0 Kudos
540

Hi, try the action like following.

INCLUDE <ICON>.

add this into your application.

define a field in the internal table you need to shown in ALV, like this:

STATUSICON(5) TYPE C,

  • STATUSICON is just a random name

don't forget the associated addition on the fieldcategory table setting

fill the field STATUSICON as following:

MOVE ICON_RED_LIGHT TO XXXX-STATUSICON.

you can choose some other icons, like

ICON_RED_LIGHT

ICON_GREEN_LIGHT

ICON_YELLOW_LIGHT

Hope it will be helpful

Message was edited by: zhenglin gu

Former Member
0 Kudos
541

Hi,

Check this demo program BALVSD01

Regards,

Vijay

0 Kudos
540

Hi,

Check this.

http://help.sap.com/saphelp_erp2004/helpdata/en/7f/e477e8fba211d2b48f006094192fe3/content.htm

In this link,they are discussing the sample code for traffic lights.

http://sgstocks.tripod.com/alvgrid_control.htm#Make%20an%20Exception%20field%20(%20=%20Traffic%20lig...

Message was edited by: Jayanthi Jayaraman

Message was edited by: Jayanthi Jayaraman

jayanthi_jayaraman
Active Contributor
0 Kudos
540

Hi,

To have an idea about the value of icons,check this.

http://www.sapdevelopment.co.uk/tips/tips_icons.htm

ICON_2 ICON_LED_YELLOW '@5D@'." Stop

Former Member
0 Kudos
540

Hi,

Try this sample code:

Take care to use ur strcuture name and the fields accordingly.

Program Name: zzz_light_alv
REPORT zzz_light_alv NO STANDARD PAGE HEADING.

* The Data Declarations
INCLUDE zzz_light_alv_data.

PARAMETERS p_layout LIKE disvariant-variant.

START-OF-SELECTION.
*Fetching data for the report
  PERFORM f1003_display_data.
END-OF-SELECTION.

  CALL SCREEN 9001.
TOP-OF-PAGE.

*Data Selection
  INCLUDE zzz_light_alv_forms.
*PBO & PAI Modules
  INCLUDE zzz_light_alv_screen.

* Create an include : zzz_light_alv_data

TABLES:    mara.                          " General Material Data.

TYPES : BEGIN OF ty_data,
         light TYPE ZLIGHT_STRUC-light,      " Light
         matnr TYPE mara-matnr ,             " Material number
         msgty TYPE ZLIGHT_STRUC-msgty,      " Message type
        END OF ty_data.

DATA: i_exclude TYPE ui_functions,   " Function button table definitions
      i_fieldcat TYPE lvc_t_fcat,    " Field catalogue
      i_output TYPE STANDARD TABLE OF ZLIGHT_STRUC,
      i_groups  TYPE lvc_t_sgrp,


       w_variant TYPE disvariant,          " Enable variant saving
       <b>w_layout  TYPE lvc_s_layo,          " Define the layout structure</b>
       w_output TYPE <b>ZLIGHT_STRUC</b>.


CONSTANTS:  c_a       TYPE c VALUE 'A'.          "All Layouts

DATA : o_alvgrid          TYPE REF TO cl_gui_alv_grid,
       o_dockingcontainer TYPE REF TO cl_gui_docking_container.


*Create an include: ZZZ_LIGHT_ALV_FORMS


*&---------------------------------------------------------------------*
*&      Form  f1002_value_request
*&---------------------------------------------------------------------*
*       Get the values for the layout.
*----------------------------------------------------------------------*
FORM f1002_value_request.

  DATA:    lv_exit        TYPE c,
           lw_variant     LIKE w_variant.

  w_variant-report   = sy-repid.

* Invoke function to provide drop down entries
  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
       EXPORTING
            is_variant    = w_variant
            i_save        = c_a
       IMPORTING
            e_exit        = lv_exit
            es_variant    = lw_variant
       EXCEPTIONS
            not_found     = 1
            program_error = 2
            OTHERS        = 3.
  IF sy-subrc IS INITIAL.
    IF lv_exit IS INITIAL.
      p_layout = lw_variant-variant.
    ENDIF.
  ELSE.
*    MESSAGE i037.                                    "No layouts found
  ENDIF.

ENDFORM.                    " f1002_value_request

*&---------------------------------------------------------------------*
*&      Form  f1003_display_data
*&---------------------------------------------------------------------*
*       Display Data
*----------------------------------------------------------------------*
FORM f1003_display_data.

* You can put your conditions here. Based upon the conditions you can 
* display the lights as Red, Yellow or Green

  w_output-light = '1'.                     “ Red
  w_output-matnr = '000123456'.
  w_output-msgty = '1'.
  APPEND w_output TO i_output.

  w_output-light = '2'.                     “ Yellow
  w_output-matnr = '000123457'.
  w_output-msgty = '1'.
  APPEND w_output TO i_output.

  w_output-light = '3'.                     “ Green
  w_output-matnr = '000123458'.
  w_output-msgty = '1'.
  APPEND w_output TO i_output.

ENDFORM.                    " f1003_display_data

*&---------------------------------------------------------------------*
*&      Form  f9000_objects_create
*&---------------------------------------------------------------------*
* This form creates the objects that we later reference.
*----------------------------------------------------------------------*
FORM f9000_objects_create.

* Check to see if we are runnng on online
  IF cl_gui_alv_grid=>offline( ) IS INITIAL.

    CREATE OBJECT o_dockingcontainer
      EXPORTING
        ratio                       = '95'
     EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      lifetime_dynpro_dynpro_link = 5
      others                      = 6.

    IF sy-subrc NE 0.
*      MESSAGE i001 WITH text-e01.
      LEAVE LIST-PROCESSING.
    ENDIF.

  ENDIF.

  CREATE OBJECT o_alvgrid
    EXPORTING
      i_parent = o_dockingcontainer.

ENDFORM.                    " f9000_objects_create

*&---------------------------------------------------------------------*
*&      Form  f9100_exclude_functions
*&---------------------------------------------------------------------*
* This form exclude buttons  from the toolbar.
*----------------------------------------------------------------------*
*      -->P_IEXCLUDE  text
*      -->P_1150   text
*----------------------------------------------------------------------*
FORM f9100_exclude_functions USING   pexclude LIKE i_exclude
                               value(pfunction).

  DATA: l_exclude TYPE ui_func.

  l_exclude = pfunction.
  APPEND l_exclude TO pexclude.

ENDFORM.                    " f9100_exclude_functions

*&---------------------------------------------------------------------*
*&      Form  f9200_build_field_cat
*&---------------------------------------------------------------------*
*       Building the field catalogue
*----------------------------------------------------------------------*
*      -->P_I_FIELDCAT[] - Internal table having the fields of the ALV
*                          structure
*      -->P_structure    - ALV structure to be displayed in the output
*----------------------------------------------------------------------*
FORM f9200_build_field_cat TABLES p_fieldcat STRUCTURE lvc_s_fcat
                      USING value(p_structure).

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
       EXPORTING
            i_structure_name       = p_structure
       CHANGING
            ct_fieldcat            = p_fieldcat[]
       EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.
  IF sy-subrc <> 0.
*    MESSAGE i277.
    LEAVE LIST-PROCESSING.
  ENDIF.

ENDFORM.                    " f9200_build_field_cat

*&---------------------------------------------------------------------*
*&      Form  f9400_layout
*&---------------------------------------------------------------------*
* This form sets how the grid will look.
* The title, alternate colouring on lines, if the column widths are
* optimised for the data contents and the display variant if_used.
*----------------------------------------------------------------------*
*      -->P_SY_TITLE - Title bar text
*      -->P_0015     - Alternating line color (striped)
*      -->P_0016     - Selection mode
*      -->P_0017     - Optimize column width
*      -->P_P_DISVAR - Report name
*----------------------------------------------------------------------*
FORM f9400_layout USING    value(ptitle)
                     value(pzebra)
                     value(pmode)
                     value(pwidth)
                     value(pvariant).

  w_layout-grid_title = ptitle.
  w_layout-zebra      = pzebra.
  w_layout-sel_mode   = pmode.
  w_layout-cwidth_opt = pwidth.
  w_variant-handle    = pvariant.
  w_variant-report    = sy-repid.
<b>  w_layout-excp_fname = 'LIGHT'. </b>                     " To display Light

ENDFORM.                    " f9400_layout

*&---------------------------------------------------------------------*
*&      Form  f9500_display_data
*&---------------------------------------------------------------------*
*       Display the output data
*----------------------------------------------------------------------*
*      -->P_IOUTPUT  - Output table to be displayed in the ALV
*      -->P_groups   - Field groups
*      -->P_exclude  - Excluded toolbar standard functions
*      -->P_fieldcat - Field catalog
*      -->P_layout   - Layout
*----------------------------------------------------------------------*
FORM f9500_display_data TABLES p_output
                         p_groups
                         p_exclude
                         p_fieldcat
                  USING value(p_layout).

  CALL METHOD o_alvgrid->set_table_for_first_display
     EXPORTING
       is_variant                    = w_variant
       i_save                        = c_a
       is_layout                     = p_layout
       it_special_groups             = p_groups[]
       it_toolbar_excluding          = p_exclude[]
    CHANGING
       it_outtab                     = p_output[]
       it_fieldcatalog               = p_fieldcat[]
    EXCEPTIONS
       invalid_parameter_combination = 1
       program_error                 = 2
       too_many_lines                = 3
       OTHERS                        = 4.

  IF sy-subrc <> 0.
*    MESSAGE i278.
    LEAVE LIST-PROCESSING.
  ENDIF.

ENDFORM.                    " f9500_display_data

*&---------------------------------------------------------------------*
*&      Form  f9600_free_objects
*&---------------------------------------------------------------------*
*  This form handles the freeing of the following objects
*  ALV Docking Container
*----------------------------------------------------------------------*
*      -->P_O_ALVGRID - Object to be freed
*      -->P_0020      - Type of the object
*      -->P_0021      - Object text
*----------------------------------------------------------------------*
FORM f9600_free_objects USING pobject
                    value(ptype)
                    value(ptext).

  DATA: l_objectalv TYPE REF TO cl_gui_alv_grid.
* Need to type the field symbol or it does not work

  CASE ptype.
    WHEN 'ALV'.

      l_objectalv = pobject.

      IF NOT ( l_objectalv IS INITIAL ).
        CALL METHOD l_objectalv->free
          EXCEPTIONS
            cntl_error        = 1
           cntl_system_error = 2
            OTHERS            = 3.
        CLEAR: pobject, l_objectalv.
        PERFORM f9700_error_handle USING ptext.

      ENDIF.
    WHEN 'DOCKING'.
      DATA: lobjectdock TYPE REF TO cl_gui_docking_container.
      lobjectdock = pobject.

      IF NOT ( lobjectdock IS INITIAL ).
        CALL METHOD lobjectdock->free
          EXCEPTIONS
            cntl_error        = 1
           cntl_system_error = 2
            OTHERS            = 3.
        CLEAR: pobject, lobjectdock.
        PERFORM f9700_error_handle USING ptext.

      ENDIF.
    WHEN 'CONTAINER'.
      DATA: lobjectcontainer TYPE REF TO cl_gui_container.
      lobjectcontainer = pobject.

      IF NOT ( lobjectcontainer IS INITIAL ).
        CALL METHOD lobjectcontainer->free
          EXCEPTIONS
            cntl_error        = 1
           cntl_system_error = 2
            OTHERS            = 3.
        CLEAR: pobject, lobjectcontainer.
        PERFORM f9700_error_handle USING ptext.

      ENDIF.
    WHEN OTHERS.
      sy-subrc = 1.
      PERFORM f9700_error_handle USING
                                text-e04.
  ENDCASE.

ENDFORM.                    " f9600_free_objects

*&---------------------------------------------------------------------*
*&      Form  f9700_error_handle
*&---------------------------------------------------------------------*
*       This form is used to handle errors
*----------------------------------------------------------------------*
*      -->P_PTEXT - Text holding the messsage to be displayed as
*                   information
*----------------------------------------------------------------------*
FORM f9700_error_handle USING    value(ptext).

  IF sy-subrc NE 0.
* Add your handling, for example
    CALL FUNCTION 'POPUP_TO_INFORM'
         EXPORTING
              titel = text-e03
              txt2  = sy-subrc
              txt1  = ptext.
  ENDIF.

ENDFORM.                    " f9700_error_handle


* Create a screen: 9001.

* Create an include: ZZZ_LIGHT_ALV_SCREEN

MODULE status_9001 OUTPUT.

  IF o_dockingcontainer IS INITIAL.

    SET PF-STATUS 'ZSTATUS'.
    SET TITLEBAR 'ZTITLE'.

*Create Objects
    PERFORM f9000_objects_create.

*Build field catalog
    PERFORM f9200_build_field_cat TABLES i_fieldcat
                             USING 'ZLIGHT_STRUC'.

*Layout
    PERFORM f9400_layout USING sy-title 'X' 'X' 'X' p_layout.

*Display data
    PERFORM f9500_display_data TABLES i_output
                                i_groups
                                i_exclude
                                i_fieldcat
                          USING w_layout.

  ENDIF.

ENDMODULE.                 " STATUS_9001  OUTPUT
*&---------------------------------------------------------------------
*&      Module  USER_COMMAND_9001  INPUT
*&---------------------------------------------------------------------
* This is used for PAI details
*----------------------------------------------------------------------
MODULE user_command_9001 INPUT.

  CASE sy-ucomm.

    WHEN 'EXIT' OR  'CANC'.
      PERFORM f9600_free_objects:
               USING o_alvgrid 'ALV' text-e02,
               USING o_dockingcontainer 'DOCKING'
                       text-e01.
      LEAVE PROGRAM.

    WHEN 'BACK'.
      PERFORM f9600_free_objects:
               USING o_alvgrid 'ALV' text-e02,
               USING o_dockingcontainer 'DOCKING'
                       text-e01.
      SET SCREEN '0'.
      LEAVE SCREEN.

    WHEN OTHERS.

  ENDCASE.

ENDMODULE.                 " USER_COMMAND_9001  INPUT


Create a structure: <b>ZLIGHT_STRUC</b>

Components:
           LIGHT
           MATNR
           MSGTY

Regards,

Anjali