<?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: Using Parentheses to Call a Method? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-parentheses-to-call-a-method/m-p/6636945#M1442812</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great answers! From the naming convention tips, to the syntax suggestions! Thank-You All!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 04 Feb 2010 15:20:29 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-02-04T15:20:29Z</dc:date>
    <item>
      <title>Using Parentheses to Call a Method?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-parentheses-to-call-a-method/m-p/6636939#M1442806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So my code looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: o_ztransload_tools TYPE REF TO zcl_transload_toolbox.

           CREATE OBJECT o_ztransload_tools.

         o_ztransload_tools-&amp;gt;zzcreate_date_range( zzobjin_dtlw    = zzin_dtlw 
                                                  zzobjin_dthigh  = zzin_dthigh )  .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This class method returns a date range. I would like to understand how to write this code without using the 'IMPORT' 'EXPORT' , parameter identifiers...if possible., and just using parentheses, as a shorthand way of writing the call method. So, from what I've read, it is possible to write the code this way.But when I try to add code for the single returning value, I get syntax errors.  How should the code be written for the method's returning value to be syntactically correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    Thank-You, Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Feb 2010 20:15:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-parentheses-to-call-a-method/m-p/6636939#M1442806</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-02-03T20:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using Parentheses to Call a Method?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-parentheses-to-call-a-method/m-p/6636940#M1442807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have one necessary import parameter and one returning parameter you can call the method java / c# style.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;l_day = lr_object-&amp;gt;get_day_from_date( SY-DATUM ).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Feb 2010 21:14:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-parentheses-to-call-a-method/m-p/6636940#M1442807</guid>
      <dc:creator>rb</dc:creator>
      <dc:date>2010-02-03T21:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using Parentheses to Call a Method?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-parentheses-to-call-a-method/m-p/6636941#M1442808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Halo Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For your information there can only be one returning parameter for a method and that too will be set optional flag automatically&lt;/P&gt;&lt;P&gt;So your code should be like &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a part of SAP standard naming convention &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use lr_ for class reference variables&lt;/P&gt;&lt;P&gt;Use l_ for normal variables&lt;/P&gt;&lt;P&gt;Use lx_ for exception reference variables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please dont use zz for method names ( as it is not mandatory to start with Z for method names )&lt;/P&gt;&lt;P&gt;and use i_* for importing parameters &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So your code will have more clarity like below &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; DATA: lr_transload_tools TYPE REF TO zcl_transload_toolbox.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;           CREATE OBJECT lr_transload_tools.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;         l_transload_tools-&amp;gt;create_date_range( i_objin_dtlw    = in_dtlw &lt;/P&gt;&lt;P&gt;                                                                        i_ objin_dthigh  =in_dthigh )  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Feb 2010 04:43:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-parentheses-to-call-a-method/m-p/6636941#M1442808</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-02-04T04:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using Parentheses to Call a Method?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-parentheses-to-call-a-method/m-p/6636942#M1442809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can write the code without using the IMPORTING Parameters in the following manner: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IMPORTING Parameter - If it is used in the class as NON - OPTIONAL or OPTIONAL Parameter &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example :&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; 
DATA : lr_test TYPE REF TO ZCLASS_TEST_001. 
data : lv_name(20) TYPE c. 
create OBJECT lr_test. 


lr_test-&amp;gt;call_me( name = lv_name 
                  ret_name = lv_name  ). 

WRITE : lv_name.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Samantak.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Samantak Chatterjee on Feb 4, 2010 2:45 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Feb 2010 09:15:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-parentheses-to-call-a-method/m-p/6636942#M1442809</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-02-04T09:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using Parentheses to Call a Method?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-parentheses-to-call-a-method/m-p/6636943#M1442810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Perhaps your class method definition must be incorrect. Make sure that you have a parameter of type "RETURNING"  and not "EXPORTING". Only then you can assign a method call on the RHS to a variable directly on the LHS .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
class lcl_class1 definition.
public section.
methods m1 importing i_input type i 
                  returning value(r_output) type i.

endclass.

class lcl_class1 implementation.
 method m1.
    r_output = i_input.
 endmethod.
endclass.

start-of-selection.

data ref_class1 type ref to lcl_class1.
data input type i value '10'.
data result type i.

create object ref_class.

result = ref_class-&amp;gt;m1( input ).

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this is a global class, simple use the returning parameter and make sure to tick the Pass value checkbox.&lt;/P&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;Br,&lt;/P&gt;&lt;P&gt;Advait&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Feb 2010 09:33:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-parentheses-to-call-a-method/m-p/6636943#M1442810</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-02-04T09:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using Parentheses to Call a Method?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-parentheses-to-call-a-method/m-p/6636944#M1442811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There would a several different combinations you may have to use depending on the type of parameters.&lt;/P&gt;&lt;P&gt;If you have a single RETURNING parameter and single IMPORTING parameter, you can receive the results in that variable directly. Llike:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  lv_Day = zcl_Test=&amp;gt;give_day( sy-datum ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have multiple Importing parameters, you call the method like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
zcl_test=&amp;gt;get_data( 
  io_data = o_data
  io_data2 = o_data ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also set the the preferred parameter, when you have more than one importing parameter. Like IO_DATA and IO_DATA2. If make the preferred parameter as the IO_DATA2, than you can use pass this parameter without specifying parameter name.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  zcl_test=&amp;gt;get_Data( o_data_second ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have importing, exporting, changing parameters; than you have to explicitly mention the word EXPORTING, IMPORTING ... etc to let the system know what to change&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  zcl_test_alv=&amp;gt;factory(
    EXPORTING
      iv_alv_type = alv_1
    IMPORTING
      eo_alv = me-&amp;gt;o_alv
    changing
      ct_Data = t_Data ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can't have Receiving parameter along with Changing and Exporting parameters in the same method. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Feb 2010 15:01:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-parentheses-to-call-a-method/m-p/6636944#M1442811</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2010-02-04T15:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using Parentheses to Call a Method?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-parentheses-to-call-a-method/m-p/6636945#M1442812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great answers! From the naming convention tips, to the syntax suggestions! Thank-You All!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Feb 2010 15:20:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-parentheses-to-call-a-method/m-p/6636945#M1442812</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-02-04T15:20:29Z</dc:date>
    </item>
  </channel>
</rss>

