--add concurrent via backend
BEGIN
  FOR C IN (
   SELECT   DISTINCT 
            bFEV.User_Executable_Name
           ,bFEV.executable_name
           ,bFEV.description description_exe
           ,bFEV.execution_file_name
           ,fcpt.description description_pro
           ,fcpt.user_concurrent_program_name
           ,fcp.concurrent_program_name
          ,(SELECT MEANING
              FROM fnd_lookup_values
             WHERE lookup_type   = 'CP_EXECUTION_METHOD_CODE'
               AND enabled_flag  = 'Y'
               AND LANGUAGE      = 'PTB'
               AND lookup_code   = 'I') execution_method
           ,fapp.application_short_name
           ,fapt.application_name
           ,rq.request_group_name
           ,fcpt.language
      FROM apps.fnd_concurrent_programs/*DBLINK_ORIGEM*/     fcp
           ,apps.fnd_concurrent_programs_tl/*DBLINK_ORIGEM*/ fcpt
           ,apps.fnd_executables/*DBLINK_ORIGEM*/            fe
           ,apps.fnd_executables_tl/*DBLINK_ORIGEM*/         fet
           ,fnd_concurrent_programs_vl/*DBLINK_ORIGEM*/      aFCP
           ,fnd_executables_vl/*DBLINK_ORIGEM*/              bFEV
           ,fnd_application/*DBLINK_ORIGEM*/                 fapp
           ,fnd_application_tl/*DBLINK_ORIGEM*/              fapt
           ,(
               SELECT frg.request_group_name
                     ,fcpt.user_concurrent_program_name
                 FROM fnd_request_groups/*DBLINK_ORIGEM*/         frg
                     ,fnd_request_group_units/*DBLINK_ORIGEM*/    frgu
                     ,fnd_concurrent_programs/*DBLINK_ORIGEM*/    fcp
                     ,fnd_concurrent_programs_tl/*DBLINK_ORIGEM*/ fcpt
                     ,fnd_responsibility_tl/*DBLINK_ORIGEM*/      frt
                     ,fnd_responsibility/*DBLINK_ORIGEM*/         frs
               WHERE frgu.unit_application_id  = fcp.application_id
                 AND frgu.request_unit_id      = fcp.concurrent_program_id
                 AND frg.request_group_id      = frgu.request_group_id
                 AND frg.application_id        = frgu.application_id
                 AND fcp.application_id        = fcpt.application_id
                 AND fcp.concurrent_program_id = fcpt.concurrent_program_id
                 AND frs.application_id        = frt.application_id
                 AND frs.responsibility_id     = frt.responsibility_id
                 AND frs.request_group_id      = frg.request_group_id
                 AND frs.application_id        = frg.application_id
                 AND frt.language              = 'PTB'
            ) RQ
     WHERE fe.executable_id                = fet.executable_id
       AND fcp.concurrent_program_id       = fcpt.concurrent_program_id
       AND fcpt.language                   = fet.language
       AND fcp.executable_id               = fe.executable_id
       AND fcp.executable_application_id   = fe.application_id
       AND fcpt.language                   = 'PTB'
       AND aFCP.executable_id              = bFEV.executable_id
       AND aFCP.ENABLED_FLAG               = 'Y'
       AND aFCP.CONCURRENT_PROGRAM_ID      = fcpt.concurrent_program_id
       AND fapp.application_id             = fcp.application_id
       AND fapp.application_id             = fapt.application_id
       AND RQ.user_concurrent_program_name = fcpt.user_concurrent_program_name
       AND bFEV.execution_file_name     like 'XXX_XXXX_SYNC_TABLES_PK%' --NOME DA PACKAGE OU PROCEDURE
   )
  LOOP
    BEGIN--CRIA EXECUTÁVEL
      FND_PROGRAM.executable(executable            => c.user_executable_name     -- Executable Name
                            ,application           => c.application_short_name   -- Application Short Name
                            ,short_name            => c.executable_name          -- Executable Short Name
                            ,description           => c.description_EXE          -- Description,DEFAULT NULL
                            ,execution_method      => c.execution_method         -- Execution Method
                            ,execution_file_name   => c.execution_file_name      -- Execution File Name,DEFAULT NULL
                            ,subroutine_name       => NULL                       -- Subroutine Name,DEFAULT NULL
                            ,icon_name             => NULL                       -- Icon Name,DEFAULT NULL
                            ,language_code         => c.language                 -- Language Code,DEFAULT 'US'
                            ,execution_file_path   => NULL);                     -- Execution File Path, DEFAULT NULL
  EXCEPTION
    WHEN OTHERS THEN
      NULL;
  END;
  --
  BEGIN--CRIA CONCORRENTE
    FND_PROGRAM.register(program                => c.user_concurrent_program_name-- CP Name
                        ,application            => c.application_short_name      -- Application Short Name
                        ,enabled                => 'Y'                           -- Flag to Enable/Disable a CP
                        ,short_name             => c.concurrent_program_name     -- CP Short Name
                        ,description            => c.description_pro             -- Description,DEFAULT NULL
                        ,executable_short_name  => c.executable_name             -- Executable Short Name
                        ,executable_application => c.application_short_name      -- Executable Application Short Name
                        ,save_output            => 'Y'                           -- Save Output,DEFAULT 'Y',
                        ,print                  => 'Y'                           -- Print,DEFAULT 'Y',
                        ,style_required         => 'N'                           -- DEFAULT 'N',
                        ,use_in_srs             => 'Y'                           -- DEFAULT 'N',
                        ,allow_disabled_values  => 'N'                           -- DEFAULT 'N',
                        ,run_alone              => 'N'                           -- DEFAULT 'N',
                        ,output_type            => 'TEXT'                        -- DEFAULT 'TEXT'
                        ,enable_trace           => 'N'                           -- DEFAULT 'N',
                        ,restart                => 'Y'                           -- DEFAULT 'Y',
                        ,nls_compliant          => 'Y'                           -- DEFAULT 'Y',
                        ,language_code          => c.language);                  -- DEFAULT 'US',        
  EXCEPTION
    WHEN OTHERS THEN
      NULL;
  END;
  BEGIN--ASSOCIA COCORRENTE AO GRUPO DE SOLICITAÇÃO
    apps.fnd_program.add_to_group (program_short_name    => c.concurrent_program_name
                                  ,program_application   => c.application_name
                                  ,request_group         => c.request_group_name
                                  ,group_application     => c.application_name);
  EXCEPTION
    WHEN OTHERS THEN
      NULL;
  END;
 END LOOP; 
 COMMIT;
END;

Deixe um comentário