Monday, September 3, 2007

Conversion routine

Write this simple code.


REPORT ZFIELDCONV.
data: d_auart LIKE vbak-auart.
d_auart = 'TA'.
WRITE d_auart.

What the result output on screen do you expect, "TA"? No, the result will be "OR".

The result comes from conversion routine of its domain. In SE11 open table VBAK, find field AUART, double click to go to data element AUART, then double click to open domain AUART. You will see its conversion routine, named AUART. Double click the conversion routine, you got at least two conversion routine conversion routine input & output. They are function module, you can test them in SE37.
The INPUT routine performs the conversion from display format to internal format. The OUTPUT routine performs the conversion from internal format to display format. Take attention when we hard code value as a condition value in "WHERE condition", you must convert its value into internal format.

Other commonly used conversion routine is ALPHA. It is conversion used to insert leading zero for document number. For example, in sales order (VBAK-VBELN length 10), when we key in order no, for example we key in '4302', conversion routine input will automatically add leading zero, so it will become '0000004302', this is real value stored in table VBAK. On conversion routine output, it will delete leading zero.

In SE16, we can view the data wheather in internal format or display format, to toggle format, in display list, go to Setting->User Parameter, in tab strip "Data browser" choose "format, field conversion exit".

Read More......