Rational Developer for System z

오류 피드백 XML을 생성하는 COBOL 스니펫

다음 COBOL 프로그램 스니펫은 자신의 프리프로세서를 작성할 때 유용할 수 있는 몇 가지 주제를 설명합니다.

스니펫은 프리프로세서의 입력 파일에 대한 파일 변수를 설정합니다. SYSIN이 입력 변수로 사용됩니다. 기본적으로, SYSIN 변수는 호출에 대해 JCL이 생성될 때 System z®용 Rational® Developer에서 설정합니다. SYSXMLSD 및 SYSOUT의 파일 변수도 선언됩니다.

스니펫의 PERFORM Extract-DDDSN 명령문은 DYNQUERY를 호출하는 단락을 수행합니다. DYNQUERY의 출력은 ZFLDATA의 출력과 유사합니다. 처리는 다르며, 어셈블러에서 작성됩니다. 사용자 사이트에 C 컴파일러가 없지만 상위 레벨 어셈블러가 있는 경우, DD 이름에서 데이터 세트 이름을 검색하기 위해 프리프로세서에서 DYNQUERY를 호출하도록 결정해야 할 수도 있습니다.

PERFORM Write-xml-line 명령문은 XML 파일의 행을 UTF-8로 쓰는 단락을 수행합니다. XML 파일을 UTF-8로 작성하는 경우, 특성 그룹 편집기에서 프리프로세서에 대한 새 단계를 추가할 때 컴파일러 오류용 데이터 세트 규정자 입력 필드에 ERRWDZ를 규정자 중 하나로 포함하십시오.

       Identification DIVISION.Program-ID.  MPREPROC. Environment DIVISION. Input-output section. File-control. Select in-file                                                       
Assign to SYSIN                                                  
*         Organization is line sequential                                 
File status is in-file-status. Select out-file                                                      
Assign to outfile                                                
*         Organization is line sequential                                 
File status is out-file-status. Select xml-file                                                      
Assign to SYSXMLSD                                               
*         Organization is line sequential                                 
File status is xml-file-status. Data Division.
        File section. Fd in-file                                                              
label records are standard                                         
*       recording mode is f                                               
record contains 80 characters                                      
block contains 0 records                                           
data record is Input-data. 01 Input-data pic x(80). Fd out-file                                                             
label records are standard                                         
*       recording mode is f                                               
record contains 80 characters                                      
block contains 0 records                                           
data record is output-data. 01 output-data pic x(80). Fd xml-file                                                             
label records are standard                                         
*       recording mode is v                                               
*      16383 - word for storing the record length
record varying from 1 to 16379 characters                          
DEPENDING ON xml-length                                          
block contains 0 records                                           
data record is xml-data. 01 xml-data pic x(16379). *
      *  To run this, use a ddname
*  //OUTFILE DD DSN=[DATASET](MEMBER),DISP=SHR                            
*
       Working-Storage Section.
        01 Source-name pic x(54). 01 Target-name pic x(54). 01 Reverse-data pic x(16379). 01 Temp-data pic x(16379). 01 Nat-data pic n(16379) USAGE National. 01 Num-chars pic 99999. 01 xml-length pic 9(5). 01 Program-flags. 05 in-file-status pic xx value "00". 88 inputfile-success value "00". 05 out-file-status pic xx value "00". 88 outputfile-success value "00". 05 xml-file-status pic xx value "00". 88 xmlfile-success value "00". 05 In-file-count pic 999. 05 Out-file-count pic 999. 05 Input-eof pic x value " ". 05 line-cursor pic 99999. 05 line-cursor-end pic 99999. 05 ddname pic x(8). 05 dsn pic x(54). 05 spacestart pic 99. 05 spaceend pic 99. =================
          =================
          =================
       Procedure DIVISION . mainline SECTION. =================
          =================
          =================
           PERFORM Extract-dsnnames                                             
* Open the input and output files
OPEN INPUT in-file                                                   
if not inputfile-success                                             
display 'Error opening input file ' in-file-status                 
stop run                                                           
end-if                                                               
OPEN OUTPUT out-file                                                 
if not outputfile-success                                            
display 'Error opening output file ' out-file-status               
stop run                                                           
end-if                                                               
OPEN OUTPUT xml-file                                                 
if not xmlfile-success                                               
display 'Error opening xml file ' xml-file-status                  
stop run                                                           
end-if                                                               
=================
          =================
          =================
           Perform until Input-eof IS EQUAL TO "1"                              
=================
          =================
          =================
               READ in-file into Temp-data at end move "1" to Input-eof         
END-READ                                                         
IF Input-eof IS EQUAL TO "0"                                     
PERFORM Process-line                                           
End-IF                                                           
End-perform. =================
          =================
          =================
           PERFORM Generate-xml-end-package                                     
goback                                                               
.
      * Output: Source-name, Target-name
Extract-dsnnames. MOVE SPACES to ddname                                                
MOVE "SYSIN" to ddname                                               
PERFORM Extract-DDDSN                                                
MOVE SPACES to Source-name                                           
MOVE dsn to Source-name                                              
MOVE SPACES to ddname                                                
MOVE "OUTFILE" to ddname                                             
PERFORM Extract-DDDSN                                                
MOVE SPACES to Target-name                                           
MOVE dsn to Target-name                                              
.
      * Input: DDNAME
* Output: DSN
Extract-DDDSN. MOVE SPACES TO dsn                                                   
CALL "DYNQUERY" USING DDNAME, DSN. IF RETURN-CODE > 0 THEN                                              
DISPLAY "Error retrieving DSN for DDNAME " DDNAME                  
DISPLAY "Return Code = " RETURN-CODE                               
EVALUATE RETURN-CODE                                               
WHEN 1080                                                        
DISPLAY "DD for " DDNAME " was not found"                      
STOP RUN
WHEN OTHER                                                       
STOP RUN
END-EVALUATE                                                       
END-IF
           PERFORM Remove-DSN-Spaces                                            
=================
          =================
          =================
        Generate-xml-end-package. MOVE SPACES TO Temp-data                                             
MOVE end-package TO Temp-data                                        
PERFORM Write-xml-line                                               
=================
          =================
          =================


        Write-xml-line. *    Assume text to be written to xml-file is in Temp-data
*    Convert text to UTF-8 text
Move Temp-data to Nat-data                                           
Move Function Display-of(Nat-data, 01208)                            
to xml-data                                                        
*    Calculate length of UTF-8 text
Move Function Reverse(Temp-data) to Reverse-data                     
Move 0 to Num-chars                                                  
INSPECT Function Reverse(Temp-data)                                  
TALLYING Num-chars FOR LEADING SPACES                              
Compute Num-chars = Function Length(Temp-data) - Num-chars           
Compute xml-length = Function LENGTH(                                
Function Display-of(Nat-data(1:Num-chars),                         
01208)                                         
)
           WRITE xml-data                                                       
.
       End program MPREPROC.

이용 약관 | 피드백

이 Information Center는 Eclipse 기술로 구현됩니다. (http://www.eclipse.org 웹사이트 참조)