Vendor No. " does not exist ?

upasanisandipupasanisandip Member Posts: 405
Hi All,
I am running 1 custom codeunit. But getting error that
Vendor No. " does not exist.
I have imported this table data from 1 .csv file.

The code I have used in codeunit is like this.
VEND1.GET;
IF VEND1.FIND('-') THEN

REPEAT
IF VEND1.City<>'' THEN
IF VEND1.City='MUMBAI' THEN
BEGIN
VEND1.City:='MUM'
END;
VEND1.MODIFY;
UNTIL VEND1.NEXT=0;

Anyone have solution about this?

Thanks,
Sandip

Answers

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    VEND1.GET;
    IF VEND1.FIND('-') THEN
    This code is not correct. How should the codeunit know which Vendor to read?
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • ClausHamannClausHamann Member Posts: 80
    VEND1.GET;

    The above code tries to get a Vendor with blank primary key (blank No.) and that why you get the error "Vendor No. " does not exist. "

    Regards

    Claus

    Copy from Navision help:

    GET (Record)
    Use this function to find a record based on values stored in primary key fields.

    [Ok :=] Record.GET([Value] ,...)
    Ok

    Data type: boolean

    If you omit this optional return value, a run-time error occurs if the system cannot find the record. When you include the return value, the system assumes you will handle any errors. The return value can have these values:
  • upasanisandipupasanisandip Member Posts: 405
    Hi,
    VEND1 is the recrod variable for table Vendor defined in C/AL Globals.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Try this code instead. This will do the same as what you are trying to do.
    Vend1.SETRANGE(City,'MUMBAI');
    Vend1.MODIFYALL(City,'MUM');
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
Sign In or Register to comment.