<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ALV display using oops in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-display-using-oops/m-p/4776602#M1119288</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use this sample code....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp; REPORT ysample&lt;/P&gt;&lt;P&gt;*&amp;amp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;report ysample.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*CLASS cl_gui_alv_grid DEFINITION LOAD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types : begin of ty_output,&lt;/P&gt;&lt;P&gt;         locid type /sapapo/locid,&lt;/P&gt;&lt;P&gt;         locno type /sapapo/locno,&lt;/P&gt;&lt;P&gt;         tzone type tznzone,&lt;/P&gt;&lt;P&gt;         adrnummer type ad_addrnum,&lt;/P&gt;&lt;P&gt;        end of ty_output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : t_output type table of ty_output,&lt;/P&gt;&lt;P&gt;       l_output like line of t_output,&lt;/P&gt;&lt;P&gt;       t_output1 type table of ty_output,&lt;/P&gt;&lt;P&gt;       l_output1 like line of t_output1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : ref_container type ref to cl_gui_custom_container,&lt;/P&gt;&lt;P&gt;       ref_alv       type ref to cl_gui_alv_grid,&lt;/P&gt;&lt;P&gt;       ref_container1 type ref to cl_gui_custom_container,&lt;/P&gt;&lt;P&gt;       ref_alv1       type ref to cl_gui_alv_grid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : w_fcat   type lvc_s_fcat,&lt;/P&gt;&lt;P&gt;       w_layout type lvc_s_layo,&lt;/P&gt;&lt;P&gt;       i_fcat   type lvc_t_fcat,&lt;/P&gt;&lt;P&gt;       i_fcat1   type lvc_t_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : g_variant  type disvariant,&lt;/P&gt;&lt;P&gt;       g_save     type flag,&lt;/P&gt;&lt;P&gt;       i_sort     type lvc_t_sort ,&lt;/P&gt;&lt;P&gt;       w_sort     type lvc_s_sort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      CLASS lcl_toolbar_event_receiver DEFINITION&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;class lcl_toolbar_event_receiver definition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  public section.&lt;/P&gt;&lt;P&gt;    methods: on_double_click&lt;/P&gt;&lt;P&gt;               for event double_click of cl_gui_alv_grid&lt;/P&gt;&lt;P&gt;                 importing e_row&lt;/P&gt;&lt;P&gt;                           e_column&lt;/P&gt;&lt;P&gt;                           es_row_no.&lt;/P&gt;&lt;P&gt;endclass.                    "lcl_toolbar_event_receiver DEFINITION&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      CLASS lcl_toolbar_event_receiver IMPLEMENTATION&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;class lcl_toolbar_event_receiver implementation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  method on_double_click.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    read table t_output into l_output index e_row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      l_output1-locid = l_output-locid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      append l_output1 to t_output1.&lt;/P&gt;&lt;P&gt;      clear l_output1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call screen 200 starting at 10 5 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endmethod.                    "on_double_click&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endclass.                    "lcl_toolbar_event_receiver IMPLEMENTATION&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data :        event_receiver type ref to lcl_toolbar_event_receiver.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  select locid locno tzone adrnummer&lt;/P&gt;&lt;P&gt;  from /sapapo/loc&lt;/P&gt;&lt;P&gt;  into table t_output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  call screen 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  fcat&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; --&amp;gt;  p1        text&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;--  p2        text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form fcat .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; CLEAR w_fcat .&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; w_fcat-col_pos = 1.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; w_fcat-fieldname = 'LOCID'.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; w_fcat-coltext   = 'LOCATIONID'.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; w_fcat-ref_table = 'T_OUTPUT'.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; APPEND w_fcat TO i_fcat.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  clear w_fcat .&lt;/P&gt;&lt;P&gt;  w_fcat-col_pos = 2.&lt;/P&gt;&lt;P&gt;  w_fcat-fieldname = 'LOCNO'.&lt;/P&gt;&lt;P&gt;  w_fcat-coltext   = 'LOCATION'.&lt;/P&gt;&lt;P&gt;  w_fcat-ref_table = 'T_OUTPUT'.&lt;/P&gt;&lt;P&gt;  append w_fcat to i_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  clear w_fcat .&lt;/P&gt;&lt;P&gt;  w_fcat-col_pos = 3.&lt;/P&gt;&lt;P&gt;  w_fcat-fieldname = 'TZONE'.&lt;/P&gt;&lt;P&gt;  w_fcat-coltext   = 'TIME-ZONE'.&lt;/P&gt;&lt;P&gt;  w_fcat-ref_table = 'T_OUTPUT'.&lt;/P&gt;&lt;P&gt;  append w_fcat to i_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  clear w_fcat .&lt;/P&gt;&lt;P&gt;  w_fcat-col_pos = 4.&lt;/P&gt;&lt;P&gt;  w_fcat-fieldname = 'ADRNUMMER'.&lt;/P&gt;&lt;P&gt;  w_fcat-coltext   = 'ADDR-NO'.&lt;/P&gt;&lt;P&gt;  w_fcat-ref_table = 'T_OUTPUT'.&lt;/P&gt;&lt;P&gt;  append w_fcat to i_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.                    " fcat&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  flayout&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; --&amp;gt;  p1        text&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;--  p2        text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form flayout .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  w_layout-zebra = 'X'.&lt;/P&gt;&lt;P&gt;  w_layout-cwidth_opt = 'X'.&lt;/P&gt;&lt;P&gt;  w_layout-grid_title = 'Sample Program using ABAP Objects'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.                    " flayout&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  sort&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; --&amp;gt;  p1        text&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;--  p2        text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form sort .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  w_sort-fieldname = 'LOCNO'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; w_sort-subtot = 'X'.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  append w_sort to i_sort.&lt;/P&gt;&lt;P&gt;  clear w_sort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.                    " sort&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  fcat1&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; --&amp;gt;  p1        text&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;--  p2        text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form fcat1 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  clear w_fcat .&lt;/P&gt;&lt;P&gt;  w_fcat-col_pos = 1.&lt;/P&gt;&lt;P&gt;  w_fcat-fieldname = 'LOCID'.&lt;/P&gt;&lt;P&gt;  w_fcat-coltext   = 'LOCATIONID'.&lt;/P&gt;&lt;P&gt;  w_fcat-ref_table = 'T_OUTPUT'.&lt;/P&gt;&lt;P&gt;  append w_fcat to i_fcat1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.                                                    "fcat1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Module  STATUS_0100  OUTPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;module status_0100 output.&lt;/P&gt;&lt;P&gt;  set pf-status 'SAMPLE-TT'.&lt;/P&gt;&lt;P&gt;  set titlebar 'TT'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  if ref_container is initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    create object ref_container&lt;/P&gt;&lt;P&gt;          exporting&lt;/P&gt;&lt;P&gt;            container_name              = 'CONTROL1'&lt;/P&gt;&lt;P&gt;          exceptions&lt;/P&gt;&lt;P&gt;            cntl_error                  = 1&lt;/P&gt;&lt;P&gt;            cntl_system_error           = 2&lt;/P&gt;&lt;P&gt;            create_error                = 3&lt;/P&gt;&lt;P&gt;            lifetime_error              = 4&lt;/P&gt;&lt;P&gt;            lifetime_dynpro_dynpro_link = 5&lt;/P&gt;&lt;P&gt;            others                      = 6.&lt;/P&gt;&lt;P&gt;    if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;      message id sy-msgid type sy-msgty number sy-msgno&lt;/P&gt;&lt;P&gt;                 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    create object ref_alv&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;        i_parent          = ref_container&lt;/P&gt;&lt;P&gt;      exceptions&lt;/P&gt;&lt;P&gt;        error_cntl_create = 1&lt;/P&gt;&lt;P&gt;        error_cntl_init   = 2&lt;/P&gt;&lt;P&gt;        error_cntl_link   = 3&lt;/P&gt;&lt;P&gt;        error_dp_create   = 4&lt;/P&gt;&lt;P&gt;        others            = 5.&lt;/P&gt;&lt;P&gt;    if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;      message id sy-msgid type sy-msgty number sy-msgno&lt;/P&gt;&lt;P&gt;                 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    perform fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    perform flayout.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    perform sort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    g_variant = sy-repid.&lt;/P&gt;&lt;P&gt;    g_save = 'A'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method ref_alv-&amp;gt;set_table_for_first_display&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;        is_layout                     = w_layout&lt;/P&gt;&lt;P&gt;        is_variant                    = g_variant&lt;/P&gt;&lt;P&gt;        i_save                        = g_save&lt;/P&gt;&lt;P&gt;      changing&lt;/P&gt;&lt;P&gt;        it_outtab                     = t_output&lt;/P&gt;&lt;P&gt;        it_fieldcatalog               = i_fcat&lt;/P&gt;&lt;P&gt;        it_sort                       = i_sort&lt;/P&gt;&lt;P&gt;      exceptions&lt;/P&gt;&lt;P&gt;        invalid_parameter_combination = 1&lt;/P&gt;&lt;P&gt;        program_error                 = 2&lt;/P&gt;&lt;P&gt;        too_many_lines                = 3&lt;/P&gt;&lt;P&gt;        others                        = 4.&lt;/P&gt;&lt;P&gt;    if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;      message id sy-msgid type sy-msgty number sy-msgno&lt;/P&gt;&lt;P&gt;                 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; call method cl_gui_control=&amp;gt;set_focus exporting control = ref_container.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    create object event_receiver.&lt;/P&gt;&lt;P&gt;    set handler event_receiver-&amp;gt;on_double_click for ref_alv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  else.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method ref_alv-&amp;gt;refresh_table_display.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endmodule.                 " STATUS_0100  OUTPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Module  USER_COMMAND_0100  INPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;module user_command_0100 input.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  case sy-ucomm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    when 'EXIT' or 'BACK' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      call method ref_alv-&amp;gt;free.&lt;/P&gt;&lt;P&gt;      leave program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    when 'CANC'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      call method ref_container-&amp;gt;free.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     IF NOT ref_container1 IS INITIAL.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       CALL METHOD ref_container1-&amp;gt;free.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     ENDIF.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      call method cl_gui_cfw=&amp;gt;flush.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endcase.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endmodule.                 " USER_COMMAND_0100  INPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Module  STATUS_0200  OUTPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;module status_0200 output.&lt;/P&gt;&lt;P&gt;  set pf-status 'SAMPLE-TT'.&lt;/P&gt;&lt;P&gt;  set titlebar 'TT'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  if ref_container1 is initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    create object ref_container1&lt;/P&gt;&lt;P&gt;            exporting&lt;/P&gt;&lt;P&gt;              container_name              = 'CONTROL2'&lt;/P&gt;&lt;P&gt;            exceptions&lt;/P&gt;&lt;P&gt;              cntl_error                  = 1&lt;/P&gt;&lt;P&gt;              cntl_system_error           = 2&lt;/P&gt;&lt;P&gt;              create_error                = 3&lt;/P&gt;&lt;P&gt;              lifetime_error              = 4&lt;/P&gt;&lt;P&gt;              lifetime_dynpro_dynpro_link = 5&lt;/P&gt;&lt;P&gt;              others                      = 6.&lt;/P&gt;&lt;P&gt;    if sy-subrc ne 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;add your handling, for example&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      call function 'POPUP_TO_INFORM'&lt;/P&gt;&lt;P&gt;        exporting&lt;/P&gt;&lt;P&gt;          titel = sy-repid&lt;/P&gt;&lt;P&gt;          txt2  = sy-subrc&lt;/P&gt;&lt;P&gt;          txt1  = 'The control could not be created'(510).&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    create object ref_alv1&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;        i_parent          = ref_container1&lt;/P&gt;&lt;P&gt;      exceptions&lt;/P&gt;&lt;P&gt;        error_cntl_create = 1&lt;/P&gt;&lt;P&gt;        error_cntl_init   = 2&lt;/P&gt;&lt;P&gt;        error_cntl_link   = 3&lt;/P&gt;&lt;P&gt;        error_dp_create   = 4&lt;/P&gt;&lt;P&gt;        others            = 5.&lt;/P&gt;&lt;P&gt;    if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;      message id sy-msgid type sy-msgty number sy-msgno&lt;/P&gt;&lt;P&gt;                 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    perform fcat1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    perform flayout.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    g_variant = sy-repid.&lt;/P&gt;&lt;P&gt;    g_save = 'A'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method ref_alv1-&amp;gt;set_table_for_first_display&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;        is_layout                     = w_layout&lt;/P&gt;&lt;P&gt;        is_variant                    = g_variant&lt;/P&gt;&lt;P&gt;        i_save                        = g_save&lt;/P&gt;&lt;P&gt;      changing&lt;/P&gt;&lt;P&gt;        it_outtab                     = t_output1&lt;/P&gt;&lt;P&gt;        it_fieldcatalog               = i_fcat1&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     it_sort                       = i_sort1&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      exceptions&lt;/P&gt;&lt;P&gt;        invalid_parameter_combination = 1&lt;/P&gt;&lt;P&gt;        program_error                 = 2&lt;/P&gt;&lt;P&gt;        too_many_lines                = 3&lt;/P&gt;&lt;P&gt;        others                        = 4.&lt;/P&gt;&lt;P&gt;    if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;      message id sy-msgid type sy-msgty number sy-msgno&lt;/P&gt;&lt;P&gt;                 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  else.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method ref_alv1-&amp;gt;refresh_table_display.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endmodule.                 " STATUS_0200  OUTPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Module  USER_COMMAND_0200  INPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;module user_command_0200 input.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  case sy-ucomm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    when 'EXIT' or 'BACK' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     CALL METHOD ref_alv1-&amp;gt;free.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    when 'CANC'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*call method ref_container-&amp;gt;free.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     IF NOT ref_container1 IS INITIAL.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       CALL METHOD ref_container1-&amp;gt;free.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     ENDIF.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     CALL METHOD cl_gui_cfw=&amp;gt;flush.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endcase.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  clear t_output1[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  leave to screen 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endmodule.                 " USER_COMMAND_0200  INPUT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;CREATE 2 SCREENS 100 &amp;amp; 200 with custom controls in them&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;SAPient&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Oct 2008 10:31:26 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-10-30T10:31:26Z</dc:date>
    <item>
      <title>ALV display using oops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-display-using-oops/m-p/4776596#M1119282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to display the report in ALV using oops.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Customer wants output like reuse_alv_list_display.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please let me know if any one knows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regrds,&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 10:06:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-display-using-oops/m-p/4776596#M1119282</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T10:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: ALV display using oops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-display-using-oops/m-p/4776597#M1119283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check examples : BCALV_GRID_01 to BCALV_GRID_11 in package SLIS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Advait&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 10:08:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-display-using-oops/m-p/4776597#M1119283</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T10:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: ALV display using oops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-display-using-oops/m-p/4776598#M1119284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you need to use the method set_table_for_first_display.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method w_alv1-&amp;gt;set_table_for_first_display&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;        is_layout                     = s_layout&lt;/P&gt;&lt;P&gt;        is_variant                    = s_disvariant&lt;/P&gt;&lt;P&gt;        i_save                        = 'U'&lt;/P&gt;&lt;P&gt;        it_toolbar_excluding          = lt_toolbar_excluding[]&lt;/P&gt;&lt;P&gt;      changing&lt;/P&gt;&lt;P&gt;        it_outtab                     = t_print_rep1&lt;/P&gt;&lt;P&gt;        it_fieldcatalog               = t_fieldcat[]&lt;/P&gt;&lt;P&gt;      exceptions&lt;/P&gt;&lt;P&gt;        invalid_parameter_combination = 1&lt;/P&gt;&lt;P&gt;        program_error                 = 2&lt;/P&gt;&lt;P&gt;        too_many_lines                = 3&lt;/P&gt;&lt;P&gt;        others                        = 4.&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Ramya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 10:10:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-display-using-oops/m-p/4776598#M1119284</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T10:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: ALV display using oops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-display-using-oops/m-p/4776599#M1119285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vijay,&lt;/P&gt;&lt;P&gt;Check out the ALV Sample program in oops.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZCC_OOPS_ALV_EDITABLE
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*

REPORT  ZCC_OOPS_ALV_EDITABLE.


tables sflight.
data: begin of gt_outtab occurs 0.     "with header line
        include structure sflight.
data: celltab type lvc_t_styl.
data: end of gt_outtab.
data: gt_fieldcat type lvc_t_fcat.
data: g_carrid like sflight-carrid,
      g_connid like sflight-connid.
data: gs_spfli type spfli.                                  "#EC NEEDED

data: g_custom_container type ref to cl_gui_custom_container.
data:  g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1'.
data: g_grid  type ref to cl_gui_alv_grid.
data: wa_outtab like gt_outtab.

*---------------------------------------------------------------------*
*       CLASS lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
class lcl_event_receiver definition.

*.............

  public section.

    types: begin of sflight_key.
    types:   carrid type s_carr_id.
    types:   connid type s_conn_id.
    types:   fldate type s_date.
    types: end of sflight_key.

    types: sflight_keys type standard table of sflight_key,
           sflight_table type standard table of sflight.

    methods:
      handle_data_changed
         for event data_changed of cl_gui_alv_grid
             importing er_data_changed.

    methods:
      get_inserted_rows
           exporting
              inserted_rows type sflight_keys.

    methods:
      get_deleted_rows
          exporting
              deleted_rows type sflight_table.

    methods:
       refresh_delta_tables.

    methods: set_table_is_initial.

    methods: set_table_is_not_initial.

    methods: table_is_initial
                returning value(initial) type char01.

*..............

  private section.

* §4.Define internal tables to remember inserted and deleted lines,
*    thus the delta between input made after the last saving.

    data: inserted_rows type sflight_keys,
          deleted_rows type standard table of sflight.


* This flag is set if any error occured in one of the
* following methods:
    data: error_in_data type c.

* This flag signals that no records were read for the flight
* table initially:
    data: initial_table type c.
** Methods to modularize event handler method HANDLE_DATA_CHANGED:
*
    methods:
      check_double_entries
         importing
            pr_data_changed type ref to cl_alv_changed_data_protocol.

    methods:
      update_delta_tables
         importing
            pr_data_changed type ref to cl_alv_changed_data_protocol.

    methods:
      perform_semantic_checks
         importing
            pr_data_changed type ref to cl_alv_changed_data_protocol.

    methods:
      get_cell_values
           importing
             row_id          type int4
             pr_data_changed type ref to cl_alv_changed_data_protocol
           exporting
             key             type sflight_key.



endclass.                    "lcl_event_receiver DEFINITION
**---------------------------------------------------------
class lcl_event_receiver implementation.
  method handle_data_changed.
*
*    data: ls_good type lvc_s_modi,
*          l_price type s_price,
*          ls_new type lvc_s_moce.
*
*    error_in_data = space.
*
** check if there exist double entries
*    call method check_double_entries( er_data_changed ).
*
** remember new or deleted lines for saving
*    call method update_delta_tables( er_data_changed ).
*
** check mt_good_cells semantically
*    call method perform_semantic_checks( er_data_changed ).
*
*    if error_in_data = 'X'.
*      call method er_data_changed-&amp;gt;display_protocol.
*    endif.

  endmethod.                    "handle_data_changed

*-----------------------------------------------------------------------
  method check_double_entries.
    data: lt_good_cells type lvc_t_modi,
          ls_good type lvc_s_modi,
          ls_key type sflight_key,
          ls_sflight type sflight,
          l_flightdate like gt_outtab-fldate,
          l_del_row type lvc_s_moce,
          ls_outtab like line of gt_outtab,
          l_reentered type c.



* §5.Check if there exist already other records with equal key fields.

*.............................................
* Check if the user has entered two new lines where the key fields
* are equal.
*.............................................
* Since CARRID and CONNID are read only, the check is restrained
* to field FLDATE.
*
* Algorithm: Copy all entries in MT_GOOD_CELLS to a dummy table.
*            During the copying procedure check if there exists
*            already a line with the same Flight date.
*
*    loop at pr_data_changed-&amp;gt;mt_good_cells into ls_good.
*      case ls_good-fieldname.
*        when 'FLDATE'.
*
*          call method pr_data_changed-&amp;gt;get_cell_value
*                      exporting
*                            i_row_id = ls_good-row_id
*                            i_fieldname = ls_good-fieldname
*                      importing e_value = l_flightdate.
*
*          read table lt_good_cells with key
*                            value = l_flightdate
*                            transporting no fields.
*          if sy-subrc = 0.
** There exists already a line with the same flight date!
*            call method pr_data_changed-&amp;gt;add_protocol_entry
*                         exporting
*              i_msgid = '0K' i_msgno = '000'  i_msgty = 'E'
*              i_msgv1 = text-m01
*              i_fieldname = ls_good-fieldname
*              i_row_id = ls_good-row_id.
*
*            error_in_data = 'X'.
*          else.
*            ls_good-value = l_flightdate.
*            append ls_good to lt_good_cells.
*          endif.
*      endcase.
*
*    endloop.
*
**.........................
** Check if any new entries already exist in gt_outtab.
** At this point, lt_good_cells contains only lines with
** FIELDNAME = 'FLDATE'.
**........................
*    loop at lt_good_cells into ls_good.
*      l_flightdate = ls_good-value.      "flightdate, see above
*      read table gt_outtab with key
*                    carrid = g_carrid
*                    connid = g_connid
*                    fldate = l_flightdate
*                    transporting no fields.
*
*      if sy-subrc = 0.
** Check if this entry was deleted before, i.e. it is in the table
** of deleted rows. If so, the entry does not exist twice. The user
** has deleted a line and then reentered it.
*        l_reentered = space.
*
*        loop at pr_data_changed-&amp;gt;mt_deleted_rows into l_del_row.
*          read table gt_outtab into ls_outtab index l_del_row-row_id.
*          if sy-subrc ne 0.
*            message i000(0k) with text-e01."Fehler beim Löschen
*          elseif
*                    ls_outtab-carrid eq g_carrid
*                and ls_outtab-connid eq g_connid
*                and ls_outtab-fldate eq ls_good-value.
*            l_reentered = 'X'.
*          endif.
*        endloop.
*
*        if l_reentered ne 'X'.
*          call method pr_data_changed-&amp;gt;add_protocol_entry
*                         exporting
*              i_msgid = '0K' i_msgno = '000'  i_msgty = 'E'
*              i_msgv1 = text-m01
*              i_fieldname = ls_good-fieldname
*              i_row_id = ls_good-row_id.
*
*          error_in_data = 'X'.
*        endif.
*      endif.
*    endloop.
*
** In this demo report you may prevent the selection
** of data by setting parameter 'p_ds'.
** If this is done, the next check is required:
*    if me-&amp;gt;table_is_initial( ) eq 'X'.
*      call method get_cell_values
*           exporting row_id          = 1
*                     pr_data_changed = pr_data_changed
*           importing key             = ls_key.
*
*      select single * from sflight into ls_sflight
*                where carrid = ls_key-carrid
*                  and connid = ls_key-connid
*                  and fldate = ls_key-fldate.
*
*      if sy-subrc = 0.
*        call method pr_data_changed-&amp;gt;add_protocol_entry
*                       exporting
*            i_msgid = '0K' i_msgno = '000'  i_msgty = 'E'
*            i_msgv1 = text-m01
*            i_fieldname = 'FLDATE'
*            i_row_id = 1.
*
*        error_in_data = 'X'.
*      endif.
** flag initial_table is reset in method 'update_delta_tables'
*    endif.

  endmethod.                    "check_double_entries
*-------------------------------------------------------
  method update_delta_tables.
*    data: l_ins_row type lvc_s_moce,
*          l_del_row type lvc_s_moce,
*          ls_key type sflight_key,
*          ls_sflight type sflight,
*          ls_outtab like line of gt_outtab.
*
** §6.Use protocol attributes MT_DELETED_ROWS and MT_INSERTED_ROWS
**    to remember which lines where deleted or inserted. Save this
**    information in your internal tables.
*
**..........
** deleted rows
**.............
*    loop at pr_data_changed-&amp;gt;mt_deleted_rows into l_del_row.
*      read table gt_outtab into ls_outtab index l_del_row-row_id.
*      if sy-subrc ne 0.
*        message i000(0k) with text-e01."Fehler beim Löschen
*      else.
*        move-corresponding ls_outtab to ls_sflight.
** It should no be possible that the same line is deleted twice,
** so we just add the new key line to 'deleted_rows'.
*        append ls_sflight to deleted_rows.
** If this line was inserted just before it is deleted:
*        delete me-&amp;gt;inserted_rows
*             where carrid = ls_outtab-carrid
*             and   connid = ls_outtab-connid
*             and   fldate = ls_outtab-fldate.
*      endif.
*    endloop.
*
**..........
** inserted rows
** At this point ALV has not added new lines
** to gt_outtab, so you can not access their values
** by reading gt_outtab.
** Table MT_GOOD_CELLS holds new values that can be
** referenced using the ROW_ID.
**..........
*    if me-&amp;gt;table_is_initial( ) eq 'X'.
** No flights were selected initially. This is the first new line.
*      call method get_cell_values
*            exporting row_id          = 1
*                      pr_data_changed = pr_data_changed
*            importing key             = ls_key.
*
*      append ls_key to inserted_rows.
*      call method me-&amp;gt;set_table_is_not_initial.
*    endif.
*
*    loop at pr_data_changed-&amp;gt;mt_inserted_rows into l_ins_row.
*      call method get_cell_values
*              exporting row_id          = l_ins_row-row_id
*                        pr_data_changed = pr_data_changed
*              importing key             = ls_key.
**      READ TABLE gt_outtab INTO ls_outtab INDEX l_ins_row-row_id.
*
** Just insert the new row regardless if the input is wrong
*      append ls_key to inserted_rows.
*    endloop.
*
  endmethod.                    "update_delta_tables
*---------------------------------------------------------
  method get_cell_values.
* get values of key cells of row ROW_ID

** CARRIER
*    call method pr_data_changed-&amp;gt;get_cell_value
*          exporting
*                 i_row_id    = row_id
*                 i_fieldname = 'CARRID'
*               importing
*                 e_value = key-carrid.
*
*    if sy-subrc ne 0.
*      message i000(0k) with text-e02.  "Fehler beim Einfügen
*    endif.
** CONNID
*    call method pr_data_changed-&amp;gt;get_cell_value
*          exporting
*                 i_row_id    = row_id
*                 i_fieldname = 'CONNID'
*               importing
*                 e_value = key-connid.
*
*    if sy-subrc ne 0.
*      message i000(0k) with text-e02.  "Fehler beim Einfügen
*    endif.
*
** FLDATE
*    call method pr_data_changed-&amp;gt;get_cell_value
*          exporting
*                 i_row_id    = row_id
*                 i_fieldname = 'FLDATE'
*               importing
*                 e_value = key-fldate.
*
*    if sy-subrc ne 0.
*      message i000(0k) with text-e02.  "Fehler beim Einfügen
*    endif.



  endmethod.                    "get_cell_values

*---------------------------------------------------------
  method perform_semantic_checks.
*    data: ls_good type lvc_s_modi,
*          l_planetype type s_planetye,
*          l_seatsmax type s_seatsmax.
*
*    loop at pr_data_changed-&amp;gt;mt_good_cells into ls_good.
*      case ls_good-fieldname.
*        when 'PLANETYPE'.
*          call method pr_data_changed-&amp;gt;get_cell_value
*             exporting
*               i_row_id = ls_good-row_id
*               i_fieldname = ls_good-fieldname
*             importing
*               e_value = l_planetype.
*
*          select single seatsmax from saplane into l_seatsmax
*                        where planetype = l_planetype.
*
*          if sy-subrc ne 0.
*            call method pr_data_changed-&amp;gt;add_protocol_entry
*                            exporting
*                 i_msgid = '0K' i_msgno = '000'  i_msgty = 'E'
*                 i_msgv1 = text-m02
*                 i_fieldname = ls_good-fieldname
*                 i_row_id = ls_good-row_id.
*
*            error_in_data = 'X'.
*          else.
*
*
*            call method pr_data_changed-&amp;gt;modify_cell
*              exporting i_row_id    = ls_good-row_id
*                        i_fieldname = 'SEATSMAX'
*                        i_value     = l_seatsmax.
*          endif.
*      endcase.
*    endloop.
  endmethod.                    "perform_semantic_checks

*------------------------------------------------------

  method get_inserted_rows.
*    inserted_rows = me-&amp;gt;inserted_rows.
  endmethod.                    "get_inserted_rows
*------------------------------------------------------

  method get_deleted_rows.
*    deleted_rows = me-&amp;gt;deleted_rows.
  endmethod.                    "get_deleted_rows
*------------------------------------------------------
  method refresh_delta_tables.
*    clear me-&amp;gt;inserted_rows[].
*    clear me-&amp;gt;deleted_rows[].
  endmethod.                    "refresh_delta_tables
*------------------------------------------------------
  method set_table_is_initial.
*    initial_table = 'X'.
  endmethod.                    "set_table_is_initial
*------------------------------------------------------
  method set_table_is_not_initial.
*    initial_table = space.
  endmethod.                    "set_table_is_not_initial
*------------------------------------------------------
  method table_is_initial.
*    if initial_table = 'X'.
*      initial = 'X'.
*    else.
*      initial = space.
*    endif.
  endmethod.                    "table_is_initial


endclass.                    "lcl_event_receiver IMPLEMENTATION


data: g_verifier type ref to lcl_event_receiver.
data: g_max type i value 100.

data: gs_layout type lvc_s_layo.
data: ok_code like sy-ucomm,
      save_ok like sy-ucomm.

parameters: p_ds type c as checkbox.   "delete selection

select-options s_carrid for sflight-carrid
                            no intervals no-extension default 'LH'.
select-options s_connid for sflight-connid
                           no intervals no-extension default '0400'.

start-of-selection.

  g_carrid = s_carrid-low.
  g_connid = s_connid-low.

* first check airline and connection
  select single * from spfli into gs_spfli
                     where carrid = g_carrid
                     and connid = g_connid.

  call screen 100.
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  STATUS_0100  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0100 output.
  set pf-status 'MAIN100'.
  set titlebar 'MAIN100'.
  if g_custom_container is initial.
    perform create_and_init_alv changing gt_outtab[]
                                         gt_fieldcat.
  endif.
endmodule.                 " STATUS_0100  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  create_and_init_alv
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      &amp;lt;--P_GT_OUTTAB[]  text
*      &amp;lt;--P_GT_FIELDCAT  text
*----------------------------------------------------------------------*
form create_and_init_alv changing pt_outtab like gt_outtab[]
                                  pt_fieldcat type lvc_t_fcat.
  data: lt_exclude type ui_functions.

  create object g_custom_container
         exporting container_name = g_container.
  create object g_grid
         exporting i_parent = g_custom_container.
* Create Objekt to verify input values.
* (This object is already needed in form SELECT_DATA).
  create object g_verifier.
*  SET HANDLER g_verifier-&amp;gt;handle_data_changed FOR g_grid.
  perform select_data changing pt_outtab[].
  perform build_fieldcat changing pt_fieldcat.
  perform exclude_tb_functions changing lt_exclude.
  gs_layout-stylefname = 'CELLTAB'.

  call method g_grid-&amp;gt;set_table_for_first_display
    exporting
      it_toolbar_excluding = lt_exclude
      is_layout            = gs_layout
    changing
      it_fieldcatalog      = pt_fieldcat
      it_outtab            = pt_outtab[].

* Set editable cells to ready for input initially
  call method g_grid-&amp;gt;set_ready_for_input
    exporting
      i_ready_for_input = 1.

endform.                    " create_and_init_alv

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  select_data
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      &amp;lt;--P_GT_OUTTAB  text
*----------------------------------------------------------------------*
form select_data changing pt_outtab like gt_outtab[].
  data: lt_sflight type table of sflight,
        ls_sflight type sflight,
        ls_outtab like line of gt_outtab,
        l_index type i,
        ls_spfli type spfli,                                "#EC NEEDED
        lt_celltab type lvc_t_styl.



* Check parameter 'p_ds'=&amp;gt;optionally select no data
  if p_ds is initial.
* Select data from sflight
    select * from sflight into table lt_sflight up to g_max rows
                     where carrid = g_carrid
                       and connid = g_connid.
  endif.

  if sy-subrc ne 0 or not p_ds is initial.
* no flights were found!
* We provide some default values for the first line that is entered:
    ls_outtab-carrid = g_carrid.
    ls_outtab-connid = g_connid.
    case g_carrid.
      when 'LH'.
        ls_outtab-currency = 'DEM'.
      when others.
        ls_outtab-currency = 'US'.
    endcase.
    ls_outtab-seatsocc = 0.
    ls_outtab-paymentsum = 0.

* set fields FLDATE, PRICE and PLANETYPE to editable
    perform fill_celltab using 'RW'
                         changing lt_celltab.
    insert lines of lt_celltab into table ls_outtab-celltab.
    append ls_outtab to pt_outtab.

* Tell Verify-Objekt that the table was initial
    call method g_verifier-&amp;gt;set_table_is_initial.
  else.
    call method g_verifier-&amp;gt;set_table_is_not_initial.
* move corresponding fields from lt_sflight to gt_outtab
    loop at lt_sflight into ls_sflight.
      move-corresponding ls_sflight to ls_outtab.
      append ls_outtab to pt_outtab.
    endloop.

* §3.Set all cells of the table non-editable by using the style table.

    loop at pt_outtab into ls_outtab.
      l_index = sy-tabix.
      refresh lt_celltab.
      perform fill_celltab using 'RO'
                        changing lt_celltab.
* Copy your celltab to the celltab of the current row of gt_outtab.
      insert lines of lt_celltab into table ls_outtab-celltab.
      modify pt_outtab from ls_outtab index l_index.
    endloop.
  endif.

endform.                               " select_data
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  fill_celltab
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;VALUE(P_MODE)  text
*      --&amp;gt;PT_CELLTAB     text
*----------------------------------------------------------------------*
form fill_celltab using value(p_mode)
                  changing pt_celltab type lvc_t_styl.
  data: ls_celltab type lvc_s_styl,
        l_mode type raw4.
* This forms sets the style of columns 'PRICE', FLDATE and PLANETYPE
* editable

  if p_mode eq 'RW'.
    l_mode = cl_gui_alv_grid=&amp;gt;mc_style_enabled.
  else.                                "p_mode eq 'RO'
    l_mode = cl_gui_alv_grid=&amp;gt;mc_style_disabled.
  endif.

  ls_celltab-fieldname = 'FLDATE'.
  ls_celltab-style = l_mode.
  insert ls_celltab into table pt_celltab.
  ls_celltab-fieldname = 'PRICE'.
  ls_celltab-style = l_mode.
  insert ls_celltab into table pt_celltab.
  ls_celltab-fieldname = 'PLANETYPE'.
  ls_celltab-style = l_mode.
  insert ls_celltab into table pt_celltab.

endform.                               " FILL_CELLTAB
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  BUILD_FIELDCAT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      &amp;lt;--P_GT_FIELDCAT  text
*----------------------------------------------------------------------*
form build_fieldcat changing pt_fieldcat type lvc_t_fcat.

  data ls_fcat type lvc_s_fcat.

  call function 'LVC_FIELDCATALOG_MERGE'
    exporting
      i_structure_name = 'SFLIGHT'
    changing
      ct_fieldcat      = pt_fieldcat.

  loop at pt_fieldcat into ls_fcat.
    if    ls_fcat-fieldname eq 'PRICE'
       or ls_fcat-fieldname eq 'PLANETYPE'
       or ls_fcat-fieldname eq 'FLDATE'.

* §1.Set status of columns FLDATA, PRICE and PLANETYPE to editable.
*    Since all cells are set to non-editable (see step 3) the cells
*    of this columns will only be editable for new lines.

      ls_fcat-edit = 'X'.

* Field 'checktable' is set to avoid shortdumps that are caused
* by inconsistend data in check tables. You may comment this out
* when the test data of the flight model is consistent in your system.
      ls_fcat-checktable = '!'.        "do not check foreign keys

      modify pt_fieldcat from ls_fcat.
    elseif ls_fcat-fieldname = 'CARRID'
       or ls_fcat-fieldname = 'CONNID'
       or ls_fcat-fieldname = 'CURRENCY'.

* §2.Use field AUTO_VALUE of the fieldcatalog to preset values when new
*    lines are added.

      ls_fcat-auto_value = 'X'.
      ls_fcat-checktable = '!'.   "do not check foreign key relations

      modify pt_fieldcat from ls_fcat.
    endif.

  endloop.

endform.                    "build_fieldcat
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  exclude_tb_functions
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      &amp;lt;--P_LT_EXCLUDE  text
*----------------------------------------------------------------------*
*---------------------------------------------
form exclude_tb_functions changing pt_exclude type ui_functions.
*
  data ls_exclude type ui_func.

  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_loc_insert_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_loc_undo.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_loc_copy_row.
  append ls_exclude to pt_exclude.

endform.                               " EXCLUDE_TB_FUNCTIONS
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  USER_COMMAND_0100  INPUT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0100 input.
  save_ok = sy-ucomm.
  clear ok_code.
  case save_ok.
    when 'SAVE'.
*      perform save_data.
    when 'BACK'.
* §10.Unlock your database table.
*      perform unlock_sflight.
      leave to screen 0.
    when 'EXIT'.
      perform exit_program.
    when 'ADD'.
      perform add_line_item.
    when others.
*     do nothing
  endcase.
endmodule.                 " USER_COMMAND_0100  INPUT
*---------------------------------------------------------------------*
*       FORM EXIT_PROGRAM                                             *
*---------------------------------------------------------------------*
form exit_program.
  leave program.
endform.                    "exit_program
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  ADD_LINE_ITEM
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
form add_line_item .
data: lt_rows type lvc_t_row.
data: wa_rows type lvc_t_row with header line.
data: tabix type sy-tabix.
*&amp;amp;Find the  row ( index ) number
 call method g_grid-&amp;gt;get_selected_rows
          importing et_index_rows = lt_rows.
 call method cl_gui_cfw=&amp;gt;flush.
 read table lt_rows into wa_rows index 1.

 tabix = wa_rows-index .

insert gt_outtab  index tabix.
*REFRESH_TABLE_DISPLAY

call method g_grid-&amp;gt;refresh_table_display
*  EXPORTING
*    IS_STABLE      =
*    I_SOFT_REFRESH =
*  EXCEPTIONS
*    FINISHED       = 1
*    others         = 2
        .
if sy-subrc &amp;lt;&amp;gt; 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

endform.                    " ADD_LINE_ITEM
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chidanand&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 10:12:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-display-using-oops/m-p/4776599#M1119285</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T10:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: ALV display using oops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-display-using-oops/m-p/4776600#M1119286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vijay,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can find a sample code for ALV using OOPS at this link.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[http://saptechnical.com/Tutorials/ALV/Interactive/oops.htm] &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amit.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 10:15:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-display-using-oops/m-p/4776600#M1119286</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T10:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: ALV display using oops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-display-using-oops/m-p/4776601#M1119287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;U can use SALV....this is the best for reporting.....&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: gr_table      TYPE REF TO cl_salv_table,
      gr_functions  TYPE REF TO cl_salv_functions,
      gr_layout     TYPE REF TO cl_salv_layout,
      gr_column     TYPE REF TO cl_salv_column_table,
      gr_columns    TYPE REF TO cl_salv_columns_table,
      gr_display    TYPE REF TO cl_salv_display_settings,
      gr_selections TYPE REF TO cl_salv_selections,
      gr_agg        TYPE REF TO cl_salv_aggregations,
      key           TYPE salv_s_layout_key VALUE sy-repid.

"Required------------------------------------------------
*&amp;amp;--Display the ALV
    cl_salv_table=&amp;gt;factory( IMPORTING r_salv_table = gr_table CHANGING t_table = it_mseg_mat ).

"Optional------------------------------------------------
*---Setting the ALV toolbar
    gr_functions = gr_table-&amp;gt;get_functions( ).
    gr_functions-&amp;gt;set_all( abap_true ).
*---Setting the Layout Save property
    gr_layout = gr_table-&amp;gt;get_layout( ).
    gr_layout-&amp;gt;set_key( key ).
    gr_layout-&amp;gt;set_save_restriction( cl_salv_layout=&amp;gt;restrict_none ).
*---Setting the list header
    gr_display = gr_table-&amp;gt;get_display_settings( ).
    gr_display-&amp;gt;set_list_header( header ).

"Optional------------------------------------------------
*---Setting the Columns/Layout
    gr_columns = gr_table-&amp;gt;get_columns( ).
    gr_columns-&amp;gt;set_key_fixation( abap_true ).
    gr_columns-&amp;gt;set_color_column( 'COLOR' ).
*---Setting the key columns
    gr_column ?= gr_columns-&amp;gt;get_column( 'MBLNR' ).
    gr_column-&amp;gt;set_key( if_salv_c_bool_sap=&amp;gt;true ).
*---Setting the Selection mode
    gr_selections = gr_table-&amp;gt;get_selections( ).
    gr_selections-&amp;gt;set_selection_mode( 1 ).
*---Setting the Aggregate/Sum columns
    gr_agg = gr_table-&amp;gt;get_aggregations( ).
    gr_agg-&amp;gt;add_aggregation( 'MENGE' ).
    gr_agg-&amp;gt;add_aggregation( 'DMBTR' ).

"Required------------------------------------------------
*---Displaying the ALV
    gr_table-&amp;gt;display( ).

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Search SCN for SALV....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Sukriti...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 10:15:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-display-using-oops/m-p/4776601#M1119287</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T10:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: ALV display using oops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-display-using-oops/m-p/4776602#M1119288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use this sample code....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp; REPORT ysample&lt;/P&gt;&lt;P&gt;*&amp;amp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;report ysample.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*CLASS cl_gui_alv_grid DEFINITION LOAD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types : begin of ty_output,&lt;/P&gt;&lt;P&gt;         locid type /sapapo/locid,&lt;/P&gt;&lt;P&gt;         locno type /sapapo/locno,&lt;/P&gt;&lt;P&gt;         tzone type tznzone,&lt;/P&gt;&lt;P&gt;         adrnummer type ad_addrnum,&lt;/P&gt;&lt;P&gt;        end of ty_output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : t_output type table of ty_output,&lt;/P&gt;&lt;P&gt;       l_output like line of t_output,&lt;/P&gt;&lt;P&gt;       t_output1 type table of ty_output,&lt;/P&gt;&lt;P&gt;       l_output1 like line of t_output1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : ref_container type ref to cl_gui_custom_container,&lt;/P&gt;&lt;P&gt;       ref_alv       type ref to cl_gui_alv_grid,&lt;/P&gt;&lt;P&gt;       ref_container1 type ref to cl_gui_custom_container,&lt;/P&gt;&lt;P&gt;       ref_alv1       type ref to cl_gui_alv_grid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : w_fcat   type lvc_s_fcat,&lt;/P&gt;&lt;P&gt;       w_layout type lvc_s_layo,&lt;/P&gt;&lt;P&gt;       i_fcat   type lvc_t_fcat,&lt;/P&gt;&lt;P&gt;       i_fcat1   type lvc_t_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : g_variant  type disvariant,&lt;/P&gt;&lt;P&gt;       g_save     type flag,&lt;/P&gt;&lt;P&gt;       i_sort     type lvc_t_sort ,&lt;/P&gt;&lt;P&gt;       w_sort     type lvc_s_sort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      CLASS lcl_toolbar_event_receiver DEFINITION&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;class lcl_toolbar_event_receiver definition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  public section.&lt;/P&gt;&lt;P&gt;    methods: on_double_click&lt;/P&gt;&lt;P&gt;               for event double_click of cl_gui_alv_grid&lt;/P&gt;&lt;P&gt;                 importing e_row&lt;/P&gt;&lt;P&gt;                           e_column&lt;/P&gt;&lt;P&gt;                           es_row_no.&lt;/P&gt;&lt;P&gt;endclass.                    "lcl_toolbar_event_receiver DEFINITION&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      CLASS lcl_toolbar_event_receiver IMPLEMENTATION&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;class lcl_toolbar_event_receiver implementation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  method on_double_click.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    read table t_output into l_output index e_row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      l_output1-locid = l_output-locid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      append l_output1 to t_output1.&lt;/P&gt;&lt;P&gt;      clear l_output1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call screen 200 starting at 10 5 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endmethod.                    "on_double_click&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endclass.                    "lcl_toolbar_event_receiver IMPLEMENTATION&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data :        event_receiver type ref to lcl_toolbar_event_receiver.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  select locid locno tzone adrnummer&lt;/P&gt;&lt;P&gt;  from /sapapo/loc&lt;/P&gt;&lt;P&gt;  into table t_output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  call screen 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  fcat&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; --&amp;gt;  p1        text&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;--  p2        text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form fcat .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; CLEAR w_fcat .&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; w_fcat-col_pos = 1.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; w_fcat-fieldname = 'LOCID'.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; w_fcat-coltext   = 'LOCATIONID'.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; w_fcat-ref_table = 'T_OUTPUT'.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; APPEND w_fcat TO i_fcat.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  clear w_fcat .&lt;/P&gt;&lt;P&gt;  w_fcat-col_pos = 2.&lt;/P&gt;&lt;P&gt;  w_fcat-fieldname = 'LOCNO'.&lt;/P&gt;&lt;P&gt;  w_fcat-coltext   = 'LOCATION'.&lt;/P&gt;&lt;P&gt;  w_fcat-ref_table = 'T_OUTPUT'.&lt;/P&gt;&lt;P&gt;  append w_fcat to i_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  clear w_fcat .&lt;/P&gt;&lt;P&gt;  w_fcat-col_pos = 3.&lt;/P&gt;&lt;P&gt;  w_fcat-fieldname = 'TZONE'.&lt;/P&gt;&lt;P&gt;  w_fcat-coltext   = 'TIME-ZONE'.&lt;/P&gt;&lt;P&gt;  w_fcat-ref_table = 'T_OUTPUT'.&lt;/P&gt;&lt;P&gt;  append w_fcat to i_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  clear w_fcat .&lt;/P&gt;&lt;P&gt;  w_fcat-col_pos = 4.&lt;/P&gt;&lt;P&gt;  w_fcat-fieldname = 'ADRNUMMER'.&lt;/P&gt;&lt;P&gt;  w_fcat-coltext   = 'ADDR-NO'.&lt;/P&gt;&lt;P&gt;  w_fcat-ref_table = 'T_OUTPUT'.&lt;/P&gt;&lt;P&gt;  append w_fcat to i_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.                    " fcat&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  flayout&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; --&amp;gt;  p1        text&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;--  p2        text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form flayout .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  w_layout-zebra = 'X'.&lt;/P&gt;&lt;P&gt;  w_layout-cwidth_opt = 'X'.&lt;/P&gt;&lt;P&gt;  w_layout-grid_title = 'Sample Program using ABAP Objects'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.                    " flayout&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  sort&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; --&amp;gt;  p1        text&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;--  p2        text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form sort .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  w_sort-fieldname = 'LOCNO'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; w_sort-subtot = 'X'.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  append w_sort to i_sort.&lt;/P&gt;&lt;P&gt;  clear w_sort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.                    " sort&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  fcat1&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; --&amp;gt;  p1        text&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;--  p2        text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form fcat1 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  clear w_fcat .&lt;/P&gt;&lt;P&gt;  w_fcat-col_pos = 1.&lt;/P&gt;&lt;P&gt;  w_fcat-fieldname = 'LOCID'.&lt;/P&gt;&lt;P&gt;  w_fcat-coltext   = 'LOCATIONID'.&lt;/P&gt;&lt;P&gt;  w_fcat-ref_table = 'T_OUTPUT'.&lt;/P&gt;&lt;P&gt;  append w_fcat to i_fcat1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.                                                    "fcat1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Module  STATUS_0100  OUTPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;module status_0100 output.&lt;/P&gt;&lt;P&gt;  set pf-status 'SAMPLE-TT'.&lt;/P&gt;&lt;P&gt;  set titlebar 'TT'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  if ref_container is initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    create object ref_container&lt;/P&gt;&lt;P&gt;          exporting&lt;/P&gt;&lt;P&gt;            container_name              = 'CONTROL1'&lt;/P&gt;&lt;P&gt;          exceptions&lt;/P&gt;&lt;P&gt;            cntl_error                  = 1&lt;/P&gt;&lt;P&gt;            cntl_system_error           = 2&lt;/P&gt;&lt;P&gt;            create_error                = 3&lt;/P&gt;&lt;P&gt;            lifetime_error              = 4&lt;/P&gt;&lt;P&gt;            lifetime_dynpro_dynpro_link = 5&lt;/P&gt;&lt;P&gt;            others                      = 6.&lt;/P&gt;&lt;P&gt;    if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;      message id sy-msgid type sy-msgty number sy-msgno&lt;/P&gt;&lt;P&gt;                 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    create object ref_alv&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;        i_parent          = ref_container&lt;/P&gt;&lt;P&gt;      exceptions&lt;/P&gt;&lt;P&gt;        error_cntl_create = 1&lt;/P&gt;&lt;P&gt;        error_cntl_init   = 2&lt;/P&gt;&lt;P&gt;        error_cntl_link   = 3&lt;/P&gt;&lt;P&gt;        error_dp_create   = 4&lt;/P&gt;&lt;P&gt;        others            = 5.&lt;/P&gt;&lt;P&gt;    if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;      message id sy-msgid type sy-msgty number sy-msgno&lt;/P&gt;&lt;P&gt;                 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    perform fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    perform flayout.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    perform sort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    g_variant = sy-repid.&lt;/P&gt;&lt;P&gt;    g_save = 'A'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method ref_alv-&amp;gt;set_table_for_first_display&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;        is_layout                     = w_layout&lt;/P&gt;&lt;P&gt;        is_variant                    = g_variant&lt;/P&gt;&lt;P&gt;        i_save                        = g_save&lt;/P&gt;&lt;P&gt;      changing&lt;/P&gt;&lt;P&gt;        it_outtab                     = t_output&lt;/P&gt;&lt;P&gt;        it_fieldcatalog               = i_fcat&lt;/P&gt;&lt;P&gt;        it_sort                       = i_sort&lt;/P&gt;&lt;P&gt;      exceptions&lt;/P&gt;&lt;P&gt;        invalid_parameter_combination = 1&lt;/P&gt;&lt;P&gt;        program_error                 = 2&lt;/P&gt;&lt;P&gt;        too_many_lines                = 3&lt;/P&gt;&lt;P&gt;        others                        = 4.&lt;/P&gt;&lt;P&gt;    if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;      message id sy-msgid type sy-msgty number sy-msgno&lt;/P&gt;&lt;P&gt;                 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; call method cl_gui_control=&amp;gt;set_focus exporting control = ref_container.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    create object event_receiver.&lt;/P&gt;&lt;P&gt;    set handler event_receiver-&amp;gt;on_double_click for ref_alv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  else.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method ref_alv-&amp;gt;refresh_table_display.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endmodule.                 " STATUS_0100  OUTPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Module  USER_COMMAND_0100  INPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;module user_command_0100 input.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  case sy-ucomm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    when 'EXIT' or 'BACK' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      call method ref_alv-&amp;gt;free.&lt;/P&gt;&lt;P&gt;      leave program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    when 'CANC'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      call method ref_container-&amp;gt;free.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     IF NOT ref_container1 IS INITIAL.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       CALL METHOD ref_container1-&amp;gt;free.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     ENDIF.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      call method cl_gui_cfw=&amp;gt;flush.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endcase.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endmodule.                 " USER_COMMAND_0100  INPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Module  STATUS_0200  OUTPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;module status_0200 output.&lt;/P&gt;&lt;P&gt;  set pf-status 'SAMPLE-TT'.&lt;/P&gt;&lt;P&gt;  set titlebar 'TT'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  if ref_container1 is initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    create object ref_container1&lt;/P&gt;&lt;P&gt;            exporting&lt;/P&gt;&lt;P&gt;              container_name              = 'CONTROL2'&lt;/P&gt;&lt;P&gt;            exceptions&lt;/P&gt;&lt;P&gt;              cntl_error                  = 1&lt;/P&gt;&lt;P&gt;              cntl_system_error           = 2&lt;/P&gt;&lt;P&gt;              create_error                = 3&lt;/P&gt;&lt;P&gt;              lifetime_error              = 4&lt;/P&gt;&lt;P&gt;              lifetime_dynpro_dynpro_link = 5&lt;/P&gt;&lt;P&gt;              others                      = 6.&lt;/P&gt;&lt;P&gt;    if sy-subrc ne 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;add your handling, for example&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      call function 'POPUP_TO_INFORM'&lt;/P&gt;&lt;P&gt;        exporting&lt;/P&gt;&lt;P&gt;          titel = sy-repid&lt;/P&gt;&lt;P&gt;          txt2  = sy-subrc&lt;/P&gt;&lt;P&gt;          txt1  = 'The control could not be created'(510).&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    create object ref_alv1&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;        i_parent          = ref_container1&lt;/P&gt;&lt;P&gt;      exceptions&lt;/P&gt;&lt;P&gt;        error_cntl_create = 1&lt;/P&gt;&lt;P&gt;        error_cntl_init   = 2&lt;/P&gt;&lt;P&gt;        error_cntl_link   = 3&lt;/P&gt;&lt;P&gt;        error_dp_create   = 4&lt;/P&gt;&lt;P&gt;        others            = 5.&lt;/P&gt;&lt;P&gt;    if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;      message id sy-msgid type sy-msgty number sy-msgno&lt;/P&gt;&lt;P&gt;                 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    perform fcat1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    perform flayout.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    g_variant = sy-repid.&lt;/P&gt;&lt;P&gt;    g_save = 'A'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method ref_alv1-&amp;gt;set_table_for_first_display&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;        is_layout                     = w_layout&lt;/P&gt;&lt;P&gt;        is_variant                    = g_variant&lt;/P&gt;&lt;P&gt;        i_save                        = g_save&lt;/P&gt;&lt;P&gt;      changing&lt;/P&gt;&lt;P&gt;        it_outtab                     = t_output1&lt;/P&gt;&lt;P&gt;        it_fieldcatalog               = i_fcat1&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     it_sort                       = i_sort1&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      exceptions&lt;/P&gt;&lt;P&gt;        invalid_parameter_combination = 1&lt;/P&gt;&lt;P&gt;        program_error                 = 2&lt;/P&gt;&lt;P&gt;        too_many_lines                = 3&lt;/P&gt;&lt;P&gt;        others                        = 4.&lt;/P&gt;&lt;P&gt;    if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;      message id sy-msgid type sy-msgty number sy-msgno&lt;/P&gt;&lt;P&gt;                 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  else.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method ref_alv1-&amp;gt;refresh_table_display.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endmodule.                 " STATUS_0200  OUTPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Module  USER_COMMAND_0200  INPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;module user_command_0200 input.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  case sy-ucomm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    when 'EXIT' or 'BACK' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     CALL METHOD ref_alv1-&amp;gt;free.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    when 'CANC'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*call method ref_container-&amp;gt;free.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     IF NOT ref_container1 IS INITIAL.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       CALL METHOD ref_container1-&amp;gt;free.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     ENDIF.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     CALL METHOD cl_gui_cfw=&amp;gt;flush.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endcase.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  clear t_output1[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  leave to screen 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endmodule.                 " USER_COMMAND_0200  INPUT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;CREATE 2 SCREENS 100 &amp;amp; 200 with custom controls in them&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;SAPient&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 10:31:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-display-using-oops/m-p/4776602#M1119288</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T10:31:26Z</dc:date>
    </item>
  </channel>
</rss>

