FUNCTION ZWY_IPADR2STRING.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(IPADR) LIKE MSXXLIST-HOSTADR
*" EXPORTING
*" REFERENCE(STRING) TYPE C
*"----------------------------------------------------------------------
DATA: I TYPE I,
X TYPE X,
IP(20).
*---------------------------------------------------------------------
* Konvertiert Hex-Darstellung in IP-Adresse als String
*---------------------------------------------------------------------
CLEAR IP.
X = IPADR(1).
I = X.
WRITE I TO IP LEFT-JUSTIFIED.
IP+4 = '.'.
CONDENSE IP NO-GAPS.
X = IPADR+1(1).
I = X.
WRITE I TO IP+5 LEFT-JUSTIFIED.
IP+10 = '.'.
CONDENSE IP NO-GAPS.
X = IPADR+2(1).
I = X.
WRITE I TO IP+10 LEFT-JUSTIFIED.
IP+16 = '.'.
CONDENSE IP NO-GAPS.
X = IPADR+3(1).
I = X.
WRITE I TO IP+15 LEFT-JUSTIFIED.
CONDENSE IP NO-GAPS.
STRING = IP.
ENDFUNCTION.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(IPADR) LIKE MSXXLIST-HOSTADR
*" EXPORTING
*" REFERENCE(STRING) TYPE C
*"----------------------------------------------------------------------
DATA: I TYPE I,
X TYPE X,
IP(20).
*---------------------------------------------------------------------
* Konvertiert Hex-Darstellung in IP-Adresse als String
*---------------------------------------------------------------------
CLEAR IP.
X = IPADR(1).
I = X.
WRITE I TO IP LEFT-JUSTIFIED.
IP+4 = '.'.
CONDENSE IP NO-GAPS.
X = IPADR+1(1).
I = X.
WRITE I TO IP+5 LEFT-JUSTIFIED.
IP+10 = '.'.
CONDENSE IP NO-GAPS.
X = IPADR+2(1).
I = X.
WRITE I TO IP+10 LEFT-JUSTIFIED.
IP+16 = '.'.
CONDENSE IP NO-GAPS.
X = IPADR+3(1).
I = X.
WRITE I TO IP+15 LEFT-JUSTIFIED.
CONDENSE IP NO-GAPS.
STRING = IP.
ENDFUNCTION.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15117617/viewspace-557560/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/15117617/viewspace-557560/