Well, I finally make it, there's some discussions on SCN but I might just use the wrong key words in searching this.
This FM solves the problem
* Get hostname and port of server
call function 'TH_GET_VIRT_HOST_DATA'
exporting
protocol = 2 "1 for http, 2 for https. Also edit Initial URL part after editing this
virt_idx = 0
* LOCAL = 1
importing
hostname = l_hostname
port = l_port
exceptions
not_found = 1
internal_error = 2
others = 3.