Wednesday, April 13, 2011

Getting the Rtf file from the Database without Accessing


In XMLP all the files such as .xml, .rtf , PDF etc are stored in the BLOB column in xdo_lobs table.
This Document briefs you on the different ways of retrieving the Rtf file from the
Database.There are 2 ways of doing this.
1) Retrieving and Storing a BLOB column in a file using UTL_FILE Package.
2) Retrieving and Storing a BLOB column in a file using Java Stored Procedure.
Retrieving and Storing a BLOB column in a file using UTL_FILE Package
We can retrieve only the RTF files from the Template Manager but using BLOB column we can
retrieve even the .xsl and files.
The following function shows how to retrieve the files stored in the blob column.
:
Step 1:
select file_data
into xmlstr
from xdo_lobs
where file_name='PO_STANDARD_PO.rtf';
Store the BLOB column FILE_DATA of xdo_lobs table in a variable of type BLOB.
Step 2:
--to write blob column data to a file
DECLARE
v_file utl_file.file_type;
line_buf RAW(32767);
maxbufsize BINARY_INTEGER := 32767;
amount BINARY_INTEGER;
offset varchar2(40);
xmlstr BLOB;
dir varchar2(50) := 'ATTACHMENTS';
filename varchar2(50) := 'PO_STANDARD_PO.rtf';
bsize number;
BEGIN
v_file := utl_file.fopen(dir,filename,'w',maxbufsize);
select file_data
into xmlstr
from xdo_lobs
where file_name='PO_STANDARD_PO.rtf';
bsize := dbms_lob.getLength(xmlstr);
dbms_output.put_line(bsize);
amount := maxbufsize;
offset := 1;
while (amount>=maxbufsize)
loop
DBMS_LOB.read(xmlstr,amount,offset,line_buf);
offset := offset+amount;
utl_file.put_raw(v_file,line_buf);
utl_file.fflush(v_file);
end loop;
--close context
utl_file.fclose(v_file);
END;
/
Store the BLOB data in the variable in a file using UTL_FILE package.
Retrieving and Storing a BLOB column in a file using Java Stored Procedure:
Another way is to used a Java Stored Procedure to retrieve the BLOB column.
Step1:
CREATE OR REPLACE JAVA SOURCE NAMED "BlobHandler" AS
import java.lang.*;
import java.sql.*;
import oracle.sql.*;
import java.io.*;
public class BlobHandler
{
public static void ExportBlob(String myFile, BLOB myBlob) throws
Exception
{
// Bind the image object to the database object
// Open streams for the output file and the blob
File binaryFile = new File(myFile);
FileOutputStream outStream = new FileOutputStream(binaryFile);
InputStream inStream = myBlob.getBinaryStream();
// Get the optimum buffer size and use this to create the read/write buffer
int size = myBlob.getBufferSize();
byte[] buffer = new byte[size];
int length = -1;
// Transfer the data
while ((length = inStream.read(buffer)) != -1)
{
outStream.write(buffer, 0, length);
outStream.flush();
}
// Close everything down
inStream.close();
outStream.close();
}
};
/
Load the java stored procedure into the database
Step2:
ALTER java source "BlobHandler" compile;
show errors java source "BlobHandler"
Compile the loaded java stored procedure code
Step3:
CREATE OR REPLACE PROCEDURE ExportBlob (p_file IN VARCHAR2,
p_blob IN BLOB)
AS LANGUAGE JAVA
NAME 'BlobHandler.ExportBlob(java.lang.String, oracle.sql.BLOB)';
/
Create a PL/SQL procedure which maps the java stored procedure
Step4:
EXEC Dbms_Java.Grant_Permission( 'APPS', 'java.io.FilePermission', '*', 'read ,write, execute,
delete');
Grant to scott in order to write to os files
Step5:
declare
xmlstr blob;
begin
select file_data
into xmlstr
from xdo_lobs
where file_name='onepage.rtf';
ExportBlob ('/data/tst1/attachment/sample.rtf', xmlstr);
end;
/
Execute the Java Stored procedure

Friday, February 18, 2011

Oracle APPS interview questions

1.List of some API’S
 FND_PROGRAM.EXECUTABLE
 FND_PROGRAM.REGISTER
 FND_PROGRAM.PARAMETER
 FND_PROGRAM.ADD_TO_GROUP
 FND_REQUEST.SUBMIT_REQUEST
 FND_PROFILE.VALUE
 FND_PROFILE.GET

2.How to get second parameter value based on first parameter?

 $flex $ value setname.

3.Forms can be development in APPS in two ways
 A) Customization by extension (using template.fond)
 B) Customization by modification (using custom.pll)

4.How to call WHO columns into the form
 By using FND_STANDARD API’S
  1. FND_STANDARD.FORM_INFO
   Provides information about the form.
   Should be called form when_new_form – instance – instance trigger.
  2. FND_standard.set_who
   loads WHO columns with proper user information.
   Should be called from PRE_UPDTE and PRE_INSERT
   Triggers for each block with WHO fields
   If this is used FND-GLOBAL need not be called.
   (FND_GLOBAL.WHO)
  3. FND_STANDARD.SYSTEM_DATE
   This is a function which returns date.
   Behave exactly like SYSDATE built-in.
  4. FNID_STANDARD.USER
   This is a function which returns varchar2
   Behaves exactly like built in USER.
  5.APPCORE API’S
   APP_COMBO
   APP_DATE
   APP_EXCEPTION
   APP_FIELD
   APP_FIND
   APP_ITEM
   APP_ITEM_PROPERTY
   APP_NAVIGATE
   APP_RECORD
   APP_REGION
   APP_STANDARD
   APP_WINDOW

  6.FNDSQF API’S
   FND_CURRENCY
   FND_DATE
   FND_GLOBAL
   FND_ORG
   FND_STANDARD
   FND_UTILITIES.OPEN_URL
   FND_UTILITIES. PARAM_EXISTS

7.How to call flex fields in the form?

   By using FND_FLEX.EVENT (EVENT varchar 2)

8.How to register an executable and define a concurrent program through backend?

 By using concurrent processing API’S
 1. FND_CONC_GLOBAL.REQUEST_DATA.SET_REQUEST_GLOBALS
 2. FND_CONCURRENT.AF_COMMIT
          .AF_ROLLBACK
          .GET_REQUEST_STATUS
          .WAIT_FOR_REQUEST
          .SET_COMPLETION_STATUS
 3. FND_FILE .
            . PUT_LINE
            .NEW_NAME
            .PUT_NAMES
              .CLOSE
 4. FND-PROGRAM . MESSAGE
 . EXECUTABLE
 . REGISTER
 . PARAMETER
 . IN COMPATIBILITY
 . EXECUTABLE_EXISTS
 5. FND_REQUEST . SET-OPTIONS
 .SET_REPEAT_OPTIONS
 .SET_PRINT_OPTIONS
 .SUBMIT_REQUEST
 .SET_MODE
 6. FND_REQUEST_INFO . GET_PARAM_NUMBER
 . GET_PARAM_INFO
 . GET_PROGRAM
 . GET_PARAMETER
 7. FND_SET . MESSAGE
 .ADD_PROGRAM
 .ADD_STAGE
 .IN COMPATIBILITY
 8. FND_SUBMIT . SET_MODE
 .SET_REQUEST_STATUS
 .SUBMIT_PROGRAM
 .SUBMIT_SET
 9. FND_PROGRAM.EXECUTABLE
 - is used to define a concurrent program executable
 - it takes 8 parameters ( all are IN mode )
 syntax procedure FND_PROGRAM.EXECUTABLE
 (executable IN varchar2,(Full name) à application IN varchar2,(executable short  name) à short name IN varchar2,description IN varchar2 default null
 execution_method IN varchar2,execution_file_name IN varchar2 default null,
 (only fol spauned & Immedaite) à subroutine_name IN varchar2 default null,
 icon_name IN varchar2 default null,language_code IN varchar2 default (VS)
 (for Java Conc Program) à execution_file_path IN varchar2 default null,

10. FND_PROGRAM.REGISTER
 - this procedure no used to define a concument program.
 - It has 30 IN paranmeters. Out of which 9 are mandatory, the remaining are  default.
 Syntax procedure FND_PROGRAM.REGISTER
 (program IN varchar2,application IN varchar2,enabled IN varchar2,short_name IN  varchar2,description IN varchar2, default null,( executable_short_name)  executable_name IN varchar2 executable_application IN varchar2,
 mls_function_shelt_name IN varchar2,mls_function_application IN varchar2,
 incrementor IN varhcar2);

11. How to register a table and columns through back end?

 by using AD_DD package
 - for registering a table à AD_DD.REGISTER_TABLE
 - for registering columns à AD_DD.REGISTER_COLUMN.
 - AD_DD BPI doesn’t check for the existence of the registered table or column in  the data base schema, but only updates the required SQL tables.
 - It should be ensured that, all the tables and columns registered exist actually  and have the same format as that defined using AD_DD API.
 - Views need not be registered.
12. How to write to a file through concurrent program.

 By using FND_FILE package and it can be used only for log and output files.
 FND_FILE package contains procedures to write text to log and output files.
 FND_FILE supports a maximum buffer line size of 32k for both and output files.

13. FND_FILE.PUT
 - this is used to write text to a file with out a new line character
 - Multilane calls to FND_FILE.PUT will produce consummated text.
 Procedure FND_FILE.PUT (which IN Number,Buff IN varchar2);

14.Which log output file
 - can be FND_FILE.LOG or FND_FILE.OUTPUT.
 2. FND_FILE.PUT_LINE
 - this procedure as used to write a line of text to a file followed by a new line  character.
 Procedure FND_FILE.PUT_LINE (which IN number,buff IN varchar2);
 EX:- FND_FILE.PUT_LINE( FND_FILE.LOG, find_message_get);
 3. FND_FILE.NEW_LINE
 - this procedure is used to write line terminators to a file
 procedure FND_FILE.NEW_LINE (which IN number LINES IN NATURAL:=1);
 Ex:- to write two newline characters to a log file Fnd_file.new_line  (fnd_file.log,2);
 4. FND_FILE.PUT_NAMES
 - this procedure as used to set the temporary log file and output filenames and  the temporary directory to the user specified values.
 - This should be called before calling my other FND_FILE procedure and only once  per a session.

15.Function FND_REQUEST.SUBMIT_REQUEST
 ( application in varchar2 default null,
 program in varchar2 default null,
 description in varchar2 default null,
 start-time in varchar2 default null,
 sub_request in bookan default False,
 argument1,
 argument2,
 argument 100) return number;
 * If this is submitted from oracle forms, all the arguments ( 1 to 100 ) must be  specified.

16. How to display Request ID in the reports?

 By using the parameter P_CONC_REQUEST_ID
 which needs to be defined always in the reports.

17. How to get username / user id in reports?

 - By using the API FND_PROFILE THE OPTION values
 can be manipulated in client / server profile caches
 - FND_PROFILE.GET, FND_GLOBAL.USER_ID,FND_GLOBAL.USER_NAME
 - this procedure is located in FNDSQF library.
 - This procedure is to located to get the current value of the specifed user profile  option or null if the profile does not exist.
 - The server_side PL/SQL package FND_GLOBAL returns the values which need to  set who columns for inserts and updates from stored procedures.
 - Procedure FND_PROFILE.GET ( name in varchar2,Value out varchar2);
 FND_PROFILE.GET (‘USER_ID’, user_id);
 FND_PROFILE.VALUE
 - this function exactly works like GET, except it returns the values of the  specified profile option as a function result
 Function FND_PROGILE.VALUE (name in varchar2
 Return varchar2;

 FND_PROFILE.PUT
 - this is used to put a value to the specified profile option
 - if the option doesn’t exist, it can also be created with PUT.
 Procedure FND_GET (‘USERNAME’, user name);
 FND_PROFILE.GET (‘USER_ID’, user_id);
 - username, user-id, vsp_id , Appl_shrt_Name, Resp_Appl_Id, Form_Name,  Form_id, Form_Appl_Name, Form_Appl_Id, Logon_Date, Last_Lagon_Date,  login_id, Gone_Request_Id, Gone_Program_Id,Gone_program_Application_Id,  Gone_Login_Id, Gone_Print_Output, Gone_printstyle_ these are the user profile  options that can be accessed via user profile option routines .
 - the values of these profile options can be retrieved in forms, reports and  program
 - these values cannot be changed except Gone_Print_Output and  Gone_Print_Style.
 - SA’s and end users also cannot see the values or change these values.
 In which directory log and output files are stored?
 APPLCSF is the top level directory in which the concurrent manager puts logs and  output files.
 APPLLOG and APPLOUT are the subdirectories in which the concurrent manager  puts log and output files.
 APPLCSF variable need to be set in the prod.env ( environmental variable ), so  that all product log files
 $ APPLCSF/ $ APPLLOG à log files
 $APPLCSF/ $ APPLOUT à out files

 concurrent manager log and out put files should go to $ FND_TOP/ $ APPLOG and  $ FND _TOP / $APPLOUT if $ APPLCSF is not set.

18. How to submit concurrent programs through OS?

 - From the operating system the utility .CONCSUB is used to submit is concurrent  program.
 - This is basically used to test a concurrent program .
 - By using the WAIT token. The utility checks the request status every 60  seconds and returns the OS prompt upon completion of the request.
 - Concurrent manager doesnot abort, shutdown or start up until the concurrent  request completes.
 * If the concurrent program is compatible with it self, it can be checked for data  integrity and dead locks by submitting it many times so that it runs concurrently  with it self.
 *PL/SQL procedures can submit a request to run a program as a concurrent  process by calling.
 FND_REQUEST. SUBMIT_REQUEST.
 Before submitting a request, the following functions also should be called  optionally.
 FND_REQUEST.SET_OPTIONS
 FND_REQUEST.SET_REPEAT_OPTIONS
 FND_REQUEST.SET_PRINT_OPTIONS
 FND_REQUEST.SET_MODE

19. How to checks the request states?

 - A PL/SQL procedure can check the status of a concurrent request by calling.
 FND_CONCURENT.GET_REQUEST_STATUS
 FND_CONCURRENT.WAIT_FOR_REQUEST
 FND_CONCURRENT.GET_REQUEST_STATUS
 - This function returns the status of a concurrent request
 - If the request is already computed, it also returns the completion message.
 - This function returns both user friendly (translatable) phase and status values  as well as developer phase and status vales that can drive program logic.
 Syntax Function FND_CONCURRENT.GET_REQUEST_STATUS
 ( request_id in out number,
 application in varchar2 default null,
 program in varchar2 default null,
 phase out varchar2,
 status out varchar,
 dev_phase out varchar2,
 dev_status out varchar2,
 message out varchar2) return BOOLEAN;
 - when application and program are specified, the request_id of the last request  for the specified program should be returned to request_id.
 - Phase, and status values should be taken from
 FND_LOOKUPS
 dev_phase dev_status
 pending normal, standby, scheduled, paused
 running normal, waiting, resuming, terminating.
 Complete normal, Error, warning, cancelled, terminated
 Inactive disabled, on-hold, No-manager, supended
 - FND_REQUEST.WAIT_FOR_REQUEST
 - This function waits for request completion, then returns the request  phase/status and completion message to the caller.
 - Goes to sleep between checks for request completion.
 Syntax FND_CONCURRENT.WAIT_FOR_REQUEST
 ( request_id in number default null,
 interval in number default 60,
 max_wait in numbe default 0,
 phase out varchar2,
 status out varchar2,
 dev_phase out varchar2,
 dev_status out varchar2,
 message out varchar2) return BOOLEN;
 FND_CONCURRENT.SET_COMPLETION_STATUS
 - this function should be called from a concurrent program to set its completion  states.
 - This function returns TRUE on success, other wise FALSE.
 Syntax function FND_CONCURRENT.SET_COMPLETION_STATUS
 ( status in varchar2, message in varchar2) return BOOLEAN;


20. How to generate fmx at OS level?

 - Forms can be generated on the forms server as the APPLMGR user.
 - Generating the form on the Form server, $ FORM60_PATH

 Should be set and the current directory should be $AV_TOP/forms?us.
 Syntax à $F60 gen userid=apps/appsp module=<form_name>. Fmb
 Output_file=<schema_top>/forms?<language>/<form_name>.fmx
 Module_type=form bath =no compile_all=special




21.
Flex fields:

Used to store information regarding industry, work or person.
Flexfiled  are made up of subfields and segments. They ca be differentiated into Key flexfield (KFF) and descriptive flexfiled(DFF)
KFF stores the key information of an organization, which appears as normal text field.
Where as descriptive flexfield stores the additional information, appears in square bracket, and show the value only if it is clicked.

Meaning full keys are called intelligent keys.

KFF & DFF uses Segment, value, validation, value set, and structure

Segment:-Subfields can be defined for the flexfield called segments. In database it will be stored in a single data column.

Value, Validation, Valuset:-are user dependent values given for the described segments.

e.g:-a segment Age has value column to be filled up, valueset can be 20, 30and 40 as we can set. After validation only defined value set can be accessed or compiled.
Structure:-Configuration of segment.

DFF used two different types of segments

1. Global-appears in pop-up window always.

2. Context Sensitive-optional to be viewed

Qualifiers:
Flexfield uses Qualifiers to identify a particular segment of KFF

PL/SQL Scripts

List all the registered concurrent programs by module 
 Summary
SQL script to list all the registered concurrent programs by module.
SELECT   SUBSTR(a.application_name,1,60) Application_NAME
,        b.application_short_name SHORT_NAME
,        DECODE(SUBSTR(cp.user_concurrent_program_name,4,1),':'
         ,      'Concurrent Manager Executable'
         ,      'Subprogram or Function') TYPE
,        SUBSTR(d.concurrent_program_name,1,16) PROGRAM
,        SUBSTR(cp.user_concurrent_program_name,1,55) USER_PROGRAM_NAME
FROM     applsys.FND_CONCURRENT_PROGRAMS_TL cp, applsys.FND_CONCURRENT_PROGRAMS d, applsys.FND_APPLICATION_TL a, applsys.fnd_application b
WHERE    cp.application_id = a.application_id
AND      d.CONCURRENT_PROGRAM_ID = cp.CONCURRENT_PROGRAM_ID
AND      a.APPLICATION_ID = b.APPLICATION_ID
AND      b.application_short_name LIKE UPPER('PA')
UNION ALL
SELECT   SUBSTR(a.application_name,1,60) c1
,        b.application_short_name c2  ,        'Form Executable' c3
,        SUBSTR(f.form_name,1,16) c4 ,       
SUBSTR(d.user_form_name,1,55) c5
FROM     applsys.fnd_form f ,        applsys.FND_APPLICATION_TL a, applsys.fnd_application b, applsys.FND_FORM_TL d
WHERE    f.application_id = a.application_id
AND      d.FORM_ID = f.FORM_ID
AND      a.APPLICATION_ID = b.APPLICATION_ID
AND      b.application_short_name LIKE UPPER('PA') ORDER BY 1
,2,3,4;


A list of E-Business Suite modules along with some usefull columns.
SELECT * FROM
(
SELECT fat.application_name MODULE,
       fa.application_short_name short_name,
       fa.basepath,
       fat.description,
       fl.meaning,
    fpi.patch_level,
       fpi.product_version
  FROM apps.fnd_application fa,
       apps.fnd_application_tl fat,
       apps.fnd_product_installations fpi,
       apps.fnd_lookups fl
 WHERE fa.APPLICATION_ID = fat.APPLICATION_ID
   AND fa.application_id = fpi.application_id
   AND fpi.status = fl.lookup_code
   AND fl.lookup_type = 'FND_PRODUCT_STATUS'
   AND fat.LANGUAGE = USERENV('LANG')
UNION
SELECT fa.application_short_name,
       fa.basepath,
       fat.application_name,
       fat.description,
       'Custom', ' ',
       fu.user_name||' ( '||fa.creation_date ||' )'
  FROM apps.fnd_application fa,
       apps.fnd_application_tl fat,
       apps.fnd_user fu
 WHERE fa.APPLICATION_ID = fat.APPLICATION_ID
  AND fat.LANGUAGE = USERENV('LANG')
  AND fa.created_by = fu.user_id
  AND fa.application_id NOT IN ( SELECT fpi.application_id
                                   FROM apps.fnd_product_installations fpi )
           )
--where short_name like '%AR%'
ORDER BY MODULE ASC;

Output example when filter with short_name like '%AR%'

Module:Oracle Receivables
Short_name:AR
Short_name:AR
basepath:AR_TOP
Description:Oracle Receivables
Meaning:Installed
Patch_level:11i.AR.L


SQL script to lists all the profile settings

SELECT pot.user_profile_option_name "Profile"
 , DECODE( a.profile_option_value
          , '1', '1 (may be "Yes")'
          , '2', '2 (may be "No")'
          , a.profile_option_value) "Value"
 , DECODE( a.level_id
          , 10001, 'Site'
          , 10002, 'Appl'
          , 10003, 'Resp'
          , 10004, 'User'
          , '????') "Levl"
 , DECODE( a.level_id
          , 10002, e.application_name
          , 10003, c.responsibility_name
          , 10004, d.user_name
          , '-') "Location"
FROM applsys.fnd_application_tl e
 , applsys.fnd_user d   , applsys.fnd_responsibility_tl c
 , applsys.fnd_profile_option_values a   , applsys.fnd_profile_options b
 , applsys.fnd_profile_options_tl pot
WHERE UPPER( pot.user_profile_option_name) LIKE UPPER( '%&&v_profile%')
 AND pot.profile_option_name = b.profile_option_name
 AND b.application_id = a.application_id (+)
 AND b.profile_option_id = a.profile_option_id (+)
 AND a.level_value = c.responsibility_id (+)
 AND a.level_value = d.user_id (+)   AND a.level_value = e.application_id
(+)
 AND( UPPER( e.application_name) LIKE UPPER( '%&&v_username%')
 OR UPPER( c.responsibility_name) LIKE UPPER( '%&&v_username%')
 OR UPPER( d.user_name) LIKE UPPER( '%&&v_username%'))
 ORDER BY "Profile", "Levl", "Location", "Value"
/



Concurrent Programs assigned to a request type 

SELECT RC.REQUEST_CLASS_NAME,
       CPTL.USER_CONCURRENT_PROGRAM_NAME,
       CP.CONCURRENT_PROGRAM_NAME
  FROM APPLSYS.FND_CONCURRENT_PROGRAMS_TL CPTL,
       APPLSYS.FND_CONCURRENT_PROGRAMS CP,
       APPLSYS.FND_CONCURRENT_REQUEST_CLASS RC
 WHERE RC.APPLICATION_ID = CP.CLASS_APPLICATION_ID
   AND RC.REQUEST_CLASS_ID = CP.CONCURRENT_CLASS_ID
   AND CP.APPLICATION_ID = CPTL.APPLICATION_ID
   AND CP.CONCURRENT_PROGRAM_ID = CPTL.CONCURRENT_PROGRAM_ID
 ORDER BY REQUEST_CLASS_NAME, USER_CONCURRENT_PROGRAM_NAME;
 

Set Who columns in pre-insert:

 

BEGIN

DATA BLOCK NAME;

FND_STANDARD.SET_WHO;

PACKAGE.VALIDATE_APPROVAL;(Define this procedure in program units)          

END;

 

Set Who columns in pre-update:

 

begin

                XXGOD_JOB_NO;

                XXGOD_REV_ADD;

                fnd_standard.set_who;

                XXJOB_CARD.VALIDATE_APPROVAL1;

end;

 

Set triggers at  when-new-record-instance-level

DECLARE

                v_count number;

                v_count2 number;

 BEGIN

 

                SELECT count(*) into v_count

    FROM fnd_lookup_values

   WHERE lookup_type = ‘Receipt Number’(count records ad new in db)

  and sysdate between start_date_active and nvl(end_date_active,sysdate)

 and lookup_code=fnd_global.user_id;



                IF v_count = 0 then

--set datablock and procedure to validate                                               SET_ITEM_PROPERTY('XXGOD_JOB_CARD.APPROVE',ENABLED,PROPERTY_FALSE);

                                END IF;

 

  IF v_count = 1 THEN

  --SET_ITEM_PROPERTY('XXGOD_QUOTATION_HDR1.SALES_ORDER',ENABLED,PROPERTY_FALSE);

                                                  IF :XXGOD_JOB_CARD.APPROVALS ='Submitted' THEN

                                                   SET_ITEM_PROPERTY('XXGOD_JOB_CARD.APPROVE',ENABLED,PROPERTY_TRUE);

                                                  ELSE

                                                   SET_ITEM_PROPERTY('XXGOD_JOB_CARD.APPROVE',ENABLED,PROPERTY_FALSE);

                                    END IF;

  END IF;

 

 END;

 

 

Validating Procedure and Package:

PACKAGE XX_VALIDATE IS

  PROCEDURE VALIDATE_APPROVAL;

  PROCEDURE VALIDATE_APPROVAL1;

  PROCEDURE XVALID_DESC_PRO(EVENT IN VARCHAR2);

END;

 

PACKAGE BODY XX_VALIDATE IS

  PROCEDURE VALIDATE_APPROVAL IS

  BEGIN

                IF  :DATA_BLOCK_NAME.APPROVALS IS NULL THEN

                                                                FND_MESSAGE.SET_STRING('Status needs to be selected');

                                                                  FND_MESSAGE.SHOW;

                                                                  RAISE FORM_TRIGGER_FAILURE;

                END IF;

                IF  :DATA_BLOCK_NAME.APPROVALS!='New'THEN

                                                                                                FND_MESSAGE.SET_STRING('This is a new Job card,select the status as New');

                                                                                                FND_MESSAGE.SHOW;

                                                                                                RAISE FORM_TRIGGER_FAILURE;

                ELSE

                                                                XX_VALIDATE_1(CALLING ANOTHER PROCEDURE);

                END IF;

                EXCEPTION

                                WHEN OTHERS THEN

                                FND_MESSAGE.ERROR;

                                RAISE FORM_TRIGGER_FAILURE;

                END;

 ------------------------------------------------------------------------------------------------

                 PROCEDURE VALIDATE_APPROVAL1 IS

                 CURSOR C1 IS SELECT APPROVALS FROM table_name WHERE JOB_ID=:data_bolck.item;

   v1 VARCHAR2(20);

                 BEGIN

                                OPEN C1;

                                FETCH C1 INTO v1;

                               

  IF V1!=:DATA_BLOCK_NAME.APPROVALS THEN                           

                               

                                                IF V1='New' AND :DATA_BLOCK_NAME.APPROVALS!='Submitted' THEN

                                                                                                FND_MESSAGE.SET_STRING('This is a new Job card,needs to be Submitted');

                                                                                                FND_MESSAGE.SHOW;

                                                                                                RAISE FORM_TRIGGER_FAILURE;

                                                END IF;

                                               

                                IF V1='Submitted' and :DATA_BLOCK_NAME.APPROVALS not in('Approved','Rejected') THEN

                                                                                                FND_MESSAGE.SET_STRING('Submitted Job card,needs to be Approved or Rejected');

                                                                                                FND_MESSAGE.SHOW;

                                                                                                raise form_trigger_failure;

                                END IF;

                               

                                                                IF V1='Rejected' and :DATA_BLOCK_NAME.APPROVALS not in( 'Rejected','Submitted','Closed') THEN

                                                                                                FND_MESSAGE.SET_STRING('Rejected Quotation can only be Submitted or Closed');

                                                                                                FND_MESSAGE.SHOW;

                                                                                                raise form_trigger_failure;

                                END IF;

                  

                                                                if v1='Approved' and :DATA_BLOCK_NAME.approvals not in('Inactive','Active') then

                                                                fnd_message.set_string('Approved Job can be Active or Inactive');

                                                                fnd_message.show;

                                                                raise form_trigger_failure;

                                                                end if;

                                                               

                                                                IF v1='Inactive' and :DATA_BLOCK_NAME.approvals!='Active' then

                                                                                                FND_MESSAGE.SET_STRING('Select the status as Active');

                                                                                                FND_MESSAGE.SHOW;

                                                                                                raise form_trigger_failure;

                                                   END IF;

                                                               

                                                                IF v1='Active' and : DATA_BLOCK_NAME .approvals!='Closed' then

                                                                                                FND_MESSAGE.SET_STRING('Active Job card has to be Closed');

                                                                                                FND_MESSAGE.SHOW;

                                                                                                raise form_trigger_failure;

                                                                END IF;

                                                if  v1='Closed' and : DATA_BLOCK_NAME.approvals!='Closed' then

                                                                                                FND_MESSAGE.SET_STRING('Closed Job card can not be modified');

                                                                                                FND_MESSAGE.SHOW;

                                                                                                raise form_trigger_failure;

                                                end if;  

                END IF;

                CLOSE C1;

                                EXCEPTION

                                                                WHEN OTHERS THEN

                                                                FND_MESSAGE.ERROR;

                                RAISE FORM_TRIGGER_FAILURE;

                                END;

 

PROCEDURE XGOD_DESC_PRO(EVENT IN VARCHAR2)

IS

BEGIN

                IF EVENT='PRE-FORM' THEN

                FND_DESCR_FLEX.DEFINE(

                                                BLOCK => 'XXGOD_JOB_CARD',

                                                FIELD => 'DFF1',

                                                APPL_SHORT_NAME => 'PO',

                                                DESC_FLEX_NAME => 'JobCardDFV');

                END IF;

                IF EVENT='WHEN-NEW-FORM-INSTANCE' THEN

                FND_DESCR_FLEX.DEFINE(

                                                BLOCK => 'XXGOD_JOB_CARD',

                                                FIELD => 'DFF1',

                                                APPL_SHORT_NAME => 'PO',

                                                DESC_FLEX_NAME => 'JobCardDFV');

                                               

                FND_DESCR_FLEX.DEFINE(

                                                BLOCK => 'XXGOD_JOB_CARD',

                                                FIELD => 'DFF',

                                                APPL_SHORT_NAME => 'PO',

                                                DESC_FLEX_NAME => 'JobCardDFF1');

                END IF;

 

                EXCEPTION

                                WHEN OTHERS THEN

                                RAISE FORM_TRIGGER_FAILURE;

                END;

END;

Forms Personalization

To Customize a forms for Oracle Apps Environment.




Take the template (base form) from  $AU_TOP (Application Utility Area)
Open the template in Forms6i environment, and rename it.
 Keep the  new form (renamed) in $ AU_TOP/forms/US using FTP.
Compile & generate the form at $ AU_TOP/forms/US using Telnet.
To compile & generate the form , use following command 
 i.      <f60gen module=Form.fmb userid=apps/apps  

Move this fmb file to $ your_top/forms/US
 Launch Oracle Apps Environment 

Log in as Application Developer Responsibility , to register the form ( name of the Form must  match with the  fmb file name)go application ->form
Create a function and assign the form to the function.
Create a menu and assign the function to it
Assign this to main menu.
Create a table and register it
Launch Form Builder (Forms 6i)
Triggers to be Modified on Form Level WHEN-NEW-FORM-INSTANCE (Form Level)
FDRCSID('$Header: C21_FORM.fmb 115.11 2000/05/25 17:27:44 pkm ship                                                                                                                                                                                                                                                                     $');
APP_STANDARD.EVENT('WHEN-NEW-FORM-INSTANCE');
PRE-FORM TRIGGER (FORM LEVEL)
FND_STANDARD.FORM_INFO('$Revision: 115.11$', 'Form_Name', 'Application Short Name','$Date: 2000/05/25 17:20  $', '$Author: appldev $');
app_standard.event('PRE-FORM');
app_window.set_window_position('Window_Name', 'FIRST_WINDOW');
Create a window, canvas and create a block using Wizard . Inherit the property classes as required for different fields.
To add calendar to Date item:

subclass and inherit the  text_item_date  value from thre list

Set the list of value to ‘ENABLE_LIST_LAMP’ (Validate_From_List = No)

Add trigger Key-Listval (CODE- >CALAENDAR.SHOW) To add the calendar to this field.

Set Fire-Enter-Query Mode – NO

Execution Hierarchy – Override.

Event Handler Procedures 

Create Pkg Specification PACKAGE EVNT_HND_PKG IS

  PROCEDURE PRE_UPDATE;

  PROCEDURE PRE_INSERT;

  PROCEDURE PRE_FORM;

END C11_PKG;

  Create Pkg Body PACKAGE BODY EVNT_HND_PKG IS     PROCEDURE PRE_UPDATE IS   BEGIN             FND_STANDARD.SET_WHO;   END PRE_UPDATE;     PROCEDURE PRE_INSERT IS   BEGIN             FND_STANDARD.SET_WHO;   END PRE_INSERT; END; 

Call these Event Handlers at Block Level Using Pre-Insert and Pre-Update triggers

  Block Level Post Query Trigger add following code set_record_property(:system.trigger_record,:system.trigger_block,STATUS,QUERY_STATUS);

 To add DFF (Descriptive Flex Fields) 

Log in as Application Developer Responsibility

Create DFF and assign the Segments

Create a non data base item (NDBItem) and subclass it to text_item_desc_flex

Required -> NO

Set LOV to ‘Enable_List_Lamp’

Validate from List ->No

Create Program Unit 

PROCEDURE  DFF_DESC(EVENT VARCHAR2) IS

BEGIN

  IF (EVENT='WHEN-NEW-FORM-INSTANCE') OR (EVENT='WHEN-VALIDATE-ITEM') THEN

            FND_DESCR_FLEX.DEFINE(BLOCK=>'Block_Name',

                                  FIELD=>'NDBItem',

                                  APPL_SHORT_NAME=>'Application_Short_Name',

                                  DESC_FLEX_NAME=>'DFF_NAME');

  ELSE

            NULL;

  END IF; 

END;


  Call this Program Unit at Form Level using When-New-Form-Instance

       DFF_DESC(When-New-Form-Instance)

At Block Level

FND_FLEX.event('WHEN-NEW-ITEM-INSTANCE'); (Execution Hierarchy- > After)

FND_FLEX.event('WHEN-VALIDATE-ITEM');


  App_Custom Program Unit 

Customize the following code:>

*****if (wnd = 'Window Nmae’') then

    app_window.close_first_window;

  elsif (wnd = '<another window>') then

    --defer relations

    --close related windows  

    null; 

  elsif (wnd = '<yet another window>') then

    --defer relations

    --close related windows  

    null;

  end if; *******************

To set the Window Title 

PROCEDURE Proc_Win_Title (EVENT VARCHAR2) IS

BEGIN

  IF (EVENT = 'WHEN-VALIDATE-ITEM') OR (EVENT='PRE-RECORD')

    THEN   APP_WINDOW.SET_TITLE('C17_CHN_REP_W','',:C17_CHN_REP_B.CHN_REP_CODE);

  END IF;     END;


To Call Proc_Win_Title  Procedure use following trigger at Block Level

            Pre-Record

 To add Query window 

Open APPSTAND Form , Copy it from $AU_TOP.

Copy QUERY_FIND Object Group from APPSTAND Object Group to Forms Object Group Library .

It will copy it at 4 places , Canvas,Window,Block and Object group level,

Delete it from Object group library.

Rename Canvas_Q,Window_Q and Block_Q.

Set Previous navigation_Block  property of  Block_Q. as Std_Block (Main Block’)
Add one text field in Query Block
Required No, Database No,Intial Value => Null;
 Add  KEY-NEXTBLK  at Block Level

:parameter.G_query_find := 'TRUE';

app_find.find('Std_Block');

:parameter.G_query_find := 'FALSE';
Create Triggers Pre-Query & QUERY_FIND (User Defined) at Std_Block
At Pre-Query
BEGIN

if :parameter.G_query_find = 'TRUE' THEN

            COPY(:C11_QUERY_FIND_BLK.qf_chn_rep_code,'C11_CHN_REP.chn_rep_code');

            -- we can add more fields here which is there in the query find block

                        :parameter.G_query_find := 'FALSE';

            end if;

END;
At QUERY_FIND
/* RESULT WINDOW, QUERY WINDOW, QUERY BLK */

app_find.query_find('Std_Window','Window_Q','Block_Q');
To add Special Menu 

Write in Pre-Form trigger at Form Level app_special.instantiate('SPECIAL1','&LaunchWF','bkord');
At Block Level Pre-Block app_special.instantiate('SPECIAL1','&LaunchWF','bkord');

 Create a User Defined Trigger ‘SPECIAL1’  at Block Level
fnd_message.set_string('This is for launching the workflow');

fnd_message.show;
Note - Using SPECIAL1 Trigger we can launch any concurrent request.

To populate a hidden menu item

Register a function as subfunction , add it to them menu without Prompt.

Modify the form logic at Pre-Form Program Unit
PROCEDURE PRE_FORM IS
BEGIN

 if fnd_function.test(‘New Registered Function ') then

            fnd_message.set_string('Inside Pre-Form to check special1-TRUE');

            fnd_message.show;

            app_special.instantiate('SPECIAL1','&Run TEST','DLRPT');

            app_special.enable('SPECIAL',PROPERTY_ON);

  else

            fnd_message.set_string('Inside Pre-Form to check special1-NOT TRUE');

            fnd_message.show;

            fnd_message.debug('The special function is not available');

            null;

  end if;

end PRE_FORM;
Call it at Pre-Form Trigger 


To add Zoom (Using Custom Library) 

To call a from Your Form
Open Customm.pll in Form Builder , get it from $AU_TOP/resources and put it into the D2K/Form60.
Modify Procedure ‘EVENT’  in  Custom,pll 

Change the Procedure  named ZOOM AVAILABLE , Return ‘TRUE’

Save and close PLL ,

Transfer it to $AU_TOP/forms/US

Generate PLX file using f60gen module_type=library module=custom userid=apps/apps

Transfer the PLX at $AU_TOP/resources