ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

using DSPATR(ND) in DSPF second record format hides the First record format in Cobol

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

  • Brian Rusch
    replied
    When you want to display a second record format while keeping the first one on the display, the second record format cannot overlap the first record format. In your example, the first record format spans from line 1 to line 23 and the second record format spans from line 7 to line 11 which overlaps the first record format, even though there is no data displayed between line 7 and 11 in the first record format. To fix the problem you could remove the ERRORMSG field from the first record format and put it in it's own record format or you could move the ERRORMSG field from line 23 to a line between 1 and 6.

    Leave a comment:


  • using DSPATR(ND) in DSPF second record format hides the First record format in Cobol

    I am writing one cobol program where in the first record format user need to enter the customer number. If the customer number is not found then error message 'Customer Not Found" on line 23 sholud be displayed. If the customer number is found then customer details should be displayed (Second record format) along with the first one. In DSPF file in the first record format I have define one output field and make it non display with indicator N21. Now when the customer is not found then this get displayed with message 'Customer not found' working fine.
    The issue is that when customer is found then only detail record format is displayed. The first one gets hide and on pressing enter key then first one is displayed back.
    Please see the DSPF DDS and cobol program. Please help me out how to display the detail screen along with the first screen.

    Code:
    0000.10      A*%%TS  SD  20220905  151841  NARENKUM    REL-V7R5M0  5770-WDS                  
    0000.20      A*%%EC                                                                          
    0000.30      A                                      DSPSIZ(24 80 *DS3)                      
    0000.40      A                                      REF(NARENKUM1/CUSMSTP)                  
    0000.50      A                                      INDARA                                  
    0000.60      A                                      CA03(03 'PRESS F3 TO EXIT.')            
    0000.70      A          R CUSPMT                                                            
    0000.80      A*%%TS  SD  20220905  151841  NARENKUM    REL-V7R5M0  5770-WDS                  
    0000.90      A                                  1  3'CUSTOMER MASTER INQUIRY'                
    0001.00      A                                  3  3'CUSTOMER NUMBER'                        
    0001.10      A                                  5  3'USE F3 TO END PROGRAM, USE ENTER T-    
    0001.20      A                                      O RETURN TO PROMPT SCREEN'              
    0001.30      A            CUST      R        B  3 20REFFLD(CUSMST/CUST NARENKUM1/CUSMST-    
    0001.40      A                                      P)                                      
    0001.50      A            ERRORMSG      40   O 23  4                                        
    0001.60      A N21                                  DSPATR(ND)                              
    0001.70      A          R CUSFLDS                                                            
    0001.80      A*%%TS  SD  20220905  050052  NARENKUM    REL-V7R5M0  5770-WDS                  
    0001.90      A                                      OVERLAY                                  
    0002.00      A                                  8  3'NAME'                                    
    0002.10      A                                  9  3'ADDRESS'                                
    0002.20      A                                 10  3'CITY'                                    
    0002.30      A                                 11  3'STATE'                                  
    0002.40      A                                  7  3'CUST'                                    
    0002.50      A            CUST      R        O  7 14REFFLD(CUSMST/CUST NARENKUM1/CUSMST-      
    0002.60      A                                      P)                                        
    0002.70      A            NAME      R        O  8 14REFFLD(CUSMST/NAME NARENKUM1/CUSMST-      
    0002.80      A                                      P)                                        
    0002.90      A            ADDR      R        O  9 14REFFLD(CUSMST/ADDR NARENKUM1/CUSMST-      
    0003.00      A                                      P)                                        
    0003.10      A            CITY      R        O 10 14REFFLD(CUSMST/CITY NARENKUM1/CUSMST-      
    0003.20      A                                      P)                                        
    0003.30      A            STATE     R        O 11 14REFFLD(CUSMST/STATE NARENKUM1/CUSMS-      
    0003.40      A                                      TP)                                      
            ****************** End of data *******************************************************
            
            ​0031.00        WORKING-STORAGE SECTION.                                  
    0032.00        01  WS-FILE-STATUS.                                        
    0033.00            05 WS-CUS-FILE-STATUS PIC X(2) VALUE '00'.            
    0034.00            05 WS-CUS-SCREEN-FILE-STATUS PIC X(2) VALUE '00'.      
    0034.01                                                                  
    0035.00        01  WS-SCREEN-CONTROL-AREA.                                
    0036.00            05 WS-KEY-PRESSED PIC X(2).                            
    0039.00            88 FUNCTION-KEY03 VALUE "03".                          
    0039.04                                                                  
    0040.00        01  WS-SCREEN-INDICATORS.                                  
    0041.00            05 WS-SCR-INDICATOR PIC 1 OCCURS 99 TIMES INDICATOR 1.
    0042.00            88 INDICATOR-OFF VALUE B"0".                          
    0043.00            88 INDICATOR-ON VALUE B"1".                            
    0043.01                                                                  
    0044.00        01  WS-INDICATORS-USED.                                    
    0045.00            05 INVALID-CUSNO   PIC 9(2) VALUE 21.    
    
    0051.00        PROCEDURE DIVISION.                                        
    0052.00        0000-START.                                                
    0053.00            PERFORM 1000-INITIALISATION.                                  
    0054.00            PERFORM 2000-MAIN-PROCESSING                                  
    0055.00            UNTIL FUNCTION-KEY03.                                          
    0056.00            PERFORM 3000-TERMINATION-PROCESS.                              
    0057.00        0000-EXIT.                                                        
    0058.00            STOP RUN.    
     
    0060.00        1000-INITIALISATION.                                              
    0061.00            PERFORM 1100-OPEN-FILE.                                        
    0062.00            INITIALIZE WS-SCREEN-INDICATORS.                              
    0063.00            INITIALIZE WS-KEY-PRESSED.                                    
    0064.00            INITIALIZE CUSPMT-I.                                          
    0064.01            INITIALIZE CUSPMT-O.                                          
    0065.00            PERFORM 1200-DISPLAY-HEADER.      
    
    0070.00        1100-OPEN-FILE.                                                    
    0071.00            OPEN INPUT CUSTOMER-FILE.  
    0081.00            OPEN I-O CUSTOMER-SCREEN-FILE.  
    
    0094.00        1200-DISPLAY-HEADER.                                        
    0095.00            WRITE DISPLAY-RECORD                                    
    0096.00            FORMAT IS "CUSPMT"                                      
    0097.00            INDICATORS ARE WS-SCREEN-INDICATORS.                    
    0098.00            READ CUSTOMER-SCREEN-FILE                                
    0098.01            FORMAT IS "CUSPMT"                                      
    0099.00            INDICATORS ARE WS-SCREEN-INDICATORS.    
    
    0103.00        2000-MAIN-PROCESSING.                                        
    0103.01            MOVE CUST OF CUSPMT-I TO CUST OF CUSMST.                
    0103.02            READ CUSTOMER-FILE                                      
    0103.03              INVALID KEY                                            
    0103.04                MOVE 'CUSTOMER NOT FOUND' TO ERRORMSG OF CUSPMT-O    
    0103.05                SET INDICATOR-ON(INVALID-CUSNO) TO TRUE              
    0103.10            PERFORM 2200-DISPLAY-HEADER                              
    0103.13              NOT INVALID KEY                                        
    0103.14                 MOVE 'Y' TO WS-CHECK                                
    0103.15                 MOVE SPACES TO ERRORMSG OF CUSPMT-O                  
    0103.16                SET INDICATOR-OFF(INVALID-CUSNO) TO TRUE              
    0103.17            INITIALIZE WS-SCREEN-INDICATORS                          
    0103.18                 PERFORM 2100-WRITE-SCREEN-RECORD                    
    0103.19            IF NOT FUNCTION-KEY03                                    
    0103.20                 PERFORM 1200-DISPLAY-HEADER                          
    0103.21                 END-IF                                              
    0103.31            END-READ.        
    
    0124.01        2100-WRITE-SCREEN-RECORD.                                    
    0124.03                 MOVE NAME OF CUSMST TO NAME OF CUSFLDS-O.            
    0124.04                 MOVE CITY OF CUSMST TO CITY OF CUSFLDS-O.            
    0124.05                 MOVE STATE OF CUSMST TO STATE OF CUSFLDS-O.          
    0124.06                 MOVE ADDR OF CUSMST TO ADDR OF CUSFLDS-O.            
    0124.07                 MOVE CUST OF CUSMST TO CUST OF CUSFLDS-O.            
    0124.12            WRITE DISPLAY-RECORD                                    
    0124.13            FORMAT IS "CUSFLDS"                                    
    0124.15            END-WRITE                                              
    0124.16            READ CUSTOMER-SCREEN-FILE                              
    0124.19            END-READ.                              ​
Working...
X