2009 Jul 24 1:00 PM
Hi experts,
I have requirement for creating fixed length data like this:
Source Material.
I am getting source value dynamically. Max size of source in 10.
But sometime it may come as 'EMS01' and sometimes 'PLTN'. That its value can be of varied length.
I need to concat Source and Material with space in between. The number of spaces in between is equal to 10 - current size.
For example: If Source = 'EMS01'
then there should be 5 spaces between source and material.
If source = 'PLTN'
then there should be 6 spaces between source and material after concatenation.
I tried like this:
data: v_source(10),
v_material(8),
v_space(9),
v_spclen type i.
v_spclen = 10 - STRLEN( v_source ).
DO v_spclen TIMES.
v_space = v_space + ' '.
ENDDO.
CONCATENATE v_source v_space v_material INTO v_string.
This does not work because it is putting number 0 in v_space value.
How to resolve this? Please help!
Thanks
Gopal
Hi experts,
I have requirement for creating fixed length data like this:
Source Material.
I am getting source value dynamically. Max size of source in 10.
But sometime it may come as 'EMS01' and sometimes 'PLTN'. That its value can be of varied length.
I need to concat Source and Material with space in between. The number of spaces in between is equal to 10 - current size.
For example: If Source = 'EMS01'
then there should be 5 spaces between source and material.
If source = 'PLTN'
then there should be 6 spaces between source and material after concatenation.
I tried like this:
data: v_source(10),
v_material(8),
v_space(9),
v_spclen type i.
v_spclen = 10 - STRLEN( v_source ).
DO v_spclen TIMES.
v_space = v_space + ' '.
ENDDO.
CONCATENATE v_source v_space v_material INTO v_string.
This does not work because it is putting number 0 in v_space value.
How to resolve this? Please help!
Thanks
Gopal
2009 Jul 24 1:03 PM
Hi
Try this:
data: v_source(10),
v_material(8),
v_space(9),
v_spclen type i.
move v_source to v_string.
move v_material to v_string+10.
Max
2009 Jul 24 1:06 PM
Hi,
You can try this way...Try with offset and position..
v_string = v_source.
v_string+10 = v_material.or
data: v_source(10) value 'MANT',
v_material(8) VALUE '00001'.
data v_string type char40.
CONCATENATE v_source v_material INTO v_string RESPECTING BLANKS.
WRITE:/ v_string.
2009 Jul 24 1:08 PM
Hi,
Instead of doing a code for that you can use the addition RESPECTING BLANKS with the CONCATENATE statement.
Check the link for more understanding.
Regards
Sarves
2009 Jul 24 1:08 PM
Hi Try like this:
data: v_source(10),
v_material(8),
v_space(9),
v_spec value '#',
v_spclen type i.
v_spclen = 10 - STRLEN( v_source ).
DO v_spclen TIMES.
concatenate v_space v_spec into v_space.
ENDDO.
CONCATENATE v_source v_material INTO v_string seprated by v_space.
translate v_string using '# '.
Regards,
Himanshu
2009 Jul 24 1:14 PM
Hi Gopal,
try with the following statement:
'CONCATENATE v_source v_space v_material INTO v_string respecting blanks.'
Hope this will solve your problem. Because this statement add space of the variables(if some characters are left blank not fully occupied by the respective value) used in the concatenate statement.
Regards,
Prinan Pandit
2009 Jul 24 1:15 PM
Hi,
Try this. It may work.
v_sep = 10 - v_source.
DATA: v_source(10),
v_material(8),
v_space(10) VALUE 'v_sep'.
CONCATENATE v_source v_material INTO v_string SEPARATED BY v_space.
WRITE v_string .Thanks,
Sri.
2009 Jul 24 2:09 PM
Hi,
Try This.
data: v_source(10),
v_material(8),
v_space(9),
v_string(255) type c,
v_spclen type i,
v_spclen1 type i. * Delcare one more variable. This will contain Length of field v_string after assign V_source to it.
v_spclen = 10 - STRLEN( v_source ).
v_string = V_source.
CONDENSE v_string.
v_spclen1 = STRLEN( v_string ).
v_spclen1 = v_spclen1 + v_spclen. * I have Added v_spclen1 and v_spclen to get exact position from where i will add v_material
v_string+v_spclen1 = v_material.
write v_string.
Edited by: ShreeMohan Pugalia on Jul 24, 2009 3:13 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |