<?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 Create Fieldcatalog based on internal table (dynamic) in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-fieldcatalog-based-on-internal-table-dynamic/m-p/2030170#M416544</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;Is there a way to create Create Fieldcatalog based on internal table (dynamic).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while creating fieldcat we usually many give the fields "fieldname" and "tabname".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is there a way to get the fieldname from the main table ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg ..&lt;/P&gt;&lt;P&gt; I have i_tab as the output table. It has 3 fields "a", "b" and "c"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now when i created fieldcat manually ( in case i cannot use fieldcat_merge FM) , i have to append 3 throws in fieldcat table.&lt;/P&gt;&lt;P&gt;These rows would have "a", "b" and "c".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now i want to know if there is a way in which i can find "a" "b" and "c" fieldnames from the createdd internal tables.&lt;/P&gt;&lt;P&gt;i can then append the same to fieldcat.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Mar 2007 10:09:10 GMT</pubDate>
    <dc:creator>former_member422911</dc:creator>
    <dc:date>2007-03-20T10:09:10Z</dc:date>
    <item>
      <title>Create Fieldcatalog based on internal table (dynamic)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-fieldcatalog-based-on-internal-table-dynamic/m-p/2030170#M416544</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;Is there a way to create Create Fieldcatalog based on internal table (dynamic).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while creating fieldcat we usually many give the fields "fieldname" and "tabname".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is there a way to get the fieldname from the main table ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg ..&lt;/P&gt;&lt;P&gt; I have i_tab as the output table. It has 3 fields "a", "b" and "c"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now when i created fieldcat manually ( in case i cannot use fieldcat_merge FM) , i have to append 3 throws in fieldcat table.&lt;/P&gt;&lt;P&gt;These rows would have "a", "b" and "c".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now i want to know if there is a way in which i can find "a" "b" and "c" fieldnames from the createdd internal tables.&lt;/P&gt;&lt;P&gt;i can then append the same to fieldcat.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2007 10:09:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-fieldcatalog-based-on-internal-table-dynamic/m-p/2030170#M416544</guid>
      <dc:creator>former_member422911</dc:creator>
      <dc:date>2007-03-20T10:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create Fieldcatalog based on internal table (dynamic)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-fieldcatalog-based-on-internal-table-dynamic/m-p/2030171#M416545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi anuj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   Yes u can do that&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;chk this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**&lt;STRONG&gt;DYNAMIC CREATION OF FIELDCATALOG&lt;/STRONG&gt;***************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*FIRST 2 FIELDS FIELDS FIELD1 AND FIELD2 ARE CONSTANT, FIELDS OBTAINED IN THE LOOP ENDLOOP ARE DYNAMIC,&lt;/P&gt;&lt;P&gt;*LIKEWISE DYNAMIC FIELDCATALOG IS CREATED&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  wa_fieldcatalog-fieldname  = 'FIELD1'.
  wa_fieldcatalog-ref_table  = 'E070'.
  wa_fieldcatalog-outputlen  = '13'.
  wa_fieldcatalog-reptext    = 'Created On'.
  wa_fieldcatalog-seltext    = 'Created On'.
  APPEND wa_fieldcatalog TO it_fieldcatalog.
  CLEAR wa_fieldcatalog.
  
  wa_fieldcatalog-fieldname  = 'FIELD1'.
  wa_fieldcatalog-ref_table  = 'E070'.
  wa_fieldcatalog-outputlen  = '13'.
  wa_fieldcatalog-reptext    = 'Created On'.
  wa_fieldcatalog-seltext    = 'Created On'.
  APPEND wa_fieldcatalog TO it_fieldcatalog.
  CLEAR wa_fieldcatalog.


  LOOP AT it_mandt WHERE mandt IN s_mandt.
    CONCATENATE 'CLNT' it_mandt INTO wa_fieldcatalog-fieldname.
    wa_fieldcatalog-inttype    = 'NUMC'.
    wa_fieldcatalog-outputlen  = '14'.
    wa_fieldcatalog-reptext    = it_mandt.
    wa_fieldcatalog-seltext    = it_mandt.

    APPEND wa_fieldcatalog TO it_fieldcatalog.
    CLEAR :wa_fieldcatalog ,it_mandt.
  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2007 10:12:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-fieldcatalog-based-on-internal-table-dynamic/m-p/2030171#M416545</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-20T10:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create Fieldcatalog based on internal table (dynamic)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-fieldcatalog-based-on-internal-table-dynamic/m-p/2030172#M416546</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;Sorry but this does not answer the question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Anuj.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2007 10:17:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-fieldcatalog-based-on-internal-table-dynamic/m-p/2030172#M416546</guid>
      <dc:creator>former_member422911</dc:creator>
      <dc:date>2007-03-20T10:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create Fieldcatalog based on internal table (dynamic)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-fieldcatalog-based-on-internal-table-dynamic/m-p/2030173#M416547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Anuj , &lt;/P&gt;&lt;P&gt;You can get the field names in the intenal table by using FM &lt;/P&gt;&lt;P&gt; CALL FUNCTION 'DDIF_TABL_GET'&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      name          = u_con_name_ldb_struc&lt;/P&gt;&lt;P&gt;    TABLES&lt;/P&gt;&lt;P&gt;      dd03p_tab     = lt_dd03p&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      illegal_input = 1&lt;/P&gt;&lt;P&gt;      OTHERS        = 2.&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno&lt;/P&gt;&lt;P&gt;            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;You can use the internal table lt_dd03p to create field catalog ..&lt;/P&gt;&lt;P&gt;Is this wht u r lloking for ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2007 10:28:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-fieldcatalog-based-on-internal-table-dynamic/m-p/2030173#M416547</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-20T10:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create Fieldcatalog based on internal table (dynamic)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-fieldcatalog-based-on-internal-table-dynamic/m-p/2030174#M416548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anuj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I created a FORM routine for this 4 or 5 years ago and made a couple of refinements. Meanwhile it has prooved as very useful. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The disadvantag is that it creates the oldfashioned field catalog for the function calls. But I already used it for OO fieldcatalog of LVC type - there is a function module for this but I do not have the name here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need the two forms (second called in first) to build the field catalog from any internal table that can be used for ALV display.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  ALV_FIELDCAT_FOR_ITAB
*&amp;amp;---------------------------------------------------------------------*
*       Feldkatalog from (arbitrary) internal Table (c) Clemens Li
*       * build field catalog from        type description
*----------------------------------------------------------------------*
form alv_fieldcat_for_itab                                  "#EC *
  tables   pt_outtab                      type table        "#EC *
  changing pt_alv_fieldcat                type slis_t_fieldcat_alv."#EC *
  data:
    lv_desc                               type sydes_desc,
    ls_alv_fieldcat                       type slis_fieldcat_alv,
    lv_longfield                          type text80."CRM&amp;lt;=R/3 fname.
  field-symbols:
    &amp;lt;typeinfo&amp;gt;                            type sydes_typeinfo,
    &amp;lt;nameinfo&amp;gt;                            type sydes_nameinfo.
  describe field pt_outtab into lv_desc.                    "#EC *

  loop at lv_desc-types
      assigning &amp;lt;typeinfo&amp;gt;
      where not idx_name is initial
        and table_kind is initial "no entries for deep table like color
        and back                          = 1. "top-level-entries only.
    read table lv_desc-names index &amp;lt;typeinfo&amp;gt;-idx_name
      assigning &amp;lt;nameinfo&amp;gt;.
    check &amp;lt;nameinfo&amp;gt;-name                 &amp;lt;&amp;gt; 'INCLUDE'.
    ls_alv_fieldcat-fieldname             = &amp;lt;nameinfo&amp;gt;-name.
    while not &amp;lt;nameinfo&amp;gt;-continue is initial.
      add 1 to &amp;lt;typeinfo&amp;gt;-idx_name.
      read table lv_desc-names index &amp;lt;typeinfo&amp;gt;-idx_name
        assigning &amp;lt;nameinfo&amp;gt;.
      concatenate
        ls_alv_fieldcat-fieldname
        &amp;lt;nameinfo&amp;gt;-name
        into ls_alv_fieldcat-fieldname.
    endwhile." not &amp;lt;nameinfo&amp;gt;-continue IS INITIAL.
    read table lv_desc-names index &amp;lt;typeinfo&amp;gt;-idx_help_id
      assigning &amp;lt;nameinfo&amp;gt;.
    if sy-subrc                           = 0.

* Caution: Help-ID may be Tablename-Fieldname and thus longer
* than 30 Chars; ls_alv_fieldcat-rollname is 30 Chars only
      ls_alv_fieldcat-rollname            = &amp;lt;nameinfo&amp;gt;-name.
      lv_longfield                        = &amp;lt;nameinfo&amp;gt;-name.
      while not &amp;lt;nameinfo&amp;gt;-continue is initial.
        add 1 to &amp;lt;typeinfo&amp;gt;-idx_help_id.
        read table lv_desc-names index &amp;lt;typeinfo&amp;gt;-idx_help_id
          assigning &amp;lt;nameinfo&amp;gt;.
        concatenate
          lv_longfield
          &amp;lt;nameinfo&amp;gt;-name
          into lv_longfield.
      endwhile." not lv_desc-continue is initial.

* help id may be data element or &amp;lt;table&amp;gt;-&amp;lt;field&amp;gt;
      if lv_longfield ca '-'.

* get data                                type for table field
        perform get_rollname_4_tabfield
          using lv_longfield changing ls_alv_fieldcat.
      endif." lv_longfield ca '-'.
    else.

* No Help-ID: Use Fieldname as text
      ls_alv_fieldcat-seltext_s           =
      ls_alv_fieldcat-seltext_m           =
      ls_alv_fieldcat-seltext_l           =
      ls_alv_fieldcat-reptext_ddic        =
      &amp;lt;nameinfo&amp;gt;-name.
    endif." sy-subrc                      = 0.

* Starting 4.7: get edit mask
    if not &amp;lt;typeinfo&amp;gt;-idx_edit_mask is initial.
      read table lv_desc-names index &amp;lt;typeinfo&amp;gt;-idx_edit_mask
        assigning &amp;lt;nameinfo&amp;gt;.
      ls_alv_fieldcat-edit_mask           = &amp;lt;nameinfo&amp;gt;-name.
      if not &amp;lt;nameinfo&amp;gt;-continue is initial.
        add 1 to &amp;lt;typeinfo&amp;gt;-idx_edit_mask.
        read table lv_desc-names index &amp;lt;typeinfo&amp;gt;-idx_edit_mask
          assigning &amp;lt;nameinfo&amp;gt;.
        concatenate
          ls_alv_fieldcat-edit_mask
          &amp;lt;nameinfo&amp;gt;-name
          into ls_alv_fieldcat-edit_mask.
      endif." not &amp;lt;nameinfo&amp;gt;-continue IS INITIAL.
    endif." not &amp;lt;typeinfo&amp;gt;-IDX_EDIT_MASK is initial.

* assign length, output length and decimals
    ls_alv_fieldcat-intlen                = &amp;lt;typeinfo&amp;gt;-length.
    ls_alv_fieldcat-outputlen             = &amp;lt;typeinfo&amp;gt;-output_length.
    ls_alv_fieldcat-decimals_out          = &amp;lt;typeinfo&amp;gt;-decimals.
    ls_alv_fieldcat-inttype               = &amp;lt;typeinfo&amp;gt;-type.
    append ls_alv_fieldcat to pt_alv_fieldcat.
    clear:  "prevent anything 2 B  taken for subsequent fields
      ls_alv_fieldcat.
  endloop." at lv_desc-types where not IDX_NAME is in initial.
endform.                    " ALV_FIELDCAT_FOR_ITAB


*&amp;amp;---------------------------------------------------------------------
*&amp;amp;      Form  get_rollname_4_tabfield
*&amp;amp;---------------------------------------------------------------------
*       Get Data                          type for Table field
*----------------------------------------------------------------------
form get_rollname_4_tabfield
  using    p_fname                        type text80 ""CRM&amp;lt;=R/3 fname
  changing p_alv_fieldcat                 type slis_fieldcat_alv.
  field-symbols:
    &amp;lt;dfies&amp;gt;                               type dfies.
  data:
    lv_tabname                            type tabname,
     lt_dfies                             type table of dfies,
    lv_fieldname                          type fieldname.
  split p_fname at '-'
    into lv_tabname lv_fieldname.
  clear p_alv_fieldcat-rollname.
  call function 'DDIF_FIELDINFO_GET'
    exporting
      tabname                             = lv_tabname
      fieldname                           = lv_fieldname
*   LANGU                                 = SY-LANGU
*   LFIELDNAME                            = ' '
*   ALL_TYPES                             = ' '
* IMPORTING
*   X030L_WA                              =
*   DDOBJTYPE                             =
*   DFIES_WA                              =
*   LINES_DESCR                           =
   tables
     dfies_tab                            =  lt_dfies
*   FIXED_VALUES                          =
   exceptions
     not_found                            = 1
     internal_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.
  else.
    read table   lt_dfies assigning &amp;lt;dfies&amp;gt; index 1.
    p_alv_fieldcat-rollname               = &amp;lt;dfies&amp;gt;-rollname.
* Und wenn keinerlei Twexte gepflegt sind?
    if &amp;lt;dfies&amp;gt;-reptext is initial and
       &amp;lt;dfies&amp;gt;-scrtext_s is initial and
       &amp;lt;dfies&amp;gt;-scrtext_m is initial and
       &amp;lt;dfies&amp;gt;-scrtext_l is initial.
* No Text: Use Fieldname as text
      p_alv_fieldcat-seltext_s            =
      p_alv_fieldcat-seltext_m            =
      p_alv_fieldcat-seltext_l            =
      p_alv_fieldcat-reptext_ddic         =
      p_alv_fieldcat-fieldname.
    endif." &amp;lt;dfies&amp;gt;-reptext IS INITIAL AND
  endif.
endform.                    " get_rollname_4_tabfield

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2007 11:28:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-fieldcatalog-based-on-internal-table-dynamic/m-p/2030174#M416548</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2007-03-20T11:28:17Z</dc:date>
    </item>
  </channel>
</rss>

