‎2008 Dec 05 9:27 AM
Hi,
when I try this:
DATA: field(6) TYPE c VALUE '______'. ( ______ - six spaces )
or this:
field = '______'.
or this
field = `______`.
the variable field is empty (has no spaces inside).
But when I try this:
DATA: field2 TYPE string.
field2 = `______`.
the variable has spaces inside.
Can somebody explain me how to assign spaces to a variable of type c?
Regards,
Ladislav
‎2008 Dec 05 9:46 AM
Hello,
If you declare data as below, it will definitly have spaces,1
DATA: field(6) TYPE c VALUE '______'. ( ______ - six spaces )
to test the same try some thing like this.
data: w_test type string.
concatenate field 'This is a test' into w_test RESPECTING BLANKS.
Hope this will help.
Thanks,
Jayant
‎2008 Dec 05 9:35 AM
Hi,
Check this code. If i understood your query.Its leaving spaces for Char type also in my program. Hope you understand. Revert back to me if there is any concern..
DATA: field1 TYPE c VALUE 'a'.
DATA: field2(6) TYPE c VALUE ' '.
DATA: field3 TYPE c VALUE 'b'.
write: field1, field2, field3.
Thanks
Nitesh
‎2008 Dec 05 9:38 AM
‎2008 Dec 05 9:40 AM
How do you know 'field(6) TYPE c' doesn;t have spaces in it?
‎2008 Dec 05 9:45 AM
I have the same question
As both
DATA: field1 TYPE c VALUE 'a'.
DATA: field2(6) TYPE c VALUE ' '.
DATA: field3 TYPE c VALUE 'b'.
write: field1,field2,field3.
and
DATA: field1 TYPE c VALUE 'a'.
DATA: field2(6) TYPE c.
DATA: field3 TYPE c VALUE 'b'.
write: field1,field2,field3.
have same output you dont have to give default value as ' '.
Edited by: mrugesh phatak on Dec 5, 2008 10:47 AM
‎2008 Dec 05 9:45 AM
‎2008 Dec 05 9:46 AM
Hello,
If you declare data as below, it will definitly have spaces,1
DATA: field(6) TYPE c VALUE '______'. ( ______ - six spaces )
to test the same try some thing like this.
data: w_test type string.
concatenate field 'This is a test' into w_test RESPECTING BLANKS.
Hope this will help.
Thanks,
Jayant
‎2008 Dec 05 9:46 AM
hi,
DATA: field(6) TYPE c .
the value of the field will be space until you assign any value to it.
or try
DATA: field(6) TYPE c value space.
thanks.
‎2008 Dec 05 9:48 AM
hiii
try using Respecting blanks statement like below code.
data:
material type mara-matnr value ' ',
batchno(6) type c value ' 1',
w_string(24) type c.
concatenate material batchno into w_string respecting blanks.
write : w_string.regards
twinkal
‎2008 Dec 05 10:11 AM
Hi,
thank you all. The responses were helpful, I wish I could give you all full points.
I found out that I was using after that a CONCATENATE statement but without RESPECTING BLANKS addition (we have ecc 5.0) and that was the cause. Time for a coffee
Regards,
Ladislav
‎2008 Dec 05 10:28 AM
Charactervariables have always a fixed length, so even when they are initial they contain spaces. If you store 5 Character in a c-Var length 10, it will contain 5 spaces at the end. So how should the compiler decide if these spaces at the end belongs to the content or are just there becase of the fixed length? He cant decide, so he always cuts off spaces at the end.
Strings do have a variable length and it is stored with a length counter. Spaces at the end are always taken into account.
Assume you habe this content: "XYZ##" (# and _ will indicate spaces. If you put that into a c(10) field you will have "XYZ##_____". Cause there is no length indicator you can not decide if the spaces belongs to the content or belongs to the fill up. A string variable will contain "XYZ##" and its clear that the spaces belongs to the content.
The disadvantage of strings is that they are incompatible with a lot of function modules and because they are deep structures they arent allowed in RFC function modules.
Besides that i'm only using strings instead of c fields.
‎2009 Feb 10 10:35 AM
this works only when you want to output to the file.
BEGIN OF ls_abody, "25
matnr TYPE mast-matnr,
rtype TYPE c,
seque(3),
bmein TYPE stko-bmein,
dummy(92),
pb(02) VALUE cl_abap_char_utilities=>cr_lf,
END OF ls_abody.
In this case say we want 94 spaces. so we make a field dummy of length 92 and then make a pagebreak variable of length two. In my interface I transfer internal tables of different structures and the requirement is that all lines are of equal length.
Edited by: Maksims Jegorovcevs on Feb 10, 2009 11:37 AM