Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

First Interactive Program 1

Status
Not open for further replies.

rstitzel

MIS
Apr 24, 2002
286
US
I'm fairly new to RPG programming and so far have only created non-interactive programs. Mainly rewriting RPG II programs in RPG ILE.

I'm working on my first interactive program that was written in RPG II and have a couple of questions.

Using Code Designer I've created the display file and three records (screens) that I'll need.

In my second form is where a user fills out up to 32 fields named qtycode1, qtycode2, qtycode3 etc. To eliminate a key stroke we have the user key both the product quantity and product code in the same field. In my rpg program I have a few arrays set up.

D QTYCODE 8 0 (DIM32)
D QTY 5 0 (DIM32)
D CODE 3 0 (DIM32)

In my program I want to move all the data from the fields into my array QTYCODE. To separate out qty from code I MOVE qtycode array into the CODE array. And then I MOVEL qtycode array into the QTY array.

MY QUESTION IS "HOW DO I GET ALL THE FIELDS FROM THE SCREEN INTO MY QTYCODE ARRAY".

Thanks in advance for any and all help.

 
QtyCode(1) = QtyCode1;
QtyCode(2) = QtyCode2;
.
.
etc
.
.
QtyCode(32) = QtyCode32;

That's the only way I can think of.
Have you thought about using a subfile for the user to input the product quantity and product code? Then you just need to process the subfile to load the array, maybe something like this:
Code:
A = 1;
ReadC Subfile;
DoW Not %EoF and A <= %Elem(QtyCode);
  QtyCode(A) = InQtyCode;  
  ReadC SubFile;
EndDo;

The InQtyCode would be the field name in the subfile that the user is typing the data into.


RedMage1967
IBM Certifed - RPG IV Progammer
 
Thanks again RedMage. I'm very new to RPG and haven't used a subfile as of yet. But it sounds like a good way to accomplish what I'm doing.

I'm going to &quot;play&quot; with it and see if I can get it to work.

Thank you
 
I'm trying to set up a subfile in Code Designer. I can get all the data fields I need but can't get Headers/Titles. When I add a text constant in the ctl file it repeats the text constant as many times as I have data fields?! What I read told me that the control file is where you need to put fields and constants that you only want to appear once. I click on the ctl record and choose design and then try inserting a text constant. What am I doing wrong?

Sorry to be a pest.....Thanks in advance for any and all help.

 
Ok. I have the subfile set up for my second screen and have coded my program as you suggested above.

A = 1;
ReadC Subfile;
DoW Not %EoF and A <= %Elem(QtyCode);
QtyCode(A) = InQtyCode;
A = A + 1
ReadC SubFile;
EndDo;

When the user hits enter the code above is run and my QTYCODE array gets filled in from the data on the screen. I then break the QTYCODE array into two other arrays QTY & CODE. I then use the CODE to get the price and description and then I use QTY to extend the price.

So after I have processed all the data on the second screen I have 4 arrays QTY, CODE, DESC, EXTAMT that have all the data I need for the next screen.

I then have a third and final screen that I've created as a subfile. The fields are FQTY, FCODE, FDESC, FEXTAMT. I need to get the data from arrays from the second screen into the fields on the third screen.

This is what I thought I could do:
x = 1
dow not %eof and x <= 32
read verify
Fqty = Qty(x)
Fcode = Code(x)
Fdesc = Desc(x)
Fextamt = Extamt(x)
x = x + 1
read verify
enddo
exfmt verify

Would that work or there another way to do it?

Thank you.


 
That looks like it should work to me. I just don't see where your writting to your subfile. I'm a little rusty of subfiles myself. But, I see your reading from the subfile, loading the fields, and then reading the subfile again. I think all you need to do is to write to the subfile. Try this:

Code:
X = 1;
DoW X <= %Elem(Qty);
  FQty = Qty(X);
  FCode = Code(X);
  FDesc = Desc(X);
  FExtAmt = ExtAmt(X);
  Write Verify;
  X = X + 1;
EndDo;
ExFmt Verify;

Alternately, you could use a &quot;For&quot; loop instead.

Code:
For X = 1 to %Elem(Qty);
  FQty = Qty(X);
  FCode = Code(X);
  FDesc = Desc(X);
  FExtAmt = ExtAmt(X);
  Write Verify;
EndFor;
ExFmt Verify;

Using a &quot;For&quot; loop eliminates a couple of lines of code, since you don't need to initialize the counter (X) and you don't need to increment it (X = X + 1), the FOR takes care of both steps for you.

RedMage1967
IBM Certifed - RPG IV Progammer
 
rstitzel, do you ever get to the Cascade400 users group meeting?

RedMage1967
IBM Certifed - RPG IV Progammer
 
I haven't gone. I talk to Dave Ludeman once in a while and he sends me the invites to the Cascade400 users group but just haven't gone yet.

What about you? Do you live in the NW and attend these meetings?
 
I try to attend as many as I can. I also work in Portland. I used to work for Tim Archer when we both worked for AIS.

RedMage1967
IBM Certifed - RPG IV Progammer
 
I remember AIS. I worked with them many years ago (10) on a networking project. I will eventually start attending. The one's downtown are on my way home. Perhaps we will meet in person someday :)

One of my job responsibilities is rewriting all our RPG II/III programs into RPG IV (which I'm new to) so I really appreciate all your help with the questions I've been posting.

Take care.

 
If you need any help in the re-write, please don't hesitate to ask.

RedMage1967
IBM Certifed - RPG IV Progammer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top