Announcement

Collapse
No announcement yet.

[SOLVED] vvOut_toJSON error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [SOLVED] vvOut_toJSON error

    I'm getting the error referenced in this thread when trying to use vvOUT_toJson with multiple records ...

    // Valence service program
    vvOut.object = 'FS2290';
    vvOut.library = 'QS36F';
    vvOut.success = 'Y';
    vvOut.rootName = 'gridsls';
    vvOut_toJSON(vvOut:%addr(salesds):x);

    I have verified the data in each of the salesds elements ... the data seems to be good.
    I updated to the latetst release 7-25, and still have the problem.

    Thanks,
    Glen

  • #2
    Because it is not yet identified as a bug in Valence I moved this to the support forum.

    Comment


    • #3
      Please post up the d-spec definition for salesds and the value of x at the time of failure. A dump would also be helpful. Was this something that was working before and stopped working at some point?

      Comment


      • #4
        d spec:
        ** actual sales totals
        d sqldata e ds extname(fs2290)
        d salesds e ds extname(fs2290) qualified
        d dim(12)

        this is fed by:

        for x = 1 to 12;
        //count += 1;

        // fetch amount
        exec sql
        fetch next from cursor3
        into :sqldata;

        if sqlcode <> 0;
        leave;
        endif;

        salesds(x) = sqldata;

        dbstmt = %char(x) + ' ' + salesds(x);
        except debuga;

        The data sent to the debug file:

        STMT
        1 102201401000110499000110499
        2 102201402000145374000254373
        3 102201403000145950000400323
        4 102201404000143671000543994
        5 102201405000143241000687235
        6 102201406000144978000832213
        7 102201407000000000000000000
        8 102201408000000000000000000
        9 102201409000000000000000000
        10 102201410000000000000000000
        11 102201411000000000000000000
        12 102201412000000000000000000

        This is my first attempt at sending multiple records - it isn't something that was working before.

        I got a dump printout - it's 76 pages

        Thanks,
        Glen

        Comment


        • #5
          This is the spec for the external definition:

          Display Record Format

          File . . : FS2290 Record format . : FS2290R Record length . . : 27
          Library . : VALENCE40 File type . . . : PF Number of fields . : 5
          Text . . :

          Field Type Size Key Text
          LOC Zoned 3,0
          YEAR Zoned 4,0
          MONTH Zoned 2,0
          MAMOUNT Zoned 9,0
          YAMOUNT Zoned 9,0

          Glen

          Comment


          • #6
            Out of curiosity, if you change your for loop to stop at 6 instead of 12, does it still bomb?

            Comment


            • #7
              Yes, it does.
              Glen

              Comment


              • #8
                Hmmm, well then it's probably not a data problem... I think the only way to identify the source of the issue you're having there would be on a web meeting. Please call the support line. 312-477-7450, option 1.

                Comment


                • #9
                  After reviewing this on-line we discovered the issue is tied to how a FOR loop behaves in RPG...

                  Take this for loop example:

                  for x = 1 to 12;
                  arrayElement(x) = abc;
                  endfor;


                  Here, the value of "x" after the loop completes is actually 13 (not 12, as most JavaScript developers might expect). So passing this value of x as the third parm to vvOut_toJSON would cause the service program to choke as it tried to convert a non-existent 13th array element into JSON.

                  This may be one of the reasons FOR loops are not so popular in RPG...

                  Comment

                  Working...
                  X