ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Cobol/400 subfiles

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cobol/400 subfiles

    Hi all

    I have done page by page subfile pgm, also I am very new to cobol, if i try to call, like it is being in the display loo only..

    I am posting the code, pls help me.

    Thanks
    hsp
    Attached Files
    Last edited by hsp; September 13, 2008, 08:30 AM. Reason: Attachment of file...
    'Coding = Experience'
    hsp

  • #2
    Re: Cobol/400 subfiles

    What error are you receiving?

    Is the control record being displayed?

    If there are no subfile records, are you sure that your file contains data?

    Since you didn't post the DDS for the display file, its possible that your indicators are defined incorrectly. As a rule of thumb, you should always use the COPY statement to pull the display file indicators into your program automatically at compile time. This guarantees that your using/assigning the correct values and it also allows you to rename the indicators to useful names like this:
    Code:
    01  indicator-area.                       
        copy dds-all-formats-indic of SFL009D 
             replacing                        
                 in40 by subfile-clear        
                 in41 by subfile-ctl-display  
                 in42 by subfile-display      
                 in49 by subfile-end
    To do this, your display file must have the INDARA keyword defined in the top of the DDS source and your SELECT statement must have the SI appended to the display file name (which yours does...)...

    Also remember that you shouldn't set the SFLDSP indicator to ON -unless- you have actually written an entry to the subfile.

    Terry

    Comment


    • #3
      Re: Cobol/400 subfiles

      Hi Terry,

      Thanks a lot for ur reply...

      It will write all the records to the display file, and while in the display routine, the file status will be zere after writing the Footer and Ctl part. But after reading the records (Read DSPFILE INTO CTL-O FORMAT "CTL", the file status becomes 9k and it will not display the screen and it will be in the loop).

      I think they have removed the authority for me to cpy the src's from the screen and paste.. will write manually and send it.

      Pls give any ideas for the above problem.

      I have attached the DDS.

      Thanks
      hsp
      Attached Files
      Last edited by hsp; September 15, 2008, 11:38 PM. Reason: attachment
      'Coding = Experience'
      hsp

      Comment


      • #4
        Re: Cobol/400 subfiles

        Originally posted by hsp View Post
        But after reading the records (Read DSPFILE INTO CTL-O FORMAT "CTL", the file status becomes 9k and it will not display the screen and it will be in the loop).
        In the D4000-DISPLAY section, you are already writing and reading the subfile control record within a PERFORM loop. It is not necessary to re-execute this section again from within the P3000-USER-INPUT routine. Try removing the PERFFORM statement from P3000-USER-INPUT:
        Code:
           P3000-USER-INPUT SECTION.                                    
        *-------------------                                            
        *CHECK FOR PAGEUP AND PAGEDOWN                                  
        *-------------------                                            
              IF  INDIC-ON(ROLLUP) OR INDIC-ON(ROLLUP-CA01)             
                  IF  WS-BOF = "Y"                                      
                    MOVE "REACHED THE TOP OF FILE" TO ERRMSG OF FOOTER-O
                  ELSE                                                  
                    PERFORM ROLLUP-ROUTINE                              
                    PERFORM I1000-INITSFL                               
                  PERFORM P3000-LOAD-SUBFILE                       
                  SET INDIC-OFF(ROLLUP) TO TRUE                    
                  SET INDIC-OFF(ROLLUP-CA01) TO TRUE               
                END-IF                                             
            END-IF.                                                
                                                                   
            IF INDIC-ON(ROLLDOWN) OR INDIC-ON(ROLLDOWN-CA02)       
                IF WS-EOF = "Y"                                    
                  MOVE "REACHED THE BOTTOM OF THE FILE" TO         
                  ERRMSG OF FOOTER-O                               
                ELSE                                               
                  PERFORM ROLLDOWN-ROUTINE                         
                  PERFORM I1000-INITSFL                            
                  PERFORM P3000-LOAD-SUBFILE                       
                  SET INDIC-OFF(ROLLDOWN) TO TRUE                  
                  SET INDIC-OFF(ROLLDOWN-CA02) TO TRUE             
                 END-IF                                           
             END-IF.                                              
        ********CHECKING FOR F3 = EXIT****************************
                                                                  
             IF INDIC-ON(F03-EXIT)                                
                 PERFORM Z9999-CLOSE-FILES                        
                 GOBACK                                           
             END-IF. 
                                                     
        ---> PERFORM D4000-DISPLAY. <--- remove this...not necessary
        Terry

        Comment


        • #5
          Re: Cobol/400 subfiles

          Hi Terry,

          Thanks for the reply, I removed that Perform statement, but then also after loading it is not displaying the screen. Pls help...

          Thanks
          hsp
          'Coding = Experience'
          hsp

          Comment


          • #6
            Re: Cobol/400 subfiles

            Originally posted by hsp View Post
            Thanks for the reply, I removed that Perform statement, but then also after loading it is not displaying the screen.
            Unfortunately, I don't have time to upload your code and test it...

            What happens when you run the program? Is the subfile control record displayed? Do you receive a CPF message?

            I suspect you have a logic error or your indicators for the display file are not set properly before the WRITE statement...

            Terry

            Comment


            • #7
              Re: Cobol/400 subfiles

              The Screen will come but only the Footer will display and it will be in a it will end up abnormally.

              In Display Routine, afer writing the Subfile Ctl part, when it comes to Read there it will not at all display the screen, just it will go to next statement.

              Till write Ctl part the file status will be 00 after read the file status will be 9K..

              Pls Help.

              U give ur no..??

              Thanks
              hsp
              'Coding = Experience'
              hsp

              Comment


              • #8
                Re: Cobol/400 subfiles

                Hey HSP, i just checked the code you posted and one thing i came across is that you've used the output record format for reading the subfile control format in the display section.

                Code:
                READ  DSPSCREEN INTO M3CTL-O FORMAT 'M3CTL'      
                          END-READ
                Try replacing M3CTL-O with M3CTL-I in the above statement.

                Anyways my experience with cobol is minimal and perhaps this is not requirement.

                Comment


                • #9
                  Re: Cobol/400 subfiles

                  Originally posted by hsp View Post
                  In Display Routine, afer writing the Subfile Ctl part, when it comes to Read there it will not at all display the screen, just it will go to next statement.
                  READ does not display the screen. The WRITE of the subfile control record displays the screen -and- displays associated subfile entries if the SFLDSP indicator is properly set. The READ statement *waits* for a keypress...
                  Till write Ctl part the file status will be 00 after read the file status will be 9K..
                  The 9K status code is associated with multiple CPF return codes. Check your job log to see which CPF error message your receiving.

                  Terry

                  Comment


                  • #10
                    Re: Cobol/400 subfiles

                    Hi Terry, Could my explanation be the reason for the error? usually we only read to the input format suffixed with -I and not the output format suffixed with -O. Also in the read statement, there is no mention of the indicators, is this ok?

                    Comment


                    • #11
                      Re: Cobol/400 subfiles

                      Hi,

                      I tried that but it is still the same, also the indicators is also set properly.
                      'Coding = Experience'
                      hsp

                      Comment


                      • #12
                        Re: Cobol/400 subfiles

                        Originally posted by vikramx View Post
                        Hi Terry, Could my explanation be the reason for the error? usually we only read to the input format suffixed with -I and not the output format suffixed with -O.
                        I'm not sure that the record format is the problem because his DDS for the display file only contains (O)utput fields. Its likely that the compiler listing will show the M3CTL-I format as being "empty".

                        I do seem to recall a problem that I encountered a long time ago regarding DDS records that do not have at least one input field defined. Personally, I always define all of my displayable fields as (B)oth and then I use the following keywords for output-only data:
                        Code:
                        DSPATR(MDT CS)
                        DSPATR(PR)    
                        CHGINPDFT
                        IMO, this makes future maintenance much easier and guarantees that you have access to all data in all fields on the display. The drawback is that you end up passing a little more data across the network...
                        Originally posted by vikramx View Post
                        Also in the read statement, there is no mention of the indicators, is this ok?
                        Good catch! That is something he probably needs in order to capture his function keys!

                        I didn't see this because all of my code uses the Display File Attribute communication area to capture the function-keys

                        Terry

                        Comment

                        Working...
                        X