One way to go about this is to examine your /etc/hostname.interface files. One of these will contain the hostname. You may only have one, but if you are using IPMP you'll have others and if you're on multiple networks you'll have more.
Example of a solaris 10 host with an IPMP pair for the front-end and an IPMP pair for the back-end:
#ls -C1 /etc/hostname.*
/etc/hostname.e1000g0
/etc/hostname.e1000g1
/etc/hostname.e1000g2
/etc/hostname.e1000g3
#cat /etc/hostname.*
myhostname netmask + broadcast + group ipmp_fe up
group ipmp_fe up
myhostname-nfs netmask + broadcast + group ipmp_be up
group ipmp_be up
Each interface with an IP address will have a hostname in the corresponding /etc/hostname.interface file which corresponds to an entry in /etc/hosts. A simple shell script can parse this out for you. In the example above, this host is using IPMP so you have 2 extra files which do not contain the hostname.
There are other ways to configure solaris networking but the above is how it's been done for a long time and likely how it's done on your system.