Navigation

    DDBB

    • Register
    • Login
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    如何写第一支COBOL程序,HELLO WORLD!

    PROGRAMMING LANGUAGES
    1
    1
    1770
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      admin last edited by

      接着上一节,我们已经建立好了data set和member,现在开始写一个最简单的COBOL程序,打印出hello world

      Command ===> 下面打上I8,意思是插入8行,当然,I1就是插入一行。

         File  Edit  Edit_Settings  Menu  Utilities  Compilers  Test  Help            
      sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
      EDIT       KOK.COBOL.LIB(HELLOW) - 01.00                   Columns 00001 00072 
      Command ===>                                                  Scroll ===> PAGE 
      **i8** ***************************** Top of Data ******************************
      ****** **************************** Bottom of Data ****************************
      

      打上cols为了现实出列号,COBOL程序的写法是有区域的

         File  Edit  Edit_Settings  Menu  Utilities  Compilers  Test  Help            
      sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
      EDIT       KOK.COBOL.LIB(HELLOW) - 01.00                   Columns 00001 00072 
      Command ===>                                                  Scroll ===> PAGE 
      ****** ***************************** Top of Data ******************************
      'cols'                                                                         
      ''''''                                                                         
      ''''''                                                                         
      ''''''                                                                         
      ''''''                                                                         
      ''''''                                                                         
      ''''''                                                                         
      ''''''                                                                         
      ****** **************************** Bottom of Data ****************************
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
        F1=Help      F2=Split     F3=Exit      F5=Rfind     F6=Rchange   F7=Up        
        F8=Down      F9=Swap     F10=Left     F11=Right    F12=Cancel    
      

      按下回车后,在插入几行,你就可以看到下面的样子。

         File  Edit  Edit_Settings  Menu  Utilities  Compilers  Test  Help            
      sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
      EDIT       KOK.COBOL.LIB(HELLOW) - 01.00                   Columns 00001 00072 
      Command ===>                                                  Scroll ===> PAGE 
      ****** ***************************** Top of Data ******************************
      =COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
      ''''''                                                                         
      ''''''                                                                         
      ''''''                                                                         
      ''''''                                                                         
      ''''''                                                                         
      ''''''                                                                         
      ''''''                                                                         
      ''''''                                                                         
      ''''''                                                                         
      ****** **************************** Bottom of Data ****************************
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
        F1=Help      F2=Split     F3=Exit      F5=Rfind     F6=Rchange   F7=Up        
        F8=Down      F9=Swap     F10=Left     F11=Right    F12=Cancel   
      

      下面COPY程序里的代码

         File  Edit  Edit_Settings  Menu  Utilities  Compilers  Test  Help            
      sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
      EDIT       KOK.COBOL.LIB(HELLOW) - 01.00                   Columns 00001 00072 
      Command ===>                                                  Scroll ===> PAGE 
      ****** ***************************** Top of Data ******************************
      =COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
      000100        IDENTIFICATION                  DIVISION.                        
      000200        PROGRAM-ID.                     HELLOW.                          
      000300        ENVIRONMENT                     DIVISION.                        
      000800        DATA                            DIVISION.                        
      000900        PROCEDURE                       DIVISION.                        
      001000            DISPLAY  'HELLO WORLD!!!'.                                   
      001100            STOP RUN.                                                    
      ****** **************************** Bottom of Data ****************************
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
        F1=Help      F2=Split     F3=Exit      F5=Rfind     F6=Rchange   F7=Up        
        F8=Down      F9=Swap     F10=Left     F11=Right    F12=Cancel  
      

      然后用第一节讲的方法建立一个名为KOK.JCL.LIB的DATA SET,在创建一个名为@HELLOW的member。

      因为要生成module,所以需要建立一个Record format为U的DATA SET存放

         Menu  Utilities  Compilers  Options  Status  Help                            
      ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 
                                  ISPF Primary Option Menu                            
      Option ===> 3.2                                                                
                                                                                      
      0  Settings      Terminal and user parameters            User ID . : KOK       
      1  View          Display source data or listings         Time. . . : 14:47     
      2  Edit          Create or change source data            Terminal. : 3278      
      3  Utilities     Perform utility functions               Screen. . : 1         
      4  Foreground    Interactive language processing         Language. : ENGLISH   
      5  Batch         Submit job for language processing      Appl ID . : ISP       
      6  Command       Enter TSO or Workstation commands       TSO logon : SYSUSER   
      7  Dialog Test   Perform dialog testing                  TSO prefix: KOK       
      9  IBM Products  IBM program development products        System ID : ADCD      
      10 SCLM          SW Configuration Library Manager        MVS acct. : 12345678  
      11 Workplace     ISPF Object/Action Workplace            Release . : ISPF 5.6  
      S  SDSF          SDSF Panels                                                   
      D  DB2           DB2 Product, SPUFI and DB2 Commands                           
      A  DB2ADM        DB2 Administration Tools                                      
      M  More          Additional IBM Products                                       
                                                                                      
            Enter X to Terminate using log/list defaults                              
        F1=Help      F2=Split     F3=Exit      F7=Backward  F8=Forward   F9=Swap      
      F10=Actions  F12=Cancel 
      
         Menu  RefList  Utilities  Help                                               
      ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 
                                      Data Set Utility                                
      Option ===> A                                                                  
                                                                                      
           A Allocate new data set                 C Catalog data set                 
           R Rename entire data set                U Uncatalog data set               
           D Delete entire data set                S Short data set information       
      blank Data set information                  V VSAM Utilities                   
                                                                                      
      ISPF Library:                                                                  
          Project  . . KOK              Enter "/" to select option                    
          Group  . . . LOAD             /  Confirm Data Set Delete                    
          Type . . . . LIB                                                            
                                                                                      
      Other Partitioned, Sequential or VSAM Data Set:                                
          Data Set Name . . .                                                         
          Volume Serial . . .           (If not cataloged, required for option "C")   
                                                                                      
      Data Set Password  . .           (If password protected)                       
                                                                                      
                                                                                      
        F1=Help      F2=Split     F3=Exit      F7=Backward  F8=Forward   F9=Swap      
      F10=Actions  F12=Cancel  
      
         Menu  RefList  Utilities  Help                                               
      ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 
                                   Allocate New Data Set                              
      Command ===>                                                                   
                                                                          More:     + 
      Data Set Name  . . . : KOK.LOAD.LIB                                            
                                                                                      
      Management class . . .                (Blank for default management class)     
      Storage class  . . . .                (Blank for default storage class)        
        Volume serial . . . .                (Blank for system default volume) **     
        Device type . . . . .                (Generic unit or device address) **      
      Data class . . . . . .                (Blank for default data class)           
        Space units . . . . .                (BLKS, TRKS, CYLS, KB, MB, BYTES         
                                              or RECORDS)                             
        Average record unit                  (M, K, or U)                             
        Primary quantity  . . 10             (In above units)                         
        Secondary quantity    10             (In above units)                         
        Directory blocks  . . 5              (Zero for sequential data set) *         
        Record format . . . . U                                                       
        Record length . . . . 80                                                      
        Block size  . . . . . 8000                                                    
        Data set name type  :                (LIBRARY, HFS, PDS, or blank)  *         
        F1=Help      F2=Split     F3=Exit      F7=Backward  F8=Forward   F9=Swap      
      F10=Actions  F12=Cancel   
      

      copy如下JCL代码

         File  Edit  Edit_Settings  Menu  Utilities  Compilers  Test  Help            
      sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
      EDIT       KOK.JCL.LIB(@HELLOW) - 01.00                    Columns 00001 00072 
      Command ===>                                                  Scroll ===> PAGE 
      ****** ***************************** Top of Data ******************************
      000100 //KOKHEL1 JOB CLASS=A,MSGCLASS=H,MSGLEVEL=(1,1),                        
      000200 //             NOTIFY=&SYSUID                                           
      000300 //STEP010  EXEC PROC=IGYWCL                                             
      000500 //COBOL.SYSIN DD DSN=KOK.COBOL.LIB(HELLOW),DISP=SHR                     
      000600 //LKED.SYSLMOD DD DSN=KOK.LOAD.LIB(HELLOW),DISP=SHR                     
      000700 //STEP020  EXEC PGM=HELLOW                                              
      000800 //STEPLIB  DD DSN=KOK.LOAD.LIB(HELLOW),DISP=SHR                         
      000900 //SYSOUT   DD SYSOUT=*                                                  
      001000 //                                                                      
      ****** **************************** Bottom of Data ****************************
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
        F1=Help      F2=Split     F3=Exit      F5=Rfind     F6=Rchange   F7=Up        
        F8=Down      F9=Swap     F10=Left     F11=Right    F12=Cancel  
      

      Command ===> sub 提交,返回MAXCC=0,ok!

         File  Edit  Edit_Settings  Menu  Utilities  Compilers  Test  Help            
      sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
      EDIT       KOK.JCL.LIB(@HELLOW) - 01.00                    Columns 00001 00072 
      Command ===> sub                                              Scroll ===> PAGE 
      ****** ***************************** Top of Data ******************************
      000100 //KOKHEL1 JOB CLASS=A,MSGCLASS=H,MSGLEVEL=(1,1),                        
      000200 //             NOTIFY=&SYSUID                                           
      000300 //STEP010  EXEC PROC=IGYWCL                                             
      000500 //COBOL.SYSIN DD DSN=KOK.COBOL.LIB(HELLOW),DISP=SHR                     
      000600 //LKED.SYSLMOD DD DSN=KOK.LOAD.LIB(HELLOW),DISP=SHR                     
      000700 //STEP020  EXEC PGM=HELLOW                                              
      000800 //STEPLIB  DD DSN=KOK.LOAD.LIB(HELLOW),DISP=SHR                         
      000900 //SYSOUT   DD SYSOUT=*                                                  
      001000 //                                                                      
      ****** **************************** Bottom of Data ****************************
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
        F1=Help      F2=Split     F3=Exit      F5=Rfind     F6=Rchange   F7=Up        
        F8=Down      F9=Swap     F10=Left     F11=Right    F12=Cancel      
      

      用TSO SDSF H去查看LOG

         File  Edit  Edit_Settings  Menu  Utilities  Compilers  Test  Help            
      sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
      EDIT       KOK.JCL.LIB(@HELLOW) - 01.00                    Columns 00001 00072 
      Command ===> tso sdsf h                                       Scroll ===> PAGE 
      ****** ***************************** Top of Data ******************************
      000100 //KOKHEL1 JOB CLASS=A,MSGCLASS=H,MSGLEVEL=(1,1),                        
      000200 //             NOTIFY=&SYSUID                                           
      000300 //STEP010  EXEC PROC=IGYWCL                                             
      000500 //COBOL.SYSIN DD DSN=KOK.COBOL.LIB(HELLOW),DISP=SHR                     
      000600 //LKED.SYSLMOD DD DSN=KOK.LOAD.LIB(HELLOW),DISP=SHR                     
      000700 //STEP020  EXEC PGM=HELLOW                                              
      000800 //STEPLIB  DD DSN=KOK.LOAD.LIB(HELLOW),DISP=SHR                         
      000900 //SYSOUT   DD SYSOUT=*                                                  
      001000 //                                                                      
      ****** **************************** Bottom of Data ****************************
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
        F1=Help      F2=Split     F3=Exit      F5=Rfind     F6=Rchange   F7=Up        
        F8=Down      F9=Swap     F10=Left     F11=Right    F12=Cancel     
      

      JOBNAME前打上一个"?"

      SDSF HELD OUTPUT DISPLAY ALL CLASSES  LINES 857        LINE 1-3 (3)            
      COMMAND INPUT ===>                                            SCROLL ===> PAGE 
      NP   JOBNAME  JobID    Owner    Prty C ODisp Dest                 Tot-Rec  Tot-
            KOKHEL1  JOB07225 KOK       144 H HOLD  LOCAL                     99      
            KOKHEL1  JOB07226 KOK       144 H HOLD  LOCAL                    379      
      ?    KOKHEL1  JOB07227 KOK       144 H HOLD  LOCAL                    379     
      

      sysout前打"S"查看log

      SDSF JOB DATA SET DISPLAY - JOB KOKHEL1  (JOB07227)    LINE 1-6 (6)            
      COMMAND INPUT ===>                                            SCROLL ===> PAGE 
      NP   DDNAME   StepName ProcStep DSID Owner    C Dest               Rec-Cnt Page
            JESMSGLG JES2                 2 KOK      H LOCAL                   17     
            JESJCL   JES2                 3 KOK      H LOCAL                   71     
            JESYSMSG JES2                 4 KOK      H LOCAL                   83     
            SYSPRINT STEP010  COBOL     101 KOK      H LOCAL                   81     
            SYSPRINT STEP010  LKED      102 KOK      H LOCAL                  126     
        s   SYSOUT   STEP020            103 KOK      H LOCAL                    1   
      

      可以看到结果了

      SDSF OUTPUT DISPLAY KOKHEL1  JOB07227  DSID   103 LINE 0       COLUMNS 02- 81  
      COMMAND INPUT ===>                                            SCROLL ===> PAGE 
      ********************************* TOP OF DATA **********************************
      HELLO WORLD!!!                                                                  
      ******************************** BOTTOM OF DATA ********************************
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post