<?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 Routine from FORM -ENDFORM to METHOD in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/routine-from-form-endform-to-method/m-p/1769225#M332269</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi friends,&lt;/P&gt;&lt;P&gt;can anyone give the idea of changing FORM-ENDFORM code &lt;/P&gt;&lt;P&gt;to METHOD-ENDMETHOD&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if required i will give my code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;P&gt;raj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 09 Dec 2006 07:52:14 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-12-09T07:52:14Z</dc:date>
    <item>
      <title>Routine from FORM -ENDFORM to METHOD</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/routine-from-form-endform-to-method/m-p/1769225#M332269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi friends,&lt;/P&gt;&lt;P&gt;can anyone give the idea of changing FORM-ENDFORM code &lt;/P&gt;&lt;P&gt;to METHOD-ENDMETHOD&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if required i will give my code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;P&gt;raj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Dec 2006 07:52:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/routine-from-form-endform-to-method/m-p/1769225#M332269</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-12-09T07:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: Routine from FORM -ENDFORM to METHOD</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/routine-from-form-endform-to-method/m-p/1769226#M332270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Raj&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In general, you can transfer most of the coding possible in FORMs to methods. However, itabs with header lines must be replaced by table types, e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:
  ls_line     TYPE &amp;lt;tablename&amp;gt;,
  lt_itab     TYPE STANDARD TABLE of &amp;lt;tablename&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Certain statements are not allowed in methods, e.g. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL SCREEN&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;. If your original FORM called a screen then you have to move the CALL SCREEN statement to a function module and call this function module within your method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your original FORM contains USING and CHANGING parameters you have to define the corresponding IMPORTING and EXPORTING / CHANGING parameters in the method. Again, "itab" parameters must be defines as table types. If your FORM returned a single parameter then you can define a RETURNING parameter in your method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, like fields only exists in the context of a table (or structure) methods only exist in the context of a class. Thus, you have to define your class in the class builder (SE24) or, alternatively, define it as local class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a simple example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FORM routine USING
                         ud_matnr   TYPE matnr
              CHANGING
                         cs_mara    TYPE mara.
  
  CLEAR: cs_mara.
  SELECT SINGLE * FROM mara INTO cs_mara.

ENDFORM.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;METHOD read_single_material
  IMPORTING
    id_matnr   TYPE matnr
  RETURNING
    rs_mara    TYPE mara.

  SELECT SINGLE * FROM mara INTO rs_mara.

ENDMETHOD.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Dec 2006 09:11:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/routine-from-form-endform-to-method/m-p/1769226#M332270</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2006-12-09T09:11:52Z</dc:date>
    </item>
  </channel>
</rss>

