Search This Blog

Friday, May 8, 2020

Update fnd_user all user passwords in clone Oracle Apps r12


DECLARE
l_unenc_pwd VARCHAR2(1000);
CURSOR c1 IS
SELECT *
FROM fnd_user fu 
WHERE fu.user_name='MOGALAFZAL'--comment this line to get all users.
;
BEGIN
FOR I IN c1 LOOP
l_unenc_pwd:=dbms_random.string('x',6);
fnd_user_pkg.UpdateUser(x_user_name=>'001C.ARNAUD@GMAIL.COM'
                       ,x_owner=>'SEED'
                       ,x_unencrypted_password=>
l_unenc_pwd--'12345'
                       ,x_password_date=>to_date('2', 'J')
                       ,x_user_guid=>I.user_GUID
                       );
COMMIT;                      
END LOOP;                                           
END;


Other useful random:
select TRUNC(DBMS_RANDOM.value(1,10)) from dual;

Positive Integers:
select abs(dbms_random.random) from dual --> for updating mobile number, EID


Friday, May 1, 2020

Updating Translations for lookups in Oracle Apps R12


The below code with update the Transalation of Lookups.
Example: Arabic Translation.

First you need to upload lookups normally using the below link.
https://mogalafzal.blogspot.com/2020/05/uploading-lookups-in-oracle-apps-r12.html


/*
1. set the language you want to update.

alter session set NLS_LANGUAGE ='ARABIC';--'ARABIC' AMERICAN

select userenv('lang') from dual

COMMIT

2. custom interface table.

    CREATE TABLE XXLOOKUP_CODES_AR
    (LOOKUP_CODE VARCHAR2(30),
     MEANING_EN VARCHAR2(240),
     MEANING_AR VARCHAR2(240),
     DESCRIPTION_EN VARCHAR2(240),
     DESCRIPTION_AR VARCHAR2(240),
     ATTRIBUTE1 VARCHAR2(240),
     ATTRIBUTE2 VARCHAR2(240))
   
     alter table xxlookup_codes_ar
add (lkp_err_msg varchar2(240))

update xxlookup_codes_ar
set lkp_process_flag_ar = 'N';

SELECT * FROM xxlookup_codes_ar

SELECT * FROM FND_LOOKUP_VALUES_VL
WHERE LOOKUP_TYPE = 'TESTA'

*/



DECLARE
   CURSOR get_lookup_details
   IS
 
      SELECT ltype.application_id,
             ltype.customization_level,
             ltype.creation_date,
             ltype.created_by,
             ltype.last_update_date,
             ltype.last_updated_by,
             ltype.last_update_login,
             tl.lookup_type,
             tl.security_group_id,
             tl.view_application_id,
             tl.description,
             tl.meaning
        FROM fnd_lookup_types_tl tl, fnd_lookup_types ltype
       WHERE     ltype.lookup_type = 'FFZA_LICENSE_TYPE'
             AND ltype.lookup_type = tl.lookup_type
             AND language = 'US';

   CURSOR get_value
   IS
 

      SELECT DISTINCT
             lookup_code,
             meaning_en,
             meaning_ar,
             description_en, description_ar,lkp_err_msg,lkp_process_flag_ar
        FROM xxlookup_codes_ar
       WHERE     lkp_process_flag_ar = 'N'   
       and lookup_code <> '58'
       --AND LENGTH(substr(meaning_ar,1,80)) > 60
     
       ;

   l_err_msg   VARCHAR2 (1000) := NULL;
   l_db_nls_language       VARCHAR2 (500) := NULL;
   l_db_nls_language2 varchar2(30) := 'ARABIC';
   L_USERNAME VARCHAR2(30) := 'EG_AFZAL'; --USERNAME
BEGIN
   FOR i IN get_lookup_details
   LOOP
      FOR j IN get_value
      LOOP
         BEGIN
            fnd_lookup_values_pkg.translate_row (
               x_lookup_type           => i.lookup_type,
               x_security_group_id     => i.security_group_id,
               x_view_application_id   => i.view_application_id,
               x_owner                 => L_USERNAME, --> User NAME
               x_meaning               => j.meaning_ar,
               x_description           => j.description_ar,
               x_lookup_code           => j.lookup_code,
               X_LAST_UPDATE_DATE      => NULL,--TO_DATE('4/22/2020 9:20:58 PM'),
               X_CUSTOM_MODE            => 'FORCE');

            UPDATE xxlookup_codes_ar --> Stagging Table to Log Status
               SET lkp_process_flag_ar = 'Y', lkp_err_msg = NULL
             WHERE lookup_code = j.lookup_code;

            COMMIT;
         EXCEPTION
            WHEN OTHERS
            THEN
               l_err_msg := SQLERRM;

               UPDATE xxlookup_codes_ar
                  SET lkp_process_flag_ar = 'N', lkp_err_msg = l_err_msg
                 WHERE lookup_code = j.lookup_code;

               COMMIT;
         END;
      END LOOP;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Main Exception: ' || SQLERRM);
END;

Uploading Lookups in Oracle Apps R12 (English Only)

custom interface table.

    CREATE TABLE XXLOOKUP_CODES_AR
    (LOOKUP_CODE VARCHAR2(30),
     MEANING_EN VARCHAR2(240),
     MEANING_AR VARCHAR2(240),
     DESCRIPTION_EN VARCHAR2(240),
     DESCRIPTION_AR VARCHAR2(240),
     ATTRIBUTE1 VARCHAR2(240),
     ATTRIBUTE2 VARCHAR2(240))
   
     alter table xxlookup_codes_ar
add (lkp_err_msg varchar2(240))

update xxlookup_codes_ar
set lkp_process_flag_ar = 'N';

SELECT * FROM xxlookup_codes_ar



alter session set NLS_LANGUAGE ='AMERICAN';--'ARABIC' AMERICAN



DECLARE
   V_ERROR  VARCHAR2(4000);
   CURSOR get_lookup_details
   IS
 
      SELECT ltype.application_id,
             ltype.customization_level,
             ltype.creation_date,
             ltype.created_by,
             ltype.last_update_date,
             ltype.last_updated_by,
             ltype.last_update_login,
             tl.lookup_type,
             tl.security_group_id,
             tl.view_application_id,
             tl.description,
             tl.meaning
        FROM fnd_lookup_types_tl tl, fnd_lookup_types ltype
       WHERE     ltype.lookup_type = 'FFZA_LICENSE_TYPE'
             AND ltype.lookup_type = tl.lookup_type
             AND language = 'US';

   CURSOR get_country
   IS
 
      SELECT DISTINCT
             lookup_code,
             meaning_en,
             meaning_ar,
             description_en, description_ar
        FROM xxlookup_codes_ar
       WHERE     lkp_process_flag_ar = 'N'     
       and lookup_code <> '58'
       ;
     
   
   l_rowid   VARCHAR2 (100) := 0;
BEGIN
   FOR i IN get_lookup_details
   LOOP
      FOR j IN get_country
      LOOP
         l_rowid := NULL;
         BEGIN
            fnd_lookup_values_pkg.insert_row (
               x_rowid                 => l_rowid,
               x_lookup_type           => i.lookup_type,
               x_security_group_id     => i.security_group_id,
               x_view_application_id   => i.view_application_id,
               x_lookup_code           => j.lookup_code,
               x_tag                   => '',
               x_attribute_category    => NULL,
               x_attribute1            => NULL,
               x_attribute2            => NULL,
               x_attribute3            => NULL,
               x_attribute4            => NULL,
               x_enabled_flag          => 'Y',
               x_start_date_active     =>NULL,
               x_end_date_active       => NULL,
               x_territory_code        => NULL,
               x_attribute5            => NULL,
               x_attribute6            => NULL,
               x_attribute7            => NULL,
               x_attribute8            => NULL,
               x_attribute9            => NULL,
               x_attribute10           => NULL,
               x_attribute11           => NULL,
               x_attribute12           => NULL,
               x_attribute13           => NULL,
               x_attribute14           => NULL,
               x_attribute15           => NULL,
               x_meaning               => j.meaning_en,
               x_description           => j.description_en,--j.B,
               x_creation_date         => SYSDATE,
               x_created_by            => i.created_by,
               x_last_update_date      => i.last_update_date,
               x_last_updated_by       => i.last_updated_by,
               x_last_update_login     => i.last_update_login);

            COMMIT;

          -- update XX_LOOKUP_VALUES set upload_status= 'DONE' WHERE LOOKUP_CODE=J.LOOKUP_CODE;
         EXCEPTION
            WHEN OTHERS
            THEN
             V_ERROR := (SQLERRM);
             DBMS_OUTPUT.PUT_LINE(V_ERROR);
              --   update XX_LOOKUP_VALUES set upload_status= 'Inner Exception: ' || V_ERROR WHERE LOOKUP_CODE=J.LOOKUP_CODE;
         END;
      END LOOP;
   END LOOP;
--EXCEPTION
--   WHEN OTHERS
--   THEN
--      update XX_COUNTRY set upload_status='Main Exception: ' || V_ERROR  WHERE LOOKUP_CODE=J.LOOKUP_CODE;
END;