Wednesday, 23 July 2014

How to download attachment stored in fnd_lobs table.


How to download attachment stored in fnd_lobs table


-        -          Open employee’s record and click on attachment icon.


-      Attach any new document under category as show below.





Now you can see the attachment symbol.



Attachment will be stored in fnd_lobs table.

below are queries to identify the attachment record.

select * from fnd_attached_documents
where entity_name='PER_PEOPLE_F'
and pk1_value=33579
order by creation_date desc;


select * from fnd_documents
where document_id=2349427;

select * from fnd_lobs
where file_id=2990785;

Now if you download the attachment through pl/sql procedure.

prerequisite 

- server directory -  where you want to download the file - generally database tier
- read/write access on the that directory.
- proper privileges on UTL_file packages

you can below procedure to download above attachment.



CREATE OR REPLACE PROCEDURE APPS.xx_download_attachment
AS
   CURSOR cur_new_attmt
   IS
      SELECT fl.file_id, fl.file_name, fl.file_data,
             DBMS_LOB.getlength (fl.file_data) file_length
        FROM fnd_lobs fl
       WHERE fl.file_id =2990785;

   v_start           NUMBER             DEFAULT 1;
   v_bytelen         NUMBER             DEFAULT 32000;
   v_len_copy        NUMBER;
   v_raw_var         RAW (32000);
   v_output          UTL_FILE.file_type;
   v_inv_file_name   VARCHAR2 (100);
   v_position        NUMBER;
   v_first_rec       BOOLEAN            DEFAULT TRUE;
BEGIN
   v_position := 10;

   FOR rec_inv IN cur_new_attmt
   LOOP
      v_inv_file_name := NULL;
      v_inv_file_name := rec_inv.file_name;
      v_position := 20;
      -- define output directory AND OPEN THE file IN WRITE BYTE MODE
      v_output := UTL_FILE.fopen ('ODPDIR', v_inv_file_name, 'wb', 32760);
      v_position := 30;

      -- maximum size OF buffer parameter IS 32767 BEFORE
      -- which you have TO flush  your buffer
      IF rec_inv.file_length < 32760
      THEN
         UTL_FILE.put_raw (v_output, rec_inv.file_data);
         UTL_FILE.fflush (v_output);
      ELSE
         v_position := 40;
         v_start := 1;
         v_bytelen := 32000;
         v_len_copy := rec_inv.file_length;

         WHILE v_start < rec_inv.file_length AND v_bytelen > 0
         LOOP
            v_position := 50;
            DBMS_LOB.READ (rec_inv.file_data, v_bytelen, v_start, v_raw_var);
            v_position := 60;
            UTL_FILE.put_raw (v_output, v_raw_var);
            v_position := 70;
            UTL_FILE.fflush (v_output);
            v_start := v_start + v_bytelen;
            v_len_copy := v_len_copy - v_bytelen;

            IF v_len_copy < 32000
            THEN
               v_bytelen := v_len_copy;
            END IF;
         END LOOP;

         v_position := 80;
         UTL_FILE.fclose (v_output);
      END IF;

      v_position := 90;
      DBMS_OUTPUT.put_line (' File_name :' || rec_inv.file_name);
   END LOOP;
END xx_download_attachment;
/


=======================================================================


execute the procedure to download the attachment.


execute xx_download_attachment;

Note : 

-  'ODPDIR' is the directory name.

refer dba_directories for more detail.

select * from dba_directories;





Tuesday, 22 July 2014

How to change current session language


How to change current session language in oracle

select * from per_business_groups;

output : no rows selected.

sometime some views will not return any data because of current session language.
Language install in your application is 'US', but what if your current session language is 'GB' or 'AR'.

sometimes your current session language depends on the tool that you are using or some default setup.

Generally it returns 'US'.
=====================================

select userenv('LANG') from dual;

output : US

=====================================

If it's not then you can your current session language by using alter session command.

eg. For AR

alter session set NLS_LANGUAGE='ARABIC';

eg. For GB

alter session set NLS_LANGUAGE='ENGLISH';

eg. For US

alter session set NLS_LANGUAGE='AMERICAN';

=================================================================


Friday, 30 May 2014

Set application message and token and retrieve it / Oracle application messages / FND Messages



Create a new application message as shown below.





You can set the message ,it's tokens, retrieve the value and then you can use it user hooks,form personalizations and other scripts.


DECLARE

   lv_msgdata   VARCHAR2 (32000);

BEGIN

   apps.fnd_message.set_name ('PER', 'XX_MSG_1');
   apps.fnd_message.set_token ('MSG_NAME', 'XXXX', TRANSLATE => TRUE);
   apps.fnd_message.set_token ('MSG_START_DATE',
                               '01-Jan-2014',
                               TRANSLATE      => TRUE
                              );
   lv_msgdata := apps.fnd_message.get ();

END;



Wednesday, 28 May 2014

How to Hide Reassign and Request for information button in workflow notification in oracle apps



HIDE REASSIGN BUTTON

Create an attribute with below details and drag and drop under the message for which you want to hide reassign button.




HIDE REQUEST FOR INFORMATION BUTTON

Create an attribute with below details and drag and drop under the message for which you want to hide reassign button.



Sunday, 25 May 2014

Running the pre-processor after registering user-hook in oracle apps / Alternative of pre-processor


To run the pre-processor run one of the following commands:

cd $PER_TOP/admin/sql
Log into SQLPLUS as the APPS user
SQL> @hrahkall.sql

or

SQL> @hrahkone.sql


The first script will create all hook package bodies, whilst the second will
create hook package bodies for one API module only, and prompt for that
api_module_id.

==========================================================

Sometimes if you don't have server credentials then you can use below alternative to run the pre-processor through sqlplus

Log in to database through apps

SQL> @hrahkall.sql

instead of running above script you can execute below statement

exec hr_api_user_hooks_utility.create_hooks_all_modules;

SQL> @hrahkone.sql

instead of running above script you can execute below statement

exec hr_api_user_hooks_utility.create_hooks_one_module(p_module_id);


Saturday, 24 May 2014

How to send attachment in oracle workflow notification / blob documents as attachment in oracle workflow notification



Create normal workflow process with simple notification as below.





Create a new document type attribute with below details.





drag and drop this attribute under "Attachment_notification"(notification message). Set the Attributes property as shown below.





Your workflow is complete. Now write the following PL/SQL code and run the workflow to get the notification. 


Sequence for item key :::

create sequence xx_example_s
start with 1
increment by 1;




CREATE OR REPLACE PACKAGE xx_example
IS
   PROCEDURE xx_training_wf;

   PROCEDURE xx_attach_p (
      document_id     IN       VARCHAR2,
      display_type    IN       VARCHAR2,
      document        IN OUT   BLOB,
      document_type   IN OUT   VARCHAR2
   );
END;

CREATE OR REPLACE PACKAGE BODY xx_example
IS
   gv_document_id   VARCHAR2 (100) := '2955797';

   PROCEDURE xx_training_wf
   IS
      l_itemtype   VARCHAR2 (30)  := 'XXTEST';
      l_itemkey    VARCHAR2 (300);
   ---l_file_name   VARCHAR2 (100) := 'holidaylist.xls';
   --l_unique_id   VARCHAR2 (50)  := unique_id;
   BEGIN
      SELECT TO_CHAR (xx_example_s.NEXTVAL)
        INTO l_itemkey
        FROM DUAL;

      wf_engine.createprocess (l_itemtype, l_itemkey, 'XX_TEST_ATTACHMENT');
      wf_engine.setitemattrdocument
                         (itemtype        => l_itemtype,
                          itemkey         => l_itemkey,
                          aname           => 'XX_ATT1',
                          documentid      =>    'PLSQLBLOB:XX_EXAMPLE.XX_ATTACH_P/'
                                             || gv_document_id
                         );
      wf_engine.setitemattrtext (itemtype      => l_itemtype,
                                 itemkey       => l_itemkey,
                                 aname         => '#FROM_ROLE',
                                 avalue        => 'WF_EMP1'
                                );
      wf_engine.setitemattrtext (itemtype      => l_itemtype,
                                 itemkey       => l_itemkey,
                                 aname         => 'XXTIMEOUT',
                                 avalue        => 2880
                                );
      wf_engine.startprocess (l_itemtype, l_itemkey);
      COMMIT;
   END xx_training_wf;

   PROCEDURE xx_attach_p (
      document_id     IN       VARCHAR2,
      display_type    IN       VARCHAR2,
      document        IN OUT   BLOB,
      document_type   IN OUT   VARCHAR2
   )
   IS
      lv_file_name           VARCHAR2 (100) := NULL;
      lv_file_content_type   VARCHAR2 (100) := NULL;
      ld_document            BLOB;
   BEGIN
      SELECT file_name, file_content_type, file_data
        INTO lv_file_name, lv_file_content_type, ld_document
        FROM fnd_lobs
       WHERE file_id = 2955797;

      document_type := lv_file_content_type || ';name=' || lv_file_name;
      DBMS_LOB.COPY (document, ld_document, DBMS_LOB.getlength (ld_document));
      COMMIT;
   EXCEPTION
      WHEN OTHERS
      THEN
         wf_core.CONTEXT ('xx_example',
                          'xx_attach_p',
                          'document_id',
                          'display_type'
                         );
         RAISE;
   END xx_attach_p;
END xx_example;



====================================================

Now execute procedure  to initiate the workflow.

execute xx_example.xx_training_wf ;

====================================================

Attachment will look like this










TImeout functionality in workflow notification / Due date of notification in workflow



- Log in to workflow builder , open the workflow process





select the notification , right click and select properties then click on node tab.

it will be as below.





In the timeout section you can select timeout properties.

There are 3 options.


1- No timeout : It means no due date of the notification.


2 -  Relative Time : It is nothing but the constant time details .
you can set the value in days, hours and minutes combination.






3 - Item Attribute : You can create number type attribute and assign it here.





you can set the attribute value as below.


wf_engine.setitemattrtext (itemtype      => l_itemtype,
                                 itemkey       => l_itemkey,
                                 aname         => 'XXTIMEOUT',
                                 avalue        => 2880
                                );

2880 - it is  minutes.

if you want to set due date to 3 days then value should be =(24*60*3)= 4320.











How to Restrict Global Assignment EFF Values by Employee Legislation in Oracle Fusion HCM

How to Restrict Global Assignment EFF Values by Employee Legislation in Oracle Fusion HCM In global Oracle Fusion HCM implementations, one...