There is a function for this in the "Function Module". I believe the function is called BIS_fnc_PosToGrid (I'm not 100% sure of the name).
So to get the map grid position of unit "_unit" simply write:
_mapGrid = (getPos _unit) call BIS_fnc_PosToGrid;
"_mapGrid" is an array of two elements, the first is the horizontal grid no., the second is the vertical. Both elements are strings.