<?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 Can we write perform statement in class Methods in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-write-perform-statement-in-class-methods/m-p/5943342#M1334951</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My requirement is&lt;/P&gt;&lt;P&gt;CLASS lcl_alv_new IMPLEMENTATION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  METHOD set_columns.&lt;/P&gt;&lt;P&gt;    DATA: ref_column TYPE REF TO cl_salv_column.&lt;/P&gt;&lt;P&gt;    DATA: ls_color   TYPE lvc_s_colo.&lt;/P&gt;&lt;P&gt; PERFORM build_fcat USING&lt;/P&gt;&lt;P&gt;            c_neu_tissue_desc_f text-019.&lt;/P&gt;&lt;P&gt;ENDMETHOD.                    "on_user_command&lt;/P&gt;&lt;P&gt;ENDCLASS.                    "lcl_alv_new IMPLEMENTATION&lt;/P&gt;&lt;P&gt;FORM build_fcat  USING p_fname TYPE lvc_fname&lt;/P&gt;&lt;P&gt;                       p_ftext TYPE scrtext_l.&lt;/P&gt;&lt;P&gt;   TRY.&lt;/P&gt;&lt;P&gt;      ref_column = me-&amp;gt;lref_columns-&amp;gt;get_column( c_neu_tissue_desc_f ).&lt;/P&gt;&lt;P&gt;    CATCH cx_salv_not_found INTO ref_error.&lt;/P&gt;&lt;P&gt;      w_msg = ref_error-&amp;gt;get_text( ).&lt;/P&gt;&lt;P&gt;      MESSAGE w_msg TYPE 'I'.&lt;/P&gt;&lt;P&gt;  ENDTRY.&lt;/P&gt;&lt;P&gt;  ref_column-&amp;gt;set_long_text( text-019 ).&lt;/P&gt;&lt;P&gt;ENDFORM.                    " BUILD_FCAT&lt;/P&gt;&lt;P&gt;I am getting following errors:&lt;/P&gt;&lt;P&gt;1)Field "ME" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement. .		&lt;/P&gt;&lt;P&gt;2)Field "REF_COLUMN" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement.&lt;/P&gt;&lt;P&gt;3)Field "REF_COLUMN" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement. .		&lt;/P&gt;&lt;P&gt;Can any one tell how to write this perform " PERFORM build_fcat USING&lt;/P&gt;&lt;P&gt; c_neu_tissue_desc_f text-019." in Method and End Method. Thanks Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 25 Jul 2009 10:25:18 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-07-25T10:25:18Z</dc:date>
    <item>
      <title>Can we write perform statement in class Methods</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-write-perform-statement-in-class-methods/m-p/5943342#M1334951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My requirement is&lt;/P&gt;&lt;P&gt;CLASS lcl_alv_new IMPLEMENTATION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  METHOD set_columns.&lt;/P&gt;&lt;P&gt;    DATA: ref_column TYPE REF TO cl_salv_column.&lt;/P&gt;&lt;P&gt;    DATA: ls_color   TYPE lvc_s_colo.&lt;/P&gt;&lt;P&gt; PERFORM build_fcat USING&lt;/P&gt;&lt;P&gt;            c_neu_tissue_desc_f text-019.&lt;/P&gt;&lt;P&gt;ENDMETHOD.                    "on_user_command&lt;/P&gt;&lt;P&gt;ENDCLASS.                    "lcl_alv_new IMPLEMENTATION&lt;/P&gt;&lt;P&gt;FORM build_fcat  USING p_fname TYPE lvc_fname&lt;/P&gt;&lt;P&gt;                       p_ftext TYPE scrtext_l.&lt;/P&gt;&lt;P&gt;   TRY.&lt;/P&gt;&lt;P&gt;      ref_column = me-&amp;gt;lref_columns-&amp;gt;get_column( c_neu_tissue_desc_f ).&lt;/P&gt;&lt;P&gt;    CATCH cx_salv_not_found INTO ref_error.&lt;/P&gt;&lt;P&gt;      w_msg = ref_error-&amp;gt;get_text( ).&lt;/P&gt;&lt;P&gt;      MESSAGE w_msg TYPE 'I'.&lt;/P&gt;&lt;P&gt;  ENDTRY.&lt;/P&gt;&lt;P&gt;  ref_column-&amp;gt;set_long_text( text-019 ).&lt;/P&gt;&lt;P&gt;ENDFORM.                    " BUILD_FCAT&lt;/P&gt;&lt;P&gt;I am getting following errors:&lt;/P&gt;&lt;P&gt;1)Field "ME" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement. .		&lt;/P&gt;&lt;P&gt;2)Field "REF_COLUMN" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement.&lt;/P&gt;&lt;P&gt;3)Field "REF_COLUMN" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement. .		&lt;/P&gt;&lt;P&gt;Can any one tell how to write this perform " PERFORM build_fcat USING&lt;/P&gt;&lt;P&gt; c_neu_tissue_desc_f text-019." in Method and End Method. Thanks Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Jul 2009 10:25:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-write-perform-statement-in-class-methods/m-p/5943342#M1334951</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-25T10:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Can we write perform statement in class Methods</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-write-perform-statement-in-class-methods/m-p/5943343#M1334952</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;You cannot use PERFORM of FORM..ENDFORM statements in the class methods.... either you can call methods or Function Modules.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Jul 2009 10:37:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-write-perform-statement-in-class-methods/m-p/5943343#M1334952</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-25T10:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: Can we write perform statement in class Methods</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-write-perform-statement-in-class-methods/m-p/5943344#M1334953</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;Sure you can, althought it would be recommended to implement it in a method. &lt;/P&gt;&lt;P&gt;You get this errors because outside method/class (in your form) reference to ALV is no longer accessible. The same applies to REF_COLUMN. This is beacuse within class data are &lt;STRONG&gt;encapulated&lt;/STRONG&gt; , which means are not visible outside unless it is explicitly defined as such (public section).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use two approaches:&lt;/P&gt;&lt;P&gt;1) pass reference &lt;STRONG&gt;me&lt;/STRONG&gt; and column reference to form&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FORM build_fcat USING p_fname TYPE lvc_fname
                                       p_ftext TYPE scrtext_l
                                       me type ref to "here goes name of your class where method is implemented
                                       ref_column type ref to  cl_salv_column.
TRY.
   ref_column = me-&amp;gt;lref_columns-&amp;gt;get_column( c_neu_tissue_desc_f ).  "now you can access it
CATCH cx_salv_not_found INTO ref_error.
   w_msg = ref_error-&amp;gt;get_text( ).
MESSAGE w_msg TYPE 'I'.
ENDTRY.
   ref_column-&amp;gt;set_long_text( text-019 ).  "now you can access it
ENDFORM. " BUILD_FCAT

"Now  you can call it like
perform build_fcat using ....  me ref_column.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;2) implement it in class - this is highly recommened as data stay encapsulated within class bounds&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"class definition 
data: ref_column TYPE REF TO cl_salv_column. "ref column must be declared as ATTRIBUTE of class in order each method of that class can access it without passing it as parameter

method build_fcat USING p_fname TYPE lvc_fname
                                       p_ftext TYPE scrtext_l.   "you now longer have to pass ME neither REF_COLUMN as it is automatically visible in method

"implementation
method buid_fcat.
  TRY.
      ref_column = me-&amp;gt;lref_columns-&amp;gt;get_column( c_neu_tissue_desc_f ).  "here you are addressing attribute of a class
   CATCH cx_salv_not_found INTO ref_error.
         w_msg = ref_error-&amp;gt;get_text( ).
    MESSAGE w_msg TYPE 'I'.
    ENDTRY.
    ref_column-&amp;gt;set_long_text( text-019 ).   "same here
enmethod.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Please note!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Form cannot be defined within class, it must be outside it, that's why you violate encapsulation rules. Method, on the other hand, is defined within CLASS .... ENDCLASS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Marcin Pciak on Jul 25, 2009 12:39 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Jul 2009 10:38:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-write-perform-statement-in-class-methods/m-p/5943344#M1334953</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2009-07-25T10:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can we write perform statement in class Methods</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-write-perform-statement-in-class-methods/m-p/5943345#M1334954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;     Instead use Macro, define and use them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*---------------------------------------------------------------*
* Data declaration
*---------------------------------------------------------------*
DATA: lt_bdcdata TYPE TABLE OF bdcdata,               " Internal table for BDCDATA
            ls_bdcdata TYPE bdcdata.                                " Work area for BDCDATA

*---------------------------------------------------------------*
* Macro declaration for BDCDATA
*---------------------------------------------------------------*
  DEFINE bdc_.
    clear ls_bdcdata.
    if &amp;amp;3 is initial.
      ls_bdcdata-fnam  = &amp;amp;1.
      ls_bdcdata-fval   = &amp;amp;2.
    else.
      ls_bdcdata-program  = &amp;amp;1.
      ls_bdcdata-dynpro   = &amp;amp;2.
      ls_bdcdata-dynbegin = &amp;amp;3.
    endif.
    append ls_bdcdata to lt_bdcdata.
  END-OF-DEFINITION.


* Screen '0300'
        bdc_    'SAPMM06E'  '0300' 'X'.
        bdc_    'BDC_CURSOR' 'EKKO-ANGDT' ' '.
        bdc_    'BDC_OKCODE' '=KOPF' ' '.
        bdc_    'RM06E-ASART' ls_impcluster-rfq_type ' '.
        bdc_    'EKKO-SPRAS' 'EN' ' '.
        bdc_   'RM06E-ANFDT' l_date ' '.
.
.
.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Bala Krishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Jul 2009 11:50:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-write-perform-statement-in-class-methods/m-p/5943345#M1334954</guid>
      <dc:creator>former_member585060</dc:creator>
      <dc:date>2009-07-25T11:50:48Z</dc:date>
    </item>
  </channel>
</rss>

