Load both numeric and character data using prerun time array in RPGLE

3790 pts.
Tags:
RPGLE array
My pf (arry1) have one numeric field(P) and one alpha numeric field(A),
i declared like this:
   A                     R ARR1                      
   A                        HDDNO          5P         
   A                        HDDNAME       10A       
My RPGLE program:
F arry1       it   f   15        disk                           
d array1           s             15a   dim(6) fromfile(arry1) 
D i                   s              1p 0 inz(1)                 
C                      do        6                              
C     array1(i)     dsply                                    
C                      eval      i=i+1                          
C                      enddo                                    
C                      eval      *inlr = *on                      
my output show character data only with different color....
My question: "how get both character and numeric data using prerun time array in RPGLE.... please share your suggestion.... 
sathish


Software/Hardware used:
as400 v5r3

Answer Wiki

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

<pre>
Farry1 it f 13 disk
Darray1 s 13a dim(6) fromfile(arry1)
Dparray s * inz(%addr(array1))
Darrds ds dim(6) based(parray) qualified
Dnum 5p 0
Dchar 10a
Di s 1p 0 inz(1)
D wrkNum s 5p 0
D wrkChar s 10a
C 1 do 6 i
C eval wrkNum = arrds(i).num
C eval wrkChar = arrds(i).char
C wrkNum dsply
C wrkChar dsply
C enddo
C
C eval *inlr = *on </pre>
1. The way you handled counting i attempted to display (0) — arrays in RPG begin with 1
so I changed the counting loop to go from 1 to 6 populating i as it counts
2. Apparently fixed format dsply – cannot handle the qualified, array, subfield — dsply is rarely used as a production command
3. If something doesn’t work find a work around .. like the use of the WRK fields in above code.
3. Free format dsply works just fine.
<pre>
/free
dsply arrds(i).num;
/end-free
</pre>

Discuss This Question: 24  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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    d array1           s             15a   dim(6) fromfile(arry1) 
    First, you have it as 15a, but it's only 13a. Change it to:
    d array1           s             13a   dim(6) fromfile(arry1) 
    Now, you shouldn't really load a "table" defined the way you have your file set up. You have a packed field in your file. (Why? Get rid of the packed definition and save a lot of trouble.) But if you really want to make things unnecessarily complicated, try adding these lines:
         d p_array                         *   inz( %addr(array1 ))
         d arrDS           ds                  dim( 6 ) based( p_array )
         d                                     qualified
         d  numval                        5p 0
         d  charval                      10a
    my output show character data only with different color.... Of course it does. You don't have character data -- you have a mix of packed and character data in a single field (plus a couple undefined bytes at the end because you only have 13-bytes in the record). The packed bytes show up as invalid characters when you try to display it as character. Also, the undefined bytes might contain any binary pattern. I haven't seen anyone code a new prerun table or array for probably 15 years or more. I suspect that many developers have mostly forgotten them by now. Tom
    125,585 pointsBadges:
    report
  • pdsathishkumar
    d p_array * inz( %addr(array1 )) i got the error in this line: The subfield or parameter definition is not specified within a group. d arrDS ds dim( 6 ) based( p_array ) this line doesn't allow to enter....
    3,790 pointsBadges:
    report
  • philpl1jb
    The subfield or parameter definition is not specified within a group. D specs are either part of a data structure or the like (a group) or stand alone the definion of p_array isn't part of a group definition soooo it must be stand alone which requires the addition of an S. d p_array S * inz( %addr(array1 )) Phil Phil
    51,355 pointsBadges:
    report
  • philpl1jb
    The problem with this line should disappear once the other line is fixed. d arrDS ds dim( 6 ) based( p_array ) this line doesn’t allow to enter….<-- show the error message, in SEU the error will appear at the bottom of the screen. Phil
    51,355 pointsBadges:
    report
  • pdsathishkumar
    i didn't got proper answer, i got same my previous answer: display only character data with different color.... My coding: Farry1 it f 15 disk darray1 s 13a dim(6) fromfile(arry1) Dparray s * inz(%addr(array1)) Darrds ds dim(6) based(parray) D qualified Dnum 5p 0 Dchar 10a Di s 1p 0 inz(1) C do 6 C arrds(i) dsply C eval i=i+1 C enddo C eval *inlr = *on please check it...
    3,790 pointsBadges:
    report
  • philpl1jb
    I think you want something like this ... C arrds(i).numval dsply
    51,355 pointsBadges:
    report
  • TomLiotta
    Yes, first, the pointer needs to be a 'S'tandalone field. I messed that up by leaving the 'S' off of the specification. (I'm not testing this code, just coding samples.) C arrds(i) dsply You can't display the whole DS structure. Phil has it right, as far as I can tell. You have to display the subfields separately because you have mixed data types. You can't display packed and character data together. Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    and all of this for infrequently used method.
    51,355 pointsBadges:
    report
  • TomLiotta
    I'm waiting for "Example of using a 'lookahead' field?" question. Tom
    125,585 pointsBadges:
    report
  • pdsathishkumar
    I’m waiting for “Example of using a ‘lookahead’ field?” before 3 months ago i finished as400 from one institute, now i working as as400 faculty the same institute .... as well as i prepare own project... C arrds(i).num dsply - it not allow to enter, i show below the SEU error message "Entry contains data that is not valid; only valid data is used". after i tried like this -> C num dsply - it's also got below error on compile time.. "The name or indicator NUM is not defined".
    3,790 pointsBadges:
    report
  • philpl1jb
    C arrds(i).num dsply - it not allow to enter, i show below the SEU error message “Entry contains data that is not valid; only valid data is used” SEU .. then it wasn't a run time error, it wasn't even a compile time error, in SEU it can only be a syntax error. SEU wouldn't actually see the data from the file -- it's not loaded until the program is called, so it's simply the syntax of that line. Time to start improving your debug skills. Point at error message, press F1 for more info Use the RPG programming a language manuals In the ILE RPG language reference You will find a possible answer to your sintax problem Hint: it has to do with the command DSPLY and using qualified variable -------------------------- As a teacher, you will need to help your students develop certain skills - understanding specifications - designing solutions - problem analysis -- how to find errors -- how to debug programs -- how to use the manuals. I know, I've done a bit of teaching.
    51,355 pointsBadges:
    report
  • pdsathishkumar
    thanks for your advice Mr. Phil... i was learn as400 with short time from my institute... after i join there... so now only i learning rpg... Hint: it has to do with the command DSPLY and using qualified variable please clear my syntax error....
    3,790 pointsBadges:
    report
  • philpl1jb
    - problem analysis – how to find errors – how to debug programs – how to use the manuals. <--
    51,355 pointsBadges:
    report
  • pdsathishkumar
    Mr. Phil, i got your point's... but i can't find the solution... please give me the suggestion..... i m not a experience program in as400.... now only i developing this.... from here....
    3,790 pointsBadges:
    report
  • philpl1jb
    Google: ILE RPG language reference Search book for DSPLY You will find your answer thee. Phil
    51,355 pointsBadges:
    report
  • pdsathishkumar
    found the answer from Google , arrds.num dsply but i don't know, how to increase array element position... C do 6 C arrds.num dsply C eval i=i+1 C enddo
    3,790 pointsBadges:
    report
  • TomLiotta
    C arrds(i).num dsply Can you post that in {code} for mat please? It's difficult to determine the true statement when spaces are condensed out. Tom
    125,585 pointsBadges:
    report
  • pdsathishkumar
    Farry1 it f 15 disk Darray1 s 13a dim(6) fromfile(arry1) Dparray s * inz(%addr(array1)) Darrds ds dim(6) based(parray) D qualified Dnum 5p 0 Dchar 10a Di s 1p 0 inz(1) C do 6 C arrds.num dsply C eval i=i+1 C enddo C eval *inlr = *on this is my coding, my output has show only single value repeated.... i don't know how to increase array position..
    3,790 pointsBadges:
    report
  • philpl1jb
    The manual said that qualified fields must be shown in the RESULT column. Perhaps like this C dsply arrds(i).num C dsply arrds(i).char
    51,355 pointsBadges:
    report
  • pdsathishkumar
    C dsply arrds(i).num C dsply arrds(i).char Mr. Phil, i tried your hint, but it not allow to enter. i got same error message, “Entry contains data that is not valid; only valid data is used”. i refer ILE RPG language reference book, but i can't get solution... please give any suggestion....
    3,790 pointsBadges:
    report
  • philpl1jb
    1. Arrays in rpg are from 1 to 6 not 0 to 5, so I changed the way that I was computed 2. The Dsply is a very only command today only used for debugging and qualified data structures are a fairly new addition to RPG IV. The manuals say to put the qualified subfield in the DSPLY - RESULT column .. but that didn't work. Soooooooooo then you develop a work around like I did with the WRK fields below
    Farry1     it   f   13        disk                                    
    Darray1           s             13a   dim(6) fromfile(arry1)          
    Dparray           s               *   inz(%addr(array1))              
    Darrds            ds                  dim(6) based(parray) qualified  
    Dnum                             5p 0                                 
    Dchar                           10a                                   
    Di                s              1p 0 inz(1)                          
    D wrkNum          s              5p 0                                 
    D wrkChar         s             10a                                   
    C     1             do        6             i                         
    C                   eval      wrkNum  = arrds(i).num                  
    C                   eval      wrkChar = arrds(i).char                 
    C    wrkNum        dsply                                             
    C    wrkChar       dsply                                             
    C                   enddo                                             
    C                   eval      *inlr = *on                 
    
    In RPG IV Free format, the dsply works just fine
     /free                                              
                        dsply         arrds(i).num;     
     /end-free                                          
    
    Phil
    51,355 pointsBadges:
    report
  • TomLiotta
    The manual said that qualified fields must be shown in the RESULT column. Actually, I think the manual reference is simply saying that qualified names may be used as the Result value. The implication to me is that qualified names can't be used for Factor 1 nor Factor 2, in fixed format. I'd say that either the code to pull the values into work fields like wrkNum and wrkChar or the switch to free-form are the only real options if DSPLY is going to be used. Tom
    125,585 pointsBadges:
    report
  • pdsathishkumar
    Thanks Mr. Phil and Tom, i got the answer from your coding... can you do one favor for me... i want to know, where and which place, i can use the qualified variable.... i search that, but i can't get the explanation about qualified variable.... if help clear my doubt....
    3,790 pointsBadges:
    report
  • philpl1jb
    Sorry, I don't have such a list. I suspect that fixed format dsply is more of an excepotion than a rule. DSPLY isn't used in production. Phil
    51,355 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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following