<?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: Example of  a Simple ALV Report using Function Modules (not OO) in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/example-of-a-simple-alv-report-using-function-modules-not-oo/m-p/5098436#M1183190</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;Use this demo code:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  z_alv01 MESSAGE-ID zmsg.
*&amp;amp;---------------------------------------------------------------------*
*          TABLES
*&amp;amp;---------------------------------------------------------------------*
TABLES : ekpo.

*&amp;amp;---------------------------------------------------------------------*
*          TYPE POOLS
*&amp;amp;---------------------------------------------------------------------*
TYPE-POOLS : slis.

*&amp;amp;---------------------------------------------------------------------*
*          TYPE DECLARATION
*&amp;amp;---------------------------------------------------------------------*
TYPES : BEGIN OF t_ekpo,
          ebeln TYPE ekpo-ebeln,
          ebelp TYPE ekpo-ebelp,
          matnr TYPE ekpo-matnr,
          werks TYPE ekpo-werks,
          menge TYPE ekpo-menge,
        END OF t_ekpo.

*&amp;amp;---------------------------------------------------------------------*
*          PARAMETERS
*&amp;amp;---------------------------------------------------------------------*
PARAMETERS : s_var TYPE disvariant-variant.

*&amp;amp;---------------------------------------------------------------------*
*          DATA DECLARATION
*&amp;amp;---------------------------------------------------------------------*
*VARIABLES
DATA : check(1),
       rep_id TYPE sy-repid.

*INTERNAL TABLE TYPE OF ZEKPO
DATA : it_ekpo TYPE STANDARD TABLE OF t_ekpo WITH HEADER LINE.

*FIELD CATALOG
DATA : it_field TYPE slis_t_fieldcat_alv,
       wa_field TYPE slis_fieldcat_alv.

*SORTING
DATA : it_sort TYPE slis_t_sortinfo_alv,
       wa_sort TYPE slis_sortinfo_alv.

*FOR TOP OF THE PAGE
DATA : it_top TYPE slis_t_listheader,
       wa_top TYPE slis_listheader.

*FOR END OF THE PAGE
DATA : it_end TYPE slis_t_listheader,
       wa_end TYPE slis_listheader.

*TO CAPTURE EVENTS AND HANDLE
DATA : it_event TYPE slis_t_event,
       wa_event TYPE slis_alv_event.

*FOR GRID TITLE
DATA : wa_title TYPE lvc_title.

*FOR LAYOUT
DATA : wa_layout TYPE slis_layout_alv.

*FOR EXCLUDING STANDARD BUTTON FROM ALV TOOLBAR
DATA : it_exclude TYPE slis_t_extab,
       wa_exclude TYPE slis_extab.

*FOR VARIANT
DATA : wa_variant TYPE disvariant.

*&amp;amp;---------------------------------------------------------------------*
*          INITIALIZATION
*&amp;amp;---------------------------------------------------------------------*
INITIALIZATION.
  check = 'X'.
  rep_id = sy-repid.
  wa_variant-report = sy-repid.
*GET DEFUALT ON THE SELECTION SCREEN FOR DEFAULT DISPLAY
  CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
    EXPORTING
      i_save        = 'A'
    CHANGING
      cs_variant    = wa_variant
    EXCEPTIONS
      wrong_input   = 1
      not_found     = 2
      program_error = 3
      OTHERS        = 4.
  IF sy-subrc = 0.               " IF DEFAULT VARIANT FOUND
    s_var = wa_variant-variant.  " PASS THE DEFAULT VARIANT TO THE SELECTION SCREEN FIELD
  ENDIF.

*&amp;amp;---------------------------------------------------------------------*
*          AT-SELECTION SCREEN ON VALUE REQUEST
*&amp;amp;---------------------------------------------------------------------*
*          TO GET THE F4 HELP FOR VARIANT
*&amp;amp;---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_var.

  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
    EXPORTING
      is_variant                = wa_variant
*   I_TABNAME_HEADER          =
*   I_TABNAME_ITEM            =
*   IT_DEFAULT_FIELDCAT       =
     i_save                    = 'A'
*   I_DISPLAY_VIA_GRID        = ' '
   IMPORTING
*   E_EXIT                    =
     es_variant                = wa_variant
   EXCEPTIONS
     not_found                 = 1
     program_error             = 2
     OTHERS                    = 3.
  IF sy-subrc = 0.
    s_var = wa_variant-variant. " PASS THE SELECTED VARIANT TO THE SELECTION SCREEN FIELD
  ENDIF.

*&amp;amp;---------------------------------------------------------------------*
*          AT-SELECTION SCREEN
*&amp;amp;---------------------------------------------------------------------*
*          TO CHECK THE EXISTENCE FOR VARIANT
*&amp;amp;---------------------------------------------------------------------*
AT SELECTION-SCREEN.
  wa_variant-variant = s_var.
  CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
    EXPORTING
      i_save        = 'A'
    CHANGING
      cs_variant    = wa_variant
    EXCEPTIONS
      wrong_input   = 1
      not_found     = 2
      program_error = 3
      OTHERS        = 4.
  IF sy-subrc &amp;lt;&amp;gt; 0.
    MESSAGE w001.
  ENDIF.

*&amp;amp;---------------------------------------------------------------------*
*          START OF SELECTION
*&amp;amp;---------------------------------------------------------------------*
START-OF-SELECTION.

  SELECT ebeln
         ebelp
         matnr
         werks
         menge
         FROM ekpo
         INTO TABLE it_ekpo.

*&amp;amp;---------------------------------------------------------------------*
*          FIELD CATALOG
*&amp;amp;---------------------------------------------------------------------*
  wa_field-fieldname = 'EBELN'.
  wa_field-tabname = 'IT_TAB'.
  wa_field-outputlen = 10.
  wa_field-seltext_l = 'PO #'.
  APPEND wa_field TO it_field.
  CLEAR wa_field.

  wa_field-fieldname = 'EBELP'.
  wa_field-tabname = 'IT_TAB'.
  wa_field-outputlen = 10.
  wa_field-seltext_l = 'Line Item'.
  APPEND wa_field TO it_field.
  CLEAR wa_field.

  wa_field-fieldname = 'MATNR'.
  wa_field-tabname = 'IT_TAB'.
  wa_field-outputlen = 15.
  wa_field-seltext_l = 'Material'.
*  wa_field-input = check.
*  wa_field-edit = check.
  APPEND wa_field TO it_field.
  CLEAR wa_field.

  wa_field-fieldname = 'WERKS'.
  wa_field-tabname = 'IT_TAB'.
  wa_field-outputlen = 6.
  wa_field-seltext_l = 'Plant'.
*  wa_field-input = check.
*  wa_field-edit = check.
  APPEND wa_field TO it_field.
  CLEAR wa_field.

  wa_field-fieldname = 'MENGE'.
  wa_field-tabname = 'IT_TAB'.
  wa_field-outputlen = 10.
  wa_field-seltext_l = 'Qty.'.
*  wa_field-input = check.
*  wa_field-edit = check.
  wa_field-do_sum = check.
  APPEND wa_field TO it_field.
  CLEAR wa_field.

*&amp;amp;---------------------------------------------------------------------*
*          SORT W.R.T. PURCHASE ORDER NUMBER
*&amp;amp;---------------------------------------------------------------------*
  wa_sort-spos = 1.
  wa_sort-fieldname = 'EBELN'.
  wa_sort-tabname = 'IT_EKPO'.
  wa_sort-up = check.
  wa_sort-subtot = check.
  APPEND wa_sort TO it_sort.
  CLEAR wa_sort.

*&amp;amp;---------------------------------------------------------------------*
*          FOR GRID TITLE
*&amp;amp;---------------------------------------------------------------------*
  wa_title = 'Hello'.

*&amp;amp;---------------------------------------------------------------------*
*          FOR LAYOUT
*&amp;amp;---------------------------------------------------------------------*
  wa_layout-zebra = check.

*&amp;amp;---------------------------------------------------------------------*
*          FOR EXCLUDING STANDARD BUTTONS FROM ALV TOOLBAR
*&amp;amp;---------------------------------------------------------------------*
  wa_exclude-fcode = '&amp;amp;OUP'.
  APPEND wa_exclude TO it_exclude.
  CLEAR wa_exclude.

  wa_exclude-fcode = '&amp;amp;ODN'.
  APPEND wa_exclude TO it_exclude.
  CLEAR wa_exclude.

  wa_exclude-fcode = '&amp;amp;OAD'.
  APPEND wa_exclude TO it_exclude.
  CLEAR wa_exclude.

*  wa_exclude-fcode = '&amp;amp;AVE'.
*  APPEND wa_exclude TO it_exclude.
*  CLEAR wa_exclude.

  wa_exclude-fcode = '&amp;amp;INFO'.
  APPEND wa_exclude TO it_exclude.
  CLEAR wa_exclude.

*&amp;amp;---------------------------------------------------------------------*
*          POPULATE ALL EVENTS INTO INTERNAL TABLE
*&amp;amp;---------------------------------------------------------------------*
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      i_list_type     = 0
    IMPORTING
      et_events       = it_event
    EXCEPTIONS
      list_type_wrong = 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.

  READ TABLE it_event INTO wa_event WITH KEY name = 'END_OF_LIST'.
  wa_event-form = 'END'.
  MODIFY it_event FROM wa_event INDEX sy-tabix.
  CLEAR wa_event.

*&amp;amp;---------------------------------------------------------------------*
*          DISPLAY RECORDS IN ALV GRID
*&amp;amp;---------------------------------------------------------------------*
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
   i_callback_program                = rep_id
*   i_callback_pf_status_set          = 'PF'
   i_callback_user_command           = 'COMMAND'
   i_callback_top_of_page            = 'TOP'
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
*   I_BACKGROUND_ID                   = ' '
   i_grid_title                      = wa_title
*   I_GRID_SETTINGS                   =
   is_layout                         = wa_layout
   it_fieldcat                       = it_field
   it_excluding                      = it_exclude
*   IT_SPECIAL_GROUPS                 =
   it_sort                           = it_sort
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
   i_save                            = 'A'
   is_variant                        = wa_variant
   it_events                         = it_event
*   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
*   I_HTML_HEIGHT_TOP                 = 0
*   I_HTML_HEIGHT_END                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   IR_SALV_FULLSCREEN_ADAPTER        =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
    TABLES
      t_outtab                          = it_ekpo
 EXCEPTIONS
   program_error                     = 1
   OTHERS                            = 2.

  IF sy-subrc &amp;lt;&amp;gt; 0.
  ENDIF.

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  top
*&amp;amp;---------------------------------------------------------------------*
*       TO WRITE THE HEADER
*----------------------------------------------------------------------*
FORM top.

  REFRESH it_top.
  wa_top-typ = 'S'.
  wa_top-key = text-001.
  wa_top-info = rep_id.
  APPEND wa_top TO it_top.
  CLEAR wa_top.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary       = it_top
*   I_LOGO                   =
*   I_END_OF_LIST_GRID       =
*   I_ALV_FORM               =
            .

ENDFORM.                    "top

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  end
*&amp;amp;---------------------------------------------------------------------*
*       TO WRITE THE FOOTER
*----------------------------------------------------------------------*
FORM end.

  REFRESH it_end.
  wa_end-typ = 'S'.
  wa_end-key = text-001.
  wa_end-info = rep_id.
  APPEND wa_end TO it_end.
  CLEAR wa_end.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary       = it_end
*   I_LOGO                   =
*   I_END_OF_LIST_GRID       =
*   I_ALV_FORM               =
            .

ENDFORM.                    "end

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  pf
*&amp;amp;---------------------------------------------------------------------*
*       FOR PF-STATUS WITH USER DEFINED BUTTONS
*----------------------------------------------------------------------*
*      --&amp;gt;RT_EXTAB   text
*----------------------------------------------------------------------*
FORM pf USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'ZTG_PF_ALV'.
ENDFORM.                    "pf

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  command
*&amp;amp;---------------------------------------------------------------------*
*       TO HANDLE USER ACTIONS AGAINST PF-STATUS
*----------------------------------------------------------------------*
*      --&amp;gt;UCOMM      text
*      --&amp;gt;SELFIELD   text
*----------------------------------------------------------------------*
FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
  DATA : ok_code TYPE sy-ucomm.
  ok_code = ucomm.
  CASE ok_code.
    WHEN 'T_DOWN'.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = 'HELLO'
          txt1  = 'USER COMMAND'
          txt2  = 'TOTAL DOWN'.

    WHEN 'DOWN'.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = 'HELLO'
          txt1  = 'USER COMMAND'
          txt2  = 'DOWN'.

    WHEN 'UP'.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = 'HELLO'
          txt1  = 'USER COMMAND'
          txt2  = 'UP'.

    WHEN 'T_UP'.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = 'HELLO'
          txt1  = 'USER COMMAND'
          txt2  = 'TOTAL UP'.

  ENDCASE.
ENDFORM.                    "command
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Tarun Gambhir&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Jan 2009 17:40:47 GMT</pubDate>
    <dc:creator>I355602</dc:creator>
    <dc:date>2009-01-29T17:40:47Z</dc:date>
    <item>
      <title>Example of  a Simple ALV Report using Function Modules (not OO)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/example-of-a-simple-alv-report-using-function-modules-not-oo/m-p/5098431#M1183185</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;I am new to ABAP. Where can I get a proper Example of  a Simple ALV Report using Function Modules?  I searched the forum but did not find a proper solution. Kindly help. &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Smruthi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Smruthi Acharya on Jan 29, 2009 7:13 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 13:43:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/example-of-a-simple-alv-report-using-function-modules-not-oo/m-p/5098431#M1183185</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-29T13:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Example of  a Simple ALV Report using Function Modules (not OO)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/example-of-a-simple-alv-report-using-function-modules-not-oo/m-p/5098432#M1183186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check BC&lt;STRONG&gt;ALV&lt;/STRONG&gt; in se38&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 13:46:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/example-of-a-simple-alv-report-using-function-modules-not-oo/m-p/5098432#M1183186</guid>
      <dc:creator>former_member156446</dc:creator>
      <dc:date>2009-01-29T13:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Example of  a Simple ALV Report using Function Modules (not OO)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/example-of-a-simple-alv-report-using-function-modules-not-oo/m-p/5098433#M1183187</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;Check this link [ALV|https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_all&amp;amp;query=alv&lt;EM&gt;grid&lt;/EM&gt;display&lt;EM&gt;using&lt;/EM&gt;Function+Module&amp;amp;adv=false&amp;amp;sortby=cm_rnd_rankvalue]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 13:54:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/example-of-a-simple-alv-report-using-function-modules-not-oo/m-p/5098433#M1183187</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-29T13:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Example of  a Simple ALV Report using Function Modules (not OO)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/example-of-a-simple-alv-report-using-function-modules-not-oo/m-p/5098434#M1183188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; I searched the forum but did not find a proper solution. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;I think you are unaware what a Function Module is.!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Initially as a beginner, to know what are all the function modules available for ALV,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;goto Tcode - SE37, type REUSE_ALV* and press F4. It will give all the function modules.&lt;/P&gt;&lt;P&gt;With this, search here in SDN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For sample programs:&lt;/P&gt;&lt;P&gt; Goto SE38, type BCALV* and press F4, it will give all the examples.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Most commonly used Function Module in ALV is &lt;STRONG&gt;REUSE_ALV_GRID_DISPLAY&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;some std demo programs, u can check out are:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BCALV_TEST_GRID&lt;/P&gt;&lt;P&gt;BCALV_TEST_LIST&lt;/P&gt;&lt;P&gt;BALVSD02_GRID&lt;/P&gt;&lt;P&gt;BALVST02_GRID  &lt;/P&gt;&lt;P&gt;BALVST03_GRID&lt;/P&gt;&lt;P&gt;BCALV_FULLSCREEN_DEMO&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;All the Best.&lt;/P&gt;&lt;P&gt;Padmashree&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Padmashree RamMaghenthar on Jan 29, 2009 7:40 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 14:03:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/example-of-a-simple-alv-report-using-function-modules-not-oo/m-p/5098434#M1183188</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-29T14:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: Example of  a Simple ALV Report using Function Modules (not OO)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/example-of-a-simple-alv-report-using-function-modules-not-oo/m-p/5098435#M1183189</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;under Wiki (SDN)section you can find many program in ALV&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 14:21:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/example-of-a-simple-alv-report-using-function-modules-not-oo/m-p/5098435#M1183189</guid>
      <dc:creator>former_member206439</dc:creator>
      <dc:date>2009-01-29T14:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Example of  a Simple ALV Report using Function Modules (not OO)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/example-of-a-simple-alv-report-using-function-modules-not-oo/m-p/5098436#M1183190</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;Use this demo code:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  z_alv01 MESSAGE-ID zmsg.
*&amp;amp;---------------------------------------------------------------------*
*          TABLES
*&amp;amp;---------------------------------------------------------------------*
TABLES : ekpo.

*&amp;amp;---------------------------------------------------------------------*
*          TYPE POOLS
*&amp;amp;---------------------------------------------------------------------*
TYPE-POOLS : slis.

*&amp;amp;---------------------------------------------------------------------*
*          TYPE DECLARATION
*&amp;amp;---------------------------------------------------------------------*
TYPES : BEGIN OF t_ekpo,
          ebeln TYPE ekpo-ebeln,
          ebelp TYPE ekpo-ebelp,
          matnr TYPE ekpo-matnr,
          werks TYPE ekpo-werks,
          menge TYPE ekpo-menge,
        END OF t_ekpo.

*&amp;amp;---------------------------------------------------------------------*
*          PARAMETERS
*&amp;amp;---------------------------------------------------------------------*
PARAMETERS : s_var TYPE disvariant-variant.

*&amp;amp;---------------------------------------------------------------------*
*          DATA DECLARATION
*&amp;amp;---------------------------------------------------------------------*
*VARIABLES
DATA : check(1),
       rep_id TYPE sy-repid.

*INTERNAL TABLE TYPE OF ZEKPO
DATA : it_ekpo TYPE STANDARD TABLE OF t_ekpo WITH HEADER LINE.

*FIELD CATALOG
DATA : it_field TYPE slis_t_fieldcat_alv,
       wa_field TYPE slis_fieldcat_alv.

*SORTING
DATA : it_sort TYPE slis_t_sortinfo_alv,
       wa_sort TYPE slis_sortinfo_alv.

*FOR TOP OF THE PAGE
DATA : it_top TYPE slis_t_listheader,
       wa_top TYPE slis_listheader.

*FOR END OF THE PAGE
DATA : it_end TYPE slis_t_listheader,
       wa_end TYPE slis_listheader.

*TO CAPTURE EVENTS AND HANDLE
DATA : it_event TYPE slis_t_event,
       wa_event TYPE slis_alv_event.

*FOR GRID TITLE
DATA : wa_title TYPE lvc_title.

*FOR LAYOUT
DATA : wa_layout TYPE slis_layout_alv.

*FOR EXCLUDING STANDARD BUTTON FROM ALV TOOLBAR
DATA : it_exclude TYPE slis_t_extab,
       wa_exclude TYPE slis_extab.

*FOR VARIANT
DATA : wa_variant TYPE disvariant.

*&amp;amp;---------------------------------------------------------------------*
*          INITIALIZATION
*&amp;amp;---------------------------------------------------------------------*
INITIALIZATION.
  check = 'X'.
  rep_id = sy-repid.
  wa_variant-report = sy-repid.
*GET DEFUALT ON THE SELECTION SCREEN FOR DEFAULT DISPLAY
  CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
    EXPORTING
      i_save        = 'A'
    CHANGING
      cs_variant    = wa_variant
    EXCEPTIONS
      wrong_input   = 1
      not_found     = 2
      program_error = 3
      OTHERS        = 4.
  IF sy-subrc = 0.               " IF DEFAULT VARIANT FOUND
    s_var = wa_variant-variant.  " PASS THE DEFAULT VARIANT TO THE SELECTION SCREEN FIELD
  ENDIF.

*&amp;amp;---------------------------------------------------------------------*
*          AT-SELECTION SCREEN ON VALUE REQUEST
*&amp;amp;---------------------------------------------------------------------*
*          TO GET THE F4 HELP FOR VARIANT
*&amp;amp;---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_var.

  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
    EXPORTING
      is_variant                = wa_variant
*   I_TABNAME_HEADER          =
*   I_TABNAME_ITEM            =
*   IT_DEFAULT_FIELDCAT       =
     i_save                    = 'A'
*   I_DISPLAY_VIA_GRID        = ' '
   IMPORTING
*   E_EXIT                    =
     es_variant                = wa_variant
   EXCEPTIONS
     not_found                 = 1
     program_error             = 2
     OTHERS                    = 3.
  IF sy-subrc = 0.
    s_var = wa_variant-variant. " PASS THE SELECTED VARIANT TO THE SELECTION SCREEN FIELD
  ENDIF.

*&amp;amp;---------------------------------------------------------------------*
*          AT-SELECTION SCREEN
*&amp;amp;---------------------------------------------------------------------*
*          TO CHECK THE EXISTENCE FOR VARIANT
*&amp;amp;---------------------------------------------------------------------*
AT SELECTION-SCREEN.
  wa_variant-variant = s_var.
  CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
    EXPORTING
      i_save        = 'A'
    CHANGING
      cs_variant    = wa_variant
    EXCEPTIONS
      wrong_input   = 1
      not_found     = 2
      program_error = 3
      OTHERS        = 4.
  IF sy-subrc &amp;lt;&amp;gt; 0.
    MESSAGE w001.
  ENDIF.

*&amp;amp;---------------------------------------------------------------------*
*          START OF SELECTION
*&amp;amp;---------------------------------------------------------------------*
START-OF-SELECTION.

  SELECT ebeln
         ebelp
         matnr
         werks
         menge
         FROM ekpo
         INTO TABLE it_ekpo.

*&amp;amp;---------------------------------------------------------------------*
*          FIELD CATALOG
*&amp;amp;---------------------------------------------------------------------*
  wa_field-fieldname = 'EBELN'.
  wa_field-tabname = 'IT_TAB'.
  wa_field-outputlen = 10.
  wa_field-seltext_l = 'PO #'.
  APPEND wa_field TO it_field.
  CLEAR wa_field.

  wa_field-fieldname = 'EBELP'.
  wa_field-tabname = 'IT_TAB'.
  wa_field-outputlen = 10.
  wa_field-seltext_l = 'Line Item'.
  APPEND wa_field TO it_field.
  CLEAR wa_field.

  wa_field-fieldname = 'MATNR'.
  wa_field-tabname = 'IT_TAB'.
  wa_field-outputlen = 15.
  wa_field-seltext_l = 'Material'.
*  wa_field-input = check.
*  wa_field-edit = check.
  APPEND wa_field TO it_field.
  CLEAR wa_field.

  wa_field-fieldname = 'WERKS'.
  wa_field-tabname = 'IT_TAB'.
  wa_field-outputlen = 6.
  wa_field-seltext_l = 'Plant'.
*  wa_field-input = check.
*  wa_field-edit = check.
  APPEND wa_field TO it_field.
  CLEAR wa_field.

  wa_field-fieldname = 'MENGE'.
  wa_field-tabname = 'IT_TAB'.
  wa_field-outputlen = 10.
  wa_field-seltext_l = 'Qty.'.
*  wa_field-input = check.
*  wa_field-edit = check.
  wa_field-do_sum = check.
  APPEND wa_field TO it_field.
  CLEAR wa_field.

*&amp;amp;---------------------------------------------------------------------*
*          SORT W.R.T. PURCHASE ORDER NUMBER
*&amp;amp;---------------------------------------------------------------------*
  wa_sort-spos = 1.
  wa_sort-fieldname = 'EBELN'.
  wa_sort-tabname = 'IT_EKPO'.
  wa_sort-up = check.
  wa_sort-subtot = check.
  APPEND wa_sort TO it_sort.
  CLEAR wa_sort.

*&amp;amp;---------------------------------------------------------------------*
*          FOR GRID TITLE
*&amp;amp;---------------------------------------------------------------------*
  wa_title = 'Hello'.

*&amp;amp;---------------------------------------------------------------------*
*          FOR LAYOUT
*&amp;amp;---------------------------------------------------------------------*
  wa_layout-zebra = check.

*&amp;amp;---------------------------------------------------------------------*
*          FOR EXCLUDING STANDARD BUTTONS FROM ALV TOOLBAR
*&amp;amp;---------------------------------------------------------------------*
  wa_exclude-fcode = '&amp;amp;OUP'.
  APPEND wa_exclude TO it_exclude.
  CLEAR wa_exclude.

  wa_exclude-fcode = '&amp;amp;ODN'.
  APPEND wa_exclude TO it_exclude.
  CLEAR wa_exclude.

  wa_exclude-fcode = '&amp;amp;OAD'.
  APPEND wa_exclude TO it_exclude.
  CLEAR wa_exclude.

*  wa_exclude-fcode = '&amp;amp;AVE'.
*  APPEND wa_exclude TO it_exclude.
*  CLEAR wa_exclude.

  wa_exclude-fcode = '&amp;amp;INFO'.
  APPEND wa_exclude TO it_exclude.
  CLEAR wa_exclude.

*&amp;amp;---------------------------------------------------------------------*
*          POPULATE ALL EVENTS INTO INTERNAL TABLE
*&amp;amp;---------------------------------------------------------------------*
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      i_list_type     = 0
    IMPORTING
      et_events       = it_event
    EXCEPTIONS
      list_type_wrong = 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.

  READ TABLE it_event INTO wa_event WITH KEY name = 'END_OF_LIST'.
  wa_event-form = 'END'.
  MODIFY it_event FROM wa_event INDEX sy-tabix.
  CLEAR wa_event.

*&amp;amp;---------------------------------------------------------------------*
*          DISPLAY RECORDS IN ALV GRID
*&amp;amp;---------------------------------------------------------------------*
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
   i_callback_program                = rep_id
*   i_callback_pf_status_set          = 'PF'
   i_callback_user_command           = 'COMMAND'
   i_callback_top_of_page            = 'TOP'
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
*   I_BACKGROUND_ID                   = ' '
   i_grid_title                      = wa_title
*   I_GRID_SETTINGS                   =
   is_layout                         = wa_layout
   it_fieldcat                       = it_field
   it_excluding                      = it_exclude
*   IT_SPECIAL_GROUPS                 =
   it_sort                           = it_sort
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
   i_save                            = 'A'
   is_variant                        = wa_variant
   it_events                         = it_event
*   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
*   I_HTML_HEIGHT_TOP                 = 0
*   I_HTML_HEIGHT_END                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   IR_SALV_FULLSCREEN_ADAPTER        =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
    TABLES
      t_outtab                          = it_ekpo
 EXCEPTIONS
   program_error                     = 1
   OTHERS                            = 2.

  IF sy-subrc &amp;lt;&amp;gt; 0.
  ENDIF.

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  top
*&amp;amp;---------------------------------------------------------------------*
*       TO WRITE THE HEADER
*----------------------------------------------------------------------*
FORM top.

  REFRESH it_top.
  wa_top-typ = 'S'.
  wa_top-key = text-001.
  wa_top-info = rep_id.
  APPEND wa_top TO it_top.
  CLEAR wa_top.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary       = it_top
*   I_LOGO                   =
*   I_END_OF_LIST_GRID       =
*   I_ALV_FORM               =
            .

ENDFORM.                    "top

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  end
*&amp;amp;---------------------------------------------------------------------*
*       TO WRITE THE FOOTER
*----------------------------------------------------------------------*
FORM end.

  REFRESH it_end.
  wa_end-typ = 'S'.
  wa_end-key = text-001.
  wa_end-info = rep_id.
  APPEND wa_end TO it_end.
  CLEAR wa_end.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary       = it_end
*   I_LOGO                   =
*   I_END_OF_LIST_GRID       =
*   I_ALV_FORM               =
            .

ENDFORM.                    "end

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  pf
*&amp;amp;---------------------------------------------------------------------*
*       FOR PF-STATUS WITH USER DEFINED BUTTONS
*----------------------------------------------------------------------*
*      --&amp;gt;RT_EXTAB   text
*----------------------------------------------------------------------*
FORM pf USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'ZTG_PF_ALV'.
ENDFORM.                    "pf

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  command
*&amp;amp;---------------------------------------------------------------------*
*       TO HANDLE USER ACTIONS AGAINST PF-STATUS
*----------------------------------------------------------------------*
*      --&amp;gt;UCOMM      text
*      --&amp;gt;SELFIELD   text
*----------------------------------------------------------------------*
FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
  DATA : ok_code TYPE sy-ucomm.
  ok_code = ucomm.
  CASE ok_code.
    WHEN 'T_DOWN'.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = 'HELLO'
          txt1  = 'USER COMMAND'
          txt2  = 'TOTAL DOWN'.

    WHEN 'DOWN'.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = 'HELLO'
          txt1  = 'USER COMMAND'
          txt2  = 'DOWN'.

    WHEN 'UP'.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = 'HELLO'
          txt1  = 'USER COMMAND'
          txt2  = 'UP'.

    WHEN 'T_UP'.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = 'HELLO'
          txt1  = 'USER COMMAND'
          txt2  = 'TOTAL UP'.

  ENDCASE.
ENDFORM.                    "command
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Tarun Gambhir&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 17:40:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/example-of-a-simple-alv-report-using-function-modules-not-oo/m-p/5098436#M1183190</guid>
      <dc:creator>I355602</dc:creator>
      <dc:date>2009-01-29T17:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: Example of  a Simple ALV Report using Function Modules (not OO)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/example-of-a-simple-alv-report-using-function-modules-not-oo/m-p/5098437#M1183191</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 are aware what a Package means and if you have access to a SAP system, you will find loads of examples related to ALV programming with excellent explanation in the package SLIS. Goto t-code se80 and select "Package" from the dropdown in the object navigator and enter SLIS and press enter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This package not only explains the ALV reporting using function modules , but also using OOPS. That is how most of us have learnt about ALV and I would suggest you follow the same path.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By any chance you dont have access to the system, go to the SCN's WIKI section and type "ALV" in the search field you will find a plethora of examples.&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, 29 Jan 2009 17:56:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/example-of-a-simple-alv-report-using-function-modules-not-oo/m-p/5098437#M1183191</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-29T17:56:03Z</dc:date>
    </item>
  </channel>
</rss>

