2 Replies Latest reply: Apr 19, 2013 12:00 PM by MST RSS

    Line numbers should not get resequence upon deletion

    951614
      Hi,

      We are doing the following sequence of steps to implement auto sequencing in a multi record child block on a text field called "line_number "

      ----------------------------------
      Summary of logic

      WHEN-NEW-RECORD-INSTANCE
      KEY-DELREC
      name of the procedure is custom_procedure
      Detailed code is presented below.
      ------------------------------

      We are able to auto sequence the line number field...for example, if we want four lines to be entered, "Line_number" is getting populated with line numbers
      If we delete the line, the line number is getting getting recaculated...for example, if line numbers , 1,2,3,4 are entered and I delete line number 2.....line number is getting recalculated ie. line number 3 to 2 and 4 to 3.

      Now, the requiement has been modified such that the resequencing of lines shuold not happen on delete....that is if line 2 is deleted...3 should remain as 3 and 4 should remain as 4 above saving.

      Is there anyhow the belwo code can be modified to achieve the above requirement

      Thanks
      SR

      -----------------------------------------------------------------Detailed code ----------------------------------

      WHEN-NEW-RECORD-INSTANCE (this code generates the line numbers automatically)

      --------------------------------------------------------------------------------
      BEGIN
      IF :SYSTEM.mode 'ENTER-QUERY'
      THEN
      IF :SYSTEM.record_status = ('NEW')
      THEN
      CUSTOM_PROCEDURE ('DB2', 'LINE_NUMBER');
      END IF;
      END IF;
      END;

      KEY-DELREC (this code resequences the line numbers when a record is deleted from the multi record DB2)



      --------------------------------------------------------------------------------

      BEGIN

      DELETE_RECORD;



      IF GET_BLOCK_PROPERTY ('DB2', delete_allowed) = 'TRUE'
      THEN
      CUSTOM_PROCEDURE ('DB2', 'LINE_NUMBER');
      END IF;


      END;

      the CUSTOM_PROCEDURE is



      --------------------------------------------------------------------------------

      PROCEDURE CUSTOM_PROCEDURE (
      p_sourceblock IN VARCHAR2,
      p_sourcefield IN VARCHAR2
      )
      IS
      v_currec VARCHAR2(50);
      v_curfld VARCHAR2 (50);
      BEGIN
      v_currec := :SYSTEM.cursor_record;
      v_curfld := :SYSTEM.cursor_field;

      LOOP

      COPY (:SYSTEM.cursor_record, p_sourceblock || '.' || p_sourcefield);

      IF :SYSTEM.LAST_RECORD = 'TRUE'
      THEN
      EXIT;
      END IF;

      NEXT_RECORD;
      END LOOP;

      GO_RECORD (v_currec);
      go_field (v_curfld);


      END;