Join the OracleApps88 Telegram group @OracleApps88to get more information on Oracle EBS R12/Oracle Fusion applications.

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 or +91 905 957 4321 in telegram.

Saturday, April 29, 2017

Script to Add and Update Budget line (if Line not exist Update) and Baseline the budget in Oracle Projects

DECLARE
   --> variables needed for API standard parameters
   l_budget_lines_in           pa_budget_pub.budget_line_in_tbl_type;
   l_budget_lines_in_rec       pa_budget_pub.budget_line_in_rec_type;
   l_budget_lines_out          pa_budget_pub.budget_line_out_tbl_type;
   l_api_version_number        NUMBER                                := 1.0;
   l_commit                    VARCHAR2 (1)                           := 'T';
   l_return_status             VARCHAR2 (1);
   l_init_msg_list             VARCHAR2 (1)                           := 'T';
   l_msg_count                 NUMBER                                 := 0;
   l_msg_data                  VARCHAR2 (2000);
   l_data                      VARCHAR2 (2000);
   l_msg_index_out             NUMBER;
   v_task_id                   apps.pa_tasks.task_id%TYPE;
   l_line_status             NUMBER                                 := 0;
  
   --> variables needed for Oracle Project specific parameters
   l_user_id                   NUMBER;
   l_responsibility_id         NUMBER;
  
   l_pm_product_code           VARCHAR2 (10);
  
   l_budget_type_code          VARCHAR2 (50);
   l_pa_project_id             NUMBER;
   l_pm_project_reference    VARCHAR2(40);
   l_workflow_started          VARCHAR2 (1);
  
   l_pa_task_id                NUMBER;
   l_resource_list_member_id   NUMBER;
   l_raw_cost                  NUMBER;
   l_quantity                  NUMBER;
  
   API_ERROR                   EXCEPTION;
  
BEGIN
   --> PRODUCT RELATED DATA
   l_pm_product_code         := 'GMS';
  
   --> BUDGET DATA
   l_pa_project_id           := 6271;
   l_budget_type_code        := 'FC';
   l_pm_project_reference    := NULL;
  
   --> BUDGET LINE DATA
   l_pa_task_id              := 405249;
   l_resource_list_member_id := 1034;
   l_raw_cost                := 0;
   l_quantity                := 0;

   ---->>==========================================
   --> SET GLOBAL INFO
   SELECT user_id,
          responsibility_id
     INTO l_user_id,
          l_responsibility_id
     FROM pa_user_resp_v
    WHERE user_name = 'RCHINTHAPATLA';

   PA_INTERFACE_UTILS_PUB.SET_GLOBAL_INFO
      (p_api_version_number      => 1.0,
         p_responsibility_id       => l_responsibility_id,
         p_user_id                 => l_user_id,
         p_msg_count               => l_msg_count,
         p_msg_data                => l_msg_data,
         p_return_status           => l_return_status
        );

   IF l_return_status != 'S'
   THEN
      RAISE API_ERROR;
   END IF;

   ---->>==========================================
     BEGIN
      SELECT DISTINCT 1 INTO L_LINE_STATUS
      FROM PA_BUDGET_LINES_V
      WHERE 1=1
      AND TASK_ID  = l_pa_task_id ;
     EXCEPTION
      WHEN OTHERS THEN
          NULL ;
     END;  
 
   ---->>==========================================
   --> CALLING UPDATE BUDGET LINE
   IF L_LINE_STATUS = 1
   THEN
  
     DBMS_OUTPUT.put_line ('--->> Calling Project Budget Line API');
     
      PA_BUDGET_PUB.UPDATE_BUDGET_LINE
          (p_api_version_number           => l_api_version_number,
             p_commit                       => l_commit,
             p_init_msg_list                => l_init_msg_list,
             p_msg_count                    => l_msg_count,
             p_msg_data                     => l_msg_data,
             p_return_status                => l_return_status,
             p_pm_product_code              => l_pm_product_code,
             p_pa_project_id                => l_pa_project_id,
             p_budget_type_code             => l_budget_type_code,
             p_pa_task_id                   => l_pa_task_id,
             p_resource_list_member_id      => l_resource_list_member_id,
             p_raw_cost                     => l_raw_cost,
             p_quantity                     => l_quantity
            );

      IF l_return_status != 'S'
      THEN
        RAISE API_ERROR;
           DBMS_OUTPUT.PUT_LINE('MSG_COUNT: '||TO_CHAR(L_MSG_COUNT));
      END IF;

      DBMS_OUTPUT.put_line ('Update Budget Line API Status :' || l_return_status);
     
   ---->>====================================
   --> ADDING BUDGET LINE
   ELSE
  
     DBMS_OUTPUT.put_line ('--->> Calling Project Budget Line API');
  
      PA_BUDGET_PUB.ADD_BUDGET_LINE
                (p_api_version_number           => l_api_version_number,
                 p_commit                       => l_commit,
                 p_init_msg_list                => l_init_msg_list,
                 p_msg_count                    => l_msg_count,
                 p_msg_data                     => l_msg_data,
                 p_return_status                => l_return_status,
                 p_pm_product_code              => l_pm_product_code,
                 p_pa_project_id                => l_pa_project_id,
                 p_resource_list_member_id      => l_resource_list_member_id,
                 p_budget_type_code             => l_budget_type_code,
                 p_pa_task_id                   => l_pa_task_id,
                 p_raw_cost                     => l_raw_cost,
                 p_quantity                     => l_quantity
                );

      IF l_return_status != 'S'
      THEN
        RAISE API_ERROR;
           DBMS_OUTPUT.PUT_LINE('MSG_COUNT: '||TO_CHAR(L_MSG_COUNT));
      END IF;
     
           DBMS_OUTPUT.put_line ('Add Budget Line API Status ' || l_return_status);  
   END IF;
  
   ---->>==========================================
   --> CALLING BASELINE BUDGET
   IF l_return_status = 'S'
   THEN
  
     DBMS_OUTPUT.put_line ('--->> Calling Project Budget Baseline API');  
  
      PA_BUDGET_PUB.BASELINE_BUDGET
          (p_api_version_number        => l_api_version_number,
             p_commit                    => l_commit,
             p_init_msg_list             => l_init_msg_list,
             p_msg_count                 => l_msg_count,
             p_msg_data                  => l_msg_data,
             p_return_status             => l_return_status,
             p_workflow_started          => l_workflow_started,
             p_pm_product_code           => l_pm_product_code,
             p_pa_project_id             => l_pa_project_id,
             p_pm_project_reference      => l_pm_project_reference,
             p_budget_type_code          => l_budget_type_code
            );
                           
      IF l_return_status != 'S'
      THEN
        RAISE API_ERROR;
           DBMS_OUTPUT.PUT_LINE('MSG_COUNT: '||TO_CHAR(L_MSG_COUNT));
      END IF;

      DBMS_OUTPUT.put_line ('BASELINE BUDGET STATUS :' || l_return_status);
  
   END IF;

---->>=========================================  
--> HANDLE EXCEPTIONS
EXCEPTION
   WHEN API_ERROR
   THEN
      FOR i IN 1 .. l_msg_count
      LOOP
         PA_INTERFACE_UTILS_PUB.GET_MESSAGES
          (p_msg_data           => l_msg_data,
             p_data               => l_data,
             p_msg_count          => l_msg_count,
             p_msg_index_out      => l_msg_index_out
            );
         DBMS_OUTPUT.put_line ('Error Msg : ' || l_data);
         DBMS_OUTPUT.put_line ('Error Msg : ' || l_msg_data);
      END LOOP;
    
   WHEN OTHERS
   THEN
      FOR i IN 1 .. l_msg_count
      LOOP
         PA_INTERFACE_UTILS_PUB.GET_MESSAGES
          (p_msg_data           => l_msg_data,
             p_data               => l_data,
             p_msg_count          => l_msg_count,
             p_msg_index_out      => l_msg_index_out
            );
         DBMS_OUTPUT.put_line ('Error Msg : ' || l_data);
         DBMS_OUTPUT.put_line ('Error Msg : ' || l_msg_data);
      END LOOP;
    
END;
---->>=========================================


1 comment:

Raju Chinthapatla said...

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 (https://t.me/apps88) in telegram.

Post a Comment

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 or +91 905 957 4321 in telegram.
Best Blogger TipsGet Flower Effect