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!

More Subfile Questions

Status
Not open for further replies.

rstitzel

MIS
Apr 24, 2002
286
US
I have an interactive program with 3 screens.

The second screen is a subfile with the names: DATAENTRY & DATAENTCTL. The subfile contains two fields INCODE AND INQTY. The user inputs a product code and quantity. I perform some error checking and redisplay the file if an error is found. Until I have NO ERRORS.

I then want to display a third screen. On this screen I have a subfile with the names VERIFY & VERIFYCTL. The subfiles contains 4 fields FCODE, FQTY FDESC AND FEXTAMT. I want to take each of the product codes entered on the 2nd screen perform a chain to our price file, get the product description and calculate an extended cost. I then want to fill in the fields on the 3rd screen. Currently when the 3rd screen is display it is full of empty fields.

You don't have to give me the exact code but a rough idea of what needs to be done would be very helpfull.

Thanks in advance for any and all help.
 
Do you have the keys to the price file in the second subfile record? If you don't need to display them, put them in the record as hidden fields - that could be why you're not getting any hits while loading the third screen.



"When once you have tasted flight, you will forever walk the Earth with your eyes turned skyward, for here you have been, and there you will always long to return."

--Leonardo da Vinci

 
This is how my program works. On the first screen the user inputs a BLOCK number and a ROUTE number.

On the second screen the user inputs Product Code and Quantity.

The key to the price file is a combination of BLOCK# AND PRODUCT#. For example block # = 5, product code = 103. The key would be 5103. So there is no way to link the screen with the price file. At least I don't know how.

In my rpg program I combine the block and code into one variable and chain out to the price file to perform my error checking.

After the screen is error free I want to display a final screen that shows Code, Quantity, Description & Extended Amount.

So what I want to do is loop through the dataentry subfile. Chain to the price file and get up the description and calculate the price. Then fill in the 3rd screen with this data.

How can this be done.

Thank you!



 
Here's my code so far. It may make it easier to understand what I'm doing :)

RPG CODE:
F**********************************************************************************************
F*** Company..........................Alpenrose Dairy
F*** Program Name.....................Lansadev/Qrpglesrc/WIN080RS
F*** Program Alias....................Driver Add to Load Program
F*** Author...........................Robert B. Stitzel
F*** Purpoase.........................Interactive Program to Add Products To Driver's Loads
F**********************************************************************************************
FWMPRIC IF E K DISK Price File
FWACOMM IF E K DISK Communication File
FWRTFIL IF E K DISK Wholesale Route File
FSPECLD O E DISK Add to Order File
FSPECRC O E DISK Add to Order Randy's
FREPORT O F 85 PRINTER Printer File
FWIN080COPYCF E WORKSTN SFILE(DATAENTRY:RRN)
F SFILE(VERIFY:RRN)
F INDDS(INDREFS)
D**********************************************************************************************
DCOUNTER S 4 0
DD S 1 0 Day Number
DDDATE S 6 0
DDYYWWD S 5 0
DRRN S 2 0 Relative Rec Number
DX S 2 0 Counter for Loops
DPKEY S 4 0 Product Key
DDAYNAME S 3 Week Day Name
DBLANK S 16 Used to Clear ErrMsg
DWRK12 S 12 0 Numeric 12 Digits
DPTIME S 6 0 Time
DPDATE S 6 0 Date
DQTYCODE S 8 0 DIM(32) Quantity/Code
DCODE S 3 0 DIM(32) Product Code
DCODETEST S 3 0 DIM(32) Testing Codes
DQTY S 5 0 DIM(32) Quantity
DDESC S 16 DIM(32) Product Description
DLOADOUTSEQ S 3 0 DIM(32) Load Out Sequence
DCOOLERSEQ S 3 0 DIM(32) Cooler Sequence
DEXTAMT S 10 2 DIM(32) Extended Amount
DERRORS S 70 DIM(10) Error Messages
D*** Indicator Data Structure
DINDREFS DS 99 Indicator DS
DACCEPTQTY 04 04N F4 Accepts Qty >1000
DACCEPTORDER 05 05N Accepts Order
DDISPSUBFILE 30 30N Display SF Ctl File
DINITSUBFILE 31 31N Creates Entry Fields
DNEXTCHGREC 33 33N Next Chg Record Ind
DSHOWERRMSG 50 50N Show Err Msg Indicat
DERRIND 70 70N Error Indicator
DEXIT 03 03N F3 Exit Program
C**********************************************************************************************
C *INZSR BEGSR Initial SubRoutine
C 001 CHAIN WACOMM Read Communic File
C MOVEL WALFOR DYYWWD Last Forecast Date
C MOVE DYYWWD D Day Number
C MOVE WACFDT DDATE Forecast Date
C MOVE ' ' BLANK
C TIME WRK12
C MOVEL WRK12 PTIME
C MOVE WRK12 PDATE
C*** Assign Delivery Day Name to DAYNAME Variable. Used in Report
C IF D =1
C EVAL DAYNAME ='MON'
C ELSEIF D =2
C EVAL DAYNAME ='TUE'
C ELSEIF D =3
C EVAL DAYNAME ='WED'
C ELSEIF D =4
C EVAL DAYNAME ='THU'
C ELSEIF D =5
C EVAL DAYNAME ='FRI'
C ELSEIF D =6
C EVAL DAYNAME ='SAT'
C ENDIF
C*** Move Day Number and Date to Corresponding Fields in the Display File
C MOVEL D FDAY
C MOVEL DDATE FDATE
C EVAL SHOWERRMSG =*OFF
C EVAL ERRIND =*OFF
C*** Assign Error Messages
/FREE
ERRORS(1) = 'THERE ARE ERRORS ON THE PAGE, PLEASE CORRECT';
ERRORS(2) = 'INVALID DATE, PLEASE CORRECT';
ERRORS(3) = 'INVALID ROUTE, PLEASE CORRECT';
ERRORS(4) = 'QUANTITY IS OVER 1000, SELECT F4 TO ACCEPT';
ERRORS(5) = ' INACTIVE PRODUCT CODE, PLEASE CORRECT';
ERRORS(6) = 'INVALID BLOCK, MUST BE 0 OR 5, PLEASE CORRECT';
/END-FREE
C EXSR SCREEN1
C ENDSR
C**********************************************************************************************
C*** DISPLAY SCREEN 1 "INPUT"
C**********************************************************************************************
C SCREEN1 BEGSR
C SCREEN1TAG TAG
C EXFMT INPUT
C EXSR INPUTSR
C IF ERRIND =*ON
C GOTO SCREEN1TAG
C ELSE
C EVAL NEXTCHGREC =*OFF
C EXSR SCREEN2
C ENDIF
C ENDSR
C**********************************************************************************************
C*** PROCESS SCREEN 1 "INPUT"
C**********************************************************************************************
C INPUTSR BEGSR
C*** End Program if User Pressed F3
C IF EXIT =*ON
C EXSR ENDPROGRAM
C ENDIF
C IF EXIT =*OFF
C*** Check for Valid Block Number (0 or 5 only)
C EVAL ERRIND =*OFF
C EVAL SHOWERRMSG =*OFF
C*** Check for Valid Block Number 0 or 5
C IF BLOCK <>0
C IF BLOCK <>5
C EVAL ERRIND =*ON
C EVAL SHOWERRMSG =*ON
C MOVE ERRORS(6) ERRORMSG
C LEAVESR
C ENDIF
C ENDIF
C*** If Block is Correct, Check to see if Route is Valid
C BLOCK IFEQ 0
C BLOCK OREQ 5
C ROUTE CHAIN WRTFILR
C*** If Route Not Found, Display Error Message
C IF NOT %FOUND
C EVAL ERRIND =*ON Set Error Indicator
C EVAL SHOWERRMSG =*ON
C MOVE ERRORS(3) ERRORMSG Invalid Route
C LEAVESR
C*** Otherwise continue processing
C ELSE
C EVAL ERRIND =*OFF No Errors
C EVAL SHOWERRMSG =*OFF Hide Error Field
C EVAL DISPSUBFILE =*ON
C EVAL INITSUBFILE =*ON Initialize Form
C ENDIF
C ENDIF
C ENDIF
C ENDSR
C**********************************************************************************************
C*** DISPLAY SCREEN 2 &quot;DATAENTRY&quot;
C**********************************************************************************************
C SCREEN2 BEGSR
C SCREEN2TAG TAG
C WRITE DFOOTER
C EXFMT DATAENTCTL
C EXSR DATAENTRYSR
C IF ERRIND =*ON
C GOTO SCREEN2TAG
C ELSE
C WRITE DATAENTCTL
C EVAL SHOWERRMSG =*OFF
C EVAL ERRIND =*OFF
C EVAL DISPSUBFILE =*ON
C EVAL INITSUBFILE =*ON
C EXSR SCREEN3
C EXSR ENDPROGRAM
C ENDIF
C ENDSR
C**********************************************************************************************
C*** PROCESS SCREEN 2 &quot;DATAENTRY&quot;
C**********************************************************************************************
C DATAENTRYSR BEGSR
C IF EXIT =*ON
C EXSR ENDPROGRAM
C ENDIF
C*** Initialize Indicators
C EVAL ERRIND =*OFF
C EVAL SHOWERRMSG =*OFF
C EVAL INITSUBFILE =*OFF
C*** Clear Arrays
C CLEAR CODETEST
C*** Move data from display fields into array
C Z-ADD 1 X
C READC DATAENTRY
C DOW NOT %EOF
C MOVE INCODE CODETEST(X)
C*** Create KEY to chain out to Price File
C MOVE BLOCK PKEY
C MOVE CODETEST(X) PKEY
C*** Look for Product Code
C PKEY CHAIN WMPRIC
C*** If not Found, Invalid Product Code, Display Error Message
C IF NOT %FOUND
C EVAL NEXTCHGREC =*ON
C EVAL SHOWERRMSG =*ON
C EVAL ERRIND =*ON
C MOVEL ERRORS(1) ERRORMSG
C EVAL INDESC ='INVALID'
C UPDATE DATAENTRY
C EVAL NEXTCHGREC =*OFF
C ENDIF
C*** If Valid Product Check if Active
C IF %FOUND
C PPDELT IFEQ 'D'
C PPDELT OREQ 'I'
C EVAL NEXTCHGREC =*ON
C EVAL SHOWERRMSG =*ON
C EVAL ERRIND =*ON
C MOVEL ERRORS(1) ERRORMSG
C EVAL INDESC ='INACTIVE'
C UPDATE DATAENTRY
C EVAL NEXTCHGREC =*OFF
C ENDIF
C ENDIF
C X ADD 1 X
C READC DATAENTRY
C ENDDO
C ENDSR
C**********************************************************************************************
C*** DISPLAY SCREEN 3 &quot;VERIFICATION SCREEN&quot;
C**********************************************************************************************
C SCREEN3 BEGSR
C WRITE VFOOTER
C EXFMT VERIFYCTL
C ENDSR
C**********************************************************************************************
C*** DISPLAY VERIFICATION SCREEN
C**********************************************************************************************
C**********************************************************************************************
C*** WRITE THE ORDER
C**********************************************************************************************
C POSTORDER BEGSR
C Z-ADD 1 X
C EXCEPT HEADER1
C EXCEPT HEADER2
C EXCEPT HEADER3
C OPEN SPECLD Open Spec Load File
C OPEN SPECRC Open Spc Load Randy
C DOW NOT %EOF
C IF CODE(X) >0
C Z-ADD ROUTE ROUTENUM
C Z-ADD BLOCK BLOCKNUM
C Z-ADD LOADOUTSEQ(X) LOSEQ
C Z-ADD 0 CUSTCODE
C Z-ADD BLOCK PBLOCK
C Z-ADD CODE(X) PRODCODE
C Z-ADD QTY(X) SLQTY
C Z-ADD 0 ROUTESEQ
C Z-ADD 0 SEQSEPLD
C Z-ADD COOLERSEQ(X) CLRSEQ
C WRITE SPECLDR
C WRITE SPECRCR
C EXCEPT DETAILS
C ENDIF
C X ADD 1 X Increment Counter
C ENDDO
C*** End Program
C EVAL *INLR =*ON
C RETURN
C ENDSR
C ENDPROGRAM BEGSR
C EVAL *INLR =*ON
C RETURN
C ENDSR
O**********************************************************************************************
OREPORT E HEADER1
O 8 '* * *'
O 29 'DRIVER ADD TO LOAD'
O 37 '* * *'
O PDATE Y 47
O PTIME 57 ' : : '
O ROUTE 72
O 69 'ROUTE'
O DYYWWD 80
O E HEADER2 1
O 66 'DELIVERED'
O DAYNAME 70
O DDATE Y 80
O 46 'BLOCK'
O BLOCK 48
O E HEADER3 2
O 9 'QTY'
O 20 'CODE'
O 39 'DESCRIPTION'
O E DETAILS 2
O CODE(X) 20 Product Order Code
O QTY(X) J 10 Product Order Qty
O DESC(X) 42 Product Description

DDS Code:
A*%%TS DD 20031001 141501 QUSER REL-V5.1 iSeries WDT
A*%%FD Driver's Add to Load Display File
A*%%EC
A DSPSIZ(24 80 *DS3)
A REF(LANSADEV/WMPRIC WMPRICR)
A INDARA
A R INPUT TEXT('MAIN INPUT SCREEN')
A*%%TS DD 20030929 123344 QUSER REL-V5.1 iSeries WDT
A CF03(03 'Exit')
A 3 5'Wholesale Driver Add to Load Progr-
A am'
A 8 5'Enter Block and Route Number, and -
A then Press ENTER:'
A COLOR(WHT)
A 11 5'Block#:'
A BLOCK 1Y 0B 11 14TEXT('BLOCK NUMBER')
A EDTCDE(3)
A 11 20'Route#:'
A ROUTE 2Y 0B 11 29TEXT('ROUTE NUMBER')
A EDTCDE(3)
A 11 36'Day#:'
A FDAY 1Y 0O 11 43TEXT('DAY NUMBER')
A EDTCDE(3)
A 11 49'Date:'
A FDATE 6Y 0O 11 56TEXT('DELIVERY DATE')
A EDTWRD(' / / ')
A 22 5'F3-Exit'
A COLOR(WHT)
A 70 ERRORMSG 70 O 24 5TEXT('ERROR MESSAGES')
A COLOR(RED)
A N50 DSPATR(ND)
A DSPATR(HI)
A DSPATR(BL)
A 2 5'Alpenrose Dairy'
A 2 67'WIN080RS'
A COLOR(WHT)
A*%%GP ADDTOLOAD 01
A R DATAENTRY
A*%%TS DD 20031001 135546 QUSER REL-V5.1 iSeries WDT
A SFL
A 33 SFLNXTCHG
A INCODE 3Y 0B 5 6TEXT('ORDER CODE INPUT FIELD')
A EDTCDE(4)
A INQTY 5S 0B 5 13TEXT('ORDER QUANTITY INPUT FIELD')
A INDESC 10 O 5 22TEXT('ERROR DESCRIPTION')
A 70 DSPATR(RI)
A*%%GP ADDTOLOAD 02
A*%%GP UNTITLED 01
A R DATAENTCTL
A*%%TS DD 20031001 120856 QUSER REL-V5.1 iSeries WDT
A SFLCTL(DATAENTRY)
A 30 SFLDSP
A SFLPAG(32)
A SFLSIZ(32)
A CF03(03 'Exit')
A SFLDSPCTL
A 31 SFLINZ
A SFLRNA
A OVERLAY
A CF04
A SFLLIN(5)
A 2 5'D R I V E R A D D T O L O A D'
A 2 41'Block:'
A BLOCK 1Y 0O 2 49TEXT('BLOCK NUMBER')
A EDTCDE(3)
A 2 54'Route:'
A ROUTE 2Y 0O 2 62TEXT('Route Number')
A EDTCDE(3)
A 4 6'CODE'
A COLOR(WHT)
A DSPATR(UL)
A 4 13'QTY.'
A COLOR(WHT)
A DSPATR(UL)
A 4 37'CODE'
A COLOR(WHT)
A DSPATR(UL)
A 4 44'QTY.'
A COLOR(WHT)
A DSPATR(UL)
A 4 22'ERROR DESC'
A COLOR(WHT)
A DSPATR(UL)
A N70 DSPATR(ND)
A 4 53'ERROR DESC'
A COLOR(WHT)
A DSPATR(UL)
A N70 DSPATR(ND)
A*%%GP ADDTOLOAD 03
A*%%GP UNTITLED 02
A R VERIFY
A*%%TS DD 20031001 141501 QUSER REL-V5.1 iSeries WDT
A SFL
A FCODE 3Y 0B 5 4EDTCDE(3)
A FQTY 5S 0B 5 9
A FDESC 16 B 5 17TEXT('PRODUCT DESCRIPTION')
A*%%GP ADDTOLOAD 04
A R VERIFYCTL
A*%%TS DD 20031001 141501 QUSER REL-V5.1 iSeries WDT
A SFLCTL(VERIFY)
A 30 SFLDSP
A SFLPAG(32)
A SFLSIZ(32)
A CF05
A SFLLIN(5)
A CF03(03 'Exit')
A CF04(04 'Accept Quantity')
A SFLDSPCTL
A 31 SFLINZ
A SFLRNA
A OVERLAY
A 2 4'D R I V E R A D D T O L O A D'
A ROUTE 2Y 0O 2 54EDTCDE(3)
A COLOR(WHT)
A FDATE 6Y 0O 2 58COLOR(WHT)
A EDTWRD(' / / ')
A 4 4'Num'
A COLOR(WHT)
A 4 9'Qty.'
A COLOR(WHT)
A 4 17'Description'
A COLOR(WHT)
A 4 38'Num'
A COLOR(WHT)
A 4 43'Qty.'
A COLOR(WHT)
A 4 51'Description'
A COLOR(WHT)
A*%%GP ADDTOLOAD 05
A R DFOOTER TEXT('FOOTER FOR DATA ENTRY SCREEN')
A*%%TS DD 20031001 120856 QUSER REL-V5.1 iSeries WDT
A 22 5'Push ENTER to Process Order -
A F3- Exit Program'
A COLOR(WHT)
A 70 ERRORMSG 70 O 24 5TEXT('ERROR MESSAGE HOLDER')
A N50 DSPATR(ND)
A COLOR(RED)
A R VFOOTER TEXT('FOOTER FOR VERIFY SCREEN')
A*%%TS DD 20030929 090905 QUSER REL-V5.1 iSeries WDT
A 70 ERRORMSG 70 O 24 5TEXT('ERROR MESSAGE HOLDER')
A COLOR(RED)
A DSPATR(BL)
A N50 DSPATR(ND)
A 22 2'F3-Exit F5-Accept Order'
A COLOR(YLW)
 
I asked before if you were using hidden fields in the subfile record in the display file. Hidden fields have type H (instead of I, O, or B). There are in the subfile record, you just can't see them on the screen. You can add the key fields that you need to chain to your file as hidden fields:

Code:
     A          R DTADIS                                                  
     A                                      SFL                           
     A            HIDTYP         3A  H                                    
     A            HIDAMT         9S 2H                                    
     A            NBRCRD         3S 0H                                    
     A            CNDTIA         9S 2H                                    
     A            CNDDIS         9S 2H                                    
     A            PRGSEQ         3S 0H                                    
     A            CNDGRP         5A  H                                    
     A            CNDTYP         3A  H                                    
     A            CNDNCD         1A  H                                    
     A            WKSORT         3S 0H                                    
     A            CNDPNO    R        O 13  3REFFLD(CND/CNDPNO *LIBL/ARCND)
     A  85                                                                
     AON82                                  DSPATR(ND)                    
     A            CNCCSQ    R        O 13 14REFFLD(CNC/CNCCSQ *LIBL/ARCNC)
     A  85                                  DSPATR(ND)                    
     A            DESC1         30A  O 13 18

This is an example form a subfile data record that we use. All but the last 3 fields on it are hidden. The otheres are populated before the subfile record format is written with a WRITE. With those hidden fields, we have all the information we need for popup windows, and so forth. When the user selects a particular record, you find it with the READC opcode and you have all the information you need.

I hope this gives you some ideas you can use.


&quot;When once you have tasted flight, you will forever walk the Earth with your eyes turned skyward, for here you have been, and there you will always long to return.&quot;

--Leonardo da Vinci

 
Could you also give me the rpg code example so I can see how it's implemented in code. Thank you.
 
Nothing really to it; you just make sure that all of your key fields to the file are on the subfile record (either hidden or visible). Then, using the KLIST with those fields, chain to your file. If you get a hit, write to your subfile record, and increment the RRN. Then you can display it.

I don't have a convenient sample, sorry.


&quot;When once you have tasted flight, you will forever walk the Earth with your eyes turned skyward, for here you have been, and there you will always long to return.&quot;

--Leonardo da Vinci

 
No that gives me enough information. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top