<?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: Dynamic Abap in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-abap/m-p/12349331#M1992608</link>
    <description>&lt;P&gt;Hah, I hope you put together a blog post about this when you're done... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And I hope you mind all the security aspects, when it comes to dynamic programming and these kind of things. And speaking of those, since you should have control over what is used and allowed, you could create methods for some of the calculations you need, and allow. You could call these dynamically with CALL METHOD (meth).&lt;/P&gt;&lt;P&gt;And, as I said before, doing sy-datum(6) - 1 will not work for january...&lt;/P&gt;</description>
    <pubDate>Mon, 08 Mar 2021 19:15:40 GMT</pubDate>
    <dc:creator>joltdx</dc:creator>
    <dc:date>2021-03-08T19:15:40Z</dc:date>
    <item>
      <title>Dynamic Abap</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-abap/m-p/12349328#M1992605</link>
      <description>&lt;P&gt;Hello. &lt;/P&gt;
  &lt;P&gt;I'm trying to validate some programs, but I came across the following error. &lt;/P&gt;
  &lt;P&gt;data: v1 type string. &lt;/P&gt;
  &lt;P&gt;FIELD-SYMBOLS: &amp;lt;fs&amp;gt; type any. &lt;/P&gt;
  &lt;P&gt;v1 = 'sy-datum (6)'. &lt;/P&gt;
  &lt;P&gt;ASSIGN (v1) to &amp;lt;fs&amp;gt;. &lt;/P&gt;
  &lt;P&gt;write: / &amp;lt;fs&amp;gt;. &lt;/P&gt;
  &lt;P&gt;This returns me the current year / month. &lt;/P&gt;
  &lt;P&gt;v2 = 'sy-datum (6) - 1'. &lt;/P&gt;
  &lt;P&gt;ASSIGN (v2) to &amp;lt;fs&amp;gt;.&lt;/P&gt;
  &lt;P&gt; write: / &amp;lt;fs&amp;gt;. &lt;/P&gt;
  &lt;P&gt;when i try to do the code above, it returns the same value as the first example, instead of year / month -1.&lt;/P&gt;
  &lt;P&gt;Is there any way to do this assignment?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 17:31:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-abap/m-p/12349328#M1992605</guid>
      <dc:creator>former_member1254559</dc:creator>
      <dc:date>2021-03-08T17:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Abap</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-abap/m-p/12349329#M1992606</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;We are talking about the &lt;A href="https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abapassign.htm"&gt;ASSIGN&lt;/A&gt; statement here, and specifically with a &lt;A href="https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abapassign_mem_area_dynamic_dobj.htm"&gt;dynamic area&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;You have spaces in your example, but I guess that's a typo. For&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;v1 = 'sy-datum(6)'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;you will get the year and month from the assign statement.&lt;/P&gt;&lt;P&gt;What you can put in v1, or (name) as the documentation states it, must be the name of a data object which may contain offsets and lengths, structure component selectors, and component selectors for assigning structured data objects, attributes in classes or attributes in objects.&lt;/P&gt;&lt;P&gt;Calculations or other operations can not be specified there, so sy-datum(6) - 1 would not work, even if it had worked. Furthermore, the ASSIGN statement assigns a memory are to a field-symbol. And the result of a calculation is not a memory area unless you first put that result in a variable.&lt;/P&gt;&lt;P&gt;It is not in the documentation, but I assume that the field it takes stops at the first non-character symbol in the string v1. Like it would be expected from a character string with a fixed length. So that's why you still get '202103' and a successful assignment after also the second ASSIGN.&lt;/P&gt;&lt;P&gt;That's basically the answer to why your code behaves the way it does, and no, there is no way to do that calculation assignment that way. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now, I'm curious as to why you WANT to do it this way. Why do this dynamically?&lt;/P&gt;&lt;P&gt;And a word of warning regarding sy-datum(6) - 1, even though that was not really a part of your question... For instance for January of this year, that would be 202101 - 1 = 202100, and I doubt that is what you want? I wrote a bit about date handling in the blog post &lt;A href="https://blogs.sap.com/2020/12/29/safe-dating-in-abap/" target="_blank"&gt;Safe dating in ABAP&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 18:25:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-abap/m-p/12349329#M1992606</guid>
      <dc:creator>joltdx</dc:creator>
      <dc:date>2021-03-08T18:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Abap</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-abap/m-p/12349330#M1992607</link>
      <description>&lt;P&gt;Hey Jorgen. &lt;/P&gt;&lt;P&gt;Thanks for the answer. &lt;/P&gt;&lt;P&gt;I am developing some classes where I will parameterize the name of the program and the fields to be filled with the desired values (for this reason I would like to fill in the table the sy-datum (6) - 1). &lt;/P&gt;&lt;P&gt;These classes will be used in my monthly closing jobs.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 18:35:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-abap/m-p/12349330#M1992607</guid>
      <dc:creator>former_member1254559</dc:creator>
      <dc:date>2021-03-08T18:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Abap</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-abap/m-p/12349331#M1992608</link>
      <description>&lt;P&gt;Hah, I hope you put together a blog post about this when you're done... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And I hope you mind all the security aspects, when it comes to dynamic programming and these kind of things. And speaking of those, since you should have control over what is used and allowed, you could create methods for some of the calculations you need, and allow. You could call these dynamically with CALL METHOD (meth).&lt;/P&gt;&lt;P&gt;And, as I said before, doing sy-datum(6) - 1 will not work for january...&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 19:15:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-abap/m-p/12349331#M1992608</guid>
      <dc:creator>joltdx</dc:creator>
      <dc:date>2021-03-08T19:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Abap</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-abap/m-p/12349332#M1992609</link>
      <description>&lt;P&gt;ASSIGN ('something') ... is not meant to have operations in "something". See &lt;A href="https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abapassign_mem_area_dynamic_dobj.htm"&gt;ABAP documentation&lt;/A&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;something &lt;EM&gt;"must be the name of a data object which may contain offsets and lengths, structure component selectors, and component selectors for assigning structured data objects, attributes in classes or attributes in objects. The content of name does not have to be in uppercase letters."&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;If you want a fully-dynamic code then you must generate the ABAP code with GENERATE SUBROUTINE-POOL (only supported way)&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 07:02:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-abap/m-p/12349332#M1992609</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-03-09T07:02:52Z</dc:date>
    </item>
  </channel>
</rss>

