diff --git a/SAILPOINT/Functions/ES_REMOVE_MAPICS_USER.sql b/SAILPOINT/Functions/ES_REMOVE_MAPICS_USER.sql
index f533cb4..b854d39 100644
--- a/SAILPOINT/Functions/ES_REMOVE_MAPICS_USER.sql
+++ b/SAILPOINT/Functions/ES_REMOVE_MAPICS_USER.sql
@@ -1 +1,82 @@
-âÅã@×ÁãÈ@\ÓÉÂÓ@^@
%
%ÃÙÅÁãÅ@ÖÙ@ÙÅ×ÓÁÃÅ@ÆäÕÃãÉÖÕ@âÁÉÓ×ÖÉÕãKÅâmÙÅÔÖåÅmÔÁ×ÉÃâmäâÅÙ@M@
%ÅÕåÉÄ@ÃÈÁÙMò]@k@
%äâÅÙÕÁÔÅ@ÃÈÁÙMñð]@]@
%ÙÅãäÙÕâ@ÃÓÖÂMòñô÷ôøóöô÷]@@@
%ÓÁÕÇäÁÇÅ@âØÓ@
%â×ÅÃÉÆÉÃ@âÁÉÓ×ÖÉÕã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ÙÅãäÙÕ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ãÉÔÅâãÁÔ×@
%]@
%]@]@^@
%ÅÕÄ@^@
%âÅã@ÃÉâãÖÖÓâ@K@ÓÉÂÓ@~@ÃÉâãÖÖÓâ@K@âÅãmÓÉÂÙÁÙèmÓÉâã@M@ÅÕåÉÄ@]@^@
%``@Ù…”–¥…@çÁ@¤¢…™@™…ƒ–™„@
%ÃÁÓÓ@âÁÉÓ×ÖÉÕã@K@ÄÅÓÅãÅmÅâmäâÅÙ@M@×mäâÅÙ@~n@äâÅÙÕÁÔÅ@]@^@
%``@Ù…“…�¢…@çÁ@Ó‰ƒ…•¢…@
%ÃÁÓÓ@âÁÉÓ×ÖÉÕã@K@ÙÅåÖÒÅmçÁmÓÉÃÅÕâÅ@M@]@^@
%``@Ä…“…£…@¤¢…™@†™–”@Ô�—‰ƒ¢@†‰“…¢@‰†@…§‰¢£¢@
%ÄÅÓÅãÅ@ÆÙÖÔ@ÔéÇäÃ××@æÈÅÙÅ@ÇäÂäÃÄ@~@äâÅÙÕÁÔÅ@^@
%ÄÅÓÅãÅ@ÆÙÖÔ@ÔéÆðÙÅ×@æÈÅÙÅ@ÆðÂäÃÄ@~@äâÅÙÕÁÔÅ@^@
%``@æ™‰£…@�@ˆ‰¢£–™¨@™…ƒ–™„@
%ÉÕâÅÙã@ÉÕãÖ@ÅâÄÅãÁÉÓ@
%åÁÓäÅâ@M@ÅÕåÉÄ@k@äâÅÙÕÁÔÅ@k@}}@k@}}@k@}ÁÃÃÔÁ×ÉÃâ}@k@}}@k@}Ù}@k@}ñð}@k@
%ÃäÙÙÅÕãmÄÁãÅ@k@ÃäÙÙÅÕãmãÉÔÅ@k@ÃäÙÙÅÕãmäâÅÙ@k@}ÅâÙÔåÔäâÙ}@k@
%}âÁÉÓ×ÖÉÕã}@k@ÃÉâãÖÖÓâ@K@ãÖmÃèÔÄ@M@]@k@éÖÕÅÄ@M@ÃäÙÙÅÕãmãÉÔÅ@]@k@
%}Ä…“…£…„@¥‰�@â�‰“—–‰•£@Á×É}@k@}}@k@}}@k@}}@k@}}@k@}}@]@^@
%ÙÅãäÙÕ@
%ÃÖÁÓÅâÃÅ@M@
%ÑâÖÕmÖÂÑÅÃã@M@
%}¢¤ƒƒ…¢¢}@åÁÓäÅ@}£™¤…}@k@
%}„�£�}@åÁÓäÅ@
%}Ô�—‰ƒ¢@¤¢…™@™…ƒ–™„@„…“…£…„@�•„@“‰ƒ…•¢…@™…¥–’…„}@
%]@k@ÑâÖÕmÖÂÑÅÃã@M@
%}¢¤ƒƒ…¢¢}@åÁÓäÅ@}†�“¢…}@k@}âØÓÉ•†–}@åÁÓäÅ@ÑâÖÕmÖÂÑÅÃã@M@
%}”…¢¢�‡…ÉÄ}@åÁÓäÅ@}âØÓðòððð}@k@
%}”…¢¢�‡…}@åÁÓäÅ@}Ù…˜¤…¢£…„@™…¢–¤™ƒ…@•–£@†–¤•„@}@k@
%}ƒ¤™™…•£ã‰”…¢£�”—}@z@ÃäÙÙÅÕãmãÉÔÅâãÁÔ×@
%]@
%]@]@^@
%ÅÕÄ@@^@
%
%ÇÙÁÕã@ÁÓãÅÙ@k@ÅçÅÃäãÅ@@@
%ÖÕ@â×ÅÃÉÆÉÃ@ÆäÕÃãÉÖÕ@âÁÉÓ×ÖÉÕãKÅâÙÔåÔäâÙ@
%ãÖ@ÁÔÁ×ÉÃâ@æÉãÈ@ÇÙÁÕã@Ö×ãÉÖÕ@^@
%
%ÇÙÁÕã@ÅçÅÃäãÅ@@@
%ÖÕ@â×ÅÃÉÆÉÃ@ÆäÕÃãÉÖÕ@âÁÉÓ×ÖÉÕãKÅâÙÔåÔäâÙ@
%ãÖ@×äÂÓÉÃ@^@
%
%
\ No newline at end of file
+SET PATH *LIBL ; 
+
+CREATE OR REPLACE FUNCTION SAILPOINT.ES_REMOVE_MAPICS_USER ( 
+	ENVID CHAR(2) , 
+	USERNAME CHAR(10) ) 
+	RETURNS CLOB(2147483647)   
+	LANGUAGE SQL 
+	SPECIFIC SAILPOINT.ESRMVMUSR 
+	NOT DETERMINISTIC 
+	MODIFIES SQL DATA 
+	CALLED ON NULL INPUT 
+	NOT FENCED 
+	SET OPTION  ALWBLK = *ALLREAD , 
+	ALWCPYDTA = *OPTIMIZE , 
+	COMMIT = *NONE , 
+	DECRESULT = (31, 31, 00) , 
+	DYNDFTCOL = *NO , 
+	DYNUSRPRF = *USER , 
+	SRTSEQ = *HEX   
+	BEGIN 
+DECLARE LIBL VARCHAR ( 1024 ) DEFAULT '' ; 
+DECLARE CUR_USR VARCHAR ( 10 ) DEFAULT '' ; 
+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 
+( 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 ; 
+SET CISTOOLS . LIBL = CISTOOLS . SET_LIBRARY_LIST ( ENVID ) ; 
+-- Remove XA user record 
+CALL SAILPOINT . DELETE_ES_USER ( P_USER => USERNAME ) ; 
+-- Release XA License 
+CALL SAILPOINT . REVOKE_XA_LICENSE ( ) ; 
+-- Delete user from Mapics files if exists 
+DELETE FROM MZGUCPP WHERE GUBUCD = USERNAME ; 
+DELETE FROM MZF0REP WHERE F0BUCD = USERNAME ; 
+-- Write a history record 
+INSERT INTO ESDETAIL 
+VALUES ( ENVID , USERNAME , '' , '' , 'ACCMAPICS' , '' , 'R' , '10' , 
+CURRENT_DATE , CURRENT_TIME , CURRENT_USER , 'ESRMVMUSR' , 
+'SAILPOINT' , CISTOOLS . TO_CYMD ( ) , ZONED ( CURRENT_TIME ) , 
+'Deleted via Sailpoint API' , '' , '' , '' , '' , '' ) ; 
+RETURN 
+COALESCE ( 
+JSON_OBJECT ( 
+'success' VALUE 'true' , 
+'data' VALUE 
+'Mapics user record deleted and license revoked' 
+) , JSON_OBJECT ( 
+'success' VALUE 'false' , 'SQLInfo' VALUE JSON_OBJECT ( 
+'messageID' VALUE 'SQL02000' , 
+'message' VALUE 'Requested resource not found ' , 
+'currentTimestamp' : CURRENT_TIMESTAMP 
+) 
+) ) ; 
+END  ; 
+
+GRANT ALTER , EXECUTE   
+ON SPECIFIC FUNCTION SAILPOINT.ESRMVMUSR 
+TO AMAPICS WITH GRANT OPTION ; 
+
+GRANT EXECUTE   
+ON SPECIFIC FUNCTION SAILPOINT.ESRMVMUSR 
+TO PUBLIC ; 
+
