Question

  Asked: Dec 13 2007   5:22 AM GMT
  Asked by: Leiloon


READ FROM SUBFILE


Subfile, CHAIN, RNN

Hi, I have a problem in reading my subfile:
After loading the subfile and display that on screen, I want to read the records of subfile and write them on preint file. But inspite of managing the RRN, every CHAIN command get the last record of subfile. here is the code:
C EVAL RRN = 1
C DOW RRN < 13
C RRN CHAIN SFLREC
C EVAL PTITLE = SFLTITLE
C EVAL PNO = SFLNO
C EVAL PAMTC = SFLAMTC
C EVAL PAMTD = SFLAMTD
C EVAL PLMT = SFLLMT
C EVAL PMARK = SFLMARK
C WRITE DETAIL
C EVAL RRN = RRN + 1
C ENDDO
and here is the introduction of subfile:
A R SFLREC SFL
A SFLTITLE 20 O 9 2
A SFLNO 2Y 0O 9 24
A SFLAMTC 13Y 3O 9 28EDTCDE(J)
A SFLAMTD 13Y 3O 9 47EDTCDE(J)
A SFLLMT 9Y 3O 9 66EDTCDE(J)
A SFLMARK 1 O 9 79COLOR(RED)
** SUBFILE CONTROL FORMAT
A R CONTROL SFLCTL(SFLREC)
A 85 SFLDSPCTL
A 95 SFLDSP
A 75 SFLCLR
A SFLSIZ(0050)
A SFLPAG(0013)
A 65 SFLINZ
A SFLRNA
A 90 SFLEND(*MORE)
A OVERLAY PUTOVR

please help me! thanx

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
+1
Click to Vote:
  •   1
  •  0



Try using the READC opcode instead of the CHAIN opcode.

Also, it appears you are missing the following on your SFLCTL format:

A SFL0RRN 4S 0H TEXT('SFL Relative Record Number')
A SFLRCDNBR
  • AddThis Social Bookmark Button

Browse more Questions and Answers on AS/400.

Looking for relevant AS/400 Whitepapers? Visit the Search400.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

Vids  |   Dec 14 2007  5:41AM GMT

The RPG code hich you have given as follows -
C EVAL RRN = 1
C DOW RRN

 

Andy Mansell  |   Dec 14 2007  2:42PM GMT

As suggested above the best way to read a subfile is the READC opcode.
Make sure you set SFLNXTCHG, this will stop the Modified data tag from being changed allowing you to read the subfile first for validation and the again for processing.

 

Leiloon  |   Dec 15 2007  4:12AM GMT

Thank you everybody for your comments,

Actually my problem solved. the code you saw here was correct. my mistake was in where i use this subroutine to read the subfile.

Thanks again
1