2006 Feb 15 11:33 PM
Hi
I just have a doubt which I need to clear. Were using some code logic in which we are passing some "C" variables value to FM and return the value and replace (<b>.</b>) by Some Character ( A,b,c,d) . After that perform_call I am doing something like
Data:vari_n(11) type N,
vari_c(13) type c.
The value in vari_c is like '000000002224D'.
<b> MOVE Vari_c+2(11) TO vari_N.</b>
I was expecting that after move statement the value in Vari_n should be like '0000002224D' but in fact its not its like '00000002224'.
<b>It was working correct before , why its not working now ?</b>
Now I made a change into code and write code like
<b> write Vari_c+2(11) TO vari_N.</b>
But my question is that why its not working with move statement.
Please give your input/suggestions.
Thanks
*----
I read Move help and its says that ---
If the field types or lengths differ, the system automatically carries out type conversion. Type I fields are handled like type P fields. If you select the fixed point arithmetic attribute for an ABAP program, type P fields are either rounded according to the number of decimal places or filled with zeros.
See: Conversion Table for the MOVE Statement
If the assignment is allowed but the source field type cannot be converted to the target field type, the contents of the target field are undefined. This would be the case, if you were to assign a C field containing 'ABCD' to a type D or T field.
<b>The operation is terminated only if the target field is a numeric type ( I, P or F).</b>
If the target field has type C, you must decide between MOVE and WRITE TO. The MOVE statement is intended for assignments within a program, and it generates a standard display that is compatible with the source type. This can be converted back into the original value using MOVE again, as long as it was not truncated in the assignment. For this reason, the period (.) is always used as the decimal sign, and dates cannot be converted, regardless of the user defaults.
You use the WRITE TO statement to generate a readable ('external') display for the value of the source field. The target field is usually displayed on a screen or in a list, after further processing if necessary. Unlike MOVE, WRITE TO has several formatting options, which, for some data types, are user-defined. A conversion exit may be called implicitly.
**----
Message was edited by: Saquib Khan
2006 Feb 15 11:45 PM
2006 Feb 15 11:54 PM
I need to achieve the value '0000002224D'.
<b>I change the code to
write Vari_c+2(11) TO vari_N.
Its working fine..</b>
But the guys over here keep saying it was working fine earlier.. and they are getting their required result ..Thats why I asked ..
Thanks Rich for a prompt reply!!!
2006 Feb 15 11:57 PM
I have never seen a move from c to N carry the alphas along. Again, what is the end result that you require?
In this example, i have put ABC in the middle, it will be stripped out and will only write the numeric value.
report zrich_0001.
Data:vari_n(11) type N,
vari_c(13) type c.
vari_c = '00000<b>ABC</b>2224D'.
MOVE Vari_c+2(11) TO vari_N.
write:/ vari_n.
Regards,
Rich Heilman
2006 Feb 16 12:01 AM
<b>'0000002224D'.</b>
report zrich_0001.Data:vari_n(11)
type N,vari_c(13) type c.
vari_c = '00000ABC2224D'.
<b>MOVE Vari_c+2(11) TO vari_N.</b>
I changed it to :
<b>write Vari_c+2(11) TO vari_N.</b>
and it worked....as I posted earlier...
write:/ vari_n.
Thanks ..case closed:)
2006 Feb 16 12:06 AM
type n variables with an alpha at the end are actually negative. The last character is an 'overtype' code, can't remember the exact sequence but it's something like a = -0, b = -1, c= -2 etc. This must be the only case where alpha values are tolerated within type n.
2006 Feb 16 12:08 AM
Ok, this is kinda of strange to me. The reason for having a numeric field is to have a true numeric value. If you wanted the exact string as it was from the character field, then whats the point is using a numeric. Remember, if the N value is used in a calculation, you will get a runtime error for haveing alphas in your numeric field,.
report zrich_0001.
Data:vari_n(11) type N,
vari_c(13) type c,
result type i.
vari_c = '00000ABC2224D'.
write Vari_c+2(11) TO vari_N.
result = vari_n + 1.
write:/ vari_n.
Regards,
Rich Heilman
2006 Feb 16 12:28 AM
Rich, this is a special case. They are numeric values, but negative. It is a hangover from pre-historic days when they needed to save space on punched cards. Negative numbers didn't need an extra character they could be represented by using the 'overtype' code on the final character. for example -1134 could be 113D, -1135 113E etc(codes are not necessarily correct but the concept is).