‎2008 May 14 4:02 PM
Hello,
i have a requirement where I need to pass integer value only and do not need leading spaces. Can someone please help me to get this issue resolved?
I have tried using "shift"/condense and many more options. None of them works as they are for type C,N,D,T.
Plese help.
‎2008 May 14 4:10 PM
Hi Michael,
u can't use CONDENSE for deleting leading spaces of TYPE I fields. MOVE THIS DATA to character/String Variable and then CONDENSE this.
eg:
DATA: w_num TYPE I VALUE 8,
w_char TYPE string.
MOVE w_num TO w_char.
CONDENSE w_char.
WRITE :/1 w_num
/1 w_char.
Thanks,
Vinod.
‎2008 May 14 4:05 PM
u need to use convert_exit_apha_output FM
in se37 chek for Convertalphaoutput FM
‎2008 May 14 4:07 PM
Hi Michael ,
INtegers wont have leading spaces , what exactly do want to acheive .
Regards
Arun
Edited by: Arun R on May 14, 2008 8:44 PM
‎2008 May 14 4:09 PM
‎2008 May 14 4:10 PM
Hi Michael,
u can't use CONDENSE for deleting leading spaces of TYPE I fields. MOVE THIS DATA to character/String Variable and then CONDENSE this.
eg:
DATA: w_num TYPE I VALUE 8,
w_char TYPE string.
MOVE w_num TO w_char.
CONDENSE w_char.
WRITE :/1 w_num
/1 w_char.
Thanks,
Vinod.
‎2008 May 14 4:10 PM
An interger field can not have spaces. So passing the field would have leading zeroes.
‎2008 May 14 4:11 PM
DATA : lv_num TYPE i VALUE '123'.
data : lv_num1(10) type c .
lv_num1(10) = lv_num.
SHIFT lv_num1 LEFT DELETING LEADING space.
WRITE:/ lv_num1.
hope this helps..
regds
‎2008 May 14 4:19 PM
Thanks for the prompt reply.
but my question is to remove space in integer.
Condense/ covertalphainput/output will all be applied on char type. These will not resolve my problem.
my problem is like I have an integer whose value is ' 8' (do not refer quote, it is used to show leading space). I have to get only 8 and that to in integer.
‎2008 May 14 4:25 PM
Micheal,
Integers are stored as Binary. So you can't have a space.
To prove this, put a breakpoint in your program at the field with the value in it. Then when in debug, double click on the
field. Where it shows the value, yes you will see ' 8'. however, if you push the Magnifying glass with the + in it, you will see the true
value of the field in HEX.
Passing this field should pass the integer in binary. You must make sure that the sizes are the same in the sending and receiving fields of what ever you are attempting to pass it to.
‎2008 May 14 4:26 PM
Hi Michael ,
You cannot acheive it using int data type , you need to move it to a variable of type n and then use shift to acheive the result.
Here is a sample code for the same
data v1 type i.
data v2(10) type n.
v1 = 8.
v2 = v1.
shift v2 left deleting leading '0'.Regards
Arun
‎2008 May 14 4:30 PM
Hi
your issue is not very clear, I can't understand where u have the integer and where u have to put the integer, anyway try to see if this sample is helpfull for you:
DATA: V_CHAR(10) TYPE C,
I TYPE I VALUE 8,
LEN TYPE I.
WRITE I TO V_CHAR.
CONDENSE V_CHAR NO-GAPS.
LEN = STRLEN( V_CHAR ).
WRITE V_CHAR(LEN).Max
‎2008 Jul 24 8:13 AM
Hi,
What is every material number also have few zero infront, like some is 0000001000 and another once is 00123456 , how to remove the front zero for matnr field?
Thanks
‎2008 May 14 4:33 PM
Here is a sample code. i tried to replicate the same case,
data : v_int type i.
v_int = 56.
write v_int.
Here you will get the spaces. How to remove spaces in integer(i do not want ouput in any other data type).
‎2008 May 14 4:35 PM
Hi
DATA : V_INT TYPE I.
V_INT = 56.
WRITE V_INT LEFT-JUSTIFIED.
Max
‎2008 May 14 4:37 PM
check the post of Max for the solution to your problem , it would have been great if you had mentioned that you want to acheive it in write statement .
use LEFT-JUSTIFIED along with the write statement
data v1 type i.
v1 = 8.
write v1.
skip 1 .
write v1 LEFT-JUSTIFIED.
skip 1.
‎2008 May 14 4:37 PM
Then if you are not passing it to a FM, or another program etc...
Max's suggestion is the best solution.
Or
You can move it to a character type field as many here have suggested and use the SHIFT LEFT deleteing leading zeros.
Then, print the Character field.
‎2008 May 14 4:38 PM
form alpha_input using p_var.
call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = p_var
importing
output = p_var.
endform. " alpha_input
‎2008 May 14 4:39 PM
Ok..
Try like this:
data : v_int type i,
v_len type i,
v_char type char10.
v_int = 356.
v_char = v_int.
condense v_char.
v_len = strlen( v_char ).
write at (v_len)v_int.
Regards,
Naimesh Patel
‎2008 May 14 4:38 PM
I have to use this variable containing no spaces furher. So "left-justified' will not work. Anyways good one. Please help me in this requirement.
‎2008 May 14 4:39 PM
Writing Left justified does NOT effect the original value. It's simply the displaying of it.
‎2008 May 14 4:41 PM
‎2008 May 14 4:56 PM
n type will also not help me in resolving the issue.
It is like i have to pass integer value in BDC and it is not accepting value in any other data type and even spaces in front of integer will not fetch me my result in BDC. Only option for me is to remove spaces in front of integer.
need help
‎2008 May 14 5:05 PM
what about this
data: l_v type i value 36,
l_n(6) type n.
l_n = l_v.
write l_n to l_n no-zero.
condense l_n.
write l_n.
‎2008 May 14 5:06 PM
try using data type n in BDC ; i dont thnik BDC has an issue with data type till the data you are passing to field is correct.
Try it and tell the result .
‎2008 May 14 5:06 PM
Hi
If you're creating a BDC report, the BDC structure has only char field, so u can use the statament:
WRITE <INTEGER> LEFT-JUSTIFIED TO BDCDATA-FVAL.
Max
‎2008 May 14 5:21 PM
Hello everybody,
i have recorded transaction ML81 and have to make changes in the Service entry sheet. When making changes into the same i have to pass line no. which needs to be modified as i have to modify quantity. In order to pass line no. I have read data using sy-tabix and then passed the same into a temporary integer value which signifies line no. But due to spaces present in it BDC is not capturing the line no. So it skips this step and move further without amendment
‎2008 May 14 5:30 PM
When you pass your line number to BDC table use CONDENSE to remove the leading space from the BDC field.
Like:
BDCDATA-FVAL = L_INDEX.
condense BDCDATA-FVAL.
APPEND BDCDATA.
Regards,
Naimesh Patel
‎2008 May 14 5:37 PM
Hi
I don't know that trx, but if you're speaking about a tablecontrol, u should transfer the line value beetween ()
Max
‎2008 May 14 5:44 PM
May be try this RegEx
report zars.
data: l_v type i value ' 36',
l_c(13) type c.
data : regex type c length 120 value '^[ ]+|[ ]+$'.
write l_v to l_c.
replace regex regex in l_c
with space ignoring case.
write l_c.
a®
‎2016 Aug 05 11:31 AM