Wednesday, 28 December 2011

How to delete a DFF Context

How to delete a DFF Context


Sometime I'm quite annoyed by the typo mistake when creating a DFF context. The DFF segment screen doesn't allow deletion of context. Fortunately, Oracle has internal API to do such thing. Following is a sample.

--*******************************************
--* Delete a descriptive flexfield
--*******************************************
SET ECHO OFF
SET FEEDBACK OFF
SET SERVEROUTPUT ON SIZE 1000000
DECLARE
  l_application_id                NUMBER := 0;
  l_descriptive_flexfield_name    VARCHAR2(100) :=  'FND_COMMON_LOOKUPS' ;
  l_descriptive_flex_context_cod  VARCHAR2(100) :=  'XFND_CLWW_PURGE_FOLDER';
BEGIN
  --FND_DESCRIPTIVE_FLEXS_PKG --this package is for DFF
  --FND_DESCR_FLEX_CONTEXTS_PKG --this package is for DFF Context
  --FND_DESCR_FLEX_COL_USAGE_PKG --this package is for DFF Column useage
  --When creating a new DFF Context, it will check the DFF Column usage if the context is already used.
  --so when deleting a DFF Context, both the context and column usage should be deleted.
  FOR c IN (SELECT application_column_name
              FROM fnd_descr_flex_column_usages
             WHERE application_id = l_application_id
               AND descriptive_flexfield_name = l_descriptive_flexfield_name
               AND descriptive_flex_context_code = l_descriptive_flex_context_cod)
  LOOP
 
    fnd_descr_flex_col_usage_pkg.delete_row(
         x_application_id                => l_application_id
        ,x_descriptive_flexfield_name    => l_descriptive_flexfield_name
        ,x_descriptive_flex_context_cod  => l_descriptive_flex_context_cod
        ,x_application_column_name       => c.application_column_name
        );
  END LOOP;

  fnd_descr_flex_contexts_pkg.delete_row(
         x_application_id                => l_application_id,
        ,x_descriptive_flexfield_name    => l_descriptive_flexfield_name
        ,x_descriptive_flex_context_cod  => l_descriptive_flex_context_cod
         );
 
  --commit;
end;



--


2 comments:

Pavan Kotharu said...

Hi Prasanth,

I have gone through your post for deleting a context_name but this approach is not supported by oracle and it might fail in some scenarios which might cause the DFF to stop working properly.

Below is the API we need to use to delete a context name.

FND_FLEX_DSC_API.CREATE_CONTEXT

Thanks
Pavan Kotharu

Pavan Kotharu said...

Sorry, the above method was to create the context name. Below is what we need to use to delete the context name.

FND_FLEX_DSC_API.DELETE_CONTEXT

Thanks
--Pavan Kotharu