Google
オフコン練習帳内を検索
インターネット全体を検索

NECオフコン関連
オフコン一般
情報

トップ  >  COBOLプログラムからWindowsファイルの読み込み/書き出しを行う

プログラム

000010 IDENTIFICATION DIVISION.                                                 
000020************************************************************              
000030**   SAMPLE PROGRAM                                       **              
000040**   ファイルからファイルにデータをコピーする             **              
000050************************************************************              
000060 PROGRAM-ID.    AKITA.                                                    
000070*                                                                         
000080 ENVIRONMENT    DIVISION.                                                 
000090 INPUT-OUTPUT   SECTION.                                                  
000100 FILE-CONTROL.                                                            
000110      SELECT WINFILE1 ASSIGN TO FILE01-MSD                                
000120                      ORGANIZATION IS SEQUENTIAL                          
000130                      FILE STATUS WFSTS1.                                 
000140      SELECT AVXFILE1 ASSIGN TO FILE02-FDU                                
000150                      ORGANIZATION IS SEQUENTIAL                          
000160                      FILE STATUS AFSTS1.                                 
000170 I-O-CONTROL.                                                             
000180      APPLY EXCLUSIVE-MODE ON WINFILE1.                                   
000190*                                                                         
000200 DATA           DIVISION.                                                 
000210 FILE           SECTION.                                                 
000220 FD   WINFILE1                                                           
000230      BLOCK CONTAINS 256 CHARACTERS                                      
000240      LABEL RECORD IS STANDARD                                           
000250      VALUE OF IDENTIFICATION IS "WINFILE01".                            
000260 01   WINREC.                                                            
000270      02 A1 PIC X(80).                                                   
000280      02 A2 PIC X(176).                                                  
000290 FD   AVXFILE1                                                           
000300      BLOCK CONTAINS 240 CHARACTERS                                      
000310      RECORD CONTAINS 80 CHARACTERS                                      
000320      LABEL RECORD IS STANDARD                                           
000330      VALUE OF IDENTIFICATION IS "SWPATCH".                              
000340 01   AVXREC PIC X(80).                                                  
000350*                                                                        
000360 WORKING-STORAGE SECTION.                                                
000370 01   WFSTS1  PIC X(02).                                                 
000380 01   AFSTS1  PIC X(02).                                                 
000390*                                                                        
000400 01   EFLAG  PIC X(03).                                                  
000410*                                                                         
000420 PROCEDURE       DIVISION.                                                
000430************************************************                          
000440**    EFLAG = "LOP" .... READ NEXT DATA                                   
000450**          = "END" .... READ END                                         
000460************************************************                          
000470 MPROG.                                                                   
000480      OPEN OUTPUT WINFILE1                                                
000490           INPUT  AVXFILE1.                                               
000500      MOVE "LOP" TO EFLAG.                                                
000510      PERFORM UNTIL EFLAG = "END"                                         
000520         READ AVXFILE1                                                    
000530            AT END                                                        
000540               MOVE "END" TO EFLAG                                        
000550            NOT AT END                                                    
000560               MOVE AVXREC TO A1                                          
000570               WRITE WINREC                                               
000580         END-READ                                                         
000590      END-PERFORM.                                                        
000600      CLOSE WINFILE1                                                      
000610            AVXFILE1.                                                     
000620      STOP RUN.