释疑の语法Unpackpack
For?example:??與外圍系統接口,外圍系統數據庫存儲數據是有0000的,但是SAP數據庫中存儲是沒有0000,可以用前導零函數或者這個關鍵字處理
PACK格式:PACK source TO destination.
標準教材上說:?In contrast to the conversion rules for elementary data types, a decimal separator in source is ignored.說什么小數點會被忽略,反正我是不信,嘗試一下。
DATA:?LV_PACK?TYPE?P?LENGTH?8?DECIMALS?3?VALUE?'123.456',
??????CHAR1???TYPE?C?LENGTH?10,
??????CHAR2???TYPE?C?LENGTH?10.
PACK?LV_PACK?TO?CHAR1.
WRITE?:?/?CHAR1.
輸出:
果然如此,我居然無言以對。
再舉一個例子。
DATA:?LV_PACK?TYPE?CHAR255?VALUE?'王健林.王思聰',
??????CHAR1???TYPE?C?LENGTH?10,
??????CHAR2???TYPE?C?LENGTH?10.
PACK?LV_PACK?TO?CHAR1.
WRITE?:?/?CHAR1.
輸出:
原因在標準教材上也有說明:The data type of source must be character-type,flat, and its content must be interpretable as a numeric value.?
再說說比較有用的UNPACK格式:UNPACK source TO destination.?
標準教材上這樣說:
If the data type of source is not of the type p with length 16 and without decimal places, then the content of source is converted to this data type. Contrary to the rules described in conversion rules for elementary data types, any decimal separator in source is completely ignored.?
The digits of the interim result are assigned to data object destination right-aligned and without +/- sign. Any additional places in destination are filled with leading zeros. If the length of destination is not sufficient, the assigned variable is truncated from the left.?
大概意思同上面的PACK,唯一的好處是什么,就是剛開始說明的,比如別的系統是需要千導0的,我們得給他按位數轉換上。
直接看例子:
DATA:?PACK??TYPE?P?LENGTH?8?DECIMALS?3?VALUE?'123.456',
??????CHAR1?TYPE?C?LENGTH?10,
??????CHAR2?TYPE?C?LENGTH?10.
MOVE???PACK?TO?CHAR1.
UNPACK?PACK?TO?CHAR2.
WRITE?:?/?CHAR1.
WRITE?:?/?CHAR2.
輸出:
總結
以上是生活随笔為你收集整理的释疑の语法Unpackpack的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 今生共相伴
- 下一篇: 释疑の资源短缺DATASET_CANT_