Thursday, November 1, 2012

How to derive code_combination_id(CCID) programatically using fnd_flex_ext.get_combination_id

/*-----------------------------------------------------------------------------*/
/*  Function: xx_get_ccid_fnc                                                         */
/* Combination_id output may be NULL if combination is invalid.        */
/* @param application_short_name Application Short Name             */
/* @param key_flex_code Key Flexfield Code                                  */
/* @param structure_number Structure number                             */
/* @param validation_date Validation date                                     */
/* @param n_segments Number of segments                                */
/* @param segments Segment array                                            */
/* @param combination_id Code Combination Id                           */
/* @param data_set Data set number                                          */
/* @return Returns TRUE if combination is valid, FALSE otherwise. */
/*---------------------------------------------------------------------------*/

FUNCTION xx_get_comb_id (p_coa_id        IN NUMBER,
                         p_company       IN VARCHAR2,
                         p_cost_center   IN VARCHAR2,
                         p_account       IN VARCHAR2,
                         p_interco       IN VARCHAR2,
                         p_future        IN VARCHAR2)
   RETURN NUMBER
IS
   l_appl_shrt_name    VARCHAR2 (80) := 'SQLGL';
   l_key_flx_cd        VARCHAR2 (80) := 'GL#';
   l_validation_date   DATE := SYSDATE;
   l_seg_size          NUMBER := 5;
   l_segments          fnd_flex_ext.segmentarray;
   l_combination_id    NUMBER;
   l_data_set          NUMBER := NULL;
   l_account_flag      BOOLEAN;
BEGIN
   l_segments (1) := p_company;
   l_segments (2) := p_cost_center;
   l_segments (3) := p_account;
   l_segments (4) := p_interco;
   l_segments (5) := p_future;

   l_account_flag :=   fnd_flex_ext.get_combination_id (
                                                                    application_short_name   => l_appl_shrt_name,
                                                                    key_flex_code                 => l_key_flx_cd,
                                                                    structure_number            => p_coa_id,
                                                                    validation_date                => l_validation_date,
                                                                    n_segments                    => l_seg_size,
                                                                    segments                        => segments,
                                                                    combination_id                => l_combination_id,
                                                                    data_set                         => l_data_set);

   DBMS_OUTPUT.put_line ('combination_id = ' || l_combination_id);

   IF l_account_flag
   THEN
      DBMS_OUTPUT.put_line ('l_account_flag = true');
   ELSE
      DBMS_OUTPUT.put_line ('l_account_flag = false');
   END IF;

   RETURN l_combination_id;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Error in xx_get_comb_id=>' || SQLERRM);
      RETURN NULL;
END xx_get_comb_id;

No comments:

Post a Comment