Getting IP ADDRESS IN SAP
Bliss! Never thought my secret desires during childhood days, of being a sleuth, like my heroes in detective novels, could find some gratification if I pursued a career in IT!
Alright! Alright! I know there is an entire wing in IT dealing with information security and that this is not something alien in IT. But come on! This is my first experience in this area, (other than the authorization checks being done for every transaction) and I have every reason to feel excited about it! 😳
Yep! Got a requirement that if anyone tries to manipulate any sensitive information like basic pay info type or bank account info type, system should log the action with the username in SAP with which he has logged in, and the IP Address( 😯 ) of the computer that he was using for the purpose. (Well user name seemed fine, but IP Address! From SAP! Woah! Thought that would be a load of work.) And, also, immediately send a mail to manager informing him such an attempt was made, with all the details.
Well, it turned out that getting the IP Address from SAP was a piece of cake.
There are various function modules and class methods in SAP for doing this, and the one which I used was the following.
data lv_ip(30) type c.
call method cl_gui_frontend_services=>get_ip_address
ip_address = lv_ip
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
And the icing on the cake – Manager is totally happy with the output!
By the way, if anybody feels that there are loop holes in this function, do let me know. I want to be sure that when I do something such as this; it is totally fool-proof! 😎
So to sum up! Being in IT, and in SAP, I can contribute to the interests of CIA! Ahem! Not Central Intelligence Agency: Confidentiality, Integrity and Availability. 😉