qualified data structure as an array

2460 pts.
Tags:
AS400 V7.3
Hi , 
How to use qualified data structure as an array. tried below code but it's not working:- dds1 ds qualified dim(4) dstuid 6p 0 dstudname 20 dmarks 5p 2 c eval stuid=01 c eval studname='A' c eval marks=10 c eval stuid=02 c eval studname='B' c eval marks=20 c eval stuid=03 c eval studname='B' c eval marks=30 C eval ds1(1) c eval *inlr=*on

Thanks


Software/Hardware used:
AS400
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

also how can we insert different values in this array type data structure and fetch them at a single time like runqry displays all the values stored in file similarly how to display all these values stored in this array type data structure.

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • TheRealRaven
    First, because it's "qualified", you need to qualify the references:
    c                eval   ds1.stuid=01 
    Second, because the DS is dim(), you need to specify an index:
    c                eval   ds1(1).stuid=01 
    The index goes with DS1 because that's what has dim(). Each of the DS sub-fields must be similarly referenced with the indexed qualification.

    In your example code, you don't really need to declare an index variable. The index values can all be literals. But if it gets any more complex, an index variable will be useful:
    d i               s             10i 0
    c                eval   i = 1
    c                eval   ds1(i).stuid=01 

    Finally, if you're going to be using qualified DS arrays, it's strongly advised that you code in /free-form rather than fixed-form. Do it now before learning that the whole set of code needs to be converted later.
          i = 1
          ds1(i).stuid=01 
    33,210 pointsBadges:
    report
  • 6r
    Thanks,but when the value of marks field is being displayed by this program it's displaying 15 to 1500 and 20 to 2000 why these extra 2 zeros are being displayed where as values being inserted in this field(marks) are 15,20 only in debug mode how ever  it shows correctly it's value are after  ds1(1).marks=15 to 015.00 (as it's length is defined as 5p,2 (2 decimal positions and length as 5 and data type as packed decimal).

    Thanks 
    2,460 pointsBadges:
    report
  • 6r
    it's happening when DSPLY command is being used to display field values like as followings:-
                             DSPLY ds1(1).stuid;                                          
                          DSPLY ds1(1).studname;                                       
                           DSPLY ds1(1).marks; 

    id is getting displayed correctly only problem is with the 'marks' field here.
    2,460 pointsBadges:
    report
  • 6r
    any idea why marks field is not displaying the correct values inserted in it in this example?
    2,460 pointsBadges:
    report
  • 6r
    any updates by experts please?
    2,460 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: