1
votes

I'm stuck to get the full output.

Supposedly the output need to look like this : Actual output

And this is my physical file: CUREXG

I have three field in physical file which are :

  • EXGDAT = date
  • EXGCOD = exchange code
  • EXGRAT = exchange rate

My output look like this :

Output

My output displayed record for 1 June only and not both 31 May and 1 June. What should I do to get the exact output that I want? Please help me. Thanks in advance

1
I would try a SETGT and then READ without key after the write to the subfile. But why not try using SQL? Within the SQL select, use an SQL function to get the exchange rate of each specific currency, Once you get the hang of it your code will be more readable. - RockBoro
Actually i want to avoid using sql since i'm not learn that part yet. do you have any suggestion? I would like to use reade instead - D97
Is it my loop are correct? - D97
it is not rocket science. ;) You can learn two methods at the same time. - RockBoro

1 Answers

1
votes

the inner loop runs until %eof. Then you write to the subfile. The reade that follows the write to the subfile will return %eof because the cursor into the file has not been reset.

            write sfl01
    exgdat  reade curexg

use SETGT and then READ to read to the EXGDAT of the next set of currency rate records.

            write sfl01
    exgdat  setgt curexg
            read  curexg

to debug the problem where you are not reading the records you expect, try to write the results of every read to a print file. That way you have something you can look at after the program runs. Might help understand what was read and why.

FQSYSPRT   o    f  132        printer OflInd(*inOf)    

d lineData        s            132a     

      if          *inof = '1' ;                          
      except      newPage ;                              
      endif ;                                            
      lineData    = %eof + ' ' + exgcod + ' ' + 
                    %editc(exgrat:'J') +
                    ' ' + %char(exgdat:*iso) ;      
      except      detail ;                               

OQsysprt   E            NewPage           1            
O                       LineData           132         
                                                       
O          E            Detail      1                  
O                       LineData           132