<?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: Change source code of Method dynamically in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246261#M1985705</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Thanks a ton to Sandra who pointed me out to the right direction. Finally I am able to achieve what I was looking for.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1846655-method.png" /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 09:55:18 GMT</pubDate>
    <dc:creator>jayesh_mudaliar</dc:creator>
    <dc:date>2020-09-30T09:55:18Z</dc:date>
    <item>
      <title>Change source code of Method dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246252#M1985696</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;
  &lt;P&gt;I came across a requirement where I need to change the source code of method, FM and report dynamically. For report I am able to do this using INSERT REPORT.&lt;/P&gt;
  &lt;P&gt;For Method I got a FM (SEO_METHOD_GET_SOURCE)which gives the source code of the method . Now I want to change the source code of that method For Eg : I want to append one more line in the existing method dynamically. &lt;/P&gt;
  &lt;P&gt;Can anybody suggest me how this can be achieved?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:57:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246252#M1985696</guid>
      <dc:creator>jayesh_mudaliar</dc:creator>
      <dc:date>2020-09-29T12:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Change source code of Method dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246253#M1985697</link>
      <description>&lt;P&gt;You could more easily, create a report dynamicaly and execute a Form routine of this report. &lt;/P&gt;&lt;P&gt;But, this kind of code is highlighted by security audit ... &lt;/P&gt;&lt;P&gt;Could you explain why you think you need to do this action ? &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:05:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246253#M1985697</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2020-09-29T13:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Change source code of Method dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246254#M1985698</link>
      <description>&lt;P&gt;As said that "code on the fly" is generally not allowed as it is a security hole (this goes wayyyy back to the old old old way SAP would allow you to pass in code to an RFC and execute it which was quickly discovered to be a bad bad security flaw).&lt;BR /&gt;&lt;BR /&gt;Why not take advantage of OO and do everything through different implementations of a shared interface(s)? Then in your "main" code/report, you simply will check whatever business logic you need/have now and then decided which implementation to call. That will allow you to be very flexible/scalable and achieve your "dynamicness" too.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:23:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246254#M1985698</guid>
      <dc:creator>ChrisSolomon</dc:creator>
      <dc:date>2020-09-29T13:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: Change source code of Method dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246255#M1985699</link>
      <description>&lt;P&gt;Thanks for the response Christopher &amp;amp; Frederic!!&lt;/P&gt;&lt;P&gt;I know this could be a security flaw if used unethically but mine intension is to compare the 2 version of the source and if any difference is found that has to added to that respective place in the development server itself like an automation of comparison of source code. So although Christopher you suggest a good approach by achieving  this through creating multiple implementation but this wont help me out in my scenario.&lt;/P&gt;&lt;P&gt;I believe there must be something which could allow to add the entries to source code as it is there for REPORT also using FM :&lt;/P&gt;&lt;OL&gt;
&lt;LI&gt;SEO_METHOD_CREATE&lt;/LI&gt;&lt;LI&gt;SEO_METHOD_GENERATE_INCLUDE&lt;/LI&gt;&lt;LI&gt;SEO_CLASS_GENERATE_SECTIONS&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;we can create a method dynamically . so there must be some way to add/modify the existing method.&lt;BR /&gt;Please suggest !!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:55:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246255#M1985699</guid>
      <dc:creator>jayesh_mudaliar</dc:creator>
      <dc:date>2020-09-29T13:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Change source code of Method dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246256#M1985700</link>
      <description>&lt;P&gt;Are you recreating Abap Git ? &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:58:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246256#M1985700</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2020-09-29T13:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Change source code of Method dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246257#M1985701</link>
      <description>&lt;P&gt;Its a customization which I am building for reducing the time, effort and cost. If successfully built this could be a gamechanger isn't it??&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:56:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246257#M1985701</guid>
      <dc:creator>jayesh_mudaliar</dc:creator>
      <dc:date>2020-09-29T14:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Change source code of Method dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246258#M1985702</link>
      <description>&lt;P&gt;All classic ABAP code is stored in Source Code Units (reports, function modules, includes, classes, etc.) Methods of global classes are stored in source unit &amp;lt;class&amp;gt;====...CM&amp;lt;###&amp;gt; where ## is stored in table TMDIR, and must be converted to base 36 (examples 10-35 = CM00A-CM00Z and 36-45 = CM010-CM019). READ REPORT and INSERT REPORT are used to read and update Source Code Units.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:01:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246258#M1985702</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-09-29T17:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Change source code of Method dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246259#M1985703</link>
      <description>&lt;P&gt;I have written an application that generates methods and method code on the fly. The techniques were readily found in blogs and answers on this site. Have you searched much?&lt;/P&gt;&lt;P&gt;Dynamic abap is only a security issue if it allows arbitrary code injection. If what is does is specific and limited, then it's no more risky than putting any abap program into production.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:18:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246259#M1985703</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2020-09-29T20:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: Change source code of Method dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246260#M1985704</link>
      <description>&lt;P&gt;Hi Sandra, &lt;/P&gt;&lt;P&gt;Thanks for sharing the information .Just a little bit of more help. So if for an example :&lt;/P&gt;&lt;P&gt;I have a class ZABC with a method name ONE, So as per you told me it would be like :&lt;/P&gt;&lt;P&gt;ZABC================CM###. So I can use this in READ REPORT and INSERT REPORT, Is there any table which stores the exact naming convention of all this? However I debugged one standard class from which I&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1846650-debug.png" /&gt;&lt;/P&gt;&lt;P&gt;get the attached screenshot consisting :&lt;/P&gt;&lt;P&gt;CL_DEMO_OUTPUT================CM01E.&lt;/P&gt;&lt;P&gt;Also please help me understand what it means  "&lt;STRONG&gt;and must be converted to base 36 (examples 10-35 = CM00A-CM00Z and 36-45 = CM010-CM019)&lt;/STRONG&gt;." How to convert it to base 36.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 08:34:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246260#M1985704</guid>
      <dc:creator>jayesh_mudaliar</dc:creator>
      <dc:date>2020-09-30T08:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Change source code of Method dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246261#M1985705</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Thanks a ton to Sandra who pointed me out to the right direction. Finally I am able to achieve what I was looking for.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1846655-method.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 09:55:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246261#M1985705</guid>
      <dc:creator>jayesh_mudaliar</dc:creator>
      <dc:date>2020-09-30T09:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Change source code of Method dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246262#M1985706</link>
      <description>&lt;P&gt;Did you use a FM such as SEO_CLASS_GET_METHOD_INCLUDES?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 11:30:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246262#M1985706</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2020-09-30T11:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Change source code of Method dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246263#M1985707</link>
      <description>&lt;P&gt;Hi Raymond,&lt;/P&gt;&lt;P&gt;This FM SEO_CLASS_GET_METHOD_INCLUDES is Obsolete.&lt;/P&gt;&lt;P&gt;I have used the new approach provided by SAP.&lt;/P&gt;&lt;P&gt;data clskey TYPE SEOCLSKEY.&lt;BR /&gt;FIELD-SYMBOLS &amp;lt;MWI&amp;gt; TYPE any.&lt;BR /&gt;CLASS CL_OO_INCLUDE_NAMING DEFINITION LOAD.&lt;BR /&gt;DATA OREF TYPE REF TO IF_OO_CLASS_INCL_NAMING.&lt;BR /&gt;DATA MTDS_W_INCL TYPE SEOP_METHODS_W_INCLUDE.&lt;BR /&gt;clskey = &amp;lt;CLASS_NAME&amp;gt;&lt;BR /&gt;OREF ?= CL_OO_INCLUDE_NAMING=&amp;gt;GET_INSTANCE_BY_CIFKEY( CLSKEY ).&lt;BR /&gt;MTDS_W_INCL = OREF-&amp;gt;GET_ALL_METHOD_INCLUDES( ).&lt;BR /&gt;LOOP AT MTDS_W_INCL&lt;BR /&gt; ASSIGNING &amp;lt;MWI&amp;gt;.&lt;/P&gt;&lt;P&gt;ENDLOOP. &lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 12:42:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246263#M1985707</guid>
      <dc:creator>jayesh_mudaliar</dc:creator>
      <dc:date>2020-10-12T12:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: Change source code of Method dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246264#M1985708</link>
      <description>&lt;P&gt;I didn't receive an alert of your question: If you want to target someone, if this person has posted an Answer, use the button COMMENT, if this person is the Original Poster of the question he/she will be automatically informed, otherwise copy/paste their hyperlinked name (like this: &lt;SPAN class="mention-scrubbed"&gt;jayesh.mudaliar&lt;/SPAN&gt;) so that the person receives a warning (NB: @ doesn't work/but typing this character will suggest hyperlinked names).&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 15:00:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246264#M1985708</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-10-12T15:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Change source code of Method dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246265#M1985709</link>
      <description>&lt;P&gt;EDIT 2023: I realize that I posted an answer which is not directly related to the question, so including here my 2020 comment which looks more like an answer, completed with few additions:&lt;/P&gt;&lt;P&gt;All classic ABAP code is stored in Source Code Units (reports, function modules, includes, classes, etc.)&lt;/P&gt;&lt;P&gt;The methods of global classes are stored in source unit &amp;lt;class&amp;gt;====CM&amp;lt;###&amp;gt; where ## is stored in table TMDIR, and must be converted to base 36. CM must always start after the 30 characters of class, which is padded with = to fill 30 characters. Examples: CL_AAAAA======================CM001, ZCL_AAAAAAAAAAAAAAAAAAAAA=====CM001, CL_AAAAAAAAAAAAAAAAAAAAAAAAAAACM001, etc.&lt;/P&gt;&lt;P&gt;The table TMDIR has these columns:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;CLASSNAME&lt;/LI&gt;&lt;LI&gt;METHODINDX (NUMC 5) :&lt;UL&gt;&lt;LI&gt;0 : to be ignored (may exist for unknown reason, METHODNAME is empty)&lt;/LI&gt;&lt;LI&gt;1 .. 9 : CM001 .. CM009&lt;/LI&gt;&lt;LI&gt;10 .. 35 : CM00A .. CM00Z&lt;/LI&gt;&lt;LI&gt;36 .. 45 : CM010 .. CM019&lt;/LI&gt;&lt;LI&gt;46 .. 71 : CM01A .. CM01Z&lt;/LI&gt;&lt;LI&gt;72 .. 81 : CM020 .. CM02Z&lt;/LI&gt;&lt;LI&gt;etc.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;METHODNAME&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The ABAP statements &lt;A href="https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abapread_report.htm"&gt;READ REPORT prog ..&lt;/A&gt; and &lt;A href="https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abapinsert_report.htm"&gt;INSERT REPORT prog ..&lt;/A&gt; are to be used to read and update Source Code Units. For method source code units, "prog" must be &amp;lt;class&amp;gt;====CM&amp;lt;###&amp;gt; as described above.&lt;/P&gt;&lt;P&gt;Answer from 2020:&lt;/P&gt;&lt;P&gt;Here is the code + example for converting TMDIR-METHODINDX = "00035" into "00Z" (part of extension type after "CM"):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(methodindx) = CONV tmdir-methodindx( 35 ).
DATA(aaa_of_cmaaa) = '   '.

PERFORM convert_methodindx_to_cmaaa USING methodindx CHANGING aaa_of_cmaaa.

ASSERT aaa_of_cmaaa = '00Z'.


FORM convert_methodindx_to_cmaaa
    USING
      VALUE(methodindx) TYPE tmdir-methodindx
    CHANGING
      aaa_of_cmaaa TYPE char3.
  CONSTANTS base TYPE c LENGTH 36 VALUE '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
  DATA indx TYPE i.
  aaa_of_cmaaa = ''.
  DO 3 TIMES.
    indx = methodindx MOD 36.
    aaa_of_cmaaa = base+indx(1) &amp;amp;&amp;amp; aaa_of_cmaaa.
    methodindx = methodindx DIV 36.
  ENDDO.
ENDFORM.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Oct 2020 15:31:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246265#M1985709</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-10-12T15:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Change source code of Method dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246266#M1985710</link>
      <description>&lt;P&gt;Note sure that you pasted the right screenshot &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 20:57:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/change-source-code-of-method-dynamically/m-p/12246266#M1985710</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-02-24T20:57:23Z</dc:date>
    </item>
  </channel>
</rss>

