<?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: Append new column to internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120253#M444257</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi , &lt;/P&gt;&lt;P&gt;  I am not sure how  to add a new column to  an IT having entries , what i can suggest is use another IT which has this additional column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Arun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Apr 2007 08:27:51 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-04-02T08:27:51Z</dc:date>
    <item>
      <title>Append new column to internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120252#M444256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have an internal table that was generated based on an ddic structure - now i want to add a column to that table. how can i do that ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you!&lt;/P&gt;&lt;P&gt;clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2007 08:25:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120252#M444256</guid>
      <dc:creator>former_member5350</dc:creator>
      <dc:date>2007-04-02T08:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Append new column to internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120253#M444257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi , &lt;/P&gt;&lt;P&gt;  I am not sure how  to add a new column to  an IT having entries , what i can suggest is use another IT which has this additional column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Arun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2007 08:27:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120253#M444257</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-02T08:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Append new column to internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120254#M444258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;just add in the declaration part&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : begin of itab1 occurs 0.&lt;/P&gt;&lt;P&gt; include structure mara.&lt;/P&gt;&lt;P&gt; data : werks like marc-werks.&lt;/P&gt;&lt;P&gt;data : end of itab1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;shiba dutta&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2007 08:28:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120254#M444258</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-02T08:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Append new column to internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120255#M444259</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;types : begin of ty.&lt;/P&gt;&lt;P&gt;include structure mara.&lt;/P&gt;&lt;P&gt;types : new_field type c,&lt;/P&gt;&lt;P&gt;end of ty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : itab type standard table of ty,&lt;/P&gt;&lt;P&gt;         wa type ty.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2007 08:28:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120255#M444259</guid>
      <dc:creator>jayanthi_jayaraman</dc:creator>
      <dc:date>2007-04-02T08:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Append new column to internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120256#M444260</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;U can define ur Internal table as :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : begin of itab occurs 0.&lt;/P&gt;&lt;P&gt;         include structure &amp;lt;DDIC Structure&amp;gt;.&lt;/P&gt;&lt;P&gt;data : field definition,&lt;/P&gt;&lt;P&gt;end of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Himanshu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2007 08:28:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120256#M444260</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-02T08:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Append new column to internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120257#M444261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data : begin of itab occurs 0.&lt;/P&gt;&lt;P&gt;include structure &amp;lt;DDIC Structure&amp;gt;.&lt;/P&gt;&lt;P&gt;data : field definition,&lt;/P&gt;&lt;P&gt;end of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  itab-fieldname=value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append itab.&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;Regards,&lt;/P&gt;&lt;P&gt;Kalai&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2007 08:35:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120257#M444261</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-02T08:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: Append new column to internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120258#M444262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Best Method is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF &amp;lt;Internal Table Name&amp;gt; OCCURS 0.&lt;/P&gt;&lt;P&gt;          INCLUDE STRUCTURE &amp;lt;DDIC Strucuture Name&amp;gt;.&lt;/P&gt;&lt;P&gt;DATA: &amp;lt;Filed Name you want to add&amp;gt;  LIKE &amp;lt;Reference Field&amp;gt;&lt;/P&gt;&lt;P&gt;DATA: END OF &amp;lt;Internal Table Name&amp;gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2007 09:08:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120258#M444262</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-02T09:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Append new column to internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120259#M444263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi to all, thank you for your help! here is the code that i have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT *************_4 .


TYPE-POOLS : abap.

FIELD-SYMBOLS: &amp;lt;dyn_table&amp;gt; TYPE STANDARD TABLE,
               &amp;lt;dyn_wa&amp;gt;,
               &amp;lt;dyn_field&amp;gt;.

TYPE-POOLS: slis.
TABLES: dd03l, dd04t.

TYPES:
  BEGIN OF ty_table_struct,
    fieldname   TYPE dd03l-fieldname, " Tabellenname
    ddtext      TYPE dd04t-ddtext,    " Kurztext
    checkbox,
   END OF ty_table_struct.

DATA:t_fieldcat TYPE slis_t_fieldcat_alv,
     w_fieldcat TYPE slis_fieldcat_main.


DATA:
gt_table_struct TYPE TABLE OF ty_table_struct.

DATA: v_repid TYPE sy-repid.

DATA:

      dy_table TYPE REF TO data,
      dy_line  TYPE REF TO data,
      xfc TYPE lvc_s_fcat,
      ifc TYPE lvc_t_fcat,
      l_tab_fields TYPE STANDARD TABLE OF ty_table_struct,
      w_tab_fields LIKE LINE OF l_tab_fields.




SELECTION-SCREEN :
  SKIP, BEGIN OF LINE,COMMENT 5(28) v_1 FOR FIELD p_table.
PARAMETERS p_table TYPE dd03l-tabname OBLIGATORY VALUE CHECK.
SELECTION-SCREEN END OF LINE.



INITIALIZATION.
  v_1 = 'Tabelle für Dublettenprüfung'.
  v_repid = sy-repid.

START-OF-SELECTION.
  PERFORM f_read_data.
  PERFORM f_display_data.
  PERFORM get_structure.
  PERFORM create_dynamic_itab.
  PERFORM get_data.
  PERFORM write_out.


*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  get_structure
*&amp;amp;---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM get_structure.
  DATA : idetails TYPE abap_compdescr_tab,
         xdetails TYPE abap_compdescr.

  DATA : ref_table_des TYPE REF TO cl_abap_structdescr.

* Get the structure of the table.

  ref_table_des ?=
      cl_abap_typedescr=&amp;gt;describe_by_name( p_table ).
  idetails[] = ref_table_des-&amp;gt;components[].

  LOOP AT idetails INTO xdetails.
    READ TABLE l_tab_fields INTO w_tab_fields
    WITH KEY fieldname = xdetails-name.
    IF sy-subrc = 0.
      CLEAR xfc.
      xfc-fieldname = xdetails-name.
      xfc-datatype = xdetails-type_kind.
      xfc-inttype = xdetails-type_kind.
      xfc-intlen = xdetails-length.
      xfc-decimals = xdetails-decimals.
      APPEND xfc TO ifc.
    ENDIF.
  ENDLOOP.


ENDFORM.                    "get_structure



*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  create_dynamic_itab
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM create_dynamic_itab.

* Create dynamic internal table and assign to FS
  CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
    EXPORTING
      it_fieldcatalog = ifc
    IMPORTING
      ep_table        = dy_table.

  ASSIGN dy_table-&amp;gt;* TO &amp;lt;dyn_table&amp;gt;.

* Create dynamic work area and assign to FS

  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;.

ENDFORM.                    "create_dynamic_itab




*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  get_data
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM get_data.

* Select Data from table.
  SELECT (l_tab_fields) INTO CORRESPONDING FIELDS OF TABLE &amp;lt;dyn_table&amp;gt;
             FROM (p_table).

ENDFORM.                    "get_data

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  write_out
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM write_out.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
            i_program_name         = v_repid
            i_structure_name       = p_table
       CHANGING
            ct_fieldcat            = t_fieldcat
       EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.
  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.



* Show only fields that are needed

  LOOP AT t_fieldcat INTO w_fieldcat.
    READ TABLE l_tab_fields INTO w_tab_fields
    WITH KEY fieldname = w_fieldcat-fieldname.
    IF sy-subrc &amp;lt;&amp;gt; 0.
           DELETE t_fieldcat.
    ENDIF.
  ENDLOOP.
   
  w_fieldcat-tabname = '&amp;lt;dyn_table&amp;gt;'.
  w_fieldcat-fieldname = 'NETPR'.
  w_fieldcat-seltext_m = 'Net Price'.
  w_fieldcat-outputlen = 15.
  w_fieldcat-col_pos = 10.

*  w_fieldcat-do_sum = 'X'. "Display column total
  w_fieldcat-datatype = 'CURR'.
  append w_fieldcat to t_fieldcat.
 
 

* Write out data from table.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            it_fieldcat   = t_fieldcat
            I_BYPASSING_BUFFER = 'X'

       TABLES
            t_outtab      = &amp;lt;dyn_table&amp;gt;
       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.                    "write_out

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  f_read_data
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM f_read_data.
  SELECT * FROM ( dd03l
            INNER JOIN dd04t
            ON  dd03l~rollname = dd04t~rollname
            AND dd04t~ddlanguage = syst-langu
            AND dd04t~as4local = 'A' ) INTO CORRESPONDING FIELDS OF
TABLE
  gt_table_struct WHERE dd03l~tabname = p_table .
ENDFORM.                               " F_READ_DATA

*---------------------------------------------------------------------*
*      Form  f_display_data
*---------------------------------------------------------------------*
FORM f_display_data.

* Macro definition

  DEFINE m_fieldcat.
    add 1 to ls_fieldcat-col_pos.
    ls_fieldcat-fieldname   = &amp;amp;1.
    ls_fieldcat-ref_tabname = &amp;amp;2.
    ls_fieldcat-rollname = &amp;amp;3.
    append ls_fieldcat to lt_fieldcat.
  END-OF-DEFINITION.

  TYPE-POOLS: slis.                    " ALV Global types

  DATA:
    l_exit,
    ls_private  TYPE slis_data_caller_exit,
    ls_field    TYPE ty_table_struct,
    ls_fieldcat TYPE slis_fieldcat_alv,
    lt_fieldcat TYPE slis_t_fieldcat_alv.

* Build the field catalog
  m_fieldcat 'FIELDNAME' 'ty_table_struct' 'FIELDNAME'.
  m_fieldcat 'DDTEXT'    'ty_table_struct' 'DDTEXT'.

* Optimize column width
  ls_private-columnopt = 'X'.

* Display data in a popup

  CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
       EXPORTING
            i_selection          = 'X'
            i_zebra              = 'X'
            it_fieldcat          = lt_fieldcat
            i_tabname            = 'gt_table_struct'
            i_checkbox_fieldname = 'CHECKBOX'
            is_private           = ls_private
       IMPORTING
            e_exit               = l_exit
       TABLES
            t_outtab             = gt_table_struct.

  CHECK l_exit = space.

* write selected columns to the internal table for inclusion
* into fieldcat

  LOOP AT gt_table_struct INTO ls_field WHERE checkbox = 'X'.
    APPEND ls_field-fieldname TO l_tab_fields.
  ENDLOOP.

ENDFORM.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What &lt;B&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;i want it to&lt;/P&gt; do is, &lt;B&gt;&lt;P&gt;have the alvgrid displaying the fields from t_fieldcat&lt;/P&gt;&lt;/B&gt;, &lt;B&gt;&lt;P&gt;plus&lt;/P&gt;&lt;/B&gt; some &lt;B&gt;&lt;P&gt;fields&lt;/P&gt;&lt;/B&gt; ( that should be appended to the internal table before, i think ? ). What went wrong ?&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2007 09:48:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-new-column-to-internal-table/m-p/2120259#M444263</guid>
      <dc:creator>former_member5350</dc:creator>
      <dc:date>2007-04-02T09:48:38Z</dc:date>
    </item>
  </channel>
</rss>

