06-09-2016 2:59 PM
Hi,
Can someone help me understand how the below code works?
In the above code, it makes sense when the below statement throws an error as a result of structure fragmentation within unicode programs.
*lv_string = s1.
What I dont understand is how the data object <fs_x> can hold the contents of the structure 'S1'? The object <fs_x> is declared as type X which would make it 1 byte variable where as the structure S1 is more than 1 byte
Thanks,
Vikram.M
06-09-2016 8:32 PM
I think you have made a confusion between FIELD-SYMBOLS <fs_x> TYPE x which corresponds to a generic type X with undefined length (only set at runtime when the field symbol is assigned), and DATA lv_x TYPE x, which of course cannot be generic (because a data object must have a concrete type) and SAP has defined default lengths for all generic types (like C, P, N and X; and maybe decfloat, I don't remember).
06-09-2016 3:03 PM
Hello Vikram,
have you checked the output?
in your example s1 should be 'AZ 12 4444'
But it probably is not the same for <fs_x>
The thing is, field symbols are like pointers, they reference another element in memory. So what happens when the type of the reference is shorter than the referenced element, it should get be cut off.
Give it a try and print it.
regards
Markus
06-09-2016 3:14 PM
06-09-2016 3:18 PM
use:
WRITE: <fs_x>
field symbols that are to short won't cut off their originals!
edit: they don't do that as they can only change what they arereferencing, and that is only the shortened area and not the whole element
Message was edited by: Markus V
06-09-2016 8:02 PM
06-09-2016 8:32 PM
I think you have made a confusion between FIELD-SYMBOLS <fs_x> TYPE x which corresponds to a generic type X with undefined length (only set at runtime when the field symbol is assigned), and DATA lv_x TYPE x, which of course cannot be generic (because a data object must have a concrete type) and SAP has defined default lengths for all generic types (like C, P, N and X; and maybe decfloat, I don't remember).
06-09-2016 8:57 PM
Sandra,
As far as I know, a generic type is referred with:
When a data object is defined with type X, I thought it refers to a hex with 1 byte length.
Are you saying when a field symbols is defined with type X it becomes generic with undefined length? If yes, would you be able to point me to the corresponding SAP documentation?
Thanks,
Vikram.M
06-09-2016 9:19 PM
06-10-2016 10:00 AM
When a data object is defined with type X, I thought it refers to a hex with 1 byte length.
FIELD-SYMBOLS are not data objects!
When defining data objects 'x' behaves are predefined type (http://help.sap.com/abapdocu_740/en/abenbuiltin_types_byte.htm)
When defining FIELD-SYMBOLS 'x' is generic type (http://help.sap.com/abapdocu_740/en/abenbuilt_in_types_generic.htm). Which Sandra has already pointed out!
BR, Suhas
PS - RT*M, most(almost) of the things are already documented there
06-10-2016 2:02 PM