Display physical file using subfiles in AS/400

20 pts.
Tags:
AS/400
DB2
SQL
How to display a physical file record using subfiles?
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Read your file, move the data to the subfile record. when either the page is built or the subfile is loaded you would execute the subfile control record. If you are looking to do this in a different way we need more details. in you tags you list SQL. You may want to extract the data like this and read from that file.

 C/EXEC SQL                                                          
 C+    DECLARE OHB CURSOR FOR                                        
 C+       SELECT OHORD#, OHBTKY, OHSPO#, OHENTD, OHHOLD, OHFF3, OHSM 
 C+       FROM  OH                                                   
 C+       WHERE OHHOLD = 'E' AND OHFF3 <> ' ' AND OHBTKY = :INCUST   
 C+       AND OHPRKY <> 'DADANC'                                     
 C/END-EXEC                                                          
 C/EXEC SQL                                                          
 C+    OPEN OHB                                                      
 C/END-EXEC                         
                                 

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • deepu9321
    sQL suggested by Todd would be perfect to build a cursor and read through.

    If you would require more help on building subfile Go through the link below.

    4,980 pointsBadges:
    report
  • anandx
    Following pseudo code gives an idea to start with.
    DSPF: DSPX
    			INDARA
    R	SF1		SFL
    	ID	 2S 0O  10 10	
    	NAME	20   O  10 20
    R	SF1CTL		SFLCTL( SF1 )
    		        CA03( 03 'Exit' )
    			SFLSIZ( 11 )
    		        SFLPAG( 10 )
    N31			SFLDSP
    N32			SFLDSPCTL
     32		        SFLCLR
    -------------
    RPGLE
    
    dcl-f  DSPFX workStn sfile(sf1: rrn1) prefix('WS_') indara(xyz) ;
    dcl-f  PFX prefix('PF_') ;
    
    sfldspctl = *on ; // *in32, clears sfl
    write sf1ctl ;
    sfldspctl = *off ;
    clear rrn1 ;	  
    Dow not %eof ;	// this loop reads PF and writes rec to sfl
      read(e) PFX ;
      PF_id = ws_id ;  // move data, pf to dspf
      PF_name = ws_id ;
      rrn1 += 1 ; // increment sfl's relative rcd #
      write(e) sf1 ;
    enDO ;
    
    exFMT sf1ctl ; // now, dsply loaded sfl until F3 hit
    *inLR = *on ;
    ---------------
    
    765 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: