Header Ads

  • Breaking News

    PeopleSoft Array error due to ....... (read more to find that silly reason)

    One of my friend had written a PeopleSoft Application Engine which reads a csv file and processes data. The input csv file had only 2 columns and spanned with several rows of data. The App engine was working fine for so long until my friend modified the input file to have just only one row of data.

    The App Engine processed for some time and gave the below error.
    Fetching array element 1: index is not in range 1 to 0. (180,252)

    I know that this is a common error when using Arrays in Peoplecode and it is thrown if the arrays are not properly Initialized.
    Below is the code he used where the array is also initialized and was functioning fine for so long.

    &InputPath = "c:\";
    &IP_file = GetFile(&InputPath "Inputfile.csv", "R", %FilePath_Absolute);
    Local array of string &Array_IP_string;

    While &IP_file.ReadLine(&IP_string)
    &Array_IP_string = Split(&IP_string, ",");
    &IP_field1 = LTrim(&Array_IP_string [1]);
    &IP_field2 = LTrim(&Array_IP_string [2]);
    /* Processing code */
    End-While;

    Searching in Google, got the below suggestion:
    Easiest way is to have the trace on, repeat the steps you did to get the error and analyze the code behind it

    Being an AE and with just one line in input file I was puzzled on what to suggest and only later to find that the input file he used had number of blank lines below the first line which had caused this error message. The input file being a csv file had read the lines which had spaces as string and with the absence of a comma caused this error.
    On removing these blank lines in the csv file(opened in a notepad) the app engine ran successfully without any errors. The simplest of solutions which once again reinforced me that all problems have a common and simple solution which we often tend to overlook.

    5 comments:

    1. thanks a lot. You help me to solve my problem, I haven't think the upload file had problem till to read you post

      ReplyDelete
    2. Hmm.. this one worked out for me!! Thanks!

      ReplyDelete
    3. Thanks so much. This worked for me too

      ReplyDelete
    4. Thanks a ton...It helped me a lot.

      ReplyDelete
    5. It worked! Thanks so much.

      ReplyDelete

    Please refrain for marketing messages and unnecessary back links.

    Post Top Ad

    Post Bottom Ad