10.07.2015 Views

Enterprise COBOL for z/OS V4.2 Programming Guide

Enterprise COBOL for z/OS V4.2 Programming Guide

Enterprise COBOL for z/OS V4.2 Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Choosing the DYNAM or NODYNAM compileroption . . . . . . . . . . . . . . . . 429Chapter 22. Developing <strong>COBOL</strong>programs <strong>for</strong> IMS. . . . . . . . . . 431Compiling and linking <strong>COBOL</strong> programs <strong>for</strong>running under IMS . . . . . . . . . . . 431Using object-oriented <strong>COBOL</strong> and Java under IMS 432Calling a <strong>COBOL</strong> method from a Javaapplication under IMS . . . . . . . . . 432Building a mixed <strong>COBOL</strong>-Java application thatstarts with <strong>COBOL</strong> . . . . . . . . . . 433Writing mixed-language IMS applications . . . 434Chapter 23. Running <strong>COBOL</strong>programs under z/<strong>OS</strong> UNIX . . . . . 437Running in z/<strong>OS</strong> UNIX environments . . . . . 437Setting and accessing environment variables . . . 438Setting environment variables that affectexecution . . . . . . . . . . . . . . 439Runtime environment variables . . . . . . 439Example: setting and accessing environmentvariables . . . . . . . . . . . . . . 440Calling UNIX/P<strong>OS</strong>IX APIs . . . . . . . . . 440Accessing main program parameters . . . . . 442Example: accessing main program parameters 443Part 4. Structuring complexapplications . . . . . . . . . . . 445Chapter 24. Using subprograms . . . 447Main programs, subprograms, and calls . . . . 447Ending and reentering main programs orsubprograms . . . . . . . . . . . . . 448Transferring control to another program . . . . 449Making static calls. . . . . . . . . . . 450Making dynamic calls . . . . . . . . . 451AMODE switching . . . . . . . . . . 453Per<strong>for</strong>mance considerations of static anddynamic calls . . . . . . . . . . . . 455Making both static and dynamic calls . . . . 455Examples: static and dynamic CALL statements 456Calling nested <strong>COBOL</strong> programs . . . . . . 458Making recursive calls . . . . . . . . . . 461Calling to and from object-oriented programs . . 461Using procedure and function pointers . . . . . 462Deciding which type of pointer to use . . . . 463Calling alternate entry points . . . . . . . 463Making programs reentrant . . . . . . . . 464Chapter 25. Sharing data . . . . . . 465Passing data. . . . . . . . . . . . . . 465Describing arguments in the calling program 467Describing parameters in the called program 468Testing <strong>for</strong> OMITTED arguments . . . . . . 468Coding the LINKAGE SECTION . . . . . . . 469Coding the PROCEDURE DIVISION <strong>for</strong> passingarguments . . . . . . . . . . . . . . 469Grouping data to be passed . . . . . . . 470|Handling null-terminated strings . . . . . . 470Using pointers to process a chained list . . . 471Passing return-code in<strong>for</strong>mation . . . . . . . 474Understanding the RETURN-CODE specialregister . . . . . . . . . . . . . . 474Using PROCEDURE DIVISION RETURNING . ... . . . . . . . . . . . . . . . . 474Specifying CALL . . . RETURNING . . . . . 475Sharing data by using the EXTERNAL clause. . . 475Sharing files between programs (external files) . . 475Example: using external files . . . . . . . 476Chapter 26. Creating a DLL or a DLLapplication . . . . . . . . . . . . 481Dynamic link libraries (DLLs) . . . . . . . . 481Compiling programs to create DLLs . . . . . . 482Linking DLLs . . . . . . . . . . . . . 483Example: sample JCL <strong>for</strong> a procedural DLLapplication . . . . . . . . . . . . . . 484Prelinking certain DLLs . . . . . . . . . . 485Using CALL identifier with DLLs . . . . . . 485Search order <strong>for</strong> DLLs in the HFS . . . . . 486Using DLL linkage and dynamic calls together . . 486Using procedure or function pointers with DLLs 488Calling DLLs from non-DLLs . . . . . . . 488Example: calling DLLs from non-DLLs . . . . 489Using <strong>COBOL</strong> DLLs with C/C++ programs . . . 490Using DLLs in OO <strong>COBOL</strong> applications . . . . 491Chapter 27. Preparing <strong>COBOL</strong>programs <strong>for</strong> multithreading . . . . . 493Multithreading . . . . . . . . . . . . . 494Choosing THREAD to support multithreading . . 495Transferring control to multithreaded programs 495Ending multithreaded programs . . . . . . . 496Processing files with multithreading . . . . . . 496File-definition (FD) storage . . . . . . . . 497Serializing file access with multithreading . . . 497Example: usage patterns of file input andoutput with multithreading. . . . . . . . 498Handling <strong>COBOL</strong> limitations with multithreading 499Part 5. Using XML and <strong>COBOL</strong>together . . . . . . . . . . . . . 501Chapter 28. Processing XML input 503XML parser in <strong>COBOL</strong> . . . . . . . . . . 504Accessing XML documents . . . . . . . . . 506Parsing XML documents . . . . . . . . . 506Writing procedures to process XML . . . . . 508XML events . . . . . . . . . . . . . 510Trans<strong>for</strong>ming XML text to <strong>COBOL</strong> data items 514Parsing XML documents with validation . . . 515Parsing XML documents one segment at a time 518The encoding of XML documents. . . . . . . 520XML input document encoding . . . . . . 521Parsing XML documents encoded in UTF-8 . . 525Handling XML PARSE exceptions . . . . . . 526How the XML parser handles errors. . . . . 528viii<strong>Enterprise</strong> <strong>COBOL</strong> <strong>for</strong> z/<strong>OS</strong> <strong>V4.2</strong> <strong>Programming</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!