DO loop through field names ending in a numeric

Hello Experts,

I have a RPGLE question concerning looping though field names instead of having multiple routines with each field name.

Exp.   I have field names FIELD1, FIELD2, FIELD3, etc.   I know in the past(I've been away from AS/400 for years) I would use a DOU loop something like this.

DOU I = 10
FIELD,I      CHAIN    FILE       99

How do I do that in RPGLE?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Phillip KnoxSenior Systems AnalystCommented:
In free form or RPGIV?
Phillip KnoxSenior Systems AnalystCommented:
In your example, it looks like you're chaining with an array element?
MurpheyApplication ConsultantCommented:
Define the field1, field2, field3 etc in a Datastructure and do an overlay with an array
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

CompTech810Author Commented:
RPGLE.   In the example it should, from what I remember, it places the number at the end of FIELD, so if it is in it's first loop the field name would be FIELD1, then next loop FIELD2, etc.   I wish I had that old code I did.   I'm thinking Murphey is close to what I did, this was in RPGIV a long time ago.
MurpheyApplication ConsultantCommented:
Oke CompTech810

Here is some code in good old RPG :-)
D FieldsDs        Ds                                       
D Field01                       10A                        
D Field02                             Like(Field01)        
D Field03                             Like(Field01)        
D Field04                             Like(Field01)        
D Field05                             Like(Field01)        
D Field06                             Like(Field01)        
D Field07                             Like(Field01)        
D Field08                             Like(Field01)        
D Field09                             Like(Field01)        
D Field10                             Like(Field01)        
D Field                               Like(Field01) Dim(10)
D                                     Overlay(FieldDs)

Open in new window

Or if you like in fullfree, it must be look like this:
Dcl-Ds FieldDs;                                    
     Field01 Char(10);                               
     Field02 Like(Field01);                          
     Field03 Like(Field01);                          
     Field04 Like(Field01);                          
     Field05 Like(Field01);                          
     Field06 Like(Field01);                          
     Field07 Like(Field01);                          
     Field08 Like(Field01);                          
     Field09 Like(Field01);                          
     Field10 Like(Field01);                          
     Field   Like(Field01)    

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CompTech810Author Commented:
Thanks!  I really thought there was an easier solution that I did in the past.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.