code problem

mkpjsr
mkpjsr Member Posts: 587
Hi all

i want to fetch the "No. 2" field from Item table into an array under "Transfer Shipment Report", so i have written the following code to do so but not able to fix it,

globals i have used:
i->Int
TransShipLine->Rec->Transfer Shipment Line
ItemRec->Record->Item
ItemNo->Text array

i:=1;
IF TransShipLine.FINDSET THEN
REPEAT
ItemRec.GET("Item No.");
ItemNo:=ItemRec."No. 2";
i+=1;
UNTIL TransShipLine.NEXT=0;

here the dimension of the array is 6 and when i am running the report am getting an error
"The indexing 7 in the array is outside of the permitted range"
what is wrong with the code. can anybody help me

Answers

  • navuser1
    navuser1 Member Posts: 1,334
    mkpjsr wrote:
    Hi all

    i want to fetch the "No. 2" field from Item table into an array under "Transfer Shipment Report", so i have written the following code to do so but not able to fix it,

    globals i have used:
    i->Int
    TransShipLine->Rec->Transfer Shipment Line
    ItemRec->Record->Item
    ItemNo->Text array

    i:=1;
    IF TransShipLine.FINDSET THEN
    REPEAT
    ItemRec.GET("Item No.");
    ItemNo:=ItemRec."No. 2";
    i+=1;
    UNTIL TransShipLine.NEXT=0;

    here the dimension of the array is 6 and when i am running the report am getting an error
    "The indexing 7 in the array is outside of the permitted range"
    what is wrong with the code. can anybody help me


    Dimension of the array is 6 but TransShipLine.FINDSET finds more than that so you are facing the error.
    Now or Never
  • matttrax
    matttrax Member Posts: 2,309
    mkpjsr wrote:
    here the dimension of the array is 6 and when i am running the report am getting an error
    "The indexing 7 in the array is outside of the permitted range"

    You've solved your own problem. You know that your array can only hold six values, but you are trying to assign something in the 7th spot. That 7th spot doesn't exist so the error is thrown.

    Either increase the size of your array or add conditions to your REPEAT..UNTIL loop to account for finding more than you need.
  • mkpjsr
    mkpjsr Member Posts: 587
    edited 2010-02-19
    Here the line contains only two items so i think in the array i will have not more than two values at a time. I had also tried increasing the size of the array but i am getting the same error
    "The indexing n+1 in the array is outside of the permitted range". I think there is some problem with filtering
  • mkpjsr
    mkpjsr Member Posts: 587
    Here the line contains only two items so i think in the array i will have not more than two values at a time. I had also tried increasing the size of the array but i am getting the same error
    "The indexing n+1 in the array is outside of the permitted range". I think there is some problem with filtering
  • matttrax
    matttrax Member Posts: 2,309
    Since I don't see any filters in the code you posted I would say you are probably correct. Also, I didn't say what you have me quoted as saying. Please edit your response.
  • David_Singleton
    David_Singleton Member Posts: 5,479
    Why are you using an array. You will always get this issue eventually one day. Use a Temporary table.
    David Singleton
  • mkpjsr
    mkpjsr Member Posts: 587
    matttrax wrote:
    Also, I didn't say what you have me quoted as saying. Please edit your response.

    That was my mistake, i have correct it in the next post
  • mkpjsr
    mkpjsr Member Posts: 587
    Use a Temporary table.

    Can u please focus on this. should i use Integer table, if yes then how
  • SPost29
    SPost29 Member Posts: 148
    i:=1;
    IF TransShipLine.FINDSET THEN
    REPEAT
    ItemRec.GET("Item No.");
    ItemNo:=ItemRec."No. 2";
    i+=1;
    UNTIL TransShipLine.NEXT=0;

    there needs to be filters on transShipLine to findset for the specific rec
    also

    ItemRec.GET("Item No.");
    should be
    ItemRec.GET(TransShipLine."Item No.");

    Steve Post
  • mkpjsr
    mkpjsr Member Posts: 587
    SPost29 wrote:
    i:=1;
    IF TransShipLine.FINDSET THEN
    REPEAT
    ItemRec.GET("Item No.");
    ItemNo:=ItemRec."No. 2";
    i+=1;
    UNTIL TransShipLine.NEXT=0;

    there needs to be filters on transShipLine to findset for the specific rec
    also

    ItemRec.GET("Item No.");
    should be
    ItemRec.GET(TransShipLine."Item No.");

    Steve Post

    thanx, i got it and the problem is resolved