Data structure with array AS/400

220 pts.
Tags:
AS/400
AS/400 Arrays
Sorry, I do not know how to explain this. I was expecting this can be work but it can't. It seems like will getting decimal data error. Can someone help on this?
Field of FLD0 to FLD9 is from a PF which is 15,2.
DS

FLD          DIM(10) LIKE(FLD0)

FLD0 FLD1 FLD2 FLD3 FLD4 FLD5 FLD6 FLD7

FLD8

FLD9

XFOOT   FLD     TOTAL
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 12  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.
  • deepu9321
    Whats the length of your Total field. 

    And, Are you declaring file fields in DS again for copying the data to arrays? Or, Handling that in a program. 

    Bit more details would help.
    4,980 pointsBadges:
    report
  • pdraebel
    Decimal Data Error: Initialize all subfields to zero.
    7,545 pointsBadges:
    report
  • yeepiyaya
    Length of TOTAL is 15,2. 
    FLD0 to FLD9 is a field from PF.I was thinking whether when i read the file, the array FLD(x) would have the value if i using ds.
    I know It can be work if i do like
    EVAL FLD(1) = FLD0 untill FLD(10) = FLD9.

    220 pointsBadges:
    report
  • BigKat
    try this, and total should be bigger than fld0-9 to handle the summation if they were all 9999999999999.99
    d total           s             17p 2                   
    d fields          ds                                    
    d fld0
    d fld1
    d fld2
    d fld3
    d fld4
    d fld5
    d fld6
    d fld7
    d fld8
    d fld9
    d fld                                 dim(10) like(fld0)
    d                                     overlay(fields:1) 
     /free                                                  
        //for every record you read from your file with fld0-9
        total = %xfoot(fld);                                
        //will sum them up.
     /end-free          
    9,460 pointsBadges:
    report
  • yeepiyaya
    Hi BigKat, can i code like this? What does overlay mean? I did google it but seems not understand.
    d fields          ds                                    
    d fld                                dim(10) like(fld0)
    d                                    overlay(fields:1)
    d fld0
    d fld1
    d fld2
    d fld3
    d fld4
    d fld5
    d fld6
    d fld7
    d fld9
    220 pointsBadges:
    report
  • yeepiyaya
    Hi, What if I do like this, i getting decimal data error because of field fld0wk. why?
    d fields          ds                      
    d fld0wk                          like(fld1)
    d fld1
    d fld2
    d fld3
    d fld4
    d fld5
    d fld6
    d fld7
    d fld8
    d fld9
    d fld                                 dim(10) like(fld0)
    d                                     overlay(fields:1) 
    220 pointsBadges:
    report
  • pdraebel
    Did you take a Dump for the error and looked at it ? Probably its value in Hex is all X'40'. Inititalize !!
    7,545 pointsBadges:
    report
  • pdraebel
    Declare like this:
    d fld        dim(10) like(fld0) inz

    In case fld0 is a numeric field the inz keyword will automatically initialize all array elements to zero.
    7,545 pointsBadges:
    report
  • yeepiyaya
    Hi pdraebel, only the declared field fld0wk getting value in Hex. But why ?
    220 pointsBadges:
    report
  • yeepiyaya
    i did initialize that field.
    220 pointsBadges:
    report
  • pdraebel
    Probably as it is part of the DS. That should by default be an Alfa-Numeric field. Hence it would be all Hex'40' (blanks) at the beginning.
    7,545 pointsBadges:
    report
  • lance2221357
    My method as follow:
    D SALES_DS      E DS                  EXTNAME(PF:*INPUT)    
    D  AMT_AREA               5     84                                
    D  SALES                        15P 2 DIM(10)                     
    D                                     OVERLAY(AMT_AREA)       
    1. amt_area : fld0~fld9 total 80 bytes. 
    2. check %found(pf)   then %xfoot
    270 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: