Overflow exeption when you put together string and integer

bRahms
bRahms Member Posts: 44
I admit, we're complete beginners with Navision. But you can hardly find information on the internet, so i hope you guys can sort this out.

We would like to put an Integer + an Text field together in one String, but we keep on getting Overflow execeptions when converting Text to Text.
recRegio.RESET;
recRegio.SETCURRENTKEY(recRegio.RegioID);
recRegio.SETFILTER(recRegio.RegioID, '=%1',recRegio.RegioID);
IF recRegio.FIND('-') THEN
BEGIN
dossiernr := recRegio.RegioAfkorting+'/'+recDossier2.Dossiernr+'/2007';
recRegio.RegioAfkorting := dossiernr;
END

Comments

  • lakshmivalluru
    lakshmivalluru Member Posts: 168
    make sure the field size of dossiernr is greater than the field size of text + field size of integer.
    Example: text field - size 10, integer (can be any lenght) so size of dossiernr should be 30 atleast.
    also size of recRegio.RegioAfkorting

    I hope recRegio.RegioAfkorting and dossiernr are text fields
    LR
  • bRahms
    bRahms Member Posts: 44
    We figured it out now, Thank you!
  • bRahms
    bRahms Member Posts: 44
    As you can see we use 2007 now, but we want to filter the year from the date.. but how? 8-[
  • lakshmivalluru
    lakshmivalluru Member Posts: 168
    Are dossiernr and recRegio.RegioAfkorting date fields?

    u want to setfilter using SETFILTER or SETRANGE???
    or do u want the year from date [ syntax is (Date, 3) which gives year from the date]
    LR
  • bRahms
    bRahms Member Posts: 44
    They are textfields.

    The thing we want is:
    We want to create a unique number that consists of:

    First letter of the chosen region above (that's ok) + unique number of three digits + the year that the file has been posted.

    So for example: Today we make a new file in the Region: Brussels

    -> BR/001/2007

    Our problem is that we don't know how to filter the year out of the date and put it into this string.
  • lakshmivalluru
    lakshmivalluru Member Posts: 168
    ok the syntax is

    dossiernr := recRegio.RegioAfkorting+'/'+recDossier2.Dossiernr+
    FORMAT(DATE2DMY(WORKDATE,3));

    DATE2DMY(WORKDATE,3) - Returns year in integer format. so you need to change it into text using FORMAT function
    LR
  • lubost
    lubost Member Posts: 633
    As you can read from previous posts:

    Year := date2dmy(anydate, 3);

    and your code will be the next

    dossiernr := recRegio.RegioAfkorting+'/'+recDossier2.Dossiernr+'/'+format(date2dmy(workdate, 3))

    and your "dossiernr" variable must be declared to accept the longest code you can obtain.
  • bRahms
    bRahms Member Posts: 44
    Thank you very much. Glad you don't insult me for being a newbie in Navision [-o<

    Next up: The dossiernumber has to be the last one in the database (001) + 1. I'll try for myself, but any help is welcome :)
  • lakshmivalluru
    lakshmivalluru Member Posts: 168
    i will leave this to you to try for couple of hours , if yo ustill cna't then help will be on its way.
    LR
  • bRahms
    bRahms Member Posts: 44
    I think it has something to do with EVALUATE, but then it says i can't do +1, because it's a boolean.:

    numDossiernr := EVALUATE(Int, FORMAT(recDossier2.Dossiernr));
    then i want to do numDossiernr+1, but now it's a boolean, not an int.. :-k
  • SteveO
    SteveO Member Posts: 164
    When you use EVALUATE the value that gets returned is whether or not the conversion succeeded.
    The first parameter that gets passed to EVALUATE actually holds the converted value.

    So in your case:
    numDossiernr holds the value that determines whether the call to EVALUATE succeeded or failed.
    Int holds the converted value of recDossier2.Dossiernr
    This isn't a signature, I type this at the bottom of every message
  • bRahms
    bRahms Member Posts: 44
    Thanks again, with the format(Int+1) it worked out fine. But now it sais BR/8/2007 and that should be BR/008/2007. Same as the next documents then, it should be BR/010/2007 and not BR/10/2007. Is this possible?

    ... I've read that's better to start with 100?