<?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 list in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list/m-p/3237914#M772679</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;Use a variation on this program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've used VAPMA but select your own structure and use the same coding principle&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To download your list just click the EXPORT button in the GRID - it is the LAST BUT ONE button.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Standard functions such as PRINT etc are on the GRID buttons.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to create a standard screen (SE51) with just a custom control on it called CCONTAINER1 and container on it . Create also a standard STATUS (SE41)  with CANCEL BACK and EXIT buttons on it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the VERY VERY EASY code. It's completely general so all you need to do is just define your own structure in the s_elements structure and fill the table with your data instead of VAPMA data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use the same principle for almost ANY structure so ALV lists now are REALLY EASY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(For added functionality you can add events, data handling etc etc but the code here I've shown is quite sufficient for typical display lists and to download to local files).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

PROGRAM zzz_simple_editable_grid.

* Define any structure
TYPES:  BEGIN OF s_elements,
  vbeln   TYPE vapma-vbeln,
  posnr   TYPE vapma-posnr,
  matnr   TYPE vapma-matnr,
  kunnr   TYPE vapma-kunnr,
  werks   TYPE vapma-werks,
  vkorg   TYPE vapma-vkorg,
  vkbur   TYPE vapma-vkbur,
  status  TYPE c,

END OF  s_elements.

* end of your structure

DATA lr_rtti_struc TYPE REF TO cl_abap_structdescr .
DATA:
    zog                     LIKE LINE OF lr_rtti_struc-&amp;gt;components .
DATA:
  zogt                    LIKE TABLE OF zog,
wa_it_fldcat TYPE lvc_s_fcat,
it_fldcat TYPE lvc_t_fcat ,
dy_line            TYPE REF TO data,
dy_table           TYPE REF TO data.


DATA:  dref               TYPE REF TO data.
FIELD-SYMBOLS: &amp;lt;fs&amp;gt; TYPE ANY,
   &amp;lt;dyn_table&amp;gt;    TYPE  STANDARD TABLE,
   &amp;lt;dyn_wa&amp;gt;.

DATA grid_container1 TYPE REF TO cl_gui_custom_container .
DATA grid1 TYPE REF TO cl_gui_alv_grid .
DATA: ok_code TYPE sy-ucomm.
DATA: struct_grid_lset TYPE lvc_s_layo.

*now I want to build a field catalog
* First get your data structure into a field symbol

CREATE DATA dref TYPE s_elements.
ASSIGN dref-&amp;gt;* TO &amp;lt;fs&amp;gt;.

lr_rtti_struc ?= cl_abap_structdescr=&amp;gt;describe_by_data( &amp;lt;fs&amp;gt; ).

* Now get the structure details into a table.
* table zogt[] contains the structure details
* From which we can build the field catalog

zogt[]  = lr_rtti_struc-&amp;gt;components.
LOOP AT zogt INTO zog.
  CLEAR wa_it_fldcat.
  wa_it_fldcat-fieldname = zog-name .
  wa_it_fldcat-datatype = zog-type_kind.
  wa_it_fldcat-inttype = zog-type_kind.
  wa_it_fldcat-intlen = zog-length.
  wa_it_fldcat-decimals = zog-decimals.
  wa_it_fldcat-coltext = zog-name.
  wa_it_fldcat-lowercase = 'X'.
  APPEND wa_it_fldcat TO it_fldcat .
ENDLOOP.
*
* You can perform any modifications / additions to your field catalog
* here such as your own column names etc.

* Now using the field catalog created above we can
* build a dynamic table
* and populate it

* First build the dynamic table
* the table will contain entries for
* our structure defined at the start of the program

CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
       EXPORTING
            it_fieldcatalog = it_fldcat
       IMPORTING
            ep_table = dy_table.


ASSIGN dy_table-&amp;gt;* TO &amp;lt;dyn_table&amp;gt;.
CREATE DATA dy_line LIKE LINE OF &amp;lt;dyn_table&amp;gt;.
ASSIGN dy_line-&amp;gt;* TO &amp;lt;dyn_wa&amp;gt;.

* Now fill our table with data

SELECT vbeln posnr matnr kunnr werks vkorg vkbur
       UP TO 200 ROWS
       FROM vapma
       INTO  CORRESPONDING FIELDS OF TABLE &amp;lt;dyn_table&amp;gt;.

* Call the screen to display the grid
CALL SCREEN 100.

* PBO module

MODULE status_0100 OUTPUT.

  IF grid_container1 IS INITIAL.
    CREATE OBJECT grid_container1
            EXPORTING
               container_name = 'CCONTAINER1'.
    CREATE OBJECT  grid1
       EXPORTING
          i_parent = grid_container1.
    struct_grid_lset-edit = 'X'.    "To enable editing in ALV

    CALL METHOD grid1-&amp;gt;set_table_for_first_display
      EXPORTING is_layout =  struct_grid_lset
      CHANGING
                 it_outtab       = &amp;lt;dyn_table&amp;gt;
                 it_fieldcatalog = it_fldcat.


  ENDIF.
  SET PF-STATUS '001'.
  SET TITLEBAR '000'.

ENDMODULE.

* PAI module

MODULE user_command_0100 INPUT.
  CASE sy-ucomm.
    WHEN 'BACK'.
      LEAVE PROGRAM.
    WHEN 'EXIT'.
      LEAVE PROGRAM.
    WHEN 'RETURN'.
      LEAVE PROGRAM.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I don't want to see people complaining about how difficult ALV grids are or even seeing them use the old Dinosaur SLIS modules.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;jimbo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Jan 2008 11:00:13 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-01-09T11:00:13Z</dc:date>
    <item>
      <title>ALV list</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list/m-p/3237912#M772677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to Report developed to list out all Sales Orders with Billing details and download into a local file, which is used to ensure whether all the Sales Orders has been posted into SAP system to compare with legacy system.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2008 06:53:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list/m-p/3237912#M772677</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-09T06:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: ALV list</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list/m-p/3237913#M772678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Devi Vishwanath,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use VBFA table to do this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select VBELV POSNV VBELN POSNR from VBFA where VBTYP_V = 'C' and VBTYP_N = 'M' (if your invoices contain debit/credit memo, pro forma, or other types specify all type with or condition).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VBELV POSNV will contain Sales Order and Sales Order line item number. VBELN and POSNR will contain Billing document and Billing document line item number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want more details for billing document query on VBRK / VBRP table with VBELN and / or POSNR field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want more details for sales order query on VBAK / VBAP tabel with VBELV and / or POSNV field..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can get all linkages between sales document from VBFA table.. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mohaiyuddin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2008 09:16:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list/m-p/3237913#M772678</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-09T09:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: ALV list</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list/m-p/3237914#M772679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;Use a variation on this program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've used VAPMA but select your own structure and use the same coding principle&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To download your list just click the EXPORT button in the GRID - it is the LAST BUT ONE button.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Standard functions such as PRINT etc are on the GRID buttons.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to create a standard screen (SE51) with just a custom control on it called CCONTAINER1 and container on it . Create also a standard STATUS (SE41)  with CANCEL BACK and EXIT buttons on it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the VERY VERY EASY code. It's completely general so all you need to do is just define your own structure in the s_elements structure and fill the table with your data instead of VAPMA data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use the same principle for almost ANY structure so ALV lists now are REALLY EASY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(For added functionality you can add events, data handling etc etc but the code here I've shown is quite sufficient for typical display lists and to download to local files).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

PROGRAM zzz_simple_editable_grid.

* Define any structure
TYPES:  BEGIN OF s_elements,
  vbeln   TYPE vapma-vbeln,
  posnr   TYPE vapma-posnr,
  matnr   TYPE vapma-matnr,
  kunnr   TYPE vapma-kunnr,
  werks   TYPE vapma-werks,
  vkorg   TYPE vapma-vkorg,
  vkbur   TYPE vapma-vkbur,
  status  TYPE c,

END OF  s_elements.

* end of your structure

DATA lr_rtti_struc TYPE REF TO cl_abap_structdescr .
DATA:
    zog                     LIKE LINE OF lr_rtti_struc-&amp;gt;components .
DATA:
  zogt                    LIKE TABLE OF zog,
wa_it_fldcat TYPE lvc_s_fcat,
it_fldcat TYPE lvc_t_fcat ,
dy_line            TYPE REF TO data,
dy_table           TYPE REF TO data.


DATA:  dref               TYPE REF TO data.
FIELD-SYMBOLS: &amp;lt;fs&amp;gt; TYPE ANY,
   &amp;lt;dyn_table&amp;gt;    TYPE  STANDARD TABLE,
   &amp;lt;dyn_wa&amp;gt;.

DATA grid_container1 TYPE REF TO cl_gui_custom_container .
DATA grid1 TYPE REF TO cl_gui_alv_grid .
DATA: ok_code TYPE sy-ucomm.
DATA: struct_grid_lset TYPE lvc_s_layo.

*now I want to build a field catalog
* First get your data structure into a field symbol

CREATE DATA dref TYPE s_elements.
ASSIGN dref-&amp;gt;* TO &amp;lt;fs&amp;gt;.

lr_rtti_struc ?= cl_abap_structdescr=&amp;gt;describe_by_data( &amp;lt;fs&amp;gt; ).

* Now get the structure details into a table.
* table zogt[] contains the structure details
* From which we can build the field catalog

zogt[]  = lr_rtti_struc-&amp;gt;components.
LOOP AT zogt INTO zog.
  CLEAR wa_it_fldcat.
  wa_it_fldcat-fieldname = zog-name .
  wa_it_fldcat-datatype = zog-type_kind.
  wa_it_fldcat-inttype = zog-type_kind.
  wa_it_fldcat-intlen = zog-length.
  wa_it_fldcat-decimals = zog-decimals.
  wa_it_fldcat-coltext = zog-name.
  wa_it_fldcat-lowercase = 'X'.
  APPEND wa_it_fldcat TO it_fldcat .
ENDLOOP.
*
* You can perform any modifications / additions to your field catalog
* here such as your own column names etc.

* Now using the field catalog created above we can
* build a dynamic table
* and populate it

* First build the dynamic table
* the table will contain entries for
* our structure defined at the start of the program

CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
       EXPORTING
            it_fieldcatalog = it_fldcat
       IMPORTING
            ep_table = dy_table.


ASSIGN dy_table-&amp;gt;* TO &amp;lt;dyn_table&amp;gt;.
CREATE DATA dy_line LIKE LINE OF &amp;lt;dyn_table&amp;gt;.
ASSIGN dy_line-&amp;gt;* TO &amp;lt;dyn_wa&amp;gt;.

* Now fill our table with data

SELECT vbeln posnr matnr kunnr werks vkorg vkbur
       UP TO 200 ROWS
       FROM vapma
       INTO  CORRESPONDING FIELDS OF TABLE &amp;lt;dyn_table&amp;gt;.

* Call the screen to display the grid
CALL SCREEN 100.

* PBO module

MODULE status_0100 OUTPUT.

  IF grid_container1 IS INITIAL.
    CREATE OBJECT grid_container1
            EXPORTING
               container_name = 'CCONTAINER1'.
    CREATE OBJECT  grid1
       EXPORTING
          i_parent = grid_container1.
    struct_grid_lset-edit = 'X'.    "To enable editing in ALV

    CALL METHOD grid1-&amp;gt;set_table_for_first_display
      EXPORTING is_layout =  struct_grid_lset
      CHANGING
                 it_outtab       = &amp;lt;dyn_table&amp;gt;
                 it_fieldcatalog = it_fldcat.


  ENDIF.
  SET PF-STATUS '001'.
  SET TITLEBAR '000'.

ENDMODULE.

* PAI module

MODULE user_command_0100 INPUT.
  CASE sy-ucomm.
    WHEN 'BACK'.
      LEAVE PROGRAM.
    WHEN 'EXIT'.
      LEAVE PROGRAM.
    WHEN 'RETURN'.
      LEAVE PROGRAM.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I don't want to see people complaining about how difficult ALV grids are or even seeing them use the old Dinosaur SLIS modules.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;jimbo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2008 11:00:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list/m-p/3237914#M772679</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-09T11:00:13Z</dc:date>
    </item>
  </channel>
</rss>

