Code: Alles auswählen.
FUNCTION z_field_conv_inp .
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(I_FIELDNAME) LIKE DFIES-FIELDNAME
*" VALUE(I_FIELDVALUE)
*" VALUE(I_TABNAME) LIKE DFIES-TABNAME
*" EXPORTING
*" VALUE(O_FIELDVALUE)
*" EXCEPTIONS
*" CONVEXIT_OR_VALUE_NOT_FOUND
*" FIELD_OR_TAB_NOT_FOUND
*" VALUE_NOT_VALID
*" NO_CONVERSION
*"----------------------------------------------------------------------
DATA: lt_dfies LIKE STANDARD TABLE OF dfies.
DATA: wa_dfies TYPE dfies.
DATA: lv_value_out TYPE REF TO data.
DATA: lv_length_in TYPE i.
DATA: mess_typ.
FIELD-SYMBOLS: <value_out> TYPE ANY.
DATA: conversion_call(30) TYPE c VALUE 'CONVERSION_EXIT_?_INPUT'.
* bei PSP Nummern gibt es Probleme, daher
* hier ne Sonderlocke
* handle error message from function call * CJPN_PROJEKTNUMMER_UNEDIT
mess_typ = 'S'.
EXPORT mess_typ TO MEMORY ID 'EXT_MESS_TYP'.
* no fieldname set, when object key has *more as one field
IF NOT i_fieldname IS INITIAL.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = i_tabname
fieldname = i_fieldname
* LANGU = SY-LANGU
* LFIELDNAME = ' '
* ALL_TYPES = ' '
* IMPORTING
* X030L_WA =
* DDOBJTYPE =
* dfies_wa =
* LINES_DESCR =
TABLES
dfies_tab = lt_dfies
* FIXED_VALUES =
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
RAISE field_or_tab_not_found.
ENDIF.
READ TABLE lt_dfies INTO wa_dfies INDEX 1.
IF sy-subrc NE 0.
*
EXIT.
ENDIF.
CREATE DATA lv_value_out TYPE (wa_dfies-domname).
ASSIGN lv_value_out->* TO <value_out>.
lv_length_in = strlen( i_fieldvalue ).
IF lv_length_in GT wa_dfies-outputlen.
RAISE value_not_valid.
ENDIF.
IF NOT wa_dfies-convexit IS INITIAL.
* conversion exit exists
* replace conversion routine name
REPLACE '?' WITH wa_dfies-convexit INTO conversion_call.
CALL FUNCTION conversion_call
EXPORTING
input = i_fieldvalue
IMPORTING
output = <value_out>
EXCEPTIONS
not_found = 1.
IF sy-subrc NE 0.
* conversion exit or value not found (PRPS checks against database !)
RAISE convexit_or_value_not_found.
ENDIF.
ELSE.
* no conversion exit, OUT = IN
RAISE no_conversion.
ENDIF.
else.
ASSIGN i_fieldvalue TO <value_out>.
ENDIF. " IF NOT wa_dfies-convexit IS INITIAL
o_fieldvalue = <value_out>.
ENDFUNCTION.