Newbie Array Question.

JamieBrownJamieBrown Member Posts: 107
Hi, Can anyone tell me why inv[1] through to inv[4] only displays the inventory for store 001 ?

I'm sure it's a stupid mistake on my part.
store[1] := '001';
store[2] := '003';
store[3] := '008';
store[4] := '013';

FOR counter := 1 TO 4 DO BEGIN
"Stockkeeping Unit".SETFILTER("Location Code",store[counter]);
"Stockkeeping Unit".CALCFIELDS(Inventory);

inv[counter] := "stockkeeping unit".inventory;

END;

Many thanks

Answers

  • ArhontisArhontis Member Posts: 667
    AFAIK stockkeeping unit is per item/location and/or variant.

    Maybe:
    store[1] := '001'; 
    store[2] := '003'; 
    store[3] := '008'; 
    store[4] := '013'; 
    
    FOR counter := 1 TO 4 DO BEGIN 
      IF  "Stockkeeping Unit".GET(store[counter],vSomeItemNo,vSomeVariant) THEN BEGIN
        "Stockkeeping Unit".SETFILTER("Location Code",store[counter]); 
        "Stockkeeping Unit".CALCFIELDS(Inventory); 
        inv[counter] := "stockkeeping unit".inventory; 
      END
      ELSE
        inv[counter] := 0; 
    END;
    
    where the vSOmeItemNo, vSomeVaariant is the codes of the Item No. you are looking for and the variant code.

    If no variants are used then you could use the empty string ''.
  • KowaKowa Member Posts: 918
    JamieBrown wrote:
    "Stockkeeping Unit".SETFILTER("Location Code",store[counter]);

    If you insert values at runtime ,use
    "Stockkeeping Unit".SETFILTER("Location Code",'%1',store[counter]);
    
    instead.
    Kai Kowalewski
  • JamieBrownJamieBrown Member Posts: 107
    Perfect.

    Many thanks to both of you.

    Jamie
Sign In or Register to comment.