Tuesday, January 3, 2023

Script to add employee as buyer

 Introduction

This Post illustrate steps required to add employee as buyer in Oracle EBS R12.

Script to add employees as buyer

DECLARE
l_agent_id NUMBER;
l_employee_number VARCHAR2 (20);
l_buyer_rowid VARCHAR2 (100);
BEGIN
BEGIN
SELECT person_id
INTO l_agent_id
FROM apps.per_all_people_f f
WHERE employee_number = l_employee_number;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ( ‘Unable to find Agent ID for ‘
|| l_employee_number
|| SQLERRM
);
END;

apps.po_agents_pkg.insert_row (x_rowid => l_buyer_rowid,
x_agent_id => l_agent_id,
x_last_update_date => SYSDATE,
x_last_updated_by => 0,
x_last_update_login => 0,
x_creation_date => SYSDATE,
x_created_by => 0,
x_location_id => NULL,
x_category_id => NULL,
x_authorization_limit => NULL,
x_start_date_active => SYSDATE,
x_end_date_active => NULL,
x_attribute_category => NULL,
x_attribute1 => NULL,
x_attribute2 => NULL,
x_attribute3 => NULL,
x_attribute4 => 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
);
COMMIT;
DBMS_OUTPUT.put_line (‘Setup as a buyer ‘ || l_employee_number);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (‘Error in Setting up as Buyer ‘ || SQLERRM);
END;

Summary

This Post described the script to add employees as buyer in Oracle EBS R12.

Wednesday, July 20, 2022

Process Cloud Service (PCS) Overview ORACLE - FUSION

https://docs.oracle.com/en/cloud/paas/integration-cloud/user-processes/using-processes-oracle-integration.pdf

How to send test mail from workflow mailer. Send oracle workflow notifications to an email address

Notification mailer is uses to send Email Notifications to the User. In Notification mailer but when we are doing some testing in Notification Mailer and we don't want to send the Test email to the Business users then we can set one Test Email address through which we can route all the test emails from , Workflow Notification mailer to  that Test Email Address.




STEP 1  

 

 
nav => Workflow Administrator 
then oracle Application Manager 

make sure the Notification Mailier Up  (⯟)  


then edit 

send any message














API to view the email sent by workflow notification in Oracle apps R12 (WF_MAIL.GETMESSAGE)

API to view the email sent by workflow notification in Oracle apps R12 (WF_MAIL.GETMESSAGE) 


SET SERVEROUPUT ON;

DECLARE ln_nid NUMBER; lv_node VARCHAR2(100); lv_agent VARCHAR2(100); lv_replyto VARCHAR2(100); lv_subject VARCHAR2(2000); lv_text_body VARCHAR2(32000); lv_html_body VARCHAR2(32000); lv_body_atth VARCHAR2(32000); lv_error_result VARCHAR2(100); z NUMBER; ln_body_length NUMBER; -- Notification id for which we need the email message content ln_notification_id NUMBER DEFAULT 123073; PROCEDURE display_big_value( piv_message VARCHAR2) IS BEGIN z := 1; ln_body_length := 0; ln_body_length := LENGTH(piv_message); IF ln_body_length > 0 THEN LOOP IF ln_body_length < z + 255 THEN dbms_output.put_line(SUBSTR(piv_message, z, ln_body_length - z + 1)); ELSE dbms_output.put_line(SUBSTR(piv_message, z, 255)); END IF; EXIT WHEN z > ln_body_length; z := z + 255; END LOOP; END IF; END; BEGIN -- Temporarily set notification status as MAIL UPDATE wf_notifications SET status = 'OPEN', mail_status = 'MAIL' WHERE notification_id = ln_notification_id; dbms_output.enable(100000); wf_mail.getmessage(ln_notification_id, 'node', NULL, 'replyto@node.com', lv_subject, lv_text_body, lv_html_body, lv_body_atth, lv_error_result); dbms_output.put_line('**************** SUBJECT IS ******************'); display_big_value(lv_subject); dbms_output.put_line('**************** TEXT BODY IS *****************'); display_big_value(lv_text_body); dbms_output.put_line('**************** HTML BODY IS *******************'); display_big_value(lv_html_body); dbms_output.put_line('**************** HTML ATTH IS ********************'); display_big_value(lv_body_atth); ROLLBACK; -- This is to rollback the temporary assignment. END;

Query to find Requisitions Approval Pending

 Select   Q.org,Q.Requestor_Name, Q.Status, Count (*) No_Of_Lines

    From (Select Prla.Destination_Organization_Id,
(SELECT ORGANIZATION_CODE FROM apps.org_organization_definitions
                          where ORGANIZATION_ID=Prla.Destination_Organization_Id)Org,
             (Select Last_Name
                    From Apps.Per_All_People_F Papf
                   Where Papf.Person_Id = Prla.To_Person_Id
                     And Sysdate Between Effective_Start_Date
                                     And Effective_End_Date) Requestor_Name,
                 Prha.Authorization_Status Status
            From Apps.Po_Requisition_Headers_All Prha,
                 Apps.Po_Requisition_Lines_All Prla
           Where Prha.Requisition_Header_Id = Prla.Requisition_Header_Id
             And Prha.Creation_Date < Sysdate - 3
             And Prha.Authorization_Status Not In ('APPROVED', 'CANCELLED')
             And Nvl (Prla.Closed_Code, 'OPEN') <> 'FINALLY CLOSED'
             And Prla.Destination_Organization_Id = :P_Organization_Id
             And Prha.Org_Id = 687) Q
Group By Q.org,Q.Requestor_Name, Q.Status
Order By Q.org,Q.Requestor_Name, Q.Status

How To Send Notification To Multiple Users - ADHOC

How To Send Notification To Multiple Users

Oracle Workflow roles are stored in the database, in the Oracle Workflow directory service.The performer can be an item type attribute that dynamically returns a role.To send a single notification(FYI/Actionable) to multiple users we have to use Role attribute as performer of that notification.The attribute value must be the internal name of a role. 

Here we will discuss how can we send a single notification to multiple users.

Basic Requirement
Our old requirement looks like "when a person applies for a leave it should go his/her supervisor for approval.Approver must be able to provide his/her approval/rejection comments. The comments must be entered by the approver while rejecting the leave requisition.If he/she rejects the leave requisition without entering comments, then it should raise an application error.If he/she approves the requisition it should be optional.Approver must also be able to select theOrganization Leave Type from a list of values . If the leave gets rejected, don’t store any information in database.The approver should able to view/edit the person "Special Information Types" before approving the leave request.Before approving the sick leave request the approver must able to see the submitted medical document."

Now we will twist our original requirement- Instead of going to Supervisor for approval, all the leave request must go to the following identified people
  • ROLE1_APPR (User name of the person)
  • ROLE2_APPR (User name of the person)
  • ROLE3_APPR (User name of the person)
Solution Approach
First we will discuss about the changes that we need to do in workflow Definition.

A) Workflow Part
1) Load the latest workflow definition from database.
2) Create an item attribute of Type Role
 Internal Name:- XX_TEST_ROLE
 Display Name:- Test Role for Approval
 Type              :- Role

3) Now we have to add this newly created role to the performer of the notification (Initially it was Supervisor User Name). Now open the process (in our case it will be "Test Leave Approval Process"). Open the notification and go to the "Node" tab. Modify the performer.


4) Validate your design and save it to database.

B) Role Definition create Part
    Role can be defined and used in worklfow in two different ways.
          a) Create a Global Application Role
          b) Create database Adhoc Role

We will first discuss how can we define Role from Oracle Application and use the same in workflow.

a) Create a Global Application Role and its usages in workflow
    i) Go to UK HRMS Manage >> Transaction Maintanance >> Global Roles
   ii) Create your custom Global Role and add the desired users (Users must have a valid active fnd_user entry). Save your definition.

  
  iii) Our Application Role definition creation is complete now we have to set the value for our newly created Role attribute. The value of the Role attribute should be the
      name of the role. Workflow engine will take the names from the role and will send the notification automatically.
     We will set the value for Role attribute in our Trigger workflow procedure (Where we are setting the other attribute values)
      To set the Role attribute we need to call wf_engine.SetItemAttrText procedure. This will internally check for Role attribute(though this utility is for setting Text attribute) and perform the task accordingly.


   iv) Now compile the package and workflow is ready to trigger.


b) Create database Adhoc Role and usages
  Instead of creating a Global Role from application we can also create an database adhoc role and use the same to send notification.
   i)  Create a adhoc Role using wf_directory.CreateAdHocRole ultility. This will create a role in database,.

wf_directory.CreateAdHocRole(role_name                      in out varchar2,
                                              role_display_name        in out varchar2
      language                      in varchar2 default null,
     territory                         in varchar2 default null,
     role_description             in varchar2 default null,
     notification_preference   in varchar2 default ’MAILHTML’,
     role_users in varchar2    default null,
     email_address               in varchar2 default null,
     fax in varchar2               default null,
    status in varchar2           default ’ACTIVE’,
    expiration_date in           date default null,
    parent_orig_system        in varchar2 default null,
    parent_orig_system_id    in number default null,
    owner_tag                      in varchar2 default null
);


Enter the value for "role_name" (Must not be more than 320 character and keep the name in uppercase) and "role_display_name" parameter. Keep the other parameter to its default value.

If you want to make this role inactive after definite time period enter value for it (Ex:- for 365 days it should be sysdate+365. Means after 365 days role will be expired).

Here 
role_name             =>XX_TEST_ADHOC_ROLE
role_display_name=>Test Adhoc Role

 ii) Add the user to the newly created Role using wf_directory.AddUsersToAdHocRole utility.
wf_directory.AddUsersToAdHocRole(role_name in varchar2,
                                                     c in varchar2
                                                     )
Here 
role_name  => Internal name of the role 
role_name  => User name of the list of users that we need to add. The user name of the users must be either comma/space separated.
  
  iii) Now set the Role attribute value. The value of the Role attribute should be the Internal name of the adhoc role
      To set the Role attribute we need to call wf_engine.SetItemAttrText procedure. This will internally check for Role attribute(though this utility is for setting Text attribute) and perform the task accordingly.


   iv) Now compile procedure and workflow is ready to trigger.


Note:- 1) As we see we can define Role in two ways 1) Global Application Role 2) Database Adhoc Role.
              When we have a identified static list of approver/stakeholder to whom we need to send the notification we will use the Global Application 
              Role. It is easy to maintain.
              When we have a dynamic list of approver/stakeholder (if our requirement is something like send the notification to all the people who are in a
              particular grade) to whom we need to send the notification we will use the database adhoc Role.

2) If we check the "Expand Roles"(Double click on notification >> Notification Tab) check box it will send an individual copy of the notification message to each user in the role(The notification id will be different). The notification remains in a user’s notification queue until the user responds  or closes the notification.
Since this is a actionable notification and we are not using voting activity thus "First responder Win" happen.
If any of the role performer acts on the notification it will "Closed" in his/her queue. Whereas other will see it as "Cancelled".


3) Oracle Workflow does not support including the action history in a notification with the Expand Roles check box selected, which causes a separate copy of the notification to be sent to each user in the recipient role.



References:-                1) https://metalink.oracle.com
                                      2) Oracle Workflow Developer's Guide ( Release 12) B31433-04
                                      3) Oracle. Workflow API Reference Release 2.6.3.5 Part No. B12163–02
                                       4)https://sites.google.com/site/shareapps4u/learning-topic/workflow-tutorial/how-to-send-notification-to-multiple-user
                         

SQL Query to Convert number into Words for Money

SELECT INITCAP ( DECODE ( FLOOR (TO_NUMBER ( :amount)), 0, '', TO_CHAR (TO_DATE...