‎2007 Jan 02 2:22 PM
Hi All
I have a basic doubt regarding text element and constants like this.
As per my understanding both are used to elimate hard coding in that case which one we have to perfer in what scenarios? for examp I am building field categlog in ALV manually (means with out using Fun module field merge catelog) in that case we have to pass field name, table name and all to build field catelog so in this case we have to use text element or constants? what's the difference exactly between these two?which one is bettter? what's the advantage of each one?
Thanks in advance
mahesh
‎2007 Jan 02 2:26 PM
It is always better to use Text Symbols in lieu of Constatnts.. to overcome Translation issues.. & avoid errors during SLIN..
~Suresh
‎2007 Jan 02 2:29 PM
Hi Mahesh,
<b>Literals (or) Constants</b>
Literals are unnamed data objects that you create within the source code of a program. They are fully defined by their value. You cannot change the value of a literal.
There are two types of literals: numeric and character
<b>Numeric Literals</b>
Number literals are sequences of digits which can have a prefixed sign. In number literals there are no decimal separators and no notation with mantissa and exponent
'[mantissa][E][exponent]'
are possible as well
<b>Character Literals</b>
Character literals are sequences of alphanumeric characters in the source code of an ABAP program enclosed in single quotation marks or backquotes. Character literals enclosed in quotation marks have the predefined ABAP type c and are described as text field literals. Literals enclosed in backquotes have the ABAP type string and are described as string literals. The field length is defined by the number of characters. With text field literals trailing blanks are ignored while in string literals they are taken into account.
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3027358411d1829f0000e829fbfe/frameset.htm
<b>Text Symbols</b>
A text symbol is a named data object that is generated when you start the program from the texts in the text pool of the ABAP program. It always has the data type c. Its field length is that of the text in the text pool.
Text symbols, along with the program title, list headings, and selection texts, belong to the text elements of a program. Text elements allow you to create language-independent programs. Any text that the program sends to the screen can be stored as a text element in a text pool. Different text pools can be created for different languages. When a text element is changed or translated, there is no need to change the actual program code. Text elements in an ABAP program are stored in the ABAP Editor
In the text pool, each text symbol is identified by a three-character ID. Text symbols have a content, an occupied length, and a maximum length
http://help.sap.com/saphelp_nw2004s/helpdata/en/1e/401ad6ee3c11d1951d0000e8353423/frameset.htm
Regards,
Raghav
‎2007 Jan 03 6:43 AM
Hi All,
Please clarify my doubt with respect to one examp I am giving.
I am building field catelog in ALV like below.
m_fieldcat '1' 'KUNNR' 'GI_FINAL_ITAB' text-002 '10' ' '.
To remove the hard coding (for examp 'KUNNR')in the above statement we can do 2 ways one way is declare constant with value KUNNR and other way is with text element value 'KUNNR' which method we have to approach considering performance and all?
Thanks&Regards
Mahesh