on 08-16-2004 8:17 AM
Hi all,
There's a very basic doubt that I got. I have a constants statement in my program as follows:
constants: begin of g_const,
id1(30) type c value 'Name',
id2(30) type c value 'Department',
end of g_const.
Now when I do the Extended Program Check, I get an error which says "Char. strings w/o text elements will not be translated". This is expected. But I am unable to correct this error.
I get a syntax error if i try the following options:
1. constants: begin of g_const,
id1(30) type c value text-001,
id2(30) type c value text-002,
end of g_const.
2. constants: begin of g_const,
id1(30) type c value 'Name'(001),
id2(30) type c value 'Department'(002),
end of g_const.
How do I provide the text elements for the constants?
Regards,
Anand Mandalika.
These codes in 4.7:
constants: begin of g_const,
id1(30) type c value 'Name',
id2(30) type c value 'Department',
end of g_const.
don't have any error when I did extended program check. The initial problem you have must be in 4.6c or below since it is not a problem anymore for 4.7.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Anand,
Text-Elements are resolved from ABAP during runtime and can not be part of variable and constant initialization. You can use the pseudo comment "#EC NOTEXT to suppress SLIN text warnings. But in your case this seems to be no good idea, cause this is text to translate.
The only solution I know would be the use read/only vars of a local class.
Kind Regards
Klaus
report time.
*----------------------------------------------------------------------
* local classes
*----------------------------------------------------------------------
class lcl_Text definition.
public section.
class-data:
fg_Customer type c length 30 read-only,
fg_Material type c length 30 read-only.
class-methods:
class_Constructor.
endclass.
class lcl_Text implementation.
*========================
method class_Constructor.
*========================
fg_Customer = 'Customer'(CST).
fg_Material = 'Material'(MAT).
endmethod.
endclass.
*----------------------------------------------------------------------
* report eventing
*----------------------------------------------------------------------
start-of-selection.
perform sub_Main.
*----------------------------------------------------------------------
* form routines
*----------------------------------------------------------------------
*=============
form sub_Main.
*=============
* data declarartion
Constants:
c_Supplier type c length 20 value 'Supplier'. "#EC NOTEXT
* some code
write: / c_Supplier.
write: / lcl_Text=>fg_Customer.
endform.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tried it and had the same error... I think the solution is simple:
DATA: BEGIN OF g_const,
id1(30) TYPE c, " VALUE text-001,
id2(30) TYPE c, " VALUE text-002,
END OF g_const.
g_const-id1 = text-001.
g_const-id2 = text-002.
Any variable wich remains untouched is a constant 😛
Maybe it's not a "clear" solution, but it works. I tried to test the translations, but I'm new to ABAP/SAP and could not manage it... I know what I will do in the next few minutes
(tested, I could translate the text elements and it worked, just had to have care about where to assign the values)
I wish it helps,
Vic
P.S.: Thanks to your post, I learned how to do the translations in my reports. I just wish you could get any benefit from my answer like I did with your question.
Message was edited by: Vicenç Lozano (added P.S.)
Message was edited by: Vicenç Lozano
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.