CLASS lcl_conv DEFINITION.
PUBLIC SECTION.
*--------------------------------------------------------------------*
CLASS-METHODS: ipv4hex_to_ipv4string
IMPORTING
i_hexadr TYPE mshostadr
RETURNING VALUE(ret_ip) TYPE string.
ENDCLASS.
*--------------------------------------------------------------------*
CLASS lcl_conv IMPLEMENTATION.
*--------------------------------------------------------------------*
* Konvertiert IP-Adresse (Hex) nach IPv4-String
*--------------------------------------------------------------------*
* -> i_hexadr - Hostadresse (IP) in Hex
* <- ret_ip - IP-Adresse (IPv4)
*--------------------------------------------------------------------*
METHOD ipv4hex_to_ipv4string.
* IP besteht aus 4 Bytes (Hex)
IF xstrlen( i_hexadr ) = 4.
* jeder Hex-Wert wird in Integer konvertiert
ret_ip = |{ CONV i( i_hexadr+0(1) ) }.{ CONV i( i_hexadr+1(1) ) }.{ CONV i( i_hexadr+2(1) ) }.{ CONV i( i_hexadr+3(1) ) }|.
ENDIF.
ENDMETHOD.
ENDCLASS.
* mshostadr -> TYPE RAW4 -> x
* 255.255.255.0
DATA: ip_hex TYPE mshostadr VALUE 'FFFFFF00'.
WRITE: / lcl_conv=>ipv4hex_to_ipv4string( ip_hex ).