ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Error message not displayed on line 24th in display file.

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

  • Error message not displayed on line 24th in display file.

    Hi I am new to Cobol/400 and writing one program where the user will enter the Customer No. IF customer number is not present in DB then error message should be displayed " Customer invalid" for this i have defined the Indicator 21 in the DSPF. On providing the wrong customer number error message is not displayed. On providing the correct customer number details are displayed. Please help me out how to display the error message. Below is the DSPF DDS and Cobol program.
    Code:
    0000.30 A DSPSIZ(24 80 *DS3)
    0000.40 A REF(NARENKUM1/CUSMSTP)
    0000.50 A PRINT
    0000.60 A INDARA
    0000.70 A CA03(03 'PRESS F3 TO EXIT.')
    0000.80 A R CUSPMT
    0000.90 A*%%TS SD 20220901 180822 NARENKUM REL-V7R5M0 5770-WDS
    0001.00 A 1 3'CUSTOMER MASTER INQUIRY'
    0001.10 A 3 3'CUSTOMER NUMBER'
    0001.20 A 5 3'USE F3 TO END PROGRAM, USE ENTER T-
    0001.30 A O RETURN TO PROMPT SCREEN'
    0001.40 A CUST R I 3 20REFFLD(CUSMST/CUST NARENKUM1/CUSMST-
    0001.50 A P)
    0001.60 A 21 ERRMSG('CUSTOMER NOT FOUND' 21)
    0001.70 A R CUSFLDS
    0001.80 A*%%TS SD 20220902 022438 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 ************************************************** **​
    Below is the cobol/400 program

    Code:
    0001.00 IDENTIFICATION DIVISION.
    0002.00 PROGRAM-ID. CUSMINQY.
    0003.00 ENVIRONMENT DIVISION.
    0004.00 INPUT-OUTPUT SECTION.
    0005.00 FILE-CONTROL.
    0006.00 SELECT CUSTOMER-FILE
    0007.00 ASSIGN TO DATABASE-CUSMSTP
    0008.00 ORGANIZATION IS INDEXED
    0009.00 ACCESS MODE IS RANDOM
    0010.00 RECORD KEY IS EXTERNALLY-DESCRIBED-KEY
    0011.00 FILE STATUS IS WS-CUS-FILE-STATUS.
    0012.00
    0013.00 SELECT CUSTOMER-SCREEN-FILE
    0014.00 ASSIGN TO WORKSTATION-CUSMINQ-SI
    0015.00 ORGANIZATION IS TRANSACTION
    0015.01 ACCESS IS SEQUENTIAL
    0016.00 FILE STATUS IS WS-CUS-SCREEN-FILE-STATUS
    0017.00 CONTROL-AREA IS WS-SCREEN-CONTROL-AREA.
    0018.00
    0019.00 DATA DIVISION.
    0020.00 FILE SECTION.
    0021.00 FD CUSTOMER-FILE
    0022.00 LABEL RECORDS ARE STANDARD.
    0023.00 01 CUSTOMER-RECORD.
    0024.00 COPY DD-ALL-FORMATS OF CUSMSTP.
    0025.00
    0026.00 FD CUSTOMER-SCREEN-FILE
    0027.00 LABEL RECORDS ARE OMITTED.
    0028.00 01 DISPLAY-RECORD.
    0029.00 COPY DDS-ALL-FORMATS OF CUSMINQ.
    0030.00
    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.
    0045.01
    0047.00 01 WS10-ABEND-VARIABLES.
    0048.00 05 WS10-PROGRAM-NAME PIC X(9) VALUE 'CUSMINQY'.
    0049.00 05 WS10-FILE-STATUS PIC X(2) VALUE SPACES.
    0050.00 05 WS10-ERROR-MESSAGE PIC X(80) VALUE SPACES.
    0050.01
    0050.02 01 WORK-FIELDS.
    0050.03 05 WS-CHECK PIC X(1) VALUE 'N'.
    0050.05
    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.
    0059.00 *-------------------------------------*
    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.
    0065.00 PERFORM 1200-DISPLAY-HEADER.
    0066.00 *-------------------------------------------------------------*
    0067.00 * THIS SECTION WILL BE USED TO OPEN THE FILES *
    0068.00 * USED IN THIS PROGRAM. *
    0069.00 *-------------------------------------------------------------*
    0070.00 1100-OPEN-FILE.
    0071.00 OPEN INPUT CUSTOMER-FILE.
    0072.00 EVALUATE WS-CUS-FILE-STATUS
    0073.00 WHEN '00'
    0074.00 CONTINUE
    0075.00 WHEN OTHER
    0076.00 MOVE WS-CUS-FILE-STATUS TO WS10-FILE-STATUS
    0077.00 MOVE 'ERROR IN OPENING CUS FILE' TO WS10-ERROR-MESSAGE
    0078.00 PERFORM Z200-FILE-ABEND-PROCESS
    0079.00 END-EVALUATE.
    0080.00
    0081.00 OPEN I-O CUSTOMER-SCREEN-FILE.
    0082.00 EVALUATE WS-CUS-SCREEN-FILE-STATUS
    0083.00 WHEN '00'
    0084.00 CONTINUE
    0085.00 WHEN OTHER
    0086.00 MOVE WS-CUS-SCREEN-FILE-STATUS TO WS10-FILE-STATUS
    0087.00 MOVE 'ERROR IN OPENING CUS SCREEN FILE'
    0088.00 TO WS10-ERROR-MESSAGE
    0089.00 PERFORM Z200-FILE-ABEND-PROCESS
    0090.00 END-EVALUATE.
    0091.00 *--------------------------------------------------------*
    0092.00 * THIS SECTION WILL DISPLAY THE EMPLOYEE ADD SCREEN *
    0093.00 *--------------------------------------------------------*
    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.
    0100.00 *--------------------------------------------------------*
    0101.00 * DISPLAY THE EMP SCREEN UNTI F03 KEY IS PRESSED *
    0102.00 *--------------------------------------------------------*
    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 SET INDICATOR-ON(INVALID-CUSNO) TO TRUE
    0103.05 PERFORM 2200-DISPLAY-HEADER
    0103.13 NOT INVALID KEY
    0103.14 MOVE 'Y' TO WS-CHECK
    0103.15 PERFORM 2100-WRITE-SCREEN-RECORD
    0103.21 END-READ.
    0120.00 ************************************************** *********
    0121.00 *---------------------------------------------------------*
    0122.00 * THIS WILL CHECK THE EMP NO IS BLANK AND ALSO *
    0123.00 * IF THE RECORD ALREADY PRESENT IN DATA BASE *
    0124.00 *---------------------------------------------------------*
    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.08 WRITE DISPLAY-RECORD
    0124.09 FORMAT IS "CUSFLDS"
    0124.10 INDICATORS ARE WS-SCREEN-INDICATORS.
    0124.11 READ CUSTOMER-SCREEN-FILE.
    0135.00 *--------------------------------------------------------*
    0135.01 2200-DISPLAY-HEADER.
    0135.02 INITIALIZE CUSPMT-I.
    0135.04 WRITE DISPLAY-RECORD
    0135.05 FORMAT IS "CUSPMT"
    0135.06 INDICATORS ARE WS-SCREEN-INDICATORS.
    0135.07 READ CUSTOMER-SCREEN-FILE
    0135.08 FORMAT IS "CUSPMT".
    0136.00 Z200-FILE-ABEND-PROCESS.
    0137.00 DISPLAY 'PROGRAM NAME :' WS10-PROGRAM-NAME.
    0138.00 DISPLAY 'FILE STATUS :' WS10-FILE-STATUS.
    0139.00 DISPLAY 'ERROR MESSAGE :' WS10-ERROR-MESSAGE.
    0140.00 3000-TERMINATION-PROCESS.
    0141.00 CLOSE CUSTOMER-FILE.
    0142.00 CLOSE CUSTOMER-SCREEN-FILE.
    ​​

  • #2
    Can you please edit your post using code tags arround the DDS and COBOL. It is just about impossible to read like this.

    If you are not familiar with it use the marked icon here>

    Click image for larger version

Name:	2022-09-02_12-38-05.png
Views:	95
Size:	14.4 KB
ID:	157857
    I'll gladly try and help but I'm not going to try and decipher this lot.

    Comment


    • Narendra Kumar
      Narendra Kumar commented
      Editing a comment
      Please help me out. I debug the program and the indicator 21 is ON but still the error message is not displayed.

  • #3
    Code:
    0001.00 identification division.
    0002.00 program-id. Cusminqy.
    0003.00 environment division.
    0004.00 input-output section.
    0005.00 file-control.
    0006.00        select customer-file
    0007.00        assign to database-cusmstp
    0008.00        organization is indexed
    0009.00       access mode is random
    0010.00       record key is externally-described-key
    0011.00         file status is ws-cus-file-status.
    0012.00
    0013.00         select customer-screen-file
    0014.00       assign to workstation-cusminq-si
    0015.00        organization is transaction
    0015.01        access is sequential
    0016.00        file status is ws-cus-screen-file-status
    0017.00         control-area is ws-screen-control-area.
    0018.00
    0019.00 data division.
    0020.00 file section.
    0021.00 fd customer-file
    0022.00          label records are standard.
    0023.00 01 customer-record.
    0024.00         copy dd-all-formats of cusmstp.
    0025.00
    0026.00 fd customer-screen-file
    0027.00         label records are omitted.
    0028.00 01 display-record.
    0029.00        copy dds-all-formats of cusminq.
    0030.00​
    0030.00
    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.
    0045.01
    0047.00 01 ws10-abend-variables.
    0048.00          05 ws10-program-name pic x(9) value 'cusminqy'.
    0049.00          05 ws10-file-status pic x(2) value spaces.
    0050.00         05 ws10-error-message pic x(80) value spaces.
    0050.01
    0050.02 01 work-fields.
    0050.03          05 ws-check pic x(1) value 'n'.
    0050.05
    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.
    0059.00 *-------------------------------------*
    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.
    0065.00            perform 1200-display-header.
    0066.00 *-------------------------------------------------------------*
    0067.00 * this section will be used to open the files *
    0068.00 * used in this program. *
    0069.00 *-------------------------------------------------------------*
    0070.00 1100-open-file.
    0071.00              open input customer-file.
    0072.00             evaluate ws-cus-file-status
    0073.00             when '00'
    0074.00            continue
    0075.00              when other
    0076.00              move ws-cus-file-status to ws10-file-status
    0077.00            move 'error in opening cus file' to ws10-error-message
    0078.00              perform z200-file-abend-process
    0079.00              end-evaluate.
    0080.00
    0081.00                open i-o customer-screen-file.
    0082.00               evaluate ws-cus-screen-file-status
    0083.00               when '00'
    0084.00             continue
    0085.00               when other
    0086.00              move ws-cus-screen-file-status to ws10-file-status
    0087.00                move 'error in opening cus screen file'
    0088.00               to ws10-error-message
    0089.00               perform z200-file-abend-process
    0090.00             end-evaluate.
    0091.00 *--------------------------------------------------------*
    0092.00 * this section will display the employee add screen *
    0093.00 *--------------------------------------------------------*
    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.
    0100.00 *--------------------------------------------------------*
    0101.00 * display the emp screen unti f03 key is pressed *
    0102.00 *--------------------------------------------------------*
    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                 set indicator-on(invalid-cusno) to true
    0103.05                   perform 2200-display-header
    0103.13                   not invalid key
    0103.14                   move 'y' to ws-check
    0103.15                    perform 2100-write-screen-record
    0103.21                    end-read.
    0120.00 ************************************************** *********
    0121.00 *---------------------------------------------------------*
    0122.00 * this will check the emp no is blank and also *
    0123.00 * if the record already present in data base *
    0124.00 *---------------------------------------------------------*
    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.08              write display-record
    0124.09              format is "cusflds"
    0124.10             indicators are ws-screen-indicators.
    0124.11               read customer-screen-file.
    0135.00 *--------------------------------------------------------*
    0135.01 2200-display-header.
    0135.02                 initialize cuspmt-i.
    0135.04                write display-record
    0135.05                 format is "cuspmt"
    0135.06               indicators are ws-screen-indicators.
    0135.07                     read customer-screen-file
    0135.08                    format is "cuspmt".
    
    0136.00 z200-file-abend-process.
    0137.00               display 'program name :' ws10-program-name.
    0138.00             display 'file status :' ws10-file-status.
    0139.00              display 'error message :' ws10-error-message.
    0140.00 3000-termination-process.
    0141.00 close customer-file.
    0142.00 close customer-screen-file.
    ​
    Attached Files

    Comment


    • #4
      let me add the file in proper format

      Comment


      • #5
        Please see the attached DDS and cobol files Customer_Screen_DDS.txt Customer_Inquiry_Program.txt Customer_Screen_DDS.txt Customer_Inquiry_Program.txt

        Comment


        • #6
          Code:
          0000.10      A*%%TS  SD  20220902  162546  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                                      PRINT                                  
          0000.60      A                                      INDARA                                  
          0000.70      A                                      CA03(03 'PRESS F3 TO EXIT.')            
          0000.80      A          R CUSPMT                                                            
          0000.90      A*%%TS  SD  20220902  162016  NARENKUM    REL-V7R5M0  5770-WDS                
          0001.00      A                                  1  3'CUSTOMER MASTER INQUIRY'              
          0001.10      A                                  3  3'CUSTOMER NUMBER'                      
          0001.20      A                                  5  3'USE F3 TO END PROGRAM, USE ENTER T-    
          0001.30      A                                      O RETURN TO PROMPT SCREEN'              
          0001.40      A            CUST      R        I  3 20REFFLD(CUSMST/CUST NARENKUM1/CUSMST-    
          0001.50      A                                      P)                                      
          0001.60      A  21                                  ERRMSG('CUSTOMER NOT FOUND' 21)        
          0001.70      A          R CUSFLDS                                                          
          0001.80      A*%%TS  SD  20220902  022438  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 *********************************************************                    ​

          Comment


          • #7
            Please see above the cobol code in proper format and the DDS also

            Comment

            Working...
            X