<?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: class method get_data in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-method-get-data/m-p/2551222#M580948</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@Sougata: Hey, no offense !!! I see your point, but I think Joanna's question had a different background.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Joanna: you're mostly welcome !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Jul 2007 09:06:18 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-07-17T09:06:18Z</dc:date>
    <item>
      <title>class method get_data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-method-get-data/m-p/2551216#M580942</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 have code like this:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      CLASS item DEFINITION&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      ........                                                      *&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;class item definition.&lt;/P&gt;&lt;P&gt;  public section.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;      methods:&lt;/P&gt;&lt;P&gt;    constructor importing matnr type matnr,&lt;/P&gt;&lt;P&gt;    write_result,&lt;/P&gt;&lt;P&gt;    get_data.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  protected section.&lt;/P&gt;&lt;P&gt;    data: matnr type matnr,&lt;/P&gt;&lt;P&gt;          maktx type maktx,&lt;/P&gt;&lt;P&gt;          groes type groes.&lt;/P&gt;&lt;P&gt;    methods: get_maktx,&lt;/P&gt;&lt;P&gt;             get_groes.&lt;/P&gt;&lt;P&gt;             &lt;/P&gt;&lt;P&gt;endclass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      CLASS item IMPLEMENTATION&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      ........                                                      *&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;class item implementation.&lt;/P&gt;&lt;P&gt;  method constructor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    me-&amp;gt;matnr = matnr.&lt;/P&gt;&lt;P&gt;    call method: get_maktx, get_groes.&lt;/P&gt;&lt;P&gt;    call method write_result.&lt;/P&gt;&lt;P&gt;  endmethod.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  method get_maktx.&lt;/P&gt;&lt;P&gt;    select single maktx&lt;/P&gt;&lt;P&gt;             from makt into maktx "(me-&amp;gt;maktx)&lt;/P&gt;&lt;P&gt;                      where matnr = matnr.&lt;/P&gt;&lt;P&gt;  endmethod.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  method get_groes.&lt;/P&gt;&lt;P&gt;    select single groes from mara into groes&lt;/P&gt;&lt;P&gt;                 where matnr = matnr.&lt;/P&gt;&lt;P&gt;  endmethod.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  method write_result.&lt;/P&gt;&lt;P&gt; write:/ matnr, maktx, groes.&lt;/P&gt;&lt;P&gt;    uline.&lt;/P&gt;&lt;P&gt;  endmethod.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;  method get_data.&lt;/P&gt;&lt;P&gt;     .&lt;/P&gt;&lt;P&gt;     .                 &lt;/P&gt;&lt;P&gt;     .&lt;/P&gt;&lt;P&gt;  endmethod.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;endclass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: o_ref type ref to item.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  create object o_ref&lt;/P&gt;&lt;P&gt;         exporting&lt;/P&gt;&lt;P&gt;              matnr = 'A103'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How change this code to create methode get_data which allows get to data outside of class and put it to table itab which will be used in another part of program? Thanks for help.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Joanna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 07:19:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-method-get-data/m-p/2551216#M580942</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-17T07:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: class method get_data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-method-get-data/m-p/2551217#M580943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joanna, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd think this would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;public section.
methods:
[...]
get_data 
   EXPORTING 
     e_matkx TYPE maktx
     e_groes TYPE groes.

[..]

CLASS item IMPLEMENTATION.

METHOD get_data.
   e_maktx = ME-&amp;gt;maktx.
   e_groes = ME-&amp;gt;groes.
ENDMETHOD.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Calling would be something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

types: begin of ty_mat_data,
            maktx type maktx,
            groes type groes,
          end of ty_mat_data.

data: o_ref type ref to item,
        gt_mat_data type standard table of ty_mat_data,
        gs_mat_data like line of gt_mat_data.


start-of-selection.

create object o_ref
exporting
matnr = 'A103'.

call method o_ref-&amp;gt;get_matkx.
call method o_ref-&amp;gt;get_groes.

call method o_ref-&amp;gt;get_data
   importing
     e_maktx = gs_mat_data-maktx
     e_groes = gs_mat_data-groes.

append gs_mat_data to gt_mat_data.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps&lt;/P&gt;&lt;P&gt;Frank&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 07:49:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-method-get-data/m-p/2551217#M580943</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-17T07:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: class method get_data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-method-get-data/m-p/2551218#M580944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joanna,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Under Public Section of the Class definition declare an iternal table and its corresponding work area.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PUBLIC SECTION.
    DATA: t_mat TYPE STANDARD TABLE OF mara,
          w_mat TYPE mara.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, in the Class Implementation section, follow as under: (Example only)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  METHOD get_data.
    SELECT * FROM mara
           INTO TABLE t_mat
           WHERE matnr = me-&amp;gt;matnr.
  ENDMETHOD.                    "get_data&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then later in the program if you want to use this data, see as under (E.g. only)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;START-OF-SELECTION.

 CREATE OBJECT o_ref .....
    ....................

  LOOP AT o_ref-&amp;gt;t_mat INTO o_ref-&amp;gt;w_mat.
    WRITE:/ o_ref-&amp;gt;w_mat-matnr,
            o_ref-&amp;gt;w_mat-ersda,
            o_ref-&amp;gt;w_mat-ernam.
  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't forget to reward points!&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;Sougata.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 08:11:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-method-get-data/m-p/2551218#M580944</guid>
      <dc:creator>Sougata</dc:creator>
      <dc:date>2007-07-17T08:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: class method get_data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-method-get-data/m-p/2551219#M580945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sougata,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can do it like that, but -with all respect due- it wouldn't make much sense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- You don't need an internal table of mara if you have only 1 material number.&lt;/P&gt;&lt;P&gt;- Making this internal table public would be against the OO principles of encapsulation. If so at all it should be "public read-only".&lt;/P&gt;&lt;P&gt;- If you want to pass an internal table in OO you have to define a table type in the dictionary, like ZMARA_T with line type mara or define it in a type pool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Frank&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 08:23:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-method-get-data/m-p/2551219#M580945</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-17T08:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: class method get_data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-method-get-data/m-p/2551220#M580946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Frank,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had posted the code as an &amp;lt;u&amp;gt;example&amp;lt;/u&amp;gt; for an internal table which is visible outside its implemented class; I think that was the original question. I realise its not a correct approach to OO and agree to your first 2 points. The coding approach in the original post was already incorrect and I didn't have time to try and correct the entire coding...instead I made minor changes to show how the internal table data can be accessed outside the implementing class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On your third point, however, I'm pretty sure that an internal table can be passed in OO without always creating its table type in the ABAP dictionary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sougata.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 08:49:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-method-get-data/m-p/2551220#M580946</guid>
      <dc:creator>Sougata</dc:creator>
      <dc:date>2007-07-17T08:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: class method get_data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-method-get-data/m-p/2551221#M580947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Frank,&lt;/P&gt;&lt;P&gt;Thanks for your help so much.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Joanna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 08:51:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-method-get-data/m-p/2551221#M580947</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-17T08:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: class method get_data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-method-get-data/m-p/2551222#M580948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@Sougata: Hey, no offense !!! I see your point, but I think Joanna's question had a different background.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Joanna: you're mostly welcome !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 09:06:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-method-get-data/m-p/2551222#M580948</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-17T09:06:18Z</dc:date>
    </item>
  </channel>
</rss>

