之前都是smartforms显示前导0,但是不想让它显示。昨天碰到一个非常有意思的状况,想让编码显示前导0确没有显示了!下面是解决过程:
字段类型:char8
症状:
无论前面000333是几个0都不显示!
尝试方法:
1. unpack xx to xx。
补上前导0,debug中看到确实也补上了前导0,但是没用。
2. CONVERSION_EXIT_ALPHA_INPUT
通1的效果,仍然没用
前面两种方法我觉得应该是smartforms中的问题,于是:
3. 参数设置
&fields(8)& 强制显示8位,还是不行
&fields(*)& 显示原始长度,还是不行
到此我非常困惑了,是不是字符型的不能显示前导0啊?我记得是可以的啊。于是换了一个类型raw,成功了!
RAW: Uninterpreted byte string. Fields of type RAW may have only a maximum length of 255 in tables. If longer raw fields are required in tables, you should select data type LRAW.是help上的解释。
Note: the RAW data type is mapped to the string class of the Standard C++ Library, but care must be taken when using this object. When the application program calls a field getter function (Get ()) on a field of RAW type and retrieves a string object, the string object encapsulates a character array of length equal to the ABAP-defined length of the field. The character array encapsulated inside the string object may contain null character in the beginning or the middle of the array, therefore this array cannot be treated as a normal character string. Using cout of the iostream class would output a truncated character string, terminated by the first null character. Also, when the application program calls a field setter function (Set ()), the argument passed is void* , a pointer that points to the raw byte array to be copied to the intended field.
貌似和char没有太大区别,只不过sap似乎对这个类型的没有做过任何处理。不管怎样,解决了问题。