Add Logo for PO Output for Communication report

on Thursday, September 23, 2010

Login as a user with the XML Publisher Administrator responsibility and then navigate to the Home: Templates page.

From the XML Publisher Templage page, query for 'PO_STANDARD_XSLFO' code and click on the 'Standard Purchase Order Stylesheet' in the Create Template section.

On the View Template page Scroll down to the Add File section and click the Download link. This will pop save/Open option for the 'PO_STANDARD_XSLFO.xsl' spreadsheet. Save the file to your local disk.

Scroll up again to the General section and click the Update button.

Apply the end date with history date. Preferably the end date should be (SYSDATE-1) and click Apply button. This will end date the standard template.

Locate the 'PO_STANDARD_XSLFO.xsl' on your local drive. Open the file in Wordpad and press ctl+f to find the 'Logo' string in the file. Uncomment the and strings. This code is used to display the image at top left corner in the first page. The complete block after changes should read as below:


Save the file and make sure that you have taken appropiate backup of the XSL spreadsheet before doing any updates.

Navigate to XML Publisher Template page again. Click the Create Template button link and enter data per the following steps:

1. Enter a unique name in the Name field -- Custom Purchase Order Stylesheet
2. Enter unique code in the Code field -- PO_STANDARD_XSLFO1
3. Enter Purchasing in the Application field
4. Select XSL-FO from the Type drop-down list box
5. Enter Standard Purchase Order Data Source in the Data Definitionbox -- Standard Purchase Order Data Source
6. Click Browse button and navigate to the edited PO_STANDARD_XSLFO.xsl file where it is located on your computer
7. Enter English in the Language box
8. Click Apply button

Login with Purchasing Super User responsibility and then navigate to Setup / Organizations / Purchasing Options / Control TAB / set 'PO Output Format' = 'PDF'

Navigate to setup / purchasing / document types / select "Standard Purchase Order" / Set the Document Type Layout to your new template. 

Delete document from Backend

on Monday, September 20, 2010

l_entity_name varchar2(20)                :=  'PO_LINES';   
l_pk1_value varchar2 (20)                  :=  '12345';      
l_delete_document_flag varchar2 (1)   :=  'Y';     
BEGIN

fnd_global.apps_initialize ( user_id          =>  &v_user_id
                                   ,resp_id          =>  &v_resp_id
                                   ,resp_appl_id  =>  &v_resp_appl_id);
fnd_attached_documents2_pkg.delete_attachments
( X_entity_name                 =>  l_entity_name
, X_pk1_value                    =>   l_pk1_value
, X_delete_document_flag    =>   l_delete_document_flag); 
END; 
 

Attach document from Backend

on Sunday, September 19, 2010

--- Below are the main tables involved regarding attachments
fnd_attached_documents 
fnd_documents 
fnd_documents_tl 
fnd_document_categories_tl 
fnd_lobs 
fnd_documents_short_text
fnd_documents_long_text
 
Declare
v_category_id                  NUMBER;
v_attached_doc_id           NUMBER;
v_invoice_id                    NUMBER;
v_invoice_image_url         VARCHAR2(500) := 'http://rafi-oracle.blogspot.com';
v_function_name            VARCHAR2(50)   := 'APXINWKB';
v_category_name            VARCHAR2(100) := 'FromSupplier';
v_description                  VARCHAR2(300) := 'Test script for attaching image url to AP invoice';
v_entity_name                VARCHAR2(100) := 'AP_INVOICES'
v_file_name                    VARCHAR2(100) := NULL;
v_user_id                        NUMBER          := 12345; 
TYPE result_set_type IS    REF CURSOR;
v_result_set_curr             result_set_type;

--Here for example we are using "FromSupplier" as a category
--and AP_INVOICES_ALL.invoice_id as primary key value

CURSOR  cur_cat_id
IS
    SELECT     fdc.category_id
    FROM       fnd_document_categories fdc
    WHERE      fdc.name  =  v_category_name;

FUNCTION set_context( i_user_name   IN  VARCHAR2
                                 ,i_resp_name   IN  VARCHAR2
                                 ,i_org_id         IN  NUMBER)
RETURN VARCHAR2
IS
END set_context; 
  
BEGIN
 -- Setting the context
v_context := set_context('&V_USER_NAME','&V_RESPONSIBILITY',82);
IF v_context = 'F'
    THEN
        DBMS_OUTPUT.PUT_LINE('Error while setting the context');       
    END IF;
DBMS_OUTPUT.PUT_LINE('2');
--- context done
     OPEN cur_cat_id;
     FETCH cur_cat_id INTO v_category_id;
     CLOSE cur_cat_id;

-- Invoke the fnd_webattach api for attaching the URL to the invoice

        fnd_webattch.add_attachment ( seq_num                       => 100
                                                       ,category_id                   => v_category_id
                                                       ,document_description     => v_description
                                                       ,datatype_id                   => 5
                                                       ,text                             => NULL
                                                       ,file_name                      => v_file_name
                                                       ,url                                => v_invoice_image_url
                                                       ,function_name               => v_function_name
                                                       ,entity_name                  => v_entity_name
                                                       ,pk1_value                     => v_invoice_id
                                                       ,pk2_value                     => NULL
                                                       ,pk3_value                     => NULL
                                                       ,pk4_value                     => NULL
                                                       ,pk5_value                     => NULL
                                                       ,media_id                       => x_file_id
                                                       ,user_id                         => v_user_id
                                                       ,usage_type                   => 'O'
                                     );
                                                                                                                                                 
        SELECT    count(fad.attached_document_id)
        INTO      v_attached_doc_id
        FROM      fnd_attached_documents fad
        WHERE     fad.pk1_value = v_invoice_id;

        IF  v_attached_doc_id > 0
          DBMS_OUTPUT.PUT_LINE('Attached sucessfully');
        THEN
          DBMS_OUTPUT.PUT_LINE('Failed to Link the Attacment.');
        END IF;

EXCEPTION
   WHEN OTHERS THEN
         DBMS_OUTPUT.PUT_LINE('Error occured : '||SQLERRM);
   END attach_invoice;