Home » Developer & Programmer » Forms » unable to save the changes in the form
unable to save the changes in the form [message #424815] Tue, 06 October 2009 02:13 Go to next message
deepthi412
Messages: 2
Registered: September 2009
Location: bangalore
Junior Member
I have a seeded form I have personalized it so that I open a custom form from that.That custom form displays the details from the seeded form.the custom form has a save button.This is the query i have written for when-button-pressed trigger.
DECLARE
  CNT      NUMBER;
  CNT1     NUMBER;
  luser_id NUMBER (15);
BEGIN
   SELECT COUNT(*)
     INTO CNT
     FROM LTK_DIS57F4_HEADER
    WHERE FORM_ID=:LTK_DIS57F4_HEADER.FORM_ID;
  
  luser_id :=TO_NUMBER(FND_PROFILE.VALUE('USER_ID'));
  IF CNT    =0 THEN
    -- luser_id :=TO_NUMBER(FND_PROFILE.VALUE('USER_ID'));
     INSERT
       INTO LTK_DIS57F4_HEADER
      (
        TRX_NUMBER      ,
        FORM_ID         ,
        VENDOR_ID       ,
        VENDOR_SITE_ID  ,
        ORGANIZATION_ID ,
        LOCATION_ID     ,
        FORM_NUMBER     ,
        PO_HEADER_ID    ,
        FIN_YEAR        ,
        LAST_UPDATE_DATE,
        LAST_UPDATED_BY ,
        CREATION_DATE   ,
        CREATED_BY
      )
      VALUES
      (
        :LTK_DIS57F4_HEADER.TRX_NUMBER     ,
        :LTK_DIS57F4_HEADER.FORM_ID        ,
        :LTK_DIS57F4_HEADER.VENDOR_ID      ,
        :LTK_DIS57F4_HEADER.VENDOR_SITE_ID ,
        :LTK_DIS57F4_HEADER.ORGANIZATION_ID,
        :LTK_DIS57F4_HEADER.LOCATION_ID    ,
        :LTK_DIS57F4_HEADER.FORM_NUMBER    ,
        :LTK_DIS57F4_HEADER.PO_HEADER_ID   ,
        :LTK_DIS57F4_HEADER.FIN_YEAR       ,
        SYSDATE                            ,
        luser_id                           ,
        SYSDATE                            ,
        luser_id
      );
     SELECT COUNT(*)
       INTO cnt1
       FROM ja_in_57f4_lines
      WHERE form_id=:LTK_DIS57F4_HEADER.FORM_ID;
    
    FOR c IN 1..cnt1
    LOOP
       INSERT
         INTO LTK_DIS57F4_LINES
        (
          TRX_NUMBER      ,
          FORM_ID         ,
          ITEM_ID         ,
          ITEM_UOM        ,
          REQUIRED_QTY    ,
          DISPATCHED_QTY  ,
          BALANCE_QTY     ,
          LAST_UPDATE_DATE,
          LAST_UPDATED_BY ,
          CREATION_DATE   ,
          CREATED_BY      ,
          ITEM_CODE       ,
          USE_EXCESS_QTY
        )
        VALUES
        (
          :LTK_DIS57F4_HEADER.TRX_NUMBER   ,
          :LTK_DIS57F4_HEADER.FORM_ID      ,
          :LTK_DIS57F4_LINES.ITEM_ID       ,
          :LTK_DIS57F4_LINES.ITEM_UOM      ,
          :LTK_DIS57F4_LINES.REQUIRED_QTY  ,
          :LTK_DIS57F4_LINES.DISPATCHED_QTY,
          :LTK_DIS57F4_LINES.BALANCE_QTY   ,
          SYSDATE                          ,
          luser_id                         ,
          SYSDATE                          ,
          luser_id                         ,
          :LTK_DIS57F4_LINES.ITEM_CODE     ,
          :LTK_DIS57F4_LINES.USE_EXCESS_QTY
        );
      
      next_record;
    END LOOP;
    COMMIT;
    first_record;
  ELSE
     SELECT COUNT(*)
       INTO cnt
       FROM LTK_DIS57F4_LINES
      WHERE form_id=:LTK_DIS57F4_HEADER.FORM_ID;
    
    FOR c IN 1..cnt1
    LOOP
       UPDATE LTK_DIS57F4_LINES
      SET DISPATCHED_QTY=:LTK_DIS57F4_LINES.DISPATCHED_QTY,
        BALANCE_QTY     =:LTK_DIS57F4_LINES.BALANCE_QTY   ,
        USE_EXCESS_QTY  =:LTK_DIS57F4_LINES.USE_EXCESS_QTY
        WHERE FORM_ID   =:LTK_DIS57F4_HEADER.FORM_ID
      AND ITEM_CODE     =:LTK_DIS57F4_LINES.ITEM_CODE;
      
      NEXT_RECORD;
    END LOOP;
    COMMIT;
  END IF;
END;
when I open the form and save it for the first time it saves without any error.But when I save it for the second time making changes.It gives the error APP-FND-01206.this record already exists error

[Updated on: Tue, 06 October 2009 03:56] by Moderator

Report message to a moderator

Re: unable to save the changes in the form [message #424846 is a reply to message #424815] Tue, 06 October 2009 04:00 Go to previous message
cookiemonster
Messages: 12403
Registered: September 2008
Location: Rainy Manchester
Senior Member
First off, when posting code it helps a lot to format it and use code tags, because what you've got here is unreadable. If you don't know how to use code tags see the orafaq forum guide.

Judging from the error message I assume this is a unique key violation. Since I don't know what the unique keys are it's hard to say what the problem is. Really you should debug this and work out which table is giving the error and then tell us what the keys on that table are.

However this looks suspicious:
    SELECT COUNT(*) INTO cnt1 
    FROM ja_in_57f4_lines
    WHERE form_id=:LTK_DIS57F4_HEADER.FORM_ID;

    FOR c IN 1..cnt1 LOOP

      INSERT INTO LTK_DIS57F4_LINES( TRX_NUMBER,FORM_ID,ITEM_ID,ITEM_UOM,REQUIRED_QTY,DISPATCHED_QTY,BALANCE_QTY, 
        LAST_UPDATE_DATE,LAST_UPDATED_BY,CREATION_DATE,CREATED_BY,ITEM_CODE,USE_EXCESS_QTY)
      VALUES( :LTK_DIS57F4_HEADER.TRX_NUMBER,
              :LTK_DIS57F4_HEADER.FORM_ID, 
              :LTK_DIS57F4_LINES.ITEM_ID, 
              :LTK_DIS57F4_LINES.ITEM_UOM, 
              :LTK_DIS57F4_LINES.REQUIRED_QTY, 
              :LTK_DIS57F4_LINES.DISPATCHED_QTY, 
              :LTK_DIS57F4_LINES.BALANCE_QTY, 
              SYSDATE, 
              luser_id, 
              SYSDATE, 
              luser_id, 
              :LTK_DIS57F4_LINES.ITEM_CODE, 
              :LTK_DIS57F4_LINES.USE_EXCESS_QTY);
      next_record;

    end loop;
    commit;
    first_record;


It appears that unless the number of records in your LTK_DIS57F4_LINES datablock is equal to the count from the query this will probably give a unique key error. I suspect it's also missing a first_record command.
Previous Topic: Error Appear when i call form that use Webutil from client pc
Next Topic: Web Util Files Missing(frmall.jar,frmall_jinit.jar)
Goto Forum:
  


Current Time: Sat Dec 03 01:17:40 CST 2016

Total time taken to generate the page: 0.15781 seconds