‎2008 Jul 02 7:43 AM
i have an internal table
field1 field2 field3 field4
-
c1 c2 c3 c4
c5 c6 c7 c8
i am concatenating each row into a string separated by space.
my problem is this: if c3 or c4 is empty, it should be filled with space. The downloaded file should be like this.
length of c3 is 16 and length of c4 is 50
1900000094 23/05/2008 IBM INDIA LTD Purchase the LAPTOP
1900000096 23/05/2008 Training SAP
‎2008 Jul 02 8:04 AM
Try this:
data: space1 type CL_ABAP_CHAR_UTILITIES=>SPACE_STR.
l_length = strlen (itab-field1).
Do l_length times.
concatenate itab-field1 space1 into itab-field1.
enddo.
‎2008 Jul 02 8:04 AM
Try this:
data: space1 type CL_ABAP_CHAR_UTILITIES=>SPACE_STR.
l_length = strlen (itab-field1).
Do l_length times.
concatenate itab-field1 space1 into itab-field1.
enddo.
‎2008 Jul 02 9:58 AM
Hi Sourav Bhaduri,
Thanks for ur reply.. I tried this code.
data : space1 type CL_ABAP_CHAR_UTILITIES=>SPACE_STR.
I got this error : The type "SPACE_STR" is unknown.
‎2015 May 15 5:26 PM
Hi Christy,
CL_ABAP_CHAR_UTILITIES=>SPACE_STR
The Visibility for SPACE_STR is a PRIVATE, hence it cannot be used for declaration.
Regards,
Rafi
‎2015 May 15 7:30 PM
yes you are right,
but this is public.
CL_SCSM_XML_WRITER=>SPACE_STR
‎2015 May 15 7:31 PM
‎2008 Jul 02 8:14 AM
hi,
I think there are two ways to go:
1.
CONCATENATE field1 field2 ... INTO string SEPARATED BY space RESPECTING BLANKS.
However this works only in 6.0 (because of the RESPECTING BLANKS)
2. Use offsets:
string+n(16) = field3. (n will be the starting position of field3 minus 1)
string+x(50) = field4.
hope this helps
ec
‎2008 Jul 02 9:21 AM
Thanks Eric,
could you pls explain it? below is my code. this is not working.
if wa_linedata-xblnr = ' '.
here i want to fill wa_linedata-xblnr by space.
string+n(16) = wa_linedata-xblnr.
endif.
‎2008 Jul 02 9:25 AM
hi check this...use this..
data: filler(16) TYPE c VALUE cl_abap_char_utilities=>HORIZONTAL_TAB.
‎2008 Jul 02 9:57 AM
if u r facing the problem using normal concatenate statement then do some thing like this.
loop at itab.
if itab-c1 is not initial.
wk_string = itab-c1.
elseif itab-c2 is not initial.
concatenate wk_string itab-c2 into wk_string separated by space.
elseif itab-c3 is not initial.
concatenate wk_string itab-c3 into wk_string separated by space..
elseif itab-c4 is not initial.
concatenate wk_string itab-c4 into wk_string separated by space.
endif.
write wk_string.
endloop.
do find out whether there is any better way than this
‎2008 Jul 02 10:01 AM
‎2015 May 15 5:35 PM
Why are you concatenating everything into a string? Can't you just download your structured itab since all the components seem to be character type? If you actually need a space between each field then declare another work area with the same fields plus a CHAR1 field between each and download from that structure.
JIm