02-01-2012 4:44 AM
Hi Experts,
I have experienced a Strange things with NUMC.
How ever you define your Numc (straight or dictionary ref like "DATA: value1 TYPE pa0000-pernr) or what ever.
I have seen different results different scenarios as shown in below example.
REPORT znumc_test.
DATA : value1 TYPE n LENGTH 6.
DATA : value2(15) TYPE n.
DATA : value3 TYPE numc10.
DATA : ltext(40) TYPE c VALUE '0##010,SHOCKING-RIGHT,02 000'.
WRITE:/ 'Test1'.
WRITE:/ value1, value2, value3.
SPLIT ltext AT ',' INTO value1 value2 value3.
WRITE:/ value1, value2, value3.
CLEAR : value1, value2, value3.
WRITE:/ value1, value2, value3.
MOVE 'Can it be done?' TO value2.
WRITE:/ value2.
CONCATENATE 'It' 'Can' 'be' 'done.' INTO value2 SEPARATED BY space.
WRITE:/ value2.
value1 = value3 = value2.
WRITE:/ value1, value2, value3.
SPLIT 'Is This Possible?' at space INTO value1 value2 value3.
WRITE:/ value1, value2, value3.
I encounter this behavior when I was uploading my CSV file using split.
Can anyone please Define NUMC exactly for me.
Output of above in my system is show below
Test1
000000 000000000000000 0000000000
0##010 SHOCKING-RIGHT 02 000
000000 000000000000000 0000000000
000000000000000
It Can be done.
done. It Can be done. n be done.
Is This Possible?
Thanks & Regards,
Dileep .C
02-01-2012 5:11 AM
Hello Dileep,
Actually this is nothing to be shocked about, if you read the F1 documentation
This definitely goes on to show we all neglect F1 more than it should be!
BR,
Suhas
02-01-2012 5:11 AM
Hello Dileep,
Actually this is nothing to be shocked about, if you read the F1 documentation
This definitely goes on to show we all neglect F1 more than it should be!
BR,
Suhas
02-01-2012 6:25 AM
Hi Suhas,
Thanks for your information. I did went to through F1 before posting here. But I am not impressed with explanation.
I think I might missing something, Thats why I was looking for some valuable answers from experts here.
-
Properties
Type = n
Length = 1 to 262,143 characters
Standard Length = 1 characters
Name = Numeric text field
Numeric text
Character string consisting only of the digits 0 through 9. Valid content of a numeric text field.
-
Value Ranges and Initial Values
Type = n
Value Range = Any alphanumeric characters; only valid values are the digits 0 to 9, however
Initial Value = "0" for every position
-
Can you explain difference in below,
DATA : value(20) TYPE n.
MOVE 'Can it be moved?' TO value. "its not working or cant be moved
WRITE:/ value.
CONCATENATE 'It' 'Can' 'be' 'moved.' INTO value SEPARATED BY space. "its working perfect
WRITE:/ value.
My Point is pretty simple, Does NUMC allows characters in it. If yes, what are the scenario's.
Please shed some light on me.
Thanks & Regards
Dileep .C
02-01-2012 6:49 AM
> Can you explain difference in below,
>
> DATA : value(20) TYPE n. > MOVE 'Can it be moved?' TO value. "its not working or cant be moved > WRITE:/ value. "here its an assignment operation. assignment to type n only moves numeric values from a string. " source char type -> destination 'n' type.. only numbers are moved to destination "hence try this " MOVE 'Can1it2be3moved?' TO value. "this will move 1 2 and 3 into right allignment of 'value' > CONCATENATE 'It' 'Can' 'be' 'moved.' INTO value SEPARATED BY space. "its working perfect > WRITE:/ value. "this is not an assignment, this is a character processing. "hence it moves the char type value, conversion rule is not applied here >
02-01-2012 7:12 AM
Hi Dileep,
Concatinate keyword expects its destination to be a character string and treats num2 as string in order to insert the concatinated characters into num2.
Move looks at its destination's data type and since it is NUMC all the characters except 1-9 are convered to 0s only.
Best Regards.
Aswath.
02-01-2012 7:17 AM
Hello Dileep,
I did went to through F1 before posting here. But I am not impressed with explanation.
I beg to differ. SAP online documentation is pretty clear about assignments.
http://help.sap.com/abapdocu_702/en/abenvalue_assignments.htm --> Your pit-stop for all assignment operations!
I'm sure once you go through this documentation thoroughly you'll understand why CONCATENATE behaves differently from MOVE or '='.
BR,
Suhas
PS: Make sure you read the latest ABAP documentation. With every ABAP Release the documentation is getting modified and kudos to [Mr. Horst Keller and his team|] for doing a wonderful job
02-02-2012 3:14 AM
Thanks Suhas & Soumyaprakash,
That solved my doubts clearly, which was not as clear as, from one of your old thread one year back from now.
Now its more clear.
Thanks & Regards,
Dileep .C
02-01-2012 6:19 AM
There is nothing strange.. this is how assignment works..
MOVE 'Can it be done?' TO value2.
WRITE:/ value2.
clear value2. "no effect but to make your mind happy :)
MOVE 'Can 1 it 2 be 3 done?' TO value2.
WRITE:/ value2.
this should clear your doubt..
and about split and concatenate - these are char string processing units.. so they dont follow assignment conversion rules..