November 9, 2015

Image Upload -Employee

Image Upload:
Step 1:
Create a Directory To Download the Files SYS User:
CREATE OR REPLACE DIRECTORY FND_BLOBS AS '/usr/tmp/FND_LOBS[GMM1] '
Grant Access to Apps User
GRANT READ, WRITE ON DIRECTORY FND_BLOBS TO APPS;
Check the Privilege with below command,
SELECT * FROM dba_tab_privs WHERE table_name= ‘FND_BLOBS’;
Run the below Query in Apps Schema[GMM2] ,
CREATE OR REPLACE PROCEDURE XX_IMAGE_UPLOAD
AS
   CURSOR CUR_PER
   IS
      SELECT * FROM PER_ALL_PEOPLE_F  where  employee_number = 200290
      and trunc(sysdate) between effective_start_date and effective_end_date
      and business_group_id =1274;

   V_IMAGE_NAME    VARCHAR2 (240);
   V_DSTN_FILE     BLOB;
   V_SRC_FILE      BFILE;
   V_FILE_EXISTS   INTEGER := 0;
   V_AMT           INTEGER ;
BEGIN
   FOR I IN CUR_PER
   LOOP
      BEGIN
         V_IMAGE_NAME := '200290'||’.jpg’;--Image Name
         V_SRC_FILE := BFILENAME (‘XXHR_FND_BLOBS’, V_IMAGE_NAME);--File Loaction and Name
         V_FILE_EXISTS := DBMS_LOB.FILEEXISTS (V_SRC_FILE);
        
          V_AMT := DBMS_LOB.GETLENGTH(V_SRC_FILE) ;
         

         IF V_FILE_EXISTS = 1
         THEN
            DBMS_LOB.CREATETEMPORARY (V_DSTN_FILE, TRUE, DBMS_LOB.SESSION);
           
            DBMS_LOB.FILEOPEN (V_SRC_FILE, DBMS_LOB.FILE_READONLY);
            DBMS_LOB.LOADFROMFILE (V_DSTN_FILE,
                                   V_SRC_FILE,
                                    V_AMT,1,1 );
            COMMIT;
            DBMS_LOB.FILECLOSE (V_SRC_FILE);

            INSERT INTO APPS.PER_IMAGES (IMAGE_ID,
                                         PARENT_ID,
                                         TABLE_NAME,
                                         IMAGE)
                 VALUES (PER_IMAGES_S.NEXTVAL,
                         I.PERSON_ID,
                         'PER_PEOPLE_F',
                         V_DSTN_FILE);
                          DBMS_OUTPUT.put_line (
               'Uploaded the  image for the employee code : '
               || I.employee_number);
         END IF;
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.put_line (
               'Unable to upload image for the employee code : '
               || I.employee_number||sqlerrm);
      END;
   END LOOP;

   COMMIT;
END;
/


declare
begin
XX_IMAGE_UPLOAD;
end;


SET SERVEROUTPUT ON






 [GMM1]Directory Path in Apps/DB Tier


Document Of Records Download IN Oralce HRMS

Document Download:

Step 1:
Create a Directory To Download the Files SYS User:
CREATE OR REPLACE DIRECTORY FND_BLOBS AS '/usr/tmp/FND_LOBS'
(Directory Path in Apps/DB Tier)

Grant Access to Apps User
GRANT READ, WRITE ON DIRECTORY FND_BLOBS TO APPS;
Check the Privilege with below command,
SELECT * FROM dba_tab_privs WHERE table_name= ‘FND_BLOBS’;
Run the below Query in Apps Schema[GMM2] ,
DECLARE
l_file UTL_FILE.FILE_TYPE;
l_buffer RAW(32767);
l_amount BINARY_INTEGER := 32767;
l_pos INTEGER := 1;
l_blob BLOB;
l_blob_len INTEGER;
l_file_name varchar2(100);
BEGIN
-- Get LOB locator

FOR rec IN (SELECT L.file_data
  INTO   l_blob
  FROM fnd_attached_documents ad,  fnd_documents d, fnd_lobs l
 WHERE ad.pk1_value =41402(Unique Key Refers to the document for each Employee)
  and  d.document_id = ad.document_id
   AND ad.ENTITY_NAME LIKE 'R_DOCUMENT_EXTRA_INFO'(Entity Name Is the Document Reference Name)
 AND l.file_id = d.media_id)
 LOOP
l_blob_len := DBMS_LOB.getlength(rec.l_blob);

-- Open the destination file.
l_file := UTL_FILE.fopen('FND_BLOBS',rec.L.file_data,'w', 32767);

-- Read chunks of the BLOB and write them to the file
-- until complete.
WHILE l_pos < l_blob_len LOOP
DBMS_LOB.read(rec.l_blob, l_amount, l_pos, l_buffer);
UTL_FILE.put_raw(l_file, l_buffer, TRUE);
UTL_FILE.fflush (l_file);
l_pos := l_pos + l_amount;
END LOOP;

-- Close the file.
UTL_FILE.fclose(l_file);
END LOOP;
EXCEPTION
WHEN OTHERS THEN
-- Close the file if something goes wrong.
IF UTL_FILE.is_open(l_file) THEN
UTL_FILE.fclose(l_file);
END IF;
RAISE;
END;

Output directory path in Apps
/u01/(instance_name)/inst/apps/xyz/logs/appl/conc/out/FND_BLOBS

Commit and Check the Path File will Be downloaded in the specified Location.


DECLARE
l_file UTL_FILE.FILE_TYPE;
l_buffer RAW(32767);
l_amount BINARY_INTEGER := 32767;
l_pos INTEGER := 1;
l_blob BLOB;
l_blob_len INTEGER;
l_file_name varchar2(100);
BEGIN
-- Get LOB locator

FOR rec IN (SELECT L.file_data
  INTO   l_blob
  FROM fnd_attached_documents ad,  fnd_documents d, fnd_lobs l
 WHERE ad.pk1_value =41402
  and  d.document_id = ad.document_id
   AND ad.ENTITY_NAME LIKE 'R_DOCUMENT_EXTRA_INFO'
 AND l.file_id = d.media_id)
 LOOP
l_blob_len := DBMS_LOB.getlength(rec.l_blob);

-- Open the destination file.
l_file := UTL_FILE.fopen('/u01/instance name/inst/apps/xyz/logs/appl/conc/out/FCP_BLOBS',rec.L.file_data,'w', 32767);

-- Read chunks of the BLOB and write them to the file
-- until complete.
WHILE l_pos < l_blob_len LOOP
DBMS_LOB.read(rec.l_blob, l_amount, l_pos, l_buffer);
UTL_FILE.put_raw(l_file, l_buffer, TRUE);
UTL_FILE.fflush (l_file);
l_pos := l_pos + l_amount;
END LOOP;

-- Close the file.
UTL_FILE.fclose(l_file);
END LOOP;
EXCEPTION
WHEN OTHERS THEN
-- Close the file if something goes wrong.
IF UTL_FILE.is_open(l_file) THEN
UTL_FILE.fclose(l_file);
END IF;
RAISE;
END;






Commit And Check the Directory

October 19, 2015

The program can't start becuase MSVCR71.dll is missing from your computer Oracle Discoverer Desktop

After successful completion of Discoverer tools., we may not able to open the Admin and Desktop version due to the below error



Solution is: i have download the MSCVP71.dll from

http://www.dlldump.com/download-dll-files_new.php/dllfiles/M/MSVCR71.dll/7.10.3052.48/download.html

and pasted the same in my discoverer bin location., at times if we paste in C:\Windows\System32 doesn't work out.


So tried coping in Discoverer's BIN folder and that worked out.. !!!!

October 13, 2015

Delete Element and its link to Assignment

declare
CURSOR   rec_check is
select  peef.ELEMENT_ENTRY_ID,peef.EFFECTIVE_START_DATE,peef.OBJECT_VERSION_NUMBER,paaf.ASSIGNMENT_NUMBER
 from
pay_element_entries_f peef,
pay_element_types_f petf,
pay_element_links_f pelf,
per_all_assignments_f paaf
where petf.ELEMENT_TYPE_ID=pelf.ELEMENT_TYPE_ID
and peef.ELEMENT_LINK_ID=pelf.ELEMENT_LINK_ID
and peef.ELEMENT_TYPE_ID=petf.ELEMENT_TYPE_ID
and peef.ASSIGNMENT_ID=paaf.ASSIGNMENT_ID
and petf.ELEMENT_NAMe='Final Processing'
and  sysdate between paaf.effective_start_date and paaf.effective_end_date
and  sysdate between petf.effective_start_date and petf.effective_end_date
and  sysdate between peef.effective_start_date and peef.effective_end_date
and  sysdate between pelf.effective_start_date and pelf.effective_end_date;

v_object_version_number number:=1;
v_start_date date:=null;
v_end_date date:=null;
v_delete_wrg boolean ;
v_date date:=null;
begin
FOR cur in rec_check
loop
dbms_output.put_line(1);
begin
pay_element_entry_api.delete_element_entry
(p_validate=>false
,p_datetrack_delete_mode =>'ZAP'
,p_effective_date =>cur.EFFECTIVE_START_DATE---TO_DATE('22-06-2008','DD-MM-YYYY')--v_date
,p_element_entry_id =>cur.ELEMENT_ENTRY_ID
,p_object_version_number =>v_object_version_number
,p_effective_start_date =>v_start_date
,p_effective_end_date =>v_end_date
,p_delete_warning =>v_delete_wrg
);
dbms_output.put_line('Done');
EXCEPTION
when others then
dbms_output.put_line(sqlcode||sqlerrm||'Assignment'||cur.ASSIGNMENT_NUMBER);
end;
end loop;

end;


commit;

July 29, 2015

Attachment Functionality



Attachment Functionality


About Attachments:
Attachment feature enables users to link files like images, word files, emails e.t.c to a particular form/function/record. Once you link a file to a form in oracle it will be saved on your server so that you can retrieve it easily when ever you want it.

Supported Formats:
You can link the following types.
·         File (word, pdf, excel, images)
·         Short Text (Notes)
·         Long Text (emails and long descriptions)
·         Webpage (intranet or internet pages)
Related Tables:
·         FND_ATTACHED_DOCS_FORM_VL
·         FND_ATTACHED_DOCUMENTS
·         FND_ATTACHMENT_BLK_ENTITIES
·         FND_ATTACHMENT_BLOCKS
·         FND_ATTACHMENT_FUNCTIONS
·         FND_ATTACHMENT_REPLICATION
·         FND_DM_FOLDERATTACHMENTEXT 
Enable Attachments
It can be better explained using an example so follow the below example to enable the attachment link in Payments Bank Screen from Account Payables
·         Define Entities
·         Define Attachment Functions
·         Using Attachments
Form Information
Navigation: Payables Manager à Setup à Payments à Banks
Short Name: APXSUMBA
Form Name: Set Up Bank Information
Block Name: BRANCHES
Primary Key: BANK_BRANCH_ID
Table Name: AP_BANK_BRANCHES

Define Entities:
Navigation: Application Developer ResponsibilityàAttachments à Document Entities
Attachments_Oracle_Applications

Create the new record

Table: AP_BANK_BRANCHES
Entity ID: AP_BANK_BRANCHES
Entity Name: AP_BANK_BRANCHES
Prompt: Banks
Application: Payables

Attachments_Oracle_Applications

Close the form.

Navigation: Application Developer à Attachments à Attachment Functions
Attachments_Oracle_Applications

Enter the following
Type: Form
Name: APXSUMBA
User Name: Set Up Bank Information
Session Context Field:
Enabled: Check

Attachments_Oracle_Applications


Save.

Click on Categories and assign Miscellaneous

Attachments_Oracle_Applications


Save.

Close Categories Form.
Attachments_Oracle_Applications

Click on Blocks

Block Name: BRANCHES
Method: Allow Change
Secured By: None
Context 1: BRANCHES.BANK_NAME
Context 2: BRANCHES.BANK_BRANCH_ID

Attachments_Oracle_Applications

Save Now.

Click Entities

Entity: AP_BANK_BRANCHES
Display Method: Main Entity
Privileges: Always
Primary Key Fields: BRANCHES.BANK_BRANCH_ID

Save and Close.

Use Attachments:
Navigation: Payable Manager >> Setup >> Banks
Oracle_Applications_Attachments
Click to open
Oracle_Applications_Attachments
Now Query any record. If you click on attachments now it will ask you to query any record. This is because attachments are stored at record level and not at form level. ofcourse you can attach documents at form level also for that while defining your Block you should not give your context fields and primary key.
Press F11 and then CTL+F11
Oracle_Applications_Attachments

Now Click on attachments ICON Oracle_Applications_Attachments
Oracle_Applications_Attachments
Enter Category as Miscellaneous and Data Type as Short Text. You can choose the data type as you need. and finally enter some text in the yellow area.
Save and Close the Attachments Form.
Now Query the same record in Banks Screen
You should see that paper clip icon changes to Oracle_Applications_Attachments
Click on it to see your attached Text.
Note: The attachments you saved for this bank can not accessed when you query another bank. Which means all your attachments are saved at record level. You can restrict this level to form, function or record level.

COALESCE-SQL

Coalesce- return the null values from the expression. It works similar to a case statement where if expression 1 is false then goes to expr...