Translate

Tuesday, May 28, 2019

Create Bulk GL Code Combinations Using API


DECLARE

CURSOR c1
   IS
   SELECT  a.rowid row_id,a.*
FROM    temp_gl_code a
WHERE   process_flag= 'N';
   
     
  l_segment1                 GL_CODE_COMBINATIONS.SEGMENT1%TYPE;
  l_segment2                 GL_CODE_COMBINATIONS.SEGMENT2%TYPE;
  l_segment3                 GL_CODE_COMBINATIONS.SEGMENT3%TYPE;
  l_segment4                 GL_CODE_COMBINATIONS.SEGMENT4%TYPE;
  l_segment5                 GL_CODE_COMBINATIONS.SEGMENT5%TYPE;
  l_segment6                 GL_CODE_COMBINATIONS.SEGMENT6%TYPE;
  l_valid_combination        BOOLEAN;
  l_cr_combination           BOOLEAN;
  l_ccid                     GL_CODE_COMBINATIONS_KFV.code_combination_id%TYPE;
  l_structure_num            FND_ID_FLEX_STRUCTURES.ID_FLEX_NUM%TYPE;
  l_conc_segs                GL_CODE_COMBINATIONS_KFV.CONCATENATED_SEGMENTS%TYPE;
  p_error_msg1               VARCHAR2(240);
  p_error_msg2               VARCHAR2(240);
  v_error_flag               BOOLEAN;
  v_error_msg                VARCHAR2(3000) :=NULL;
  v_count1                   NUMBER;
 v_count2                    NUMBER;
 v_row_count                 NUMBER := 0;
 v_req_message               VARCHAR2(3000);
 v_req_id                    NUMBER;
 v_req_status                BOOLEAN;
 v_rphase                    VARCHAR2(20);
 v_rstatus                   VARCHAR2(20);
 v_dphase                    VARCHAR2(20);
 v_dstatus                   VARCHAR2(20);
  -- ----------------------
--START OF VALIDATION
-- ----------------------
BEGIN

 FOR i in c1

   LOOP
     v_error_flag := FALSE;
     v_error_msg := NULL;
 
  l_segment1  := i.segment1;
  l_segment2  := i.segment2;
  l_segment3  := i.segment3;
  l_segment4  := i.segment4;
  l_segment5  := i.segment5;
  l_segment6  := i.segment6;
  l_conc_segs := l_segment1||'.'||l_segment2||'.'||l_segment3||'.'||l_segment4||'.'||l_segment5||'.'||l_segment6 ;



  BEGIN
    SELECT
    id_flex_num
      INTO l_structure_num
      FROM apps.fnd_id_flex_structures
     WHERE id_flex_code        = 'GL#'
       AND id_flex_structure_code='COVAD_ACCOUNTING_FLEXFIELD';
  EXCEPTION
  WHEN OTHERS THEN
    l_structure_num:=NULL;
  END;

  ---------------Check if CCID exits with the above Concatenated Segments---------------
  BEGIN
    SELECT code_combination_id
      INTO l_ccid
      FROM apps.gl_code_combinations_kfv
     WHERE concatenated_segments = l_conc_segs;
  EXCEPTION
  WHEN OTHERS THEN
    l_ccid         :=NULL;
  END;
 
    -- -------------------------------------------------------------------------------
-- UPDATING THE PROCESS FLAG FOR ERRORS IN temp_gl_code TABLE
-- -------------------------------------------------------------------------------
    IF l_ccid IS NOT NULL THEN
    ------------------------The CCID is Available----------------------
    --DBMS_OUTPUT.PUT_LINE('COMBINATION_ID= ' ||l_ccid);
    v_error_msg := v_error_msg ||'Combination already Exists '|| '; ' ;
 
        UPDATE  temp_gl_code
        SET process_flag                = 'E'
        ,errror_message                 = 'Validation Error:'||v_error_msg
        ,last_update_date               = SYSDATE
        WHERE rowid                     = i.row_id
        AND process_flag                = 'N' ;
COMMIT;
    ELSE
 
DBMS_OUTPUT.PUT_LINE('This is a New Combination. Validation Starts....');
    ------------Validate the New Combination--------------------------
    l_valid_combination := APPS.FND_FLEX_KEYVAL.VALIDATE_SEGS
                          (
                          operation => 'CHECK_COMBINATION',
                          appl_short_name => 'SQLGL',
                          key_flex_code => 'GL#',
                          structure_number => L_STRUCTURE_NUM,
                          concat_segments => L_CONC_SEGS
                          );
    p_error_msg1 := FND_FLEX_KEYVAL.ERROR_MESSAGE;
 
    BEGIN
        UPDATE  temp_gl_code
        SET process_flag                = 'E'
        ,errror_message                  = FND_FLEX_KEYVAL.ERROR_MESSAGE
        ,last_update_date               = SYSDATE
        WHERE rowid                     = i.row_id
        AND process_flag                = 'N' ;
COMMIT;
    END;

    IF l_valid_combination then

      DBMS_OUTPUT.PUT_LINE('Validation Successful! Creating the Combination...');
      -------------------Create the New CCID--------------------------

      L_CR_COMBINATION := APPS.FND_FLEX_KEYVAL.VALIDATE_SEGS
                          (
                          operation => 'CREATE_COMBINATION',
                          appl_short_name => 'SQLGL',
                          key_flex_code => 'GL#',
                          structure_number => L_STRUCTURE_NUM,
                          concat_segments => L_CONC_SEGS );
       
          p_error_msg2 := FND_FLEX_KEYVAL.ERROR_MESSAGE;
       
       
   IF l_cr_combination THEN
        -------------------Fetch the New CCID--------------------------
        SELECT code_combination_id
          INTO l_ccid
          FROM apps.gl_code_combinations_kfv
        WHERE concatenated_segments = l_conc_segs;
     
        UPDATE  temp_gl_code
        SET process_flag                = 'S'
        ,errror_message                  = 'Import Success='|| l_ccid
        ,last_update_date               = SYSDATE
        WHERE rowid                     = i.row_id
        AND process_flag                = 'E' ;
    COMMIT;
    ELSE
        -------------Error in creating a combination-----------------
        DBMS_OUTPUT.PUT_LINE('Error in creating the combination: '||p_error_msg2);
      END IF;
    ELSE
      --------The segments in the account string are not defined in gl value set----------
      DBMS_OUTPUT.PUT_LINE('Error in validating the combination: '||p_error_msg1);
    END IF;
  END IF;
  END LOOP;
EXCEPTION
WHEN OTHERS THEN
  DBMS_OUTPUT.PUT_LINE(SQLCODE||' '||SQLERRM);
END;

Drill Down Query From GL into Project Accounting subledger

The below query will  provide the complete breakup of posted Journals with transaction distribution wise breakup details of Project Accounting sub-ledger modules.

SELECT      GLCC.concatenated_segments segments
                    ,GJL.period_name
                    ,GJH.name journal_name
                    ,GJB.name batch_name
                    ,GJH.je_source journal_source
                    ,GJH.je_category journal_category
                    ,GLCC.segment1 entity_segment
                    ,GLCC.segment2 project_segment
                    ,FFV.attribute1 project_vertical_dff
                    ,GLCC.segment3
                    ,GLCC.segment4
                    ,GLCC.segment5
                    ,GLCC.segment6
                    ,GLCC.segment7
                    ,TO_CHAR (GJH.doc_sequence_value) gl_doc_no
                    ,TO_CHAR (GJH.default_effective_date, 'DD-MON-YYYY') gl_date
                    ,TO_CHAR (GJH.posted_date, 'DD-MON-YYYY') posted_date
                    ,PE.expenditure_group document_number
                    ,PE.expenditure_group document_description
                    ,TO_CHAR (PEI.expenditure_item_date, 'DD-MON-YYYY')  document_date
--                  ,PPA.project_status_code document_status     
                    ,PPA.segment1 project_code 
                    ,PT.task_number task_code        
                    ,PEI.expenditure_type  
                    ,PEI.raw_cost transaction_cur_amount
                    ,PPA.project_currency_code entered_currency_code
                    ,PPA.project_rate_type exchange_rate_type
                    ,PEI.project_exchange_rate exchange_rat
   FROM       gl_je_batches GJB
                    ,gl_je_headers GJH
                    ,gl_je_lines   GJL
                    ,gl_code_combinations_kfv GLCC
                    ,gl_import_references GIR
                    ,xla_ae_headers  XAH
                    ,xla_ae_lines    XAL
                    ,xla_events      XE
                    ,xla_distribution_links XDL
                    ,pa_cost_distribution_lines_all PDL
                    ,pa_expenditure_items_all PEI
                    ,pa_expenditures_all PE
                    ,pa_tasks PT
                    ,pa_projects_all PPA
                    ,fnd_flex_value_sets FVS
                    ,fnd_flex_values FFV
         WHERE  GJB.je_batch_id         = GJH.je_batch_id          
         AND    GJH.je_header_id        = GJL.je_header_id
         AND    GJL.code_combination_id = GLCC.code_combination_id
         AND    GJL.je_header_id        = GIR.je_header_id
         AND    GJH.je_batch_id         = GIR.je_batch_id
         AND    GJL.je_line_num         = GIR.je_line_num
         AND    GIR.gl_sl_link_id       = XAL.gl_sl_link_id
         AND    GIR.gl_sl_link_table    = XAL.gl_sl_link_table
         AND    XAH.ae_header_id        = XAL.ae_header_id
         AND    XAH.application_id      = XAL.application_id
         AND    XAH.event_id            = XE.event_id
         AND    XAL.ae_header_id        = XDL.ae_header_id
         AND    XAL.ae_line_num         = XDL.ae_line_num
         AND    XDL.source_distribution_id_num_1 = PDL.expenditure_item_id 
         AND    PDL.expenditure_item_id  = PEI.expenditure_item_id
         AND    PEI.expenditure_id       = PE.expenditure_id
         AND    PEI.task_id              = PT.task_id
         AND    PT.project_id            = PPA.project_id
         AND    FFV.flex_value_set_id    = FVS.flex_value_set_id(+)
         AND    GLCC.segment2            = FFV.flex_value(+) 
         AND UPPER (FVS.flex_value_set_name) = UPPER ('PLL_Project')
    --  AND    XAH.entity_id        = XTE.entity_id
    --  AND xte.application_id = 275
        AND    GJH.je_source               = 'Project Accounting'
        AND    GJH.je_category             = 'Miscellaneous Transaction'
        AND    GJH.status                  = 'P' 
        AND    GJH.default_effective_date >= lc_gl_date_from
        AND    GJH.default_effective_date <= lc_gl_date_to
        AND    TRUNC (GJH.posted_date) BETWEEN NVL (lc_gl_posted_from,TRUNC (GJH.posted_date))AND NVL (lc_gl_posted_to ,TRUNC (GJH.posted_date))
        AND    GJH.je_source               = NVL (p_gl_source, GJH.je_source)
        AND    GJH.je_category             = NVL (p_gl_category, GJH.je_category)
        --        AND    GLCC.concatenated_segments BETWEEN (p_account_from) AND (p_account_to)
        AND    GLCC.segment1 BETWEEN  lc_segment_from(1) AND  lc_segment_to(1)
        AND    GLCC.segment2 BETWEEN  lc_segment_from(2) AND  lc_segment_to(2)
        AND    GLCC.segment3 BETWEEN  lc_segment_from(3) AND  lc_segment_to(3)
        AND    GLCC.segment4 BETWEEN  lc_segment_from(4) AND  lc_segment_to(4)
        AND    GLCC.segment5 BETWEEN  lc_segment_from(5) AND  lc_segment_to(5)
        AND    GLCC.segment6 BETWEEN  lc_segment_from(6) AND  lc_segment_to(6)
        AND    GLCC.segment7 BETWEEN  lc_segment_from(7) AND  lc_segment_to(7)

        AND    NVL (FFV.attribute1, '-1')      = NVL (p_proj_vertical_dff, NVL (FFV.attribute1, '-1'))

GL DRILL Down Query From GL into Fixed Assets Sub ledger Module

The below query will  provide the complete breakup of posted Journals with transaction distribution wise breakup details of Fixed assets(all sources) sub-ledger modules.

SELECT  GCC.concatenated_segments segments,
               GJL.period_name,
               GJH.NAME journal_name,
               GJB.NAME batch_name,
               GJH.je_source journal_source,
               GJH.je_category journal_category,
               GCC.segment1 entity_segment,
               GCC.segment2 project_segment,
               FFV.attribute1 project_vertical_dff,
               GCC.segment3,
               GCC.segment4,
               GCC.segment5,
               GCC.segment6,
               GCC.segment7,
               TO_CHAR (GJH.doc_sequence_value) gl_doc_no,
               TO_CHAR (GJH.default_effective_date, 'DD-MON-YYYY') gl_date,
               TO_CHAR (GJH.posted_date, 'DD-MON-YYYY') posted_date,
               NULL sla_event_class,
               XAH.event_type_code sla_event_type,
               TO_CHAR (FTH.asset_id) document_number,
               FT.description document_description,
               TO_CHAR (FB.date_placed_in_service, 'DD-MON-YYYY') document_date,
       NVL ((XAL.unrounded_entered_cr) * -1,XAL.unrounded_entered_dr) transaction_cur_amount,
               GL.currency_code entered_currency_code,
  NVL((XAL.unrounded_accounted_cr)*-1,XAL.unrounded_accounted_dr) functional_currency_amount
  FROM   xla_ae_lines XAL,
               xla_ae_headers XAH,
               xla.xla_transaction_entities XTE,
               gl_je_headers GJH,
               gl_je_lines GJL,
               gl_je_batches GJB,
               gl_import_references GIR,
               gl_je_categories GJC,
               gl_ledgers GL,
               gl_code_combinations_kfv GCC,
               fa_additions_tl FT,
               fa_books FB,
               fa_transaction_headers FTH,
               fnd_flex_value_sets FVS,
               fnd_flex_values FFV
 WHERE         1 = 1
   AND         GJL.je_header_id                     = GJH.je_header_id
   AND         GJC.je_category_name            = GJH.je_category
   AND         GCC.code_combination_id         = GJL.code_combination_id
   AND         GIR.je_header_id                     = GJH.je_header_id
   AND         XAL.gl_sl_link_id                      = GIR.gl_sl_link_id
   AND         GIR.je_line_num                       = GJL.je_line_num
   AND         GJB.je_batch_id                       = GJH.je_batch_id
   AND         XAH.ae_header_id                   = XAL.ae_header_id
   AND         XTE.entity_id                            = XAH.entity_id
   AND         FB.date_ineffective  IS NULL
   AND         GJH.actual_flag                        = 'A'
   AND         GJH.status                                = 'P'
   AND         GJH.je_source                          = 'Assets'
   AND         GJC.user_je_category_name  IN   ('Transfer', 'Reclass')
   AND         GJH.je_source                         <> 'Consolidation'
   AND         FT.asset_id                                = FTH.asset_id
   AND         FT.asset_id                                =  FB.asset_id
   AND         XTE.source_id_int_1(+)            = FTH.transaction_header_id
   AND         FB.book_type_code                  = FTH.book_type_code
   AND         GJH.ledger_id                           = GL.ledger_id
   AND         FFV.flex_value_set_id               = FVS.flex_value_set_id(+)
   AND         GCC.segment2                          = FFV.flex_value(+)
   AND         UPPER (FVS.flex_value_set_name) = UPPER ('PLL_Project')
   AND         GJH.default_effective_date     >= lc_gl_date_from
   AND         GJH.default_effective_date     <= lc_gl_date_to
 AND TRUNC (gjh.posted_date) BETWEEN NVL (lc_gl_posted_from,TRUNC (gjh.posted_date))AND NVL (lc_gl_posted_to,TRUNC (gjh.posted_date))
   AND          GJH.je_source                  = NVL (p_gl_source, GJH.je_source)
   AND          GJH.je_category                = NVL (p_gl_category, GJH.je_category)
   AND      gcc.concatenated_segments BETWEEN (p_account_from) AND (p_account_to)
   AND          GCC.segment1 BETWEEN lc_segment_from(1) AND lc_segment_to(1)
   AND          GCC.segment2 BETWEEN lc_segment_from(2) AND lc_segment_to(2)
   AND          GCC.segment3 BETWEEN lc_segment_from(3) AND lc_segment_to(3)
   AND          GCC.segment4 BETWEEN lc_segment_from(4) AND lc_segment_to(4)
   AND          GCC.segment5 BETWEEN lc_segment_from(5) AND lc_segment_to(5)
   AND          GCC.segment6 BETWEEN lc_segment_from(6) AND lc_segment_to(6)
   ---AND          GCC.segment7 BETWEEN lc_segment_from(7) AND lc_segment_to(7)
   --AND          NVL (FFV.attribute1, '-1')      = NVL (:p_proj_vertical_dff, NVL (FFV.attribute1, '-1'))
UNION ALL
SELECT         GCC.concatenated_segments segments,
               GJL.period_name,
               GJH.NAME journal_name,
               GJB.NAME batch_name,
               GJH.je_source journal_source,
               GJH.je_category journal_category,
               GCC.segment1 entity_segment,
               GCC.segment2 project_segment,
               FFV.attribute1 project_vertical_dff,
               GCC.segment3,
               GCC.segment4,
               GCC.segment5,
               GCC.segment6,
               GCC.segment7,
               TO_CHAR (GJH.doc_sequence_value) gl_doc_no,
               TO_CHAR (GJH.default_effective_date, 'DD-MON-YYYY') gl_date,
               TO_CHAR (GJH.posted_date, 'DD-MON-YYYY') posted_date,
               NULL sla_event_class,
               XAH.event_type_code sla_event_type,
               TO_CHAR (FTH.asset_id) document_number,
               FT.description document_description,
               TO_CHAR (FB.date_placed_in_service, 'DD-MON-YYYY') document_date,
        NVL ((XAL.unrounded_entered_cr) * -1,XAL.unrounded_entered_dr) transaction_cur_amount,
               GL.currency_code entered_currency_code,
               NVL ((XAL.unrounded_accounted_cr) * -1,XAL.unrounded_accounted_dr) functional_currency_amount
  FROM         xla_ae_lines XAL,
               xla_ae_headers XAH,
               xla.xla_transaction_entities XTE,
               gl_je_headers GJH,
               gl_je_lines GJL,
               gl_je_batches GJB,
               gl_import_references GIR,
               gl_je_categories GJC,
               gl_ledgers GL,
               gl_code_combinations_kfv GCC,
               fa_additions_tl FT,
               fa_books FB,
               fa_transaction_headers FTH,
               fnd_flex_value_sets FVS,
               fnd_flex_values FFV
 WHERE         1 = 1
   AND         GJL.je_header_id                           = GJH.je_header_id
   AND         GJC.je_category_name                  = GJH.je_category
   AND         GCC.code_combination_id             = GJL.code_combination_id
   AND         GIR.je_header_id                           = GJH.je_header_id
   AND         XAL.gl_sl_link_id                            = GIR.gl_sl_link_id
   AND         GIR.je_line_num                            = GJL.je_line_num
   AND         GJB.je_batch_id                            = GJH.je_batch_id
   AND         XAH.ae_header_id                        = XAL.ae_header_id
   AND         XTE.entity_id                                 = XAH.entity_id
   AND         GJH.ledger_id                                = GL.ledger_id
   AND         GJH.actual_flag                             = 'A'
   AND         GJH.status                                     = 'P'
   AND         GJH.je_source                               = 'Assets'
   AND         FB.date_ineffective    IS NULL
   AND         GJC.user_je_category_name    IN('Addition', 'CIP Addition', 'Adjustment', 'CIP Adjustment','Retirement','CIP Retirement')
   AND         GJH.je_source                              <> 'Consolidation'
   AND         FT.asset_id                                      = FTH.asset_id
   AND         FT.asset_id                                      = FB.asset_id
   AND         XTE.source_id_int_1(+)                   = FTH.transaction_header_id
   AND         FB.book_type_code                         = FTH.book_type_code
   AND         GJH.default_effective_date            >= lc_gl_date_from
   AND         GJH.default_effective_date            <= lc_gl_date_to
   AND         FFV.flex_value_set_id                      = FVS.flex_value_set_id(+)
   AND         GCC.segment2                                 = FFV.flex_value(+)
   AND         UPPER (FVS.flex_value_set_name) = UPPER ('PLL_Project')
   AND         TRUNC (GJH.posted_date) BETWEEN NVL (lc_gl_posted_from,TRUNC (GJH.posted_date))AND NVL (lc_gl_posted_to,TRUNC (GJH.posted_date))
   AND          GJH.je_source                  = NVL (p_gl_source, GJH.je_source)
   AND          GJH.je_category                = NVL (p_gl_category, GJH.je_category)
--   AND      gcc.concatenated_segments BETWEEN (p_account_from) AND (p_account_to)
   AND          GCC.segment1 BETWEEN lc_segment_from(1) AND lc_segment_to(1)
   AND          GCC.segment2 BETWEEN lc_segment_from(2) AND lc_segment_to(2)
   AND          GCC.segment3 BETWEEN lc_segment_from(3) AND lc_segment_to(3)
   AND          GCC.segment4 BETWEEN lc_segment_from(4) AND lc_segment_to(4)
   AND          GCC.segment5 BETWEEN lc_segment_from(5) AND lc_segment_to(5)
   AND          GCC.segment6 BETWEEN lc_segment_from(6) AND lc_segment_to(6)
   AND          GCC.segment7 BETWEEN lc_segment_from(7) AND lc_segment_to(7)
  --- AND          NVL (FFV.attribute1, '-1')      = NVL (:p_proj_vertical_dff, NVL (FFV.attribute1, '-1'))
   UNION ALL
   SELECT            GLCC.concatenated_segments segments
                    ,GJL.period_name
                    ,GJH.name journal_name
                    ,GJB.name batch_name
                    ,GJH.je_source journal_source
                    ,GJH.je_category journal_category
                    ,GLCC.segment1 entity_segment
                    ,GLCC.segment2 project_segment
                    ,FFV.attribute1 project_vertical_dff
                    ,GLCC.segment3
                    ,GLCC.segment4
                    ,GLCC.segment5
                    ,GLCC.segment6
                    ,GLCC.segment7
                    ,TO_CHAR (GJH.doc_sequence_value) gl_doc_no
                    ,TO_CHAR (GJH.default_effective_date, 'DD-MON-YYYY') gl_date
                    ,TO_CHAR (GJH.posted_date, 'DD-MON-YYYY') posted_date
                    ,(SELECT NAME
                             FROM xla_event_classes_tl XECT
                            WHERE XECT.event_class_code = XDL.event_class_code
                              AND XECT.application_id = XDL.application_id) sla_event_class
                    ,XAH.event_type_code sla_event_type
                    ,TO_CHAR(FDS.asset_id) document_number
                    ,FAD.description document_description
                    ,TO_CHAR (FB.date_placed_in_service, 'DD-MON-YYYY') document_date
                    ,NVL((XDL.unrounded_accounted_cr)*-1,(XDL.unrounded_accounted_dr)) transaction_cur_amount
                    ,GL.currency_code entered_currency_code
                    ,NVL((XDL.unrounded_accounted_cr)*-1,(XDL.unrounded_accounted_dr)) functional_currency_amount
  FROM         fa_additions FAD
                    ,fa_books FB
                    ,fa_book_controls FBC
                    ,fa_deprn_summary FDS
                    ,xla_distribution_links XDL
                    ,xla_ae_lines XAL
                    ,xla_ae_headers XAH
                    ,gl_import_references GIR
                    ,gl_je_lines GJL
                    ,gl_je_headers GJH
                    ,gl_je_batches GJB
                    ,gl_code_combinations_kfv GLCC
                    ,gl_ledgers GL
                    ,fnd_flex_value_sets FVS
                    ,fnd_flex_values FFV
 WHERE      1=1
   AND      FAD.asset_id                             = FB.asset_id
   AND      FB.book_type_code                  = FBC.book_type_code
   AND      FB.DATE_INEFFECTIVE IS NULL
   AND      FAD.asset_id                             = FDS.asset_id
   AND      FB.book_type_code                  =  FDS.book_type_code
   AND      FBC.book_type_code               = FDS.book_type_code
   AND      fds.deprn_source_code            ='DEPRN'
   AND      FDS.asset_id                            = XDL.source_distribution_id_num_1
   AND      FB.book_type_code                 = XDL.source_distribution_id_char_4
   AND      FBC.set_of_books_id               = GL.ledger_id
   AND      XDL.ae_header_id                   = XAL.ae_header_id
   AND      XDL.ae_line_num                    = XAL.ae_line_num
   AND      XAL.ae_header_id                   = XAH.ae_header_id
   AND      XAH.application_id                  = XAL.application_id
   AND      XAL.gl_sl_link_id                      = GIR.gl_sl_link_id
   AND      XAL.gl_sl_link_table                 = GIR.gl_sl_link_table
   AND      GIR.je_line_num                      = GJL.je_line_num
   AND      GIR.je_header_id                    = GJL.je_header_id
   AND      GIR.je_header_id                    = GJH.je_header_id
   AND      GJH.je_batch_id                      = GJB.je_batch_id
   AND      GJL.code_combination_id       = GLCC.code_combination_id
   AND      GJH.status                               = 'P'
-- and UPPER(XDL.rounding_class_code) ='ASSET'
   AND      UPPER(FDS.deprn_source_code) IN ('BOOKS','DEPRN')
   AND      UPPER (GJH.je_source)                  = 'ASSETS'
   AND      UPPER (GJH.je_category)               = 'DEPRECIATION'
   AND      FFV.flex_value_set_id                      = FVS.flex_value_set_id(+)
   AND      GLCC.segment2                               = FFV.flex_value(+)
   AND      UPPER (FVS.flex_value_set_name) = UPPER ('PLL_Project')
   AND      GJH.default_effective_date     >= lc_gl_date_from
   AND      GJH.default_effective_date     <= lc_gl_date_to
   AND      TRUNC (GJH.posted_date) BETWEEN NVL (lc_gl_posted_from,TRUNC (GJH.posted_date))AND NVL (lc_gl_posted_to,TRUNC (GJH.posted_date))
   AND      GJH.je_source                   = NVL (p_gl_source, GJH.je_source)
   AND      GJH.je_category                 = NVL (p_gl_category, GJH.je_category)
   AND      GLCC.segment1 BETWEEN lc_segment_from(1) AND lc_segment_to(1)
   AND      GLCC.segment2 BETWEEN lc_segment_from(2) AND lc_segment_to(2)
   AND      GLCC.segment3 BETWEEN lc_segment_from(3) AND lc_segment_to(3)
   AND      GLCC.segment4 BETWEEN lc_segment_from(4) AND lc_segment_to(4)
   AND      GLCC.segment5 BETWEEN lc_segment_from(5) AND lc_segment_to(5)
   AND      GLCC.segment6 BETWEEN lc_segment_from(6) AND lc_segment_to(6)
   AND      GLCC.segment7 BETWEEN lc_segment_from(7) AND lc_segment_to(7)
   ---AND      NVL (FFV.attribute1, '-1')      = NVL (:p_proj_vertical_dff, NVL (FFV.attribute1, '-1'))

Discrete Jobs End to End Cycle with Cost Roll-up in Standard Cost Organization in R12.2


STEP 1: CREATE ITEMS
Responsibility: Inventory Navigation: Items > Master Items
Select the Organization as "M1 - Seattle Manufacturing"
Create the below items;
Item
Item Template (Type)
DYS_CAR
Finished Goods
DYS_ENGINE
Purchased Item
DYS_CHASIS
Purchased Item
DYS_WHEEL
Purchased Item
DYS_SEAT
Purchased Item

Item : DYS_CAR Template/Type: Finished Goods

Item : DYS_ENGINE Template/Type: Purchased Item

Item : DYS_CHASIS Template/Type: Purchased Item
Item : DYS_WHEEL Template/Type: Purchased Item

Item : DYS_SEAT Template/Type: Purchased Item

STEP 2: DEFINE ITEM COST
Define the Item Costs like below;
Item
Item Template (Type)
Item Cost (USD)
DYS_CAR
Finished Goods

DYS_ENGINE
Purchased Item
500
DYS_CHASIS
Purchased Item
300
DYS_WHEEL
Purchased Item
100
DYS_SEAT
Purchased Item
50

Responsibility: Inventory Navigation: Costs > Item Costs
Click on "New"
Item: DYS_ENGINE Cost Type: Pending
Click on "Open"
Click on "Costs"
Cost Element / Sub-Element: Material Unit Cost: 500 USD
Save
Query the Item "DYS_ENGINE"
Can see two records for this item. One record will be in "Frozen" Cost Type and the another one will be in "Pending" Cost Type. Currently "Frozen" cost type will show only zero (0) cost. Once we run the "Update Standard Costs" then the cost will be updated in Frozen type from Pending cost.
Note: M1 - "Seattle Manufacturing" is a Standard Costing Organization. So, we need to enter the cost in "Pending" cost type.
Likewise we can enter the Item Cost for remaining items
Item: DYS_CHASIS Unit Cost: 300 USD
Item: DYS_WHEEL Unit Cost: 100 USD
Item: DYS_SEAT Unit Cost: 50 USD

STEP 3: DEFINE RESOURCES
Define the Resources like below;
Resources Name
Resource Type
Rate
UOM
DYS_ASMLY
Machine
100
HR
DYS_LBR
Person
50
HR
DYS_PNTR
Person
25
HR

Responsibility: Bills Of Material Navigation: Routing > Resources
Select the Organization as "M1 - Seattle Manufacturing"
Enter the Resource Name, Resource Type, Charge Type and enable the "Costed" & "Standard Rate" check box and enter the Absorption Account and Variance Account.
Click on "Rates"
Likewise create the remaining Resources and enter the Resource Rates.
Resource Name: DYS_LBR Type: Person Rate: 50 USD
Resource Name: DYS_PNTR Type: Person Rate: 25 USD
STEP 4: DEFINE DEPARTMENTS
Create the new Departments and assign the Resources to each Departments like below;
Department Name
Resources
DYS_ASMLY
DYS_ASMLY
DYS_LBR
DYS_PAINT
DYS_PNTR

Responsibility: Bills Of Material Navigation: Routing > Departments
Select the Organization as "M1 - Seattle Manufacturing"
Click on "Resources"
Create the another department for Painting and assign the resource.
Department Name: DYS_PAINT Resources: DYS_PNTR

Click on "Resources" and assign the Resource
Note: For this case, only Machine Resource (DYS_ASMLY) is available for 24 Hours. Person Resources (DYS_LBR and DYD_PNTR) are available only in normal day shift.
STEP 5: CREATE STANDARD OPERATIONS
Create the Standard Operations and assign the Departments like below;
Standard Operations
Department
Resources
Usage
DYSA
DYS_ASMLY
DYS_ASMLY
DYS_LBR
1
2
DYSP
DYS_PAINT
DYS_PNTR
1

Responsibility: Bills Of Material Navigation: Routing > Standard Operations
Operation Code: DYSA Department: DYS_ASMLY
Click on "Operation Resources" and assign the Resources and it's "Usage/Inverse"
Note:
  1. "DYS_ASMLY" Machine Resource will produce 1 Unit in 1 Hour (UOM = HR)
  2. "DYS_LBR" Person resource will produce only half (0.5) unit in 1 hour. That means, 2 resources are required to complete this operation in 1 hour. So, the Inverse (Output/Hour) becomes 0.5
Likewise create one more Standard Operation and assign the Department and it's Resources.
Operation Code: DYSP Department: DYS_PNTR Resource: DYS_PNTR Usage: 1
Click on "Operation Resources" and enter the Usage
Note: Painter Resource will paint 1 Unit in 1 Hour

STEP 6: DEFINE OVERHEADS
Define one Overhead and enter the Rate/Unit
Responsibility: Inventory Navigation: Setup > Costs > Sub-Elements > Overheads
Overhead Name: DYS_OVRHED Cost Element: Overhead

Click on "Resources" and enter the Cost Type and then assign the Resources
Cost Type: Pending Resource: DYS_ASMLY
Save and Close the "Resource" Form
Click on "Rates" button and enter the Amount  
Basis: Item
Now, close the form and navigate to "Resources" form in Bills Of Materials
Note:
1. If we define Overheads based on "Basis = Item" then, the Formula is
Overhead Cost Calculation = Overhead Rate or Amount
2. If we define the Overheads based on "Basis = Resource Basis" then the formula is
Resource Overhead Cost = Resource Usage  X   Resource Cost  X  Overhead Cost

Responsibility: Bills Of Materials Navigation: Routing > Resources
Query the Resource " DYS_ASMLY" (This resource was attached in Overheads)
Click on "Overheads" button
Now, we can see the Overhead "DYS_OVRHED" which was created in the pervious step has been assigned here.
STEP 7: DEFINE ROUTING
Create the Routing for our Finished Goods "DYS_CAR"
Seq
Operation Code
Department
Resources
Usage
Inverse
10
DYSA
DYS_ASMLY
DYS_ASMLY
DYS_LBR
1
2
1
0.5
20
DYSP
DYS_PNTR
DYS_PNTR
1
1

Responsibility: Bills of Materials Navigation: Routings > Routings
Click on "Operation Resources" and make sure all the assigned Resources are displaying or not for that Operation Seq.

STEP 8: DEFINE BILLS
Define the Bills of Materials for "DYS_CAR"  to produce 1 Unit
Bills
Components
Required Qty
DYS_CAR
DYS_CHASIS
1
DYS_CAR
DYS_ENGINE
1
DYS_CAR
DYS_WHEEL
5
DYS_CAR
DYS_SEAT
3

Responsibility: Bills Of Materials Navigation: Bills > Bills
Save

STEP 9: UPDATE STANDARD COST
Responsibility: Inventory Navigation: Costs > Standard Cost Update > Update Cost
Select "M1" Organization
" Update Standard Costs" program will be submitted and Running
Now, query the Item Costs for all our items
Navigation: Costs > Item Costs
Note:
  1. When we run the "Update Standard Costs" program for "Pending" Cost Type, it will pull the Pending costs and push it into "Frozen" cost type.  
  2. "DYS_CAR" doesn't reflect any cost. Because, the Cost Roll-up has not happened.



STEP 10: COST ROLL-UP
Responsibility: Cost Management
Navigation: Supply Chain Costing > Supply Chain Cost Rollup
Select the Organization as "M1 - Seattle Manufacturing"
Submit a single request and submit " Supply Chain Cost Rollup - Print Report"
Enter the parameters like below
Parameters:
Ran this report for "Pending" Cost Type for Specific Item "DYS_CAR"

View Output of "Supply Chain Cost Rollup - Print Report":

Material Cost Calculation:
Components
Qty
Item Cost
Total Cost
DYS_CHASIS
1
300
300
DYS_ENGINE
1
500
500
DYS_WHEEL
5
100
500
DYS_SEAT
3
50
150
MATERIAL COST
1450

Resource Cost Calculation:
Resources Name
Resource Type
Rate
UOM
Usage
Cost
DYS_ASMLY
Machine
100
HR
1
100
DYS_LBR
Person
50
HR
2
100
DYS_PNTR
Person
25
HR
1
25
Total Resource Cost
225

Overhead Cost Calculation:
Resource Name
Overheads
Department
Rate or Amount
DYS_ASMLY
DYS_OVRHED
DYS_ASML
10

Total Cost Calculation:
Cost Element
Value
Total Material Cost
1450
Total Material Overhead Cost
0
Total Resource Cost
225
Total Overhead Cost
10
Total Outside Processing Cost
0
Total Cost
1685

Add Additional Resource Overhead Cost based on Resource Usage:
Responsibility: Bills Of Materials Navigation: Routings > Resources

Query the Resource "DYS_LBR"

Add something existing overheads by clicking "Overheads" button
Added "Indirect" Overheads under "Pending" Cost Type.
Assign Overheads to Department/Resources:
Responsibility: Inventory Navigation: Setup > Costs > Sub-Elements > Overheads
Query the "Indirect" overhead

Click on "Resources"
Select "Pending" Cost Type and check our Resource "DYS_LBR"
Our Resource is available.
Close this form
Click on "Rates"
Select "Pending" Cost Type and add our Department "DYS_ASMLY"
Basis: Resource Value
Note:
Previously we have defined one Overhead "DYS_OVRHED" that is based on the "Basis = Item". Now, we have defined one Overhead based on "Basis = Resource Value". The Overhead Cost Calculation will be different in both the cases.
For Item Basis, cost is direct. Whatever the Rates we have entered in Overheads form that is a Cost
For Resource Basis, cost calculation is based on the below formula.
Resource Overhead Cost Calculation = Resource Usage  X   Resource Cost  X  Overhead Cost

STEP 11: UPDATE STANDARD COST
Repeat the step 10
Responsibility: Cost Management
Navigation: Item Costs > Standard Cost Update > Update Costs

Run "Update Standard Costs " program for specific item "DYS_CAR"
Submit the program
Once it's completed, do Cost Roll-up for this Item
STEP 12: COST ROLL-UP:
Navigation: Supply Chain Costing > Supply Chain Cost Rollup
Run "Supply Chain Cost Rollup - Print Report" program
Submit and View Output for "Supply Chain Cost Rollup - Print Report"

There are no changes in the Material and Resource Costs. But, there are some changes in the Overheads.
Overhead Cost for "DYS_OVRHED" = 10 USD
Overhead Cost for "Indirect" = Resource Usage  X   Resource Cost  X  Overhead Cost
Indirect Overhead Cost = 2 X 50 X 15 = 1500 USD
Total Overhead Cost = 10 USD + 1500 USD = 1510 USD

STEP 13: INCREASE ONHAND QTY FOR COMPONENTS
Do Miscellaneous Receipts or PO Receipts for Purchased Items
Save and Close the form
STEP 14: CREATE DISCRETE JOBS
Responsibility: Work In Process Navigation: Discrete > Discrete Jobs
Create a New Discrete Job for Assembly "DYS_CAR" and Save

STEP 15: RELEASE DISCRETE JOBS
Responsibility: Work In Process Navigation: Discrete > Discrete Jobs
Query the Discrete Job# 262860 that was created in the previous step

STEP 16: WIP ISSUE
Sine this Assembly's Supply Type is "Assembly Pull", it doesn't require to perform WIP Issue. System automatically issue the components upon completion of this Assembly

STEP 17: MOVE TRANSACTIONS
Responsibility: Work In Process Navigation: Move Transactions > Move Transactions
Query the JOb# 262860 and Move the Materials from Operation Seq 10 "Queue" to Operation Seq 10 "To Move"
Move the Materials from Operation Seq 10 "To Move" to Operation Seq 20 "To Move"
Save

STEP 18: ENTER QUALITY RESULTS_
If you have enabled Quality Collection Plan then enter those Quality Results
Click "OK"
To enter the Quality Results;
Navigation: Tools > Enter Quality Results or click on button from Menu bar
Enter the Quality Results
Click OK and Save

STEP 19: WIP COMPLETION
Responsibility: Work In Process Navigation: Material Transaction > Completion Transactions
Enter the Discrete Job number# 262860 and select the Transaction Type as "WIP Completion"
Click "Continue"
Sub-Inventory: FGI Qty: 10
Click "Done"

STEP 20: CLOSE DISCRETE JOBS
Responsibility: Work In Process
Navigation: Discrete > Close Discrete Jobs > Close Discrete Jobs (Forms)
Query the Discrete Jobs# 262860 which we have completed recently
Before closing the Discrete Jobs, check the Pending Transactions. To check the Pending Transactions
Navigation: Tools > Pending Actions
Select the "Pending Actions" option from Tools Menu and check for any pending actions
Only "Material Transactions" and "Resource Transactions" are enabled.
If anything other than the below mentioned actions are enabled then that means there are some pending actions
  1. Material Transactions
  2. Resource Transactions
  3. PO Requisitions
In our Discrete Jobs, there are no pending actions. So, it's eligible to Close

To Close the Discrete Jobs, Navigate to Tools Menu and select the Close option
Select "Summary" and click "OK"
Discrete Job Status = Pending Close
Navigation: Tools > View > Request
Can see two requests
  1. Close Discrete Jobs
  2. Discrete Job Value Report - Standard Costing
If there are any pending actions then the second request will not run
Select the second request "Discrete Job Value Report - Standard Costing" and check the output
View Output:
Costing:
Material Cost: 1450 USD/Unit X 10 Qty = 14,500 USD
Resource Cost: 225 USD/Unit X 10 Qty = 2,250 USD
Overhead Cost: 10 USD + 1500 USD = 1510 USD/Unit X 10 Qty = 15,100 USD
Total Cost for 1 Qty = 1450 + 225 + 1510 = 3,185 USD
Total Cost for 10 Qty = 14,500 + 2,250 + 15,100 = 31,850 USD

Accounts Receivable-AR setups in Oracle EBS Functional Financials - Apps R12

   1. Oracle Receivables -> Setup -> System ->System Options     a. Receivable GL related setup    b. Transaction and Customer rela...