diff --git a/SAILPOINT/Functions/ES_GET_ALL_MAPICS_ENVIRONMENTS.sql b/SAILPOINT/Functions/ES_GET_ALL_MAPICS_ENVIRONMENTS.sql
index b1d9621..2c9456d 100644
--- a/SAILPOINT/Functions/ES_GET_ALL_MAPICS_ENVIRONMENTS.sql
+++ b/SAILPOINT/Functions/ES_GET_ALL_MAPICS_ENVIRONMENTS.sql
@@ -1 +1,105 @@
-âÅã@×ÁãÈ@\ÓÉÂÓ@^@
%
%ÃÙÅÁãÅ@ÖÙ@ÙÅ×ÓÁÃÅ@ÆäÕÃãÉÖÕ@âÁÉÓ×ÖÉÕãKÅâmÇÅãmÁÓÓmÔÁ×ÉÃâmÅÕåÉÙÖÕÔÅÕãâ@M@]@
%ÙÅãäÙÕâ@ÃÓÖÂMòñô÷ôøóöô÷]@@@
%ÓÁÕÇäÁÇÅ@âØÓ@
%â×ÅÃÉÆÉÃ@âÁÉÓ×ÖÉÕãKÅâÁÓÓÅÕåâ@
%ÕÖã@ÄÅãÅÙÔÉÕÉâãÉÃ@
%ÔÖÄÉÆÉÅâ@âØÓ@ÄÁãÁ@
%ÃÁÓÓÅÄ@ÖÕ@ÕäÓÓ@ÉÕ×äã@
%ÕÖã@ÆÅÕÃÅÄ@
%âÅã@Ö×ãÉÖÕ@@ÁÓæÂÓÒ@~@\ÁÓÓÙÅÁÄ@k@
%ÁÓæÃ×èÄãÁ@~@\Ö×ãÉÔÉéÅ@k@
%ÃÖÔÔÉã@~@\ÕÖÕÅ@k@
%ÄÂÇåÉÅæ@~@\âÖäÙÃÅ@k@
%ÄÅÃÙÅâäÓã@~@Móñk@óñk@ðð]@k@
%ÄèÕÄÆãÃÖÓ@~@\ÕÖ@k@
%ÄèÕäâÙ×ÙÆ@~@\ÖæÕÅÙ@k@
%âÙãâÅØ@~@\ÈÅç@@@
%ÂÅÇÉÕ@
%ÄÅÃÓÁÙÅ@ÃÖÕãÉÕäÅ@ÈÁÕÄÓÅÙ@ÆÖÙ@âØÓÅçÃÅ×ãÉÖÕ@
%ÂÅÇÉÕ@
%ÄÅÃÓÁÙÅ@åmâØÓâãÁãÅ@ÃÈÁÙ@M@õ@]@^@
%ÄÅÃÓÁÙÅ@åmÄÂòmÙÅãäÙÕmÃÖÄÅ@ÉÕã@^@
%ÄÅÃÓÁÙÅ@åmÄÂòmÔÅââÁÇÅmÉÄ@ÃÈÁÙ@M@÷@]@^@
%ÄÅÃÓÁÙÅ@åmÅÙÙÖÙmÔÅââÁÇÅ@ÃÓÖÂ@M@òðôø@]@^@
%``@Ã�—£¤™…@„‰�‡•–¢£‰ƒ@‰•†–@
%ÇÅã@ÄÉÁÇÕÖâãÉÃâ@ÃÖÕÄÉãÉÖÕ@ñ@
%åmÄÂòmÙÅãäÙÕmÃÖÄÅ@~@ÄÂòmÙÅãäÙÕÅÄmâØÓÃÖÄÅ@k@
%åmâØÓâãÁãÅ@~@ÙÅãäÙÕÅÄmâØÓâãÁãÅ@k@
%åmÅÙÙÖÙmÔÅââÁÇÅ@~@ÔÅââÁÇÅmãÅçã@k@
%åmÄÂòmÔÅââÁÇÅmÉÄ@~@ÄÂòmÔÅââÁÇÅmÉÄ@^@
%ÙÅãäÙÕ@
%M@
%åÁÓäÅâ@ÑâÖÕmÖÂÑÅÃã@M@
%}¢¤ƒƒ…¢¢}@åÁÓäÅ@}†�“¢…}@k@}âØÓÉ•†–}@åÁÓäÅ@ÑâÖÕmÖÂÑÅÃã@M@
%}âØÓâ£�£…}@åÁÓäÅ@åmâØÓâãÁãÅ@k@
%}âØÓÃ–„…}@åÁÓäÅ@åmÄÂòmÙÅãäÙÕmÃÖÄÅ@k@
%}”…¢¢�‡…ÉÄ}@åÁÓäÅ@åmÄÂòmÔÅââÁÇÅmÉÄ@k@
%}”…¢¢�‡…}@åÁÓäÅ@åmÅÙÙÖÙmÔÅââÁÇÅ@k@
%}ƒ¤™™…•£ã‰”…¢£�”—}@åÁÓäÅ@ÃäÙÙÅÕãmãÉÔÅâãÁÔ×@
%]@
%]@]@^@
%ÅÕÄ@^@
%ÙÅãäÙÕ@
%ÃÖÁÓÅâÃÅ@M@
%ÑâÖÕmÖÂÑÅÃã@M@
%}¢¤ƒƒ…¢¢}@z@}£™¤…}@k@}„�£�}@åÁÓäÅ@M@
%âÅÓÅÃã@ÑâÖÕmÁÙÙÁèÁÇÇ@M@
%ÑâÖÕmÖÂÑÅÃã@M@
%}…•¥É„}@åÁÓäÅ@ÅÕåÉÄ@k@}…•¥Ä¢ƒ}@åÁÓäÅ@ÅÕÄâÃ@k@
%}…¢É•¢£�““…„}@åÁÓäÅ@ÅâmÉÕâãÁÓÓÅÄ@
%]@
%]@
%ÆÙÖÔ@ãÁÂÓÅ@M@
%âÅÓÅÃã@ÅÕåÉÄ@k@ÅÕÄâÃ@k@
%ÃÁâÅ@
%æÈÅÕ@ÆÉÓÅÃÖäÕã@n@ð@ãÈÅÕ@}£™¤…}@
%ÅÓâÅ@}†�“¢…}@
%ÅÕÄ@Áâ@ÅâmÉÕâãÁÓÓÅÄ@
%ÆÙÖÔ@ãÁÂÓÅ@M@
%âÅÓÅÃã@ÄÉâãÉÕÃã@ÅÕåÉÄ@k@ÅÕÄâÃ@k@
%ÃÖäÕã@M@ÃÅâÓÉÂ@]@ÖåÅÙ@M@
%×ÁÙãÉãÉÖÕ@Âè@ÅÕåÉÄ@k@
%ÅÕÄâÃ@
%]@Áâ@ÆÉÓÅÃÖäÕã@
%ÆÙÖÔ@ãÁÂÓÅ@M@
%âÅÓÅÃã@
%ÓÉÄÅâ@OO@ÆÉÄÅâ@
%Áâ@ÅÕåÉÄ@k@
%}ÃÅâÓÉÂ}@OO@
%ÃÁâÅ@
%ÓÉÄÅâ@OO@ÆÉÄÅâ@
%æÈÅÕ@
%}ÔÔ}@ãÈÅÕ@}}@
%ÅÓâÅ@ÆÉÄÅâ@
%ÅÕÄ@Áâ@ÃÅâÓÉÂ@k@
%ÅÕÄâÃ@
%ÆÙÖÔ@ØÇ×Ó@K@ÔÔÓÉâã@
%æÈÅÙÅ@ÙÃÄÃÄ@~@}Ôó}@
%ÁÕÄ@ÁÃÙÅÃ@~@}Á}@
%]@
%ÑÖÉÕ@ãÁÂÓÅ@M@
%Øâèâò@K@ÖÂÑÅÃãmâãÁãÉâãÉÃâ@M@
%ÃÅâÓÉÂ@k@}\ÆÉÓÅ}@]@
%]@
%ÖÕ@ñ@~@ñ@
%]@
%]@]@ÆÖÙÔÁã@ÑâÖÕ@
%]@k@ÑâÖÕmÖÂÑÅÃã@M@
%}¢¤ƒƒ…¢¢}@åÁÓäÅ@}†�“¢…}@k@}âØÓÉ•†–}@åÁÓäÅ@ÑâÖÕmÖÂÑÅÃã@M@
%}”…¢¢�‡…ÉÄ}@åÁÓäÅ@}âØÓðòððð}@k@
%}”…¢¢�‡…}@åÁÓäÅ@}Ù…˜¤…¢£…„@™…¢–¤ƒ…@•–£@†–¤•„@}@k@
%}ƒ¤™™…•£ã‰”…¢£�”—}@åÁÓäÅ@ÃäÙÙÅÕãmãÉÔÅâãÁÔ×@
%]@
%]@]@^@
%ÅÕÄ@@^@
%
%ÇÙÁÕã@ÁÓãÅÙ@k@ÅçÅÃäãÅ@@@
%ÖÕ@â×ÅÃÉÆÉÃ@ÆäÕÃãÉÖÕ@âÁÉÓ×ÖÉÕãKÅâÁÓÓÅÕåâ@
%ãÖ@ÁÔÁ×ÉÃâ@æÉãÈ@ÇÙÁÕã@Ö×ãÉÖÕ@^@
%
%ÇÙÁÕã@ÅçÅÃäãÅ@@@
%ÖÕ@â×ÅÃÉÆÉÃ@ÆäÕÃãÉÖÕ@âÁÉÓ×ÖÉÕãKÅâÁÓÓÅÕåâ@
%ãÖ@×äÂÓÉÃ@^@
%
%
\ No newline at end of file
+SET PATH *LIBL ; 
+
+CREATE OR REPLACE FUNCTION SAILPOINT.ES_GET_ALL_MAPICS_ENVIRONMENTS ( ) 
+	RETURNS CLOB(2147483647)   
+	LANGUAGE SQL 
+	SPECIFIC SAILPOINT.ESALLENVS 
+	NOT DETERMINISTIC 
+	MODIFIES SQL DATA 
+	CALLED ON NULL INPUT 
+	NOT FENCED 
+	SET OPTION  ALWBLK = *ALLREAD , 
+	ALWCPYDTA = *OPTIMIZE , 
+	COMMIT = *NONE , 
+	DBGVIEW = *SOURCE , 
+	DECRESULT = (31, 31, 00) , 
+	DYNDFTCOL = *NO , 
+	DYNUSRPRF = *OWNER , 
+	SRTSEQ = *HEX   
+	BEGIN 
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION 
+BEGIN 
+DECLARE V_SQLSTATE CHAR ( 5 ) ; 
+DECLARE V_DB2_RETURN_CODE INT ; 
+DECLARE V_DB2_MESSAGE_ID CHAR ( 7 ) ; 
+DECLARE V_ERROR_MESSAGE CLOB ( 2048 ) ; 
+-- Capture diagnostic info 
+GET DIAGNOSTICS CONDITION 1 
+V_DB2_RETURN_CODE = DB2_RETURNED_SQLCODE , 
+V_SQLSTATE = RETURNED_SQLSTATE , 
+V_ERROR_MESSAGE = MESSAGE_TEXT , 
+V_DB2_MESSAGE_ID = DB2_MESSAGE_ID ; 
+RETURN 
+( 
+VALUES JSON_OBJECT ( 
+'success' VALUE 'false' , 'SQLInfo' VALUE JSON_OBJECT ( 
+'SQLState' VALUE V_SQLSTATE , 
+'SQLCode' VALUE V_DB2_RETURN_CODE , 
+'messageID' VALUE V_DB2_MESSAGE_ID , 
+'message' VALUE V_ERROR_MESSAGE , 
+'currentTimestamp' VALUE CURRENT_TIMESTAMP 
+) 
+) ) ; 
+END ; 
+RETURN 
+COALESCE ( 
+JSON_OBJECT ( 
+'success' : 'true' , 'data' VALUE ( 
+SELECT JSON_ARRAYAGG ( 
+JSON_OBJECT ( 
+'envId' VALUE ENVID , 'envDsc' VALUE ENDSC , 
+'esInstalled' VALUE ES_INSTALLED 
+) 
+) 
+FROM TABLE ( 
+SELECT ENVID , ENDSC , 
+CASE 
+WHEN FILECOUNT > 0 THEN 'true' 
+ELSE 'false' 
+END AS ES_INSTALLED 
+FROM TABLE ( 
+SELECT DISTINCT ENVID , ENDSC , 
+COUNT ( CESLIB ) OVER ( 
+PARTITION BY ENVID , 
+ENDSC 
+) AS FILECOUNT 
+FROM TABLE ( 
+SELECT 
+LIDES || FIDES 
+AS ENVID , 
+'CESLIB' || 
+CASE 
+LIDES || FIDES 
+WHEN 
+'MM' THEN '' 
+ELSE FIDES 
+END AS CESLIB , 
+ENDSC 
+FROM QGPL . MMLIST 
+WHERE RCDCD = 'M3' 
+AND ACREC = 'A' 
+) 
+JOIN TABLE ( 
+QSYS2 . OBJECT_STATISTICS ( 
+CESLIB , '*FILE' ) 
+) 
+ON 1 = 1 
+) 
+) ) FORMAT JSON 
+) , JSON_OBJECT ( 
+'success' VALUE 'false' , 'SQLInfo' VALUE JSON_OBJECT ( 
+'messageID' VALUE 'SQL02000' , 
+'message' VALUE 'Requested resouce not found ' , 
+'currentTimestamp' VALUE CURRENT_TIMESTAMP 
+) 
+) ) ; 
+END  ; 
+
+GRANT ALTER , EXECUTE   
+ON SPECIFIC FUNCTION SAILPOINT.ESALLENVS 
+TO AMAPICS WITH GRANT OPTION ; 
+
+GRANT EXECUTE   
+ON SPECIFIC FUNCTION SAILPOINT.ESALLENVS 
+TO PUBLIC ; 
+
