DBA Data[Home] [Help]

APPS.GMD_FORMULA_PUB SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 27

      SELECT meaning
      FROM   gmd_status
      WHERE  status_code = P_status_code;
Line: 34

    FOR C_status_code IN (Select formula_status from fm_form_mst_b
                          where  formula_id = vFormula_id) LOOP
      OPEN  get_status_meaning(C_status_code.formula_status);
Line: 49

  /*   Insert_FormulaDetail                                                   */
  /*                                                                          */
  /* DESCRIPTION:                                                             */
  /*   This PL/SQL procedure is responsible for inserting a formula.          */
  /* ======================================================================== */

  /* ======================================================================== */
  /* Start of commments                                                       */
  /* API name     : Insert_Formula                                            */
  /* Type         : Public                                                    */
  /* Function     :                                                           */
  /* Paramaters   :                                                           */
  /* IN           : p_api_version             IN NUMBER   Required            */
  /*                p_init_msg_list           IN Varchar2 Optional            */
  /*                p_commit                  IN Varchar2 Optional            */
  /*                p_called_from_forms       IN VARCHAR2 DEFAULT 'NO'        */
  /*                p_formula_header_tbl_type IN Required                     */
  /* BUG#2868184    p_allow_zero_ing_qty      IN VARCHAR2  DEFAULT 'FALSE'    */
  /*                                                                          */
  /* OUT            x_return_status    OUT varchar2(1)                        */
  /*                x_msg_count        OUT Number                             */
  /*                x_msg_data         OUT varchar2(2000)                     */
  /*                                                                          */
  /* Version :  Current Version 1.0                                           */
  /*                                                                          */
  /* Notes  :                                                                 */
  /*                                                                          */
  /* History:                                                                 */
  /*   V. Ajay Kumar  08/25/2003 BUG#2930523 Added code such that a message   */
  /*                             is displayed if the user tries to create an  */
  /*                             exisiting formula/version.                   */
  /*   Jeff Baird     09/26/2003 Bug #3119000 Changed values returned         */
  /*   kkillams       23-03-2004 Added call to modify_status to set formula   */
  /*                             status to default status if default status is*/
  /*                             defined organization level w.r.t. bug 3408799*/
  /*   G Kelly	 10-MAY-2004     Bug# 3604554 Added functionality for Recipe  */
  /*				 Generation to the procedure after modify_status */
  /*   Kapil ME  05-FEB-2007     Bug# 5716318- Added the new Auto_product_calc*/
  /*                             fields for Auto -Product Qty ME              */
  /* End of comments                                                          */
  /* ======================================================================== */
  PROCEDURE Insert_Formula
  (  p_api_version           IN         NUMBER
    ,p_init_msg_list         IN         VARCHAR2
    ,p_commit                IN         VARCHAR2
    ,p_called_from_forms     IN         VARCHAR2 := 'NO'
    ,x_return_status         OUT NOCOPY VARCHAR2
    ,x_msg_count             OUT NOCOPY NUMBER
    ,x_msg_data              OUT NOCOPY VARCHAR2
    ,p_formula_header_tbl    IN         FORMULA_INSERT_HDR_TBL_TYPE
    ,p_allow_zero_ing_qty    IN VARCHAR2  := 'FALSE'
  )
  IS
     /*  Local Variables definitions */
     --BEGIN BUG#2868184
      --Created a new variables to hold the profile value and Flag.
     l_profile               NUMBER;
Line: 108

     l_api_name              CONSTANT    VARCHAR2(30)        := 'INSERT_FORMULA';
Line: 140

     p_formula_header_rec    GMD_FORMULA_COMMON_PUB.formula_insert_rec_type;
Line: 143

     l_formula_detail_tbl            GMD_FORMULA_DETAIL_PUB.formula_insert_dtl_tbl_type;
Line: 158

         SELECT formula_id
         FROM   fm_form_mst
         WHERE  formula_id = vFormula_id;
Line: 174

     SAVEPOINT  Insert_FormulaHeader_PUB;
Line: 215

       /*  for any record even if header exists we may need to insert its */
       /*  detail lines and associted effectivity. */
       l_header_exists_flag            := 'N';
Line: 220

       /*  product and ingredient while inserting a formula header. */
       /*  While looping thro each record if we come across a byproduct (line_type =2) */
       /*  we set the line counter = 2 and for ingredient or product (line_type = 1 or -1) */
       /*  we set this counter = 1 */
       l_line_type_counter             := 0;
Line: 284

               /* and do validate before inserting the header info */
               l_header_exists_flag := 'Y';
Line: 467

	    SELECT segment1,recipe_enabled_flag  INTO v_item_no, v_recipe_enabled
	     FROM mtl_system_items_b
	     WHERE (inventory_item_id =  NVL(p_formula_header_tbl(j).inventory_item_id, -9999) OR
	            segment1 = p_formula_header_tbl(j).item_no) AND
		    organization_id = p_formula_header_tbl(j).owner_organization_id;
Line: 474

	    ROLLBACK to Insert_FormulaHeader_PUB;
Line: 500

          /* Only in Inserts                                       */
          /* To insert a header it should have formula description */
          /* ===================================================== */
          IF (l_debug = 'Y') THEN
              gmd_debug.put_line(' In Formula Header Pub - '
                       ||'Before validation of formula desc '
                       ||p_formula_header_rec.formula_desc1
                       ||' - '
                       ||x_return_status);
Line: 608

          /*   Call the private API to insert header information */
          /*   ================================================== */
          IF (l_debug = 'Y') THEN
              gmd_debug.put_line(' In Formula Header Pub - '
                       ||'About to assign values before calling pvt API '
                       ||' - '
                       ||x_return_status);
Line: 677

             l_fm_form_mst_rec.delete_mark       := p_formula_header_rec.delete_mark;
Line: 680

             l_fm_form_mst_rec.last_update_date  := NVL(p_formula_header_rec.last_update_date, SYSDATE);
Line: 681

             l_fm_form_mst_rec.last_update_login := NVL(p_formula_header_rec.last_update_login, l_user_id);
Line: 682

             l_fm_form_mst_rec.last_updated_by   := l_user_id; -- 4603060
Line: 694

             GMD_FORMULA_HEADER_PVT.Insert_FormulaHeader
              (  p_api_version            =>      p_api_version
                 ,p_init_msg_list         =>      p_init_msg_list
                 ,p_commit                =>      FND_API.G_FALSE
                 ,x_return_status         =>      x_return_status
                 ,x_msg_count             =>      x_msg_count
                 ,x_msg_data              =>      x_msg_data
                 ,p_formula_header_rec    =>      l_fm_form_mst_rec
              );
Line: 711

          END IF; /* end after formula header insert   */
Line: 738

      /* Formula/Formula's are  either rolled back or inserted with warning */

       IF l_flag = 'F' AND l_formula_detail_tbl(1).line_type = -1 AND l_formula_detail_tbl(1).qty = 0 THEN
         FND_MESSAGE.SET_NAME('GMD','GMD_ZERO_INGREDIENT_QTY');
Line: 753

       /* Based on return codes we need to insert formula details too */
       /* If header inserts had failed for some reason either during  */
       /* validation or insertion we do not load fomula detail information. */


       /* Create formulalines only if the header is succesfully created */
       IF (x_return_status = FND_API.G_RET_STS_SUCCESS ) THEN
           IF (l_debug = 'Y') THEN
               gmd_debug.put_line(' In Formula Header Pub - '
                       ||'About to call the Formula line Pub API  '
                       ||' - '
                       ||x_return_status);
Line: 767

           GMD_FORMULA_DETAIL_PUB.Insert_FormulaDetail
            ( p_api_version           =>      l_api_version
             ,p_init_msg_list         =>      p_init_msg_list
             ,p_called_from_forms     =>      p_called_from_forms
             ,p_commit                =>      FND_API.G_FALSE
             ,x_return_status         =>      x_return_status
             ,x_msg_count             =>      x_msg_count
             ,x_msg_data              =>      x_msg_data
             ,p_formula_detail_tbl    =>      l_formula_detail_tbl
            );
Line: 787

          rather than trying to insert other header / lines */
       IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
           RAISE FND_API.G_EXC_ERROR;
Line: 874

        ROLLBACK to Insert_FormulaHeader_PUB;
Line: 885

        ROLLBACK to Insert_FormulaHeader_PUB;
Line: 896

        ROLLBACK to Insert_FormulaHeader_PUB;
Line: 907

        ROLLBACK to Insert_FormulaHeader_PUB;
Line: 918

  END Insert_Formula;
Line: 923

  /*   Update_FormulaHeader                                                   */
  /*                                                                          */
  /* DESCRIPTION:                                                             */
  /*   This PL/SQL procedure is responsible for updating a formula.           */
  /* HISTORY :                                                                */
  /*    Kapil M  Bug# 5716318 - Changes for Auto -Product Qty Calculation ME  */
  /* ======================================================================== */
  PROCEDURE Update_FormulaHeader
  (  p_api_version           IN          NUMBER
    ,p_init_msg_list         IN          VARCHAR2
    ,p_commit                IN          VARCHAR2
    ,p_called_from_forms     IN          VARCHAR2 := 'NO'
    ,x_return_status         OUT NOCOPY  VARCHAR2
    ,x_msg_count             OUT NOCOPY  NUMBER
    ,x_msg_data              OUT NOCOPY  VARCHAR2
    ,p_formula_header_tbl    IN          FORMULA_UPDATE_HDR_TBL_TYPE
  )
  IS
     /*  Local Variables definitions */
     l_api_name              CONSTANT    VARCHAR2(30)        := 'UPDATE_FORMULAHEADER';
Line: 952

     p_formula_header_rec    GMD_FORMULA_COMMON_PUB.formula_update_rec_type;
Line: 993

    l_dbdelete_mark FM_FORM_MST.DELETE_MARK%TYPE;
Line: 998

       SELECT * from fm_form_mst
       WHERE formula_id = vFormula_id;
Line: 1003

        Select *
        From   fm_form_mst
        Where  formula_id = vFormula_id;
Line: 1010

     SAVEPOINT  Update_FormulaHeader_PUB;
Line: 1057

       /* For updates we must  */
       /* have a formula id */
       /* ==================== */
       IF (l_debug = 'Y') THEN
          gmd_debug.put_line(' Before formula validation - '||x_return_status);
Line: 1089

       /* is not provided, update it with what */
       /* exists in the db                     */
       /* ==================================== */
       IF (l_debug = 'Y') THEN
          gmd_debug.put_line(' Assigning all not nulls from db - '||x_return_status);
Line: 1096

       FOR update_not_null_rec IN get_formula_in_db(l_formula_id)
       LOOP
         IF (p_formula_header_rec.formula_no IS NULL) THEN
             p_formula_header_rec.formula_no := update_not_null_rec.formula_no;
Line: 1103

             p_formula_header_rec.formula_vers := update_not_null_rec.formula_vers;
Line: 1107

             p_formula_header_rec.formula_desc1 := update_not_null_rec.formula_desc1;
Line: 1111

             p_formula_header_rec.owner_organization_id := update_not_null_rec.owner_organization_id;
Line: 1115

             p_formula_header_rec.owner_id := update_not_null_rec.owner_id;
Line: 1120

                               := update_not_null_rec.formula_status;
Line: 1125

                               := update_not_null_rec.formula_type;
Line: 1130

                               := update_not_null_rec.scale_type;
Line: 1135

                               := update_not_null_rec.inactive_ind;
Line: 1138

         IF (p_formula_header_rec.delete_mark IS NULL) THEN
             p_formula_header_rec.delete_mark
                               := update_not_null_rec.delete_mark;
Line: 1145

                               := update_not_null_rec.created_by;
Line: 1150

                               := update_not_null_rec.creation_date;
Line: 1154

	 p_formula_header_rec.last_updated_by
                               := l_user_id;
Line: 1157

         IF (p_formula_header_rec.last_update_date IS NULL) THEN
             p_formula_header_rec.last_update_date
                               := SYSDATE;
Line: 1161

         l_dbdelete_mark := update_not_null_rec.delete_mark;
Line: 1166

                               := update_not_null_rec.auto_product_calc;
Line: 1168

          /* Update of the Flag is prevented form the API as the user cannot specify the Percentages. */
          IF NVL(UPPER(p_called_from_forms),'NO') <> 'YES' THEN
           FND_MESSAGE.SET_NAME('GMD', 'GMD_CANNOT_AUTO_FLAG');
Line: 1188

       /* Check if update is allowed */
      IF l_lastformula_id <> l_formula_id THEN
        IF NOT GMD_COMMON_VAL.Update_Allowed('FORMULA',l_formula_id) THEN
          IF NOT  (l_dbdelete_mark = 1  AND p_formula_header_rec.delete_mark = 0) THEN
            FND_MESSAGE.SET_NAME('GMD','GMD_CANNOT_UPD_ENTITY');
Line: 1279

       /* as the user is intending to update the field to NULL */
        /*  Validate all optional parameters passed */
       IF (l_debug = 'Y') THEN
          gmd_debug.put_line(' Before G-MISS validation - '
                             ||p_formula_header_rec.formula_id
                             ||' - '
                             ||x_return_status);
Line: 1589

       /* Call the private API to update the header info */
       IF (x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
           l_fm_form_mst_rec.formula_id        := l_formula_id;
Line: 1640

           l_fm_form_mst_rec.delete_mark       := p_formula_header_rec.delete_mark; /* Important  */
Line: 1643

           l_fm_form_mst_rec.last_update_date  := p_formula_header_rec.last_update_date;
Line: 1644

           l_fm_form_mst_rec.last_update_login := p_formula_header_rec.last_update_login;
Line: 1645

           l_fm_form_mst_rec.last_updated_by   := p_formula_header_rec.last_updated_by;
Line: 1651

               gmd_debug.put_line(' Before calling the private fm update API - '
                             ||x_return_status);
Line: 1654

            GMD_FORMULA_HEADER_PVT.Update_FormulaHeader
            (  p_api_version           =>      1.0
              ,p_init_msg_list         =>      p_init_msg_list
              ,p_commit                =>      FND_API.G_FALSE
              ,x_return_status         =>      x_return_status
              ,x_msg_count             =>      x_msg_count
              ,x_msg_data              =>      x_msg_data
              ,p_formula_header_rec    =>      l_fm_form_mst_rec
            );
Line: 1664

               gmd_debug.put_line('After the private fm update API - '
                             ||x_return_status);
Line: 1671

                update FM_MATL_DTL
                SET PROD_PERCENT = NULL
                where formula_id = l_formula_id
                and line_type = 1
                and scale_type = 1;
Line: 1677

                UPDATE FM_MATL_DTL
                SET SCALE_TYPE = 0
                WHERE formula_id = l_formula_id;
Line: 1683

       END IF; /* end after update of header */
Line: 1686

          rather than trying to update other header details */
       IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
           RAISE FND_API.G_EXC_ERROR;
Line: 1710

         ROLLBACK to Update_FormulaHeader_PUB;
Line: 1721

         ROLLBACK to Update_FormulaHeader_PUB;
Line: 1732

         ROLLBACK to Update_FormulaHeader_PUB;
Line: 1743

  END Update_FormulaHeader;
Line: 1748

  /*   Delete_FormulaHeader                                                   */
  /*                                                                          */
  /* DESCRIPTION:                                                             */
  /*   This PL/SQL procedure is responsible for deleting a formula.           */
  /* ======================================================================== */

  PROCEDURE Delete_FormulaHeader
  (  p_api_version            IN          NUMBER
     ,p_init_msg_list         IN          VARCHAR2
     ,p_commit                IN          VARCHAR2
     ,p_called_from_forms     IN          VARCHAR2
     ,x_return_status         OUT NOCOPY  VARCHAR2
     ,x_msg_count             OUT NOCOPY  NUMBER
     ,x_msg_data              OUT NOCOPY  VARCHAR2
     ,p_formula_header_tbl    IN          FORMULA_UPDATE_HDR_TBL_TYPE
  )
  IS
     /*  Local Variables definitions */
     l_api_name              CONSTANT    VARCHAR2(30)        := 'DELETE_FORMULAHEADER';
Line: 1776

     p_formula_header_rec    GMD_FORMULA_COMMON_PUB.formula_update_rec_type;
Line: 1779

       SELECT *
       FROM   fm_form_mst
       WHERE  formula_id = vFormula_id;
Line: 1786

     SAVEPOINT  Delete_FormulaHeader_PUB;
Line: 1839

        /* delete a header */
        /* =======================  */
        IF (p_formula_header_rec.formula_id is NULL) THEN
           GMDFMVAL_PUB.get_formula_id(p_formula_header_rec.formula_no,
                                      p_formula_header_rec.formula_vers,
                                      l_formula_id, l_return_val);
Line: 1864

        IF NOT GMD_COMMON_VAL.Update_Allowed('FORMULA',l_formula_id) THEN
           FND_MESSAGE.SET_NAME('GMD','GMD_CANNOT_UPD_ENTITY');
Line: 1875

        /* Call the private API to update the header info */
        IF (x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
          FOR l_formula_rec IN get_fm_db_rec(l_formula_id) LOOP

            l_fm_form_mst_rec.formula_id        := l_formula_id;
Line: 1928

            l_fm_form_mst_rec.delete_mark       := 1;   /* Important */
Line: 1931

            l_fm_form_mst_rec.last_update_date  := l_formula_rec.last_update_date;
Line: 1932

            l_fm_form_mst_rec.last_update_login := l_formula_rec.last_update_login;
Line: 1933

            l_fm_form_mst_rec.last_updated_by   := l_formula_rec.last_updated_by;
Line: 1937

            GMD_FORMULA_HEADER_PVT.Update_FormulaHeader
             (  p_api_version           =>  p_api_version
               ,p_init_msg_list         =>  p_init_msg_list
               ,p_commit                =>  FND_API.G_FALSE
               ,x_return_status         =>  x_return_status
               ,x_msg_count             =>  x_msg_count
               ,x_msg_data              =>  x_msg_data
               ,p_formula_header_rec    =>  l_fm_form_mst_rec
             );
Line: 1950

           rather than trying to delete other header details */
        IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
           RAISE FND_API.G_EXC_ERROR;
Line: 1974

         ROLLBACK to Delete_FormulaHeader_PUB;
Line: 1981

         ROLLBACK to Delete_FormulaHeader_PUB;
Line: 1988

         ROLLBACK to Delete_FormulaHeader_PUB;
Line: 1995

  END Delete_FormulaHeader;