Can anybody change this logic ?

Hi,
In a form I have a block :serial_entry and two text fields one is vfi_range_quantity(number),fm_serial_number(char) I will enter vfi_range_quantity is 3 and tab curosr goes to fm_serial_number and will enter 546-878-335
and press tab it will pop up message saying 546-878-335,546-878-336,546-878-337. Its working fine.
The code for this is attached at the end.
Now what I want is I will enter vfi_range_quantity is 3, fm_serial_number 546-878-000 its poping up the message saying 546-878-0,546-878-1,546-878-2. What I want is 546-878-000,546-878-001,546-878-002
AND If I Enter vfi_range_quantity is 3 fm_serial_number 546-878-999
its poping up the message saying 546-878-999,546-878-1000,546-878-1001.
What I want is 546-878-999 only..
Thanks,
Devender
When-Validate-item of fm_serial_number
DECLARE
l_fm_serial_number VARCHAR2 (100);
l_part_number VARCHAR2 (100);
len_fm_serial_number     NUMBER;
temp_part VARCHAR2 (50);
temp_part1 VARCHAR2 (50);
temp_part5 VARCHAR2 (500);
temp_part2 NUMBER;
temp_part3 NUMBER;
temp_part4 NUMBER;
v_count_parent           NUMBER:=1;
v_count_vmsn           NUMBER;
BEGIN
     len_fm_serial_number:=length(:serial_entry.fm_serial_number);
     IF len_fm_serial_number = 11 THEN
          temp_part3:= 9;temp_part4:=7;
     END IF;
IF v_count_parent != 0 THEN
     BEGIN --++++
     temp_part2 :=
TO_NUMBER (SUBSTR (:serial_entry.fm_serial_number, temp_part3, 3));
          FOR i IN 1 ..:serial_entry.vfi_range_quantity
     LOOP
     BEGIN
temp_part1 :=
SUBSTR (:serial_entry.fm_serial_number, 1, temp_part4)|| '-'|| TO_CHAR (temp_part2);
TEMP_PART := NULL;
     END;
     temp_part2 := temp_part2 + 1;
     temp_part5 := temp_part5||','||temp_part1;
END LOOP;
Message(temp_part5);
Message(temp_part5);
END; --++++
END IF;
END;
-------------------------------

DECLARE
     FUNCTION generate_serial_numbers(
          p_serial_no IN VARCHAR2,
          p_range IN PLS_INTEGER)
          RETURN VARCHAR2 IS
          part3_num PLS_INTEGER;
          retval VARCHAR2(100) := '';
     BEGIN
          BEGIN
               part3_num := To_Number(SubStr(p_serial_no,9));
          EXCEPTION
               WHEN Value_Error THEN
                    Raise_Application_Error(-20000,'Bad serial no - use ''nnn-nnn-nnn''');
          END;
          FOR i IN 0..(p_range - 1) LOOP
               IF part3_num + i <= 999 THEN
                    IF i != 0 THEN
                         retval := retval || ', ';
                    END IF;
                    retval := retval || SubStr(p_serial_no,1,8) || To_Char(part3_num + i,'fm009');
               END IF;
          END LOOP;
          RETURN retval;
     END;
BEGIN
     Dbms_Output.put_line(generate_serial_numbers('546-878-1',3));
     Dbms_Output.put_line(generate_serial_numbers('546-878-001',3));
     Dbms_Output.put_line(generate_serial_numbers('546-878-999',3));
     Dbms_Output.put_line(generate_serial_numbers('546-878-1',6));
     Dbms_Output.put_line(generate_serial_numbers('546-878-egg',6));
END;
/any use?

Similar Messages

Maybe you are looking for

  • Error while Executing DTP for 0ic_c03

    Hi Friends, While executing the 2lis_03_bx DTP for the cube 0ic_c03, i am facing this peculiar problem. Executing the DTP takes a lot of time and after some time i am getting the error "Status 'Processed with Errors' Message no. RSBK257" I have tried

  • Common headers and footers in web applications

    I want to include common headers and footers in all web applications. I do not want to include the header/footer in each application WAR file. I've tried to follow Orion's tutorial for building a response filter, and I get it working to the point tha

  • LR3, PS CS5, Camera Raw 6.2, oh my! Compatibility issues?

    I am using LR3.2, PS CS5 (12.0.1) and Camera Raw 6.2 on Mac OS (Snow Leopard). When I open an image from Lightroom in Photoshop, filters such as Surface Blur take about 10 minutes (literally) to complete. Wile the filter is running, I checked CPU and

  • Can't preview images as thumbnil or cover flow

    Hi everyone. Previously i was able to view images in finder as thumbnails as well as cover flow, but yesterday i found out that that the images in finder takes the "preview" icon although although that in the finder view options the show icon preview

  • Check clearing or not

    How to check any clearing accounting document to settle a goods issues delivery. I have a goods issue document. I would like to know is there any clearing document for the goods document. Thanks!