What is the value of ABAP constants with prefix "%_"? - constants

We are writing a tool in Java to analyze ABAP programs. The code is extracted and given to us as text, so we do not have direct access to the ABAP system. One task is to resolve the value of constants. We now discovered constants whose name starts with %_. For example, a definition in a class pool include CL_ABAP_CHAR_UTILITIES========CU is
constants HORIZONTAL_TAB type ABAP_CHAR1 value %_HORIZONTAL_TAB.
which transitively defines the value of constant HORIZONTAL_TAB via another constant whose name has the prefix %_.
Where are these constants with %_ prefix defined? What is their value? We guess, they are system dependent. Is there an official document describing them?

These are some internal (pseudo-)constants that you will simply have to accept as a given. Stuff beginning with %_ is usually reserved for ABAP internal use and is hardly ever documented.

Related

Is it possible to create constants in Progress-4GL?

Good afternoon,
Is it possible to create constants in Progress-4GL?
The same question has been asked here, but there the question is based on object oriented programming (which I'm not doing).
There is no constant keyword in ABL.
The simplest way to create constant values is using static properties. These are available in any code, even procedural.
class ConstantValues:
define static public PI as decimal initial 3.14159 get.
end class.
You could add a private setter and do the assignment in the static constructor, instead of the initial value.
If you can't or don't want to use this approach, you can use preprocessors. If you need these values shared then define the preprocessors in includes and use those in your programs (even classes).
But that's - to me - more work than it needs to be if you're creating new constant values.
Even if not a constant and also possibly quite old school you can define precompiler statements that can work as a constant.
There's a possibility for global (&GLOBAL-DEFINE) and not global (&SCOPED-DEFINE)
Its also possible to undefine, check defined and other basic things.
These are define on compilation time so they cannot be changed dynamically when the program is running.
&SCOPED-DEFINE const1 1
&GLOBAL-DEFINE const2 hello
DISPLAY {&const1} "{&const2}".

Using Conditional Syntax (Overrides) in BitBake

Reading a book on Yocto. Got to the following page, which says:
BitBake provides a very easy-to-use way to write conditional metadata.
It is done by a mechanism called overrides.
The OVERRIDES variable contains values separated by colons (:), and
each value is an item we want to satisfy conditions. So, if we have a
variable that is conditional on arm, and arm is in OVERRIDES, then the
version of the variable that is specific to arm is used rather than
the non-conditional version, as shown:
OVERRIDES = "architecture:os:machine"
TEST = "defaultvalue"
TEST_os = "osspecificvalue"
TEST_other = "othercondvalue"
In this example, TEST will be osspecificvalue due to the condition
of os being in OVERRIDES.
I'm unclear from this explanation how did TEST become equal to osspecificvalue. Would someone be able to explain it?
Bitbake implements it's own dictionary data structure based on Python's MutableMapping in lib/bb/data_smart.py. The goal is to create a dictionary with more flexibility in that each value in the "key,value" pair can be overridden based on specific identifiers.
If you look at how the variables in this dictionary are set, you will see that the datastore allows "overrides" of variables based on a list of override identifiers. These identifiers are expected to be appended with an underscore, like in your example of "TEST_os".
In the case you are referencing, "other" identifier is not in the list of OVERRIDES, so this "smart dictionary" does not override the value of TEST with "othercondvalue". However, because the "os" identifier is in the list of OVERRIDES, the value of TEST is indeed overridden with the value "osspecificvalue".
I would highly recommend reading through the DataSmart class as this is a very simplified explanation, but hopefully it helps.
Also, see the BitBake manual entry for OVERRIDES for more information.

Can I work around name conflicts?

I have a fortran project whith some name conflicts (from doxygen's point of view). Sometimes a local variable in a procedure may have the same name as a subroutine or function. For compilation/linking there are no problems, as the different definitions live separate lives, for instance:
progA/main.f defines and uses the variable delta.
libB/delta.f defines a function named delta.
progB/main.f uses the function delta defined in libB.
progB is linked with libB, progA is not linked with libB.
In this case, when generating call/caller graphs, or linked source code, the variable delta in progA/main.f will be identified as the function delta. Is there some combination of doxygen settings I can use to inform it that progA is not supposed to use definitions in libB, or something similar?
Another issue is that I may have functions/subroutines with the same name in different subdirectories. Again, as long as they are not linked together this does not represent a problem for compilation, but doxygen cannot identify which of them is meant in links, calls, etc. Is there some work around this (without renaming procedures, that is)?

Lua Plugins Containing Local Variables

I'm trying to learn the Lua language to develop plugins for my company's products. To help me learn (along with PiL book, Reference Manual, and numerous online resources), as I read I try to decipher current plugins we use.
One thing I've noticed is that local variables are listed at the very top and are not set to a specific value. For example: local SendVar and local EndVar.
But later on, many function's and local var's are used.
My question: I understand "Scope", global and local variables. But if there are no local function's within the plugin, are all local variables used within all functions?
I'm sorry for any confusion. But I'm trying to figure out how plugins are used within another program that uses other Lua plugins. I'm taking a wild guess when stating that unless local function's are otherwise stated, all local variables are used within that plugin file only.
Am I correct?
When in Lua you write a local statement, you are declaring that the following identifiers will denote local variables, whether or not those statements actually initializes the variables.
Moreover, local variables in Lua have block scope, i.e. they are visible in the block in which they are defined and in every enclosed block. Blocks are, for example, function bodies, then-end or else-end blocks, do-end blocks, etc.
Keep in mind, also, that variables in Lua don't have type, their value have.
-- declares `a` as a local variable (having no value, i.e. `nil` value)
local a
-- declares `b` as a local variable having 2 as value
local b = 2
-- declares `f` as local var having a function as value
local f = function(x) return x * x end
do
-- `a`, `b` and `f` are visible here, because this is a block enclosed
-- in the block where those vars were declared
local aa = 2
end
-- `aa` is not visible here, because it was declared in an inner block

lua - capturing variable assignments

Ruby has this very interesting functionality in which when you create a class with 'Class.new' and assign it to a constant (uppercase), the language "magically" sets up the name of the class so it matches the constant.
# This is ruby code
MyRubyClass = Class.new(SuperClass)
puts MyRubyClass.name # "MyRubyClass"
It seems ruby "captures" the assignment and inserts sets the name on the anonymous class.
I'd like to know if there's a way to do something similar in Lua.
I've implemented my own class system, but for it to work I've got to specify the same name twice:
-- This is Lua code
MyLuaClass = class('MyLuaClass', SuperClass)
print(MyLuaClass.name) -- MyLuaClass
I'd like to get rid of that 'MyLuaClass' string. Is there any way to do this in Lua?
When assigning to global variables you can set a __newindex metamethod for the table of globals to catch assignments of class variables and do whatever is needed.
You can eliminate one of the mentions of MyLuaClass...
> function class(name,superclass) _G[name] = {superclass=superclass} end
> class('MyLuaClass',33)
> =MyLuaClass
table: 0x10010b900
> =MyLuaClass.superclass
33
>
Not really. Lua is not an object-orientated language. It can behave like one sometimes. But far from every time. Classes are not special values in Lua. A table has the value you put in it, no more. The best you can do is manually set the key in _G from the class function and eliminate having to take the return value.
I guess that if it REALLY, REALLY bothers you, you could use debug.traceback(), get a stack trace, find the calling file, and parse it to find the variable name. Then set that. But that's more than a little overkill.
With respect at least to Lua 5.2: You can capture assignments to A) the global table of a Lua State, as mentioned in a previous reply, and also B) to any other Lua Object whose __index and __newindex metamethods have been substituted (by replacing the metatable), this I can confirm as I'm currently using both these techniques to hook and redirect assignments made by Lua scripts to external C/C++ resource management.
There is a gotcha with regards to reading them back though, the trick is to NOT let the values be set in a Lua State.
As soon as they exist there, your hooks will fail to be called, so if you want to go down this path, you need to capture ALL get/set attempts, and NEVER store the values in a Lua State.