<?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: Dynamically get a method's parameter in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-get-a-method-s-parameter/m-p/4583456#M1081188</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your detailed replies, but the problem is not in the calling of the method. The problem is inside the method. Uwe's example is not my case, since I don't have control over method definition. So the enhanced_method can have this signature:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
enhanced_method
        IMPORTING
          value(id_standard_1)    TYPE i
          value(id_standard_2)    TYPE c
          value(id_enhanced_1)    TYPE c OPTIONAL.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;or this signature:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
enhanced_method
        IMPORTING
          value(id_standard_1)    TYPE i
          value(id_standard_2)    TYPE c
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The method is a BAdI implementation and I have to run with the parameters that BAdI interface provides me. And it is possible that it will either be the first case, or the second case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I need to use the id_enhanced_1 in my method implementation, but if I'm supplied with the second signature, referencing id_enhanced_1 inside the method will give a compiler error (since it's not in the signature).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I need somehow dynamically to take care of this id_enhanced_1, whether it is in the method signature, or not. I'm not even sure if it's possible, just hope some bright minds out there can put my mind at rest &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oksana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Oct 2008 13:19:08 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-10-01T13:19:08Z</dc:date>
    <item>
      <title>Dynamically get a method's parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-get-a-method-s-parameter/m-p/4583453#M1081185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a very strange problem that no-one was able to help me with so far. I need to implement some code inside a method, which is based on a method's parameter that may or may not be in the method's signature. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This situation has arisen because the method in question is a BAdI implementation that needs to be enhanced, but the BAdI's interface is off-limits. At some point an extra parameter was added to the BAdI's interface, but it is possible that the application will be in a state where this change will not be applied. At the same time, the BAdI's implementation should make use of this parameter, if it's available.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, in my method code I need smth like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: var1 type any.
if ( 'param1' ) exists
    var1 = me-&amp;gt;getThisMethodsParameterByName( 'param1' )
*   do smth with var1
endif 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where param1 is this fuzzy parameter, that may or may not be in the method's signature.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In other words, I need to shut the compiler up when the parameter is not in the method's signature, but at the same time I need to access it inside the method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any pointers will be greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oksana&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Oksana Korol on Sep 30, 2008 10:56 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Oksana Korol on Sep 30, 2008 10:57 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Oksana Korol on Sep 30, 2008 10:58 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Sep 2008 20:55:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-get-a-method-s-parameter/m-p/4583453#M1081185</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-30T20:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically get a method's parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-get-a-method-s-parameter/m-p/4583454#M1081186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See if this helps you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: objeto type ref to CL_METHOD_PPF,
object_class type ref to CL_CLASS_PPF,
l_class type SEOCLSNAME,
l_method type SEOCPDNAME,
l_bool.

l_class = 'CL_GUI_FRONTEND_SERVICES'.
l_method = 'DIRECTORY_EXIST'.
create object object_class
exporting
ip_class = l_class.

create object objeto
exporting
ip_class = l_class
ip_method = l_method
io_class = object_class.

l_bool = objeto-&amp;gt;exists( 'DIRECTORY' ).
write l_bool.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Sep 2008 21:19:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-get-a-method-s-parameter/m-p/4583454#M1081186</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-30T21:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically get a method's parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-get-a-method-s-parameter/m-p/4583455#M1081187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Oksana&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a very simple solution available for your problem.&lt;/P&gt;&lt;P&gt;The new signature parameter is optional because otherwise you would run into a dump when the standard method is called. Thus, you can use the &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IS SUPPLIED statement&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to check whether the parameter has been used in the method call or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZUS_SDN_BADI_IF_ENHANCEMENT
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Thread: Dynamically get a method's parameter
*&amp;amp; &amp;lt;a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1069319"&amp;gt;&amp;lt;/a&amp;gt;
*&amp;amp;---------------------------------------------------------------------*

REPORT  zus_sdn_badi_if_enhancement.


*----------------------------------------------------------------------*
*       CLASS lcl_badi_im_class DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_badi_im_class DEFINITION.

  PUBLIC SECTION.

    METHODS:
      constructor.

    METHODS:
      enhanced_method
        IMPORTING
          value(id_standard_1)    TYPE i
          value(id_standard_2)    TYPE c
          value(id_enhanced_1)    TYPE c OPTIONAL.

ENDCLASS.                    "lcl_badi_im_class DEFINITION


*----------------------------------------------------------------------*
*       CLASS lcl_badi_im_class IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_badi_im_class IMPLEMENTATION.

  METHOD constructor.
  ENDMETHOD.                    "constructor

  METHOD enhanced_method.

    IF ( id_enhanced_1 IS SUPPLIED ).
      MESSAGE 'Enhanced method signature is called' TYPE 'I'.
    ELSE.
      MESSAGE 'Standard method signature is called' TYPE 'I'.
    ENDIF.

  ENDMETHOD.                    "enhanced_method

ENDCLASS.                    "lcl_badi_im_class IMPLEMENTATION


data: go_badi   type ref to lcl_badi_im_class.


START-OF-SELECTION.

  create object go_badi.

  " Enhanced parameter not used in method call =&amp;gt; IS NOT SUPPLIED
  call method go_badi-&amp;gt;enhanced_method
    exporting
      id_standard_1 = 1
      id_standard_2 = 'A'
*      id_enhanced_1 =
     .

  " Enhanced parameter is used in method call =&amp;gt; IS SUPPLIED
  call method go_badi-&amp;gt;enhanced_method
    exporting
      id_standard_1 = 1
      id_standard_2 = 'A'
      id_enhanced_1 = space.

" NOTE: There is no difference in the contents of parameter ID_ENHANCED_1  
"       between the two different method calls yet the parameter
" IS SUPPLIED only in the second method call.  

END-OF-SELECTION.
&lt;/CODE&gt;&lt;/PRE&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>Wed, 01 Oct 2008 03:18:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-get-a-method-s-parameter/m-p/4583455#M1081187</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2008-10-01T03:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically get a method's parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-get-a-method-s-parameter/m-p/4583456#M1081188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your detailed replies, but the problem is not in the calling of the method. The problem is inside the method. Uwe's example is not my case, since I don't have control over method definition. So the enhanced_method can have this signature:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
enhanced_method
        IMPORTING
          value(id_standard_1)    TYPE i
          value(id_standard_2)    TYPE c
          value(id_enhanced_1)    TYPE c OPTIONAL.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;or this signature:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
enhanced_method
        IMPORTING
          value(id_standard_1)    TYPE i
          value(id_standard_2)    TYPE c
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The method is a BAdI implementation and I have to run with the parameters that BAdI interface provides me. And it is possible that it will either be the first case, or the second case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I need to use the id_enhanced_1 in my method implementation, but if I'm supplied with the second signature, referencing id_enhanced_1 inside the method will give a compiler error (since it's not in the signature).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I need somehow dynamically to take care of this id_enhanced_1, whether it is in the method signature, or not. I'm not even sure if it's possible, just hope some bright minds out there can put my mind at rest &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oksana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2008 13:19:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-get-a-method-s-parameter/m-p/4583456#M1081188</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-01T13:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically get a method's parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-get-a-method-s-parameter/m-p/4583457#M1081189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'll have to use dynamic parameters in any case, I think.  So you could use &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TRY. 
    CALL METHOD dynamically with first set of parameters
  CATCH cx_sy_dyn_call_error. 
    TRY.
      CALL METHOD dynamically with second set of parameters.
    CATCH cx_sy_dyn_call_error.
* Do "It's all gone horribly" wrong processing here
    ENDTRY.
ENDTRY&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's assuming, of course, that you know all possible alternatives.  If the additional parameter(s) are completely aribitray, perhaps decided by some third party, then another approach is needed... which I'll think about.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2008 13:29:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-get-a-method-s-parameter/m-p/4583457#M1081189</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2008-10-01T13:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically get a method's parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-get-a-method-s-parameter/m-p/4583458#M1081190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Matt, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately I don't have control over how the method is called either. All I can modify is the method implementation...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oksana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2008 13:44:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-get-a-method-s-parameter/m-p/4583458#M1081190</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-01T13:44:13Z</dc:date>
    </item>
  </channel>
</rss>

