2010 Aug 06 9:45 AM
Hi,
The requirement is i have a field in internal table of length say 35. i have to concatenate the data in this field along with other data into a variable of length 100.
eg -
field a(35) type c.
variable txt(100).
if the field A contains 10 character value then remaining 25 i have to give spaces while concatenating.
if it contains 20 charachter value, then remaining 15 should be give spaces while concatenating.
so, there can be any combination of values and spaces. I have to handle it dynamically.
Best Regards,
Hi,
The requirement is i have a field in internal table of length say 35. i have to concatenate the data in this field along with other data into a variable of length 100.
eg -
field a(35) type c.
variable txt(100).
if the field A contains 10 character value then remaining 25 i have to give spaces while concatenating.
if it contains 20 charachter value, then remaining 15 should be give spaces while concatenating.
so, there can be any combination of values and spaces. I have to handle it dynamically.
Best Regards,
2010 Aug 06 9:55 AM
Hi,
Try this.
Data: B(35) type C.
A = 'ABC'.
WRITE: A to B.
Now use B.
2010 Aug 06 10:14 AM
Hi Mohammadi siddiqui,
You can use this :
REPORT ztest1.
DATA :
lv_text1(10) VALUE 'abc',
lv_text2(20).
START-OF-SELECTION.
WRITE lv_text1 TO lv_text2 RIGHT-JUSTIFIED. <-- right-justified fills the left part with spaces automatically
Also you can calculate length difference and use SHIFT command like this code :
REPORT ztest1.
DATA :
lv_text1(10) VALUE 'abc',
lv_text2(20).
DATA :
lv_len1 TYPE i,
lv_len2 TYPE i,
lv_diff TYPE i.
START-OF-SELECTION.
" 1 move text
lv_text2 = lv_text1.
" 2 Find difference of length :
lv_len1 = STRLEN( lv_text1 ).
DESCRIBE FIELD lv_text2 LENGTH lv_len2 IN CHARACTER MODE.
lv_diff = lv_len2 - lv_len1.
" 3 Shift value abc in text lv_text2
SHIFT lv_text2 RIGHT BY lv_diff PLACES.
Edited by: Bulent Balci on Aug 6, 2010 11:15 AM
2010 Aug 06 10:15 AM
Hi,
Please try this one..
types: begin of t_out,
a(45) type c,
end of t_out.
data: gt_out type table of t_out,
wa_out type t_out,
lv_var type i,
lv_var1 type i.
wa_out-a = 'test1'.
append wa_out to gt_out.
clear: wa_out.
wa_out-a = 'test2'.
append wa_out to gt_out.
clear: wa_out.
loop at gt_out into wa_out.
lv_var = strlen( wa_out-a ).
if lv_var < 45.
lv_var1 = 45 - lv_var.
wa_out-a+lv_var(lv_var1) = ' '.
endif.
write:/ wa_out-a, 'TEST TO CHECK'.
clear: wa_out, lv_var, lv_var1.
endloop.
i have hard coded 45 has the length, but you can pass that using a variable.
thanks!
raghu
Edited by: Raghavendra nilekani on Aug 6, 2010 2:47 PM
2010 Aug 06 10:36 AM
Hi,
You can use offsets to achive this.
DATA : field(35) TYPE c,
v_field(10) TYPE c VALUE 'Hello',
txt(100) TYPE c.
field = 'ABCD'.
* As the length of field is 35, so what ever value be field having the added text(v_fied) will be after 35 characters only
txt+34(65) = v_field.
* If you still want to add any other data to txt use concatenate.
CONCATENATE txt c_value INTO txt.
WRITE :/ txt.Output
ABCD Hello c_value.
Regards
Bala Krishna
2010 Aug 06 10:42 AM
Hi,
In write the staement like this.
concatenate field variable into variable1 respecting blanks.
Regards,
Rajesh Akarte
2010 Aug 10 6:53 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |