<?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 field into internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-field-into-internal-table/m-p/12767928#M2022871</link>
    <description>&lt;P&gt;Do use the CODE button in the editor, it makes things so much easier for everyone else.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM aufm INTO TABLE @DATA(it_aufm) WHERE aufnr = @wa_mseg-aufnr AND werks = @wa_mseg-werks.

TYPES: BEGIN OF zitab_aufm,
  include TYPE aufm,
  zperiod TYPE mseg-gjahr.
TYPES END OF zitab_aufm.

DATA: final_it_aufm TYPE STANDARD TABLE OF zitab_aufm, " Goods movements for order
      temp_it_aufm TYPE zitab_aufm, " Goods movements for order
      wa_it_aufm TYPE zitab_aufm.

"Built internal table
LOOP AT it_aufm into wa_it_aufm.
  CASE wa_it_aufm-shkzg.
    WHEN 'H'.
      wa_it_aufm-dmbtr = wa_it_aufm-dmbtr * -1.
      wa_it_aufm-menge = wa_it_aufm-menge * -1.
      wa_it_aufm-erfmg = wa_it_aufm-erfmg * -1.
  ENDCASE.
  MOVE-CORRESPONDING wa_it_aufm TO temp_it_aufm.
  APPEND temp_it_aufm TO final_it_aufm.
ENDLOOP.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;See?&lt;/P&gt;&lt;P&gt;You've defined a field in your type with the name "INCLUDE" which has as its components the fields of AUFM.&lt;/P&gt;&lt;P&gt;You've clearly done a pretty print, and include is lower case. That should be a clue that you've done something wrong.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jul 2023 09:21:23 GMT</pubDate>
    <dc:creator>matt</dc:creator>
    <dc:date>2023-07-19T09:21:23Z</dc:date>
    <item>
      <title>Append field into internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-field-into-internal-table/m-p/12767924#M2022867</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt;i am trying to build a new internal table by adding new field into it because standard table doesn't exist.&lt;/P&gt; SELECT * FROM aufm INTO TABLE @DATA(it_aufm) WHERE aufnr = @wa_mseg-aufnr AND werks = @wa_mseg-werks.
  &lt;BR /&gt;
  &lt;BR /&gt; TYPES: BEGIN OF zitab_aufm,
  &lt;BR /&gt; include TYPE aufm,
  &lt;BR /&gt; zperiod TYPE mseg-gjahr.
  &lt;BR /&gt; TYPES END OF zitab_aufm.
  &lt;BR /&gt;
  &lt;BR /&gt; DATA: final_it_aufm TYPE STANDARD TABLE OF zitab_aufm, " Goods movements for order
  &lt;BR /&gt; temp_it_aufm TYPE zitab_aufm, " Goods movements for order
  &lt;BR /&gt; wa_it_aufm TYPE zitab_aufm.
  &lt;BR /&gt;
  &lt;BR /&gt; "Built internal table
  &lt;BR /&gt; LOOP AT it_aufm into wa_it_aufm.
  &lt;BR /&gt; CASE wa_it_aufm-shkzg.
  &lt;BR /&gt; WHEN 'H'.
  &lt;BR /&gt; wa_it_aufm-dmbtr = wa_it_aufm-dmbtr * -1.
  &lt;BR /&gt; wa_it_aufm-menge = wa_it_aufm-menge * -1.
  &lt;BR /&gt; wa_it_aufm-erfmg = wa_it_aufm-erfmg * -1.
  &lt;BR /&gt; ENDCASE.
  &lt;BR /&gt; MOVE-CORRESPONDING wa_it_aufm TO temp_it_aufm.
  &lt;BR /&gt; APPEND temp_it_aufm TO final_it_aufm.
  &lt;BR /&gt;
  &lt;P&gt; ENDLOOP.&lt;/P&gt;
  &lt;P&gt;but work area &lt;STRONG&gt;wa_it_aufm&lt;/STRONG&gt; doesn't recognize these fields.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2184768-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;Please help.&lt;/P&gt;
  &lt;P&gt;Regards,&lt;/P&gt;
  &lt;P&gt;RTN&lt;/P&gt;
  &lt;P&gt; SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; }.L0S31 { font-style: italic; color: #808080; }.L0S32 { color: #3399FF; }.L0S33 { color: #4DA619; }.L0S52 { color: #0000FF; }.L0S55 { color: #800080; }.L0S70 { color: #808080; }&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 08:42:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-field-into-internal-table/m-p/12767924#M2022867</guid>
      <dc:creator>ratana_pouy</dc:creator>
      <dc:date>2023-07-19T08:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Append field into internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-field-into-internal-table/m-p/12767925#M2022868</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;ratana.pouy&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;There is an issue with the way you defined the complex type. Try to define it this way:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;types: begin of zitab_aufm.
   include type aufm.
   types: zperiod type mseg-gjahr.
types end of zitab_aufm.&amp;lt;br&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;To access the variant SHKZG in your current code, you need to reference it as wa_it_aufm-include-shkzg (because of the way you defined the complex type).&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bohdan&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 08:58:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-field-into-internal-table/m-p/12767925#M2022868</guid>
      <dc:creator>Bohdan</dc:creator>
      <dc:date>2023-07-19T08:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: Append field into internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-field-into-internal-table/m-p/12767926#M2022869</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;TYPES:
  BEGIN OF zitab_aufm,  
    aufm  TYPE aufm,
    zperiod TYPE mseg-gjahr,  
  END OF zitab_aufm.

DATA: s_itab_aufm TYPE zitab_aufm.
WRITE s_itab_aufm-aufm-shkzg.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jul 2023 09:03:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-field-into-internal-table/m-p/12767926#M2022869</guid>
      <dc:creator>thkolz</dc:creator>
      <dc:date>2023-07-19T09:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Append field into internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-field-into-internal-table/m-p/12767927#M2022870</link>
      <description>&lt;P&gt;See the color of "include" which is black instead of blue.&lt;/P&gt;&lt;P&gt;black means a component named "include". Blue would mean that it's the ABAP statement INCLUDE TYPE.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2185766-image.png" /&gt;&lt;/P&gt;&lt;P&gt;Obviously, the comma above must be replaced with a dot.&lt;/P&gt;&lt;P&gt;Avoid using INCLUDE TYPE wherever possible (see Thorsten solution).&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 09:17:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-field-into-internal-table/m-p/12767927#M2022870</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-07-19T09:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Append field into internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-field-into-internal-table/m-p/12767928#M2022871</link>
      <description>&lt;P&gt;Do use the CODE button in the editor, it makes things so much easier for everyone else.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM aufm INTO TABLE @DATA(it_aufm) WHERE aufnr = @wa_mseg-aufnr AND werks = @wa_mseg-werks.

TYPES: BEGIN OF zitab_aufm,
  include TYPE aufm,
  zperiod TYPE mseg-gjahr.
TYPES END OF zitab_aufm.

DATA: final_it_aufm TYPE STANDARD TABLE OF zitab_aufm, " Goods movements for order
      temp_it_aufm TYPE zitab_aufm, " Goods movements for order
      wa_it_aufm TYPE zitab_aufm.

"Built internal table
LOOP AT it_aufm into wa_it_aufm.
  CASE wa_it_aufm-shkzg.
    WHEN 'H'.
      wa_it_aufm-dmbtr = wa_it_aufm-dmbtr * -1.
      wa_it_aufm-menge = wa_it_aufm-menge * -1.
      wa_it_aufm-erfmg = wa_it_aufm-erfmg * -1.
  ENDCASE.
  MOVE-CORRESPONDING wa_it_aufm TO temp_it_aufm.
  APPEND temp_it_aufm TO final_it_aufm.
ENDLOOP.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;See?&lt;/P&gt;&lt;P&gt;You've defined a field in your type with the name "INCLUDE" which has as its components the fields of AUFM.&lt;/P&gt;&lt;P&gt;You've clearly done a pretty print, and include is lower case. That should be a clue that you've done something wrong.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 09:21:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-field-into-internal-table/m-p/12767928#M2022871</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2023-07-19T09:21:23Z</dc:date>
    </item>
  </channel>
</rss>

