<?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: Initialization in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313541#M1225097</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your replies&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Mar 2009 09:04:05 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-03-04T09:04:05Z</dc:date>
    <item>
      <title>Initialization</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313534#M1225090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;   In report event INITIALIZATION we use. In the initialization if we call function.&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET' to get user default ALV variant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please give an example of this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                             thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                               siva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 04:53:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313534#M1225090</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T04:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Initialization</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313535#M1225091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If a user has single variant it works out otherwise which one you want to select ? This works out mostly while scheduling the job.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 04:56:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313535#M1225091</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T04:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Initialization</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313536#M1225092</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;Refer the wiki by me:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It shows the use of variant in alv. It will definitely help you.&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/learn%252bto%252bdisplay%252bdata%252bin%252balv%252bgrid" target="test_blank"&gt;https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/learn%252bto%252bdisplay%252bdata%252bin%252balv%252bgrid&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Refer to the variant use with various FM's.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tarun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 04:59:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313536#M1225092</guid>
      <dc:creator>I355602</dc:creator>
      <dc:date>2009-03-04T04:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: Initialization</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313537#M1225093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;If you want to display something as default like in parameter then initialization is required.&lt;/P&gt;&lt;P&gt;have a look&lt;/P&gt;&lt;P&gt;[LInk|http://help.sap.com/saphelp_nw70/helpdata/en/9f/db9a2135c111d1829f0000e829fbfe/content.htm]&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Shashi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 05:01:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313537#M1225093</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T05:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: Initialization</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313538#M1225094</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;&lt;STRONG&gt;For creating variant you first have to declare like this:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

DATA : s_variant TYPE disvariant.

PARAMETER  : s_var TYPE disvariant-variant.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Then in initialization event you have to write:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

INITIALIZATION.

  s_variant-report = sy-repid.
*&amp;amp;---------------------------------------------------------------------*
*** TO GET THE DEFAULT VARIANT FOR LAYOUT DISPLAY************
*&amp;amp;---------------------------------------------------------------------*
  CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
    EXPORTING
      i_save        = 'A'
    CHANGING
      cs_variant    = s_variant
    EXCEPTIONS
      wrong_input   = 1
      not_found     = 2
      program_error = 3
      OTHERS        = 4.
  IF sy-subrc = 0.              " IF DEFAULT VARIANT FOUND

    s_var = s_variant-variant.  " PASS THE DEFAULT VARIANT RECEIVED TO THE SELECTION SCREEN FIELD
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Then you can do like this to have an f4 of variants created and to check their existence:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

*&amp;amp;---------------------------------------------------------------------*
************TO GET THE LIST OF POSSIBLE VARIANT ENTRIES WHEN THE USER PRESSES F4 BUTTON**********
*&amp;amp;---------------------------------------------------------------------*

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_var.

  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
    EXPORTING
      is_variant                = s_variant
*   I_TABNAME_HEADER          =
*   I_TABNAME_ITEM            =
*   IT_DEFAULT_FIELDCAT       =
     i_save                    = 'A'
*   I_DISPLAY_VIA_GRID        = ' '
   IMPORTING
*   E_EXIT                    =
     es_variant                = s_variant
   EXCEPTIONS
     not_found                 = 1
     program_error             = 2
     OTHERS                    = 3.
*********TO GET THE SELECTED VARIANT FROM THE LIST IN THE SELECTION FIELD********************            .
  IF sy-subrc = 0.
    s_var = s_variant-variant.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

*&amp;amp;---------------------------------------------------------------------*
*********TO CHECK IF THE VARIANT GIVEN EXIST IN THE VASIANT LIST OR NOT*************
*&amp;amp;---------------------------------------------------------------------*
AT SELECTION-SCREEN.
  s_variant-variant = s_var.
  CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
    EXPORTING
      i_save        = 'A'
    CHANGING
      cs_variant    = s_variant
    EXCEPTIONS
      wrong_input   = 1
      not_found     = 2
      program_error = 3
      OTHERS        = 4.
  IF sy-subrc &amp;lt;&amp;gt; 0.
*&amp;amp;---------------------------------------------------------------------*
**********IF VARIANT DOES NOT EXIST ,GIVE WARNING MESSAGE**********************
*&amp;amp;---------------------------------------------------------------------*
    MESSAGE w000(zgg_msg).
    CLEAR s_variant.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regrds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mansi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 05:06:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313538#M1225094</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T05:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: Initialization</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313539#M1225095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;wer can can call this fm in intilization event&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u can check this below code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;report  zdp_alv_varient_example.
tables:  sflight.

**-- TYPE-POOLS Definition
**Includes the types and constants of a type group. Since the types and
*constants specified in a type group have global validity, you cannot
*use the statement within a FORM or FUNCTION.
type-pools: slis.
parameters: p_vari like disvariant-variant.

**-- ALV variables
*****- Field Catalog structure
data: ls_fieldcat     type slis_fieldcat_alv,    "Field Catalog list

**--- Field Catalog table
      gt_fieldcat     type slis_t_fieldcat_alv,  "Field Catalog

**--- Layout ( How you would like to see the output )
      gs_layout       type slis_layout_alv,       "List Layout

**--  Report name
      g_repid         like sy-repid,
       g_save(1)           type c,
      g_exit(1)           type c,
      g_variant           like disvariant,
      gx_variant          like disvariant.


**-- Flight Info Internal table
data: lt_sflight like sflight occurs 0 with header line.

************************************************************************
*                 C-O-N-S-T-A-N-T-S                                    *
************************************************************************

************************************************************************
*                 S-E-L-E-C-T-I-O-N  S-C-R-E-E-N                       *
************************************************************************

selection-screen begin of block a with frame title text-100.
select-options: s_carrid  for  sflight-carrid,
                s_connid  for  sflight-connid,
                s_fldate  for  sflight-fldate default sy-datum.
selection-screen end of block a .


************************************************************************
*                 I-N-I-T-I-A-L-I-Z-A-T-I-O-N                          *
************************************************************************
initialization.

  g_repid = sy-repid.

**-- Fill ALV field catalog
  perform initialize_fieldcat using gt_fieldcat[].

***-- Build Events
*  perform build_eventtab using gt_events[].
*
**-- Read the default variant
  perform initialize_variant.

************************************************************************
*                 A-T  S-E-L-E-C-T-I-O-N  S-C-R-E-E-N                  *
************************************************************************
at selection-screen on value-request for p_vari.
**-- Display all existing variants
  call function 'REUSE_ALV_VARIANT_F4'
       exporting
            is_variant = g_variant
            i_save     = g_save
       importing
            e_exit     = g_exit
            es_variant = gx_variant
       exceptions
            not_found  = 2.
  if sy-subrc = 2.
    message id sy-msgid type 'S'      number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  else.
    if g_exit = space.
      p_vari = gx_variant-variant.
    endif.
  endif.


************************************************************************
*                 S-T-A-R-T  O-F  S-E-L-E-C-T-I-O-N                    *
************************************************************************
start-of-selection.

**-- Read Flight information.
perform read_flight_info.

**-- Fill ALV field catalog and display report.
  if not lt_sflight[] is initial.
    perform dislay_alv_report.
  endif.

*======================================================================*
*                 FORMS / SUB ROUTINES                                 *
*======================================================================

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  initialize_fieldcat
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;P_GT_FIELDCAT[]  text
*----------------------------------------------------------------------*
form initialize_fieldcat using l_fieldcat type slis_t_fieldcat_alv.

  clear ls_fieldcat.

* Air line
  ls_fieldcat-fieldname   = 'CARRID'.
  ls_fieldcat-key         = 'X'.
  ls_fieldcat-col_pos     = 1.
  ls_fieldcat-seltext_s   = 'Airline'.
  ls_fieldcat-seltext_l   = 'Airline'.
  append ls_fieldcat to l_fieldcat.
  clear ls_fieldcat.

* Flight Number
  ls_fieldcat-fieldname   = 'CONNID'.
  ls_fieldcat-key         = 'X'.
  ls_fieldcat-col_pos     = 2.
  ls_fieldcat-seltext_s   = 'Flight Number'.
  ls_fieldcat-seltext_l   = 'Flight Number'.
  append ls_fieldcat to l_fieldcat.
  clear ls_fieldcat.

* Flight date
  ls_fieldcat-fieldname   = 'FLDATE'.
  ls_fieldcat-key         = 'X'.
  ls_fieldcat-col_pos     = 3.
  ls_fieldcat-seltext_s   = 'Flight date'.
  ls_fieldcat-seltext_l   = 'Flight date'.
  append ls_fieldcat to l_fieldcat.
  clear ls_fieldcat.

* Airfare
  ls_fieldcat-fieldname   = 'PRICE'.
  ls_fieldcat-col_pos     = 4.
  ls_fieldcat-do_sum      = 'X'.
  ls_fieldcat-seltext_s   = 'Airfare'.
  ls_fieldcat-seltext_l   = 'Airfare'.
  append ls_fieldcat to l_fieldcat.
  clear ls_fieldcat.

* Local Currency
  ls_fieldcat-fieldname   = 'CURRENCY'.
  ls_fieldcat-col_pos     = 5.
  ls_fieldcat-seltext_s   = 'Local Currency'.
  ls_fieldcat-seltext_l   = 'Local Currency'.
  append ls_fieldcat to l_fieldcat.
  clear ls_fieldcat.

* Plane Type
  ls_fieldcat-fieldname   = 'PLANETYPE'.
  ls_fieldcat-col_pos     = 6.
  ls_fieldcat-seltext_s   = 'Plane type'.
  ls_fieldcat-seltext_l   = 'Plane type'.
  append ls_fieldcat to l_fieldcat.
  clear ls_fieldcat.

* Maximum capacity
  ls_fieldcat-fieldname   = 'SEATSMAX'.
  ls_fieldcat-col_pos     = 7.
  ls_fieldcat-seltext_s   = 'Max. seats'.
  ls_fieldcat-seltext_l   = 'Max. seats'.
  append ls_fieldcat to l_fieldcat.
  clear ls_fieldcat.

* Occupied seats
  ls_fieldcat-fieldname   = 'SEATSOCC'.
  ls_fieldcat-col_pos     = 8.
  ls_fieldcat-seltext_s   = 'Seats occupied'.
  ls_fieldcat-seltext_l   = 'Seats occupied'.
  append ls_fieldcat to l_fieldcat.
  clear ls_fieldcat.

* Total
  ls_fieldcat-fieldname   = 'PAYMENTSUM'.
  ls_fieldcat-col_pos     = 9.
  ls_fieldcat-do_sum     = 'X'.
  ls_fieldcat-seltext_s   = 'Total amount'.
  ls_fieldcat-seltext_l   = 'Total amount'.
  append ls_fieldcat to l_fieldcat.
  clear ls_fieldcat.

* Total
  ls_fieldcat-fieldname   = 'PAYMENTSUM'.
  ls_fieldcat-col_pos     = 9.
  ls_fieldcat-do_sum     = 'X'.
  ls_fieldcat-seltext_s   = 'Total amount'.
  ls_fieldcat-seltext_l   = 'Total amount'.
  append ls_fieldcat to l_fieldcat.
  clear ls_fieldcat.


* Max. Capacity, Buss. Class
  ls_fieldcat-fieldname   = 'SEATSMAX_B'.
  ls_fieldcat-col_pos     = 10.
  ls_fieldcat-seltext_s   = 'Max.Buss.class cap.'.
  ls_fieldcat-seltext_l   = 'Max.Buss.class cap.'.
  append ls_fieldcat to l_fieldcat.
  clear ls_fieldcat.

* Max. occupancy, Buss. Class
  ls_fieldcat-fieldname   = 'SEATSOCC_B'.
  ls_fieldcat-col_pos     = 11.
  ls_fieldcat-seltext_s   = 'Max.Bus.CL.occupied'.
  ls_fieldcat-seltext_l   = 'Max.Bus.CL.occupied'.
  append ls_fieldcat to l_fieldcat.
  clear ls_fieldcat.

* Max. Capacity, First. Class
  ls_fieldcat-fieldname   = 'SEATSMAX_F'.
  ls_fieldcat-col_pos     = 12.
  ls_fieldcat-seltext_s   = 'Max.Buss.class cap.'.
  ls_fieldcat-seltext_l   = 'Max.Buss.class cap.'.
  append ls_fieldcat to l_fieldcat.
  clear ls_fieldcat.

* Max. occupancy, First. Class
  ls_fieldcat-fieldname   = 'SEATSOCC_F'.
  ls_fieldcat-col_pos     = 13.
  ls_fieldcat-seltext_s   = 'Max.Bus.CL.occupied'.
  ls_fieldcat-seltext_l   = 'Max.Bus.CL.occupied'.
  append ls_fieldcat to l_fieldcat.
  clear ls_fieldcat.


endform.                    " initialize_fieldcat
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  read_flight_info
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
form read_flight_info .

refresh lt_sflight.
clear   lt_sflight.

**-- Read data from SFLIGHT table
  select *
    from sflight
    into table lt_sflight
    where carrid in s_carrid
     and  connid in s_connid
     and  fldate in s_fldate.
 if sy-subrc &amp;lt;&amp;gt; 0.
   message e208(00) with text-101.
 endif.

endform.                    " read_flight_info
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  dislay_alv_report
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
form dislay_alv_report .

call function 'REUSE_ALV_GRID_DISPLAY'
 exporting
*   I_INTERFACE_CHECK              = ' '
*   I_BYPASSING_BUFFER             =
*   I_BUFFER_ACTIVE                = ' '
   i_callback_program              =  g_repid
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
   i_structure_name                =  'sflight'
*   IS_LAYOUT                      =
   it_fieldcat                     =  gt_fieldcat
*   IT_EXCLUDING                   =
*   IT_SPECIAL_GROUPS              =
*   IT_SORT                        =
*   IT_FILTER                      =
*   IS_SEL_HIDE                    =
   i_default                      = 'X'
   i_save                         = 'A'
  is_variant                     = gx_variant
*   IT_EVENTS                      =
*   IT_EVENT_EXIT                  =
*   IS_PRINT                       =
*   IS_REPREP_ID                   =
*   I_SCREEN_START_COLUMN          = 0
*   I_SCREEN_START_LINE            = 0
*   I_SCREEN_END_COLUMN            = 0
*   I_SCREEN_END_LINE              = 0
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        =
*   ES_EXIT_CAUSED_BY_USER         =
  tables
    t_outtab                       = lt_sflight
 exceptions
   program_error                  = 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.                    " dislay_alv_report
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  initialize_variant
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
form initialize_variant .
 g_save = 'A'.
  clear g_variant.
  g_variant-report = g_repid.
  gx_variant = g_variant.
  call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
       exporting
            i_save     = g_save
       changing
            cs_variant = gx_variant
       exceptions
            not_found  = 2.
  if sy-subrc = 0.
    p_vari = gx_variant-variant.
  endif.

endform.                    " initialize_variant&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 05:06:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313539#M1225095</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T05:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Initialization</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313540#M1225096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Siva,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check this code,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TABLES : sflight.
TYPE-POOLS : slis.

**INTERNAL TABLE DECLARTION
DATA : wa_sflight TYPE sflight,
       it_sflight TYPE TABLE OF sflight.

**DATA DECLARTION
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
      gd_layout    TYPE slis_layout_alv,
      gd_repid     LIKE sy-repid,
      g_save TYPE c VALUE 'X',
      g_variant TYPE disvariant,
      gx_variant TYPE disvariant.



**SELECTION SCREEN DETAILS
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002 .
PARAMETERS: variant LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK b1.

**GETTING DEFAULT VARIANT
INITIALIZATION.
  gx_variant-report = sy-repid.
  CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
    EXPORTING
      i_save     = g_save
    CHANGING
      cs_variant = gx_variant
    EXCEPTIONS
      not_found  = 2.

  IF sy-subrc = 0.
    variant = gx_variant-variant.
  ENDIF.
  
**PERFORM DECLARATIONS
START-OF-SELECTION.
  PERFORM data_retrivel.
  PERFORM build_fieldcatalog.
  PERFORM display_alv_report.
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  BUILD_FIELDCATALOG
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM build_fieldcatalog .
  fieldcatalog-fieldname   = 'CARRID'.
  fieldcatalog-seltext_m   = 'Airline Code'.
  fieldcatalog-col_pos     = 0.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'CONNID'.
  fieldcatalog-seltext_m   = 'Flight Connection Number'.
  fieldcatalog-col_pos     = 1.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'FLDATE'.
  fieldcatalog-seltext_m   = 'Flight date'.
  fieldcatalog-col_pos     = 2.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'PRICE'.
  fieldcatalog-seltext_m   = 'Airfare'.
  fieldcatalog-col_pos     = 3.
  fieldcatalog-outputlen   = 20.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
ENDFORM.                    " BUILD_FIELDCATALOG


*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  DISPLAY_ALV_REPORT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM display_alv_report .
  gd_repid = sy-repid.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = gd_repid
      it_fieldcat        = fieldcatalog[]
      i_save             = 'X'
      is_variant         = g_variant
    TABLES
      t_outtab           = it_sflight
    EXCEPTIONS
      program_error      = 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.                    "DISPLAY_ALV_REPORT"

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  DATA_RETRIVEL
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM data_retrivel .
  SELECT * FROM sflight INTO TABLE it_sflight.
ENDFORM.                    " DATA_RETRIVEL
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;execute the program,&lt;/P&gt;&lt;P&gt;-&amp;gt;save the layout&lt;/P&gt;&lt;P&gt;-&amp;gt;back to the program , re-execute , u get the layout name u saved in the parameter as default..&lt;/P&gt;&lt;P&gt;Hope it gives u a clear idea.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mdi.Deeba&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 05:48:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313540#M1225096</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T05:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Initialization</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313541#M1225097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your replies&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 09:04:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/initialization/m-p/5313541#M1225097</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T09:04:05Z</dc:date>
    </item>
  </channel>
</rss>

