® IBM Software Group Enterprise COBOL Education Using Rational Developer for System z Learn how to edit and syntax check programs, and how to debug local COBOL code Jon Sayles, IBM Software Group, Rational EcoSystems Team © 2009 IBM Corporation IBM Trademarks and Copyrights © Copyright IBM Corporation 2007, 2008, 2009, 2010. All rights reserved. The information contained in these materials is provided for informational purposes only, and is provided AS IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, these materials. Nothing contained in these materials is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software. References in these materials to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates. This information is based on current IBM product plans and strategy, which are subject to change by IBM without notice. Product release dates and/or capabilities referenced in these materials may change at any time at IBM’s sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way. IBM, the IBM logo, the on-demand business logo, Rational, the Rational logo, and other IBM Rational products and services are trademarks or registered trademarks of the International Business Machines Corporation, in the United States, other countries or both. Other company, product, or service names may be trademarks or service marks of others. 2 Course Contributing Authors Thanks to the following individuals, for assisting with this course: David Myers/IBM Bill Klein Reginaldo Barosa Mike Wrzinski/Sentry Insurance Venkatuday M Balabhadrapatruni/IBM Howard Chen/asiEGL Alisande Reeves/CapGemini Rick Anderson and Asish Toomuluru/BNSF Jim Gifkins/BNZ 3 Course Overview Audience This course is designed for application developers who have learned or programmed in COBOL, and who need to do z/OS Traditional Development and Maintenance as well as build leading-edge applications using COBOL and Rational Developer for System z. Prerequisites This course assumes that the student has a basic understanding and knowledge of software computing technologies, and general data processing terms, concepts and vocabulary, as well as a working knowledge of COBOL and z/OS. Knowledge of SQL (Structured Query Language) is assumed for database access is assumed as well. Basic PC and mouse-driven development skills, terms and concepts are also assumed. 4 Course Topics Course Name: Rational Developer for System z (RDz) Foundation Training Course Description: Learn how to use Rational Developer for System z to do z/OS traditional development, maintenance, support and for Enterprise Modernization of z/OS applications Pre-requisites: Some experience developing COBOL applications using z/OS is expected. A working knowledge of SQL is also recommended. Course Length: ~5days – or if done in self-paced mode at your own pace Topics (Agenda) Getting Started - installing and configuring RDz - and the course materials, and using Eclipse The RDz Workbench – – – – The Data Perspective: – – – Creating test data Editing complex file-types Working with mainframe ABENDs using Fault Analyzer – – Debugging Batch Applications Setting Debug Tool for Online Applications Working with File Manager – – Creating MVS Subprojects Creating and customizing project properties Debugging z/OS Applications – – Connecting to a mainframe Dataset management Accessing and editing files z/OS Application Development – – Working with relational data sources Modifying test data Editing and testing SQL statements Working with remote system resources: – – – Code analysis tools Editing Compiling programs Debugging local COBOL programs Creating Fault History views Analyzing and solving mainframe ABENDs Creating and modifying BMS Maps using the BMS Map Editor 5 UNIT The RDz Workbench Topics: The RDz Workbench – Terms and Concepts Editing COBOL Programs Debugging COBOL Programs Appendix – ISPF / LPEX Editor Comparison 6 Topic objectives After completing this topic, you should be able to: Describe the foundation Eclipse terms and vocabulary: View Perspective Menus – Context menu – Toolbar menus Work with Views: Define "view" Maximize/Minimize/Open/Close/resize different workbench views Work with Perspectives: Define "perspective" Switch perspectives Reset (to their installation defaults) Access the help system 7 If you are using these slides as self-paced RDz education Notes: You may go through the following topics in this unit either as "follow-on by trying the examples shown in the slides" – workshops, or by simply reading for understanding, then doing the workshop at the end of the section. Your workbench state (the way RDz appears after you launch it) will not look exactly like the screen captures in 100% of these slides This is okay as we need to describe the use of RDz within different contexts, and what is important for you to get comfortable with, are: – Terms, concepts and vocabulary – Navigation – Editing functionality and the RDz functionality Workshops – Note that for most (at least where marked on the slide with the: symbol ) of the slides in this topic, you should experiment with the graphical development techniques described in the slide text and screen captures. Also the COBOL source in the Slide Notes might not always match the screen capture. This may happen because we are showing a few different options or techniques and should not affect your learning in a negative way. 8 Starting Rational Developer for System z To start RDz, after successful installation either: Use the Windows start menu Or – if you copied a link on to your desktop, click the link You will be prompted to select a Workspace The default installation workspace is on the C:\ drive, but you may have customized its location on your desktop Note that if you checked this default in a previous session you will not get asked to choose a Workspace (and will not see the Workspace Launcher) (Definition) a Workspace – physically – maps to a folder on your PC. A Workspace may hold a number of RDz projects. You can use different workspaces to separate medium-to-large-scale projects and for isolating major project releases. 9 Welcome to the RDz Workbench*** The RDz Workbench is the software that enables you to create, test, modify, manage, run and deploy your COBOL applications It organizes and maintains your software development resources COBOL Editor Project Organizer Remote System View (z/OS Projects View) It provides access to tools like editors, design tools, compilers and folders for managing your application resources Additional Views as tabs Program Outline View Note- as mentioned your Workbench state might look different than this 10 ***See Slide Notes The RDz Workbench – the Eclipse IDE RDz uses as its Integrated Development Environment an open-source programming platform known as “eclipse” - http://www.eclipse.org/ Eclipse is a development platform that provides a graphical development environment that we'll be calling the RDz Workbench If you're a mainframe ISPF programmer, instead of exclusively typing in code and commands, you’ll type but a lot less, and you'll use your mouse to: Drag & Drop files – from the mainframe to your workstation and back Do certain COBOL development activities – especially ones that pertain to program maintenance and analysis Manage (Open, Close, Create, Delete, Rename, Refactor, Move) files Kick off mainframe program compiles and batch jobs - and view the results “Paint” screens – develop CICS/BMS and IMS/MFS The Eclipse graphical software development idiom is a proven productivity enhancement over keyboard-only-development. Although, we will grant, that if you’re a dyed-in-the-wool ISPF-veteran, RDz will appear very different from greenscreen technology. However, you will soon find that: For almost every development facility on the mainframe there is corresponding RDz functionality With a little practice you can become far more productive with RDz Consider – how often do you open a Windows DOS command prompt to type in commands that: create, copy, delete, organize and manage the files on your PC? 11 See Slide Notes RDz Workspace and Project Topology You will work with a variety of COBOL resources: programs, copybooks, compile listings, executables, data files and so forth Using RDz you store, organize and manage the resources associated with your projects in a Workspace. After you launch RDz and select a Workspace (3 slides back), you have access to all the files and folders inside the Workspace – typically organized in one or more projects. Workspace resources are organized into - Project(s) - Folders Workspace - Files Projects Folders Files Mainframe note. Think of a Workspace as the equivalent of your TSO account (without any accounting charge-backs) 12 What is a Project (and what's in a Project?) Workspace projects organize and manage related application resources. And projects within a workspace can be organized by: Batch application .. vs.. Online applications Lines of business/departmental applications: Accounts Payable, Inventory, Claims, Manufacturing Part Assembly, etc. Common – or shared projects, which might consist of data and record definitions that are used across multiple projects There are also a number of specific RDz project types that we will learn about as we go through the course, such as z/OS Local Projects, MVS Subprojects, etc. Projects also contain and are governed by build configuration files, known as property files** which specify generation options for your project components Projects may be further divided into folders z/OS COBOL Projects typically contain the following high-level folders: BuildOutput, cobol, copy Compile Results files COBOL Copybook Source Note that you can name the cobol and copy folders anything you’d like (and they're caseINsensitive. Distributed dev-note. Think of a build file as the equivalent of the build XML in a Java “ant” file. .NET developers – this is like your “build” file and build process Mainframe note. Think of a build file as the equivalent z/OS JCL or your SCM, in that entries and property settings within a build file are used by the compiler to customize the resultant executables 13 What is in the \cobol\ folder? \cobol\ is the default folder that is the highest level folder within a given project in your workspace, under which COBOL program resources are organized. These COBOL resources include: Sub-Folders – in case you'd like to further refine and break-down the organization of large projects cobol Note: The folder name batch \cobol\ is not required nor program1.cbl enforced program2.cbl … online program3.cbl … Or in our case, just all COBOL files: cobol program1.cbl program2.cbl … By default, COBOL files should end with one of the following file-name extensions: .cbl, .cob, .cobol 14 See Notes What is in \BuildOutput\ ? \BuildOutput\ is the default folder that is the highest level folder under which all of your compiled COBOL resources are stored inside a project. These resources include: .OBJ – object modules .exe – COBOL executables – suitable for running or debugging .adt – an internal-system file used by RDz when you do source-level debugging produced by a Compiler Directive) .lst – listing file - Shows highest error condition - Sorted XRef of COBOL variables - Other program info See Notes 15 Paper/Pencil Review Questions Where (under what folder and/or sub-folder) in your project would you look for the following files? StartApp.OBJ _______________ StartApp.cbl _______________ StartApp.exe _______________ myCopy.cpy _______________ StartApp.lst _______________ True/False – all COBOL source files (each and every one) will: a. End with an extension of .COBOL b. Be organized and exist under the \COBOL\ folder – or a sub-folder under the \cobol\ folder in your project Note – if you do not know what these file types are, do not worry, we will be covering them and their use a bit later in the course. 16 See Notes Title bar - RDz "Perspective" – Currently edited file Workbench Menu and Button Bars Menu options Button Bar Search Menu Window Menu File Menu Edit Menu RDz's menu system adheres to industry standards. It is intuitive and easy to learn and navigate – especially if you've used a graphical IDE before. 17 Workbench Views Workbench tools are arranged in small tabbed areas called COBOL Editor View “Views” Views are windows which display file or project information or which provide access to RDz functionality Remote Systems View z/OS Projects View ------------------------------------------------ Additional views --------------------------------------------------- Development tasks can require you to work with tools from several different Views: Code editing Navigation tools Program testing Remote System file management Program Outline View Multiple Views related to a common development task are integrated into what is called a "Perspective" More about that, in a bit. Let's see what's some of these Views are used for, first… 18 Important Views Out of the dozens of Workbench views available in RDz, there are only a handful you need to learn to get going and become productive: 1. Remote Systems View 2. z/OS Projects View 3. COBOL Source Editor 4. Properties View 5. Outline View 6. Remote Error List View 7. Perform Hierarchy View Note that the word "view" is often dropped when discussing RDz. You can say "From z/OS Projects" or "From the z/OS Projects View" "From Properties" or "From the Properties View" 19 Remote Systems view Organizes your mainframe projects, and allows you to: Create and manage mainframe resources: QSAM/VSAM files, and PDS/PDSE data sets PDS members Create “like” – with same dataset attributes Delete, Move and Rename Open mainframe files in the RDz editor Generate JCL for COBOL programs Perform sophisticated search operations Show file dependencies: Copy file and Includes Called subroutines Develop Web Service functionality Do file compares or source history replace operations Run mainframe syntax checks on programs, using the z/OS compiler Note – this View requires you to specify a z/OS Connection, something we will discuss later in the course 20 Remote Systems view – continued Viewing Job Entry Subsystem (JES) messages in – from the Remote Systems explorer, for z/OS jobs you have launched and want to track By Right-clicking over a resource in the Remote Systems View you access a “Context Menu” that provides these options By double-clicking over a resource in the Remote Systems View you open that resource in the COBOL Editor We will not spend any time in the Remote Systems Explorer right now, and will come back to this view, in-depth, when we begin the mainframe portion of the class 21 Properties view A context-dependent View that provides statistics (like file statistics on your PC or ISPF 3.1 Data Set statistics) Example: List data set properties on the host for: Datasets – Source – Data PDS/PDSE Properties of a z/OS PDS We will come back to this view, in-depth, when we start the z/OS portion of the class 22 z/OS Projects view Organizes your projects, and allows you to: Create new resources: COBOL programs, services, etc. Copy files Open COBOL files in the editor Manipulate files: Delete, Move and Rename Run COBOL programs Debug COBOL programs Rebuild (compile) the project Refactor When “A” is changed change related “B” resources Set project-level properties Specify entry-points, in PC applications Right-click Context Menu 23 z/OS Projects view – continued Right-clicking over a resource in the z/OS Projects accesses a “Context Menu” that provides options related to the resource "in focus" Double-clicking a resource in z/OS Projects opens that resource in the Editor mapped to that file type: BMS/MFS COBOL JCL PL/I Etc. Right-click Context Menu 24 See Slide Notes Editor Area – Program Source Editor Double-click a file from z/OS Projects to load the source into the editor Note that the program shown on this slide is not in your project, yet Note to Mainframe Developers When you edit your BMS or MFS screens, they will be loaded into the Editor Area (both the source and a graphical representation of them) Here’s a look at the COBOL editor You might not be able to tell if you're looking at printed slides but the source is “colorized”: • Keywords in blue • Identifiers (variables/paragraph/section names) in black • Literals (within in “double-quotes” or 'single quotes') in maroon • Comments in green (not shown above) 25 Slide Notes Workshop – Loading programs into the Editor Area Assuming you created the chapter1 project described in the Getting Started course unit: From z/OS Projects load StartApp.cbl or PrintApp.cbl into the COBOL Source Editor Scroll through the files Switch from one program to the other Close the editor views (click the red X in the tab) 26 Outline View Provides a consolidated, navigateable list of your program’s: Copybooks Paragraphs Variables Other COBOL resources Especially useful for: Analyzing and studying programs you did not write Browsing through large source files and selecting "elements of interest" Top-Down code analysis (i.e. Learning – or getting the gist of a large COBOL program quickly) The Outline View and the source code editor are synchronized: Note – the above program is not your project Select an Outline View entry – The line of code corresponding to that entry is selected in the editor Select a line of code in the Editor – The Outline view will shift to select the associated area of your program 27 Workshop – Outline View Steps 1. From the Slide Notes, copy the code for test1 • Use: Ctrl+A to select all lines, then press: Ctrl+C 2. From RDz – Create a new file in the chapter1 \cobol\ folder named: test1.cbl 3. Paste the source you copied into the new file • Ctrl+V 4. From the Outline View – do the following – after each step note the results in the code editor • • • • • • • Click on several of the COBOL Divisions Expand the FILE SECTION, Click on: FD STUDENT-FILE Expand the PROCEDURE DIVISION, and click on 200-PROCESS-RECORDS Click on and Expand the WORKING-STORAGE SECTION Click a line in test1.cbl code within the editor and note the effect on the Outline View Try selecting other program fields and paragraphs Optional – but useful for analyzing large production program source: • Click the Outline View's menu icon for Sort ascending (a hyperlinked SXREF) • Click some of the other toggle Outline sub-menu icons: • Note – these are "toggles" – they turn the effect on (by clicking with your mouse) then off by clicking again 28 Code in Slide Notes Remote Error List View Allows you to see syntax or structural problems in your application. By double-clicking on a problem, the file in question is opened in the COBOL Editor, and your mouse is positioned to the line in doubt Source file containing the problem Hyper-linked syntax error, in the Remote Error List view Note that you can also mouse-over the Red-X in the Editor Area, and learn more about the syntax error 29 Workshop – Remote Error List View Optional Workshop: Load test1.cbl into the RDz editor Right-click over the source in the Editor Area, and select: Local Syntax Check Enter or create a typo/syntax error See screen capture below for an example Right-click, and from the context menu select: Save and Syntax Check View the Remote Error List Press Ctrl+Z - which will undo your Right-click again, and select: Save and Syntax Check Right-click Context Menu 30 Additional Useful Views – the Perform Hierarchy Enable as follows: (from the menu on the top): Window Show View Other… Expand COBOL Select: Perform Hierarchy After successful Local Syntax Check: Select a COBOL paragraph or section Right-click and from the Context Menu, select: Open Perform Hierarchy Nests (indents) the Perform chain in the view Navigate through the Perform Hierarchy view and note the synchronization with the source code: Select a Paragraph label in the Perform Hierarchy view The Perform statement for that entry is selected in the COBOL Source Editor 31 Workshop – Perform Hierarchy After a successful Local Syntax Check of test1.cbl Select 200-PROCESS-RECORDS Right-click and from the Context Menu, select: Open Perform Hierarchy Navigate through the Procedure Division using the Perform Hierarchy view Select a Paragraph label in the Perform Hierarchy view The Perform statement for that entry is selected in the COBOL Source Editor Right-click Can navigate the source from a selected Paragraph in the Perform Hierarchy 32 Additional Views – the Bookmarks View What's a Bookmark? Bookmarks are tags that allow you to quickly find specific lines of source in your program. Use them as reminders (electronic "sticky pads") Enable as follows (from an edit session) Right click in the left-hand border, next to the line you want the Bookmark on - Select: Add Bookmark… - (optionally) Overtype the name of the Bookmark - Click OK – A small vertical book icon appears in the border To clear a Bookmark: Right-click over an existing Bookmark Select Remove Bookmark To see your Bookmarks open the Bookmark View Open the Windows Menu Select Show View Bookmarks Three Bookmarks One has a customized Bookmark name 33 See Slide Notes Additional Views – the Tasks View – 1 of 2 What's a Task? Tasks are "Bookmarks on steroids". In addition to tagging lines they allow you to: Set a task priority Specify task completion Enable as follows (from an edit session) Right click in the left-hand border, next to the line you want the Task on - Select: Add Task… - (optionally) Overtype or add text in the Task Description - Select a task Priority - Check if the task is complete 34 See Slide Notes Additional Views – the Task List View – 2 of 2 To see your Tasks in the Tasks View Open the Windows Menu Select Show View Tasks From this View you can: - Navigate to specific Tasks - Check/un-Check Task completion - Re-sort the Tasks in the view - Select and work with Tasks en masse SORT Select two or more Tasks Right-click Context Menu options 35 Workshop – the Bookmarks and Tasks View Bookmarks View - With test1.cbl open in the editor – do the following: Set two or three Bookmarks throughout the program (overtype the default name on at least one Bookmark) Navigate to the Bookmark using the green rectangle in the right-hand border of the editor Open the Bookmark View – and: View your Bookmarks Navigate to Bookmarked lines Delete all of your Bookmarks Tasks View - With test1.cbl open in the editor: Set three or four Tasks throughout the program (overtype the default name on at least one Task) Navigate to the Tasks using the green rectangle in the right-hand border of the editor Open the Tasks View – and: View your Tasks Modify the Task Description Set certain Tasks status to complete Navigate to the Task lines Sort the list by Priority Sort the list by Complete/not complete (OPTIONAL) Select all of the Task information – Copy the Tasks and paste into rows of an Excel spreadsheet Delete the Completed tasks Delete the remainder of your Tasks – en masse (using the Context Menu) 36 Working With Views You can Maximize a view by double-clicking in the middle of the View Tab (and Restore the view back, by doing the same) You can Close a view (inadvertently or on purpose) – by clicking the X To close a program you are editing: Can also use these icons – to maximize and minimize Click the close icon, on the tab Alternatively you can close an edit session by pressing Ctrl + 0 (zero) …or… Ctrl + F4 You can Re-open a View (such as the Outline View) by pulling down the Window menu, and selecting: Show View > 37 Workshop – Manipulating Views Experiment with Workbench Views – to get comfortable manipulating them and their contents Maximize, and Restore an editor view of one of your programs, or of the Outline or Properties View. Close the Outline View From the Window menu reopen the Outline view by selecting: Show View > Outline Open several programs Right-click over the tab, and select: Close Others Close all 38 RDz "Perspectives" Perspectives organize views into groupings designed for particular roles and oriented to doing specific tasks in a productive way There are only a few perspectives you will use in this course: z/OS Perspective Used for creating and testing COBOL and PL/I applications Debug Perspective Used to debug COBOL and PL/I applications RDz Workbench in the z/OS Perspective Data Perspective Used to view relational data and run SQL interactively Different Perspectives offer different views of development resources. The views will change, and even change position within the Workbench depending on the Perspective 39 z/OS Projects Perspectives You will spend most of your time in the z/OS Projects Perspective. It has default views optimized for COBOL programming, data set and file management, accessing host and local development resources. Switch Perspectives by clicking an icon here 40 Debug Perspective Used to test applications, running and viewing source code line-by-line: Locally – On your workstation Remote – An RDz feature that allows your online or batch process to run on the mainframe, while you debug on your Workstation Variables View Debug Thread View COBOL Source in the Editor Area Debugged line-by-line 41 Program Outline View Database Development Perspective DB2 Table Editor View You will do DB2 data and SQL statement development, and testing in the Database Development Perspective DB2 Tables listed in the Data Source Explorer SQL Statement Run Results View We will cover the Database Development Perspective in-depth, in a future class section 42 Working With Perspectives Options: Open Perspective From your current workbench perspective, open a new perspective with its default views and tools Reset Perspective Return to the RDz installation defaults, for a perspective Close Perspective Close a perspective if no longer needed for your work at the moment Customize and save a perspective When you have used the Workbench for awhile, you may want to create your own custom perspectives, with customized views and tools, etc. All "in-use" perspectives can be switched back and forth from an icon at the top-right corner of your Workbench which shows the perspectives Workshop: Follow the instructions above and: Open some other (not the z/OS) perspective. Close the perspective. From within a perspective close some Views. Then Reset the perspective. Switch perspectives. 43 Workspace Preferences – Customizing the Workbench The Preferences dialog (under the Windows menu) allows you to customize your Workspace development environment. You will use the dialogs and entries in this area for quite a few important z/OS COBOL development activities throughout the course: Customizing the editor Specifying Database Connection information Entering JCL JOB card information More… 44 Workspace Preferences – Customizing the Workbench – General / Editors From the Text Editors option you can set global editing characteristics for your work: Recommendations Enable by checking: Highlight current line (For mainframe ISPF developers) Disable by un-checking: Enable drag and drop of text (see notes) Current line highlighted Feel free to try changing text drag and drop or current line highlighting 45 Changing Colors You might wish to customize your editor colors. You can do this from: Preferences LPEX Editor Appearance and Parser Styles sub-options. Feel free to try changing your default editor colors 46 > Workspace Preferences – Add a Custom Function Key Operation Open the Windows menu and select Preferences Expand: LPEX Editor Click: User Key Actions (from the bottom part of the tab) Enter the following: Key: f5 From Action, select: CobolOpenDecl Click Set Click OK Note: lower-case f5 47 Workspace Preferences – Test Your Custom User Key Function From z/OS Project Explorer Double-click: PrintApp.cbl To load the source into the editor Scroll down – to the end of file Double-Click (to select): Out-Name Press: F5 Your cursor should jump to the field's declaration, in the COBOL DATA DIVISION Mainframe note (F5 / PF5) – F5 on a PC keyboard is not the equivalent of PF5 on a mainframe 3270 device (unless you setup the emulation). 48 Creating New COBOL Programs – 1 of 3 Two Approaches: 1. Use COBOL program templates ***Preferred 2. Start with a new file – and name with .cbl extension We'll begin showing you the .cbl extension approach Creating a new file (named with a .cbl extension) – steps: 1. Set focus to the project/folder 2. Right-click and select: New > File 3. Name the file <name>.cbl 4. Click: Finish You're ready to enter your COBOL statements 49 COBOL Code Templates – 2 of 3 Templates: Available from (menu): Allow you to create standards-based, code-reuse libraries of different kinds of pre-configured statements, snippets, etc. Window Preferences COBOL Code Templates Can: Select and customize any program area Export: Set focus Click: Edit A single (selected) template All of your templates Import templates 50 Creating a new file (using a Template) – Steps – 3 of 3 1. From the RDz menu system, select: File > New Click Next> > Other… > COBOL > COBOL program 2. Name the file <name> (No need to type the extension) And enter the Author name and Target 3. Click: Next> 4. Select which Project/Folder to create the file within 5. Click: Next> 6. If your program is going access: CICS or SQL databases check the appropriate options If you select these options, there is another wizard you can access to further customize the default code snippets 7. Click: Finish You're ready to enter your COBOL statements 51 Keyboard ..vs.. Mouse-Based Development Techniques You will use two different development techniques with the Workbench: 1. Type COBOL statements (business logic) using the COBOL Editor, and sometimes type other short properties in Workbench dialogs and fields. This is no different from programming in any other toolset or language 2. Navigate through the Workbench, and do “drag & drop” development (with your mouse). If you’re new to drag & drop development here are some hints. Left-mouse button Right-mouse button Open a “context menu” - From a program in the Editor Area Select something - Click – to set focus to, and select a field - Click a drawer in the Palette - Select a file in the Editor Area - Open a Declaration or Copybook - Syntax Check - Refactor - Copy/Paste/Move/Delete a selection (block) of code Scroll up and down/Right and left Double-click a resource in z/OS Project Explorer to open it in the Editor Area - Project Explorer – the context menu allows you to Open a Workbench menu (at the top) - Create a new resource - Refactor/Rename - Generate (compile) a resource - Run a local program - Build a project Select (Left-mouse), hold, drag and drop a resource – used primarily for: - Opening Split-Screen views in the editor - Dragging and dropping Remote Project resources - CICS/BMS and IMS/MFS screen painting 52 Review – Concepts Match the Following Terms and RDz Vocabulary 1. Editor Area ___ The highest level folder that contains all of project folders you can work with. You choose this right after launching RDz 2. Remote Systems View ___ The perspective where you test your development work – running the code while you view source lines 3. z/OS Projects View ___ The area (view) in which you edit files and use to layout and create BMS and MFS maps. 4. Perspective ___ A perspective that displays and organizes views that are optimal for doing z/OS COBOL and PL/I development 5. Outline View ___ A View that allows you to select and open files, delete them, create new files, generate (“compile”), run and debug COBOL & PL/I applications 6. The Eclipse menu ___ The View that shows your z/OS connection and all of your mainframe PDS libraries as folders (as well as JES – jobs and individual datasets) 7. Preferences ___ The View that shows (and allows you to navigate to) the areas of your COBOL or PL/I source quickly 8. Remote Error List View ___ An organized collection of Views 9. Properties View ___ The area of the Workbench where you customize the workspace’s behavior, setup 10. z/OS Perspective ___ The View that allows you to see the characteristics of datasets and files 11. Debug Perspective ___ The view that contains all of the syntactical errors in your COBOL or PL/I source, and configuration errors for your project 12. Workspace ___ The standard window IDE system for organizing software options – such as File, Edit, Search, etc. 53 Answer the following questions using the RDz Workbench 1. Under what menu option, can you access windows to change perspectives and open Views, modify your Workspace preferences? 2. From the product Help/Help Contents search on – and read (skim) the contents of the following topics: • System z LPEX Editor • Interactive System Productivity Facility LPEX commands • z/OS Projects Perspective 3. Questions on the z/OS Projects View – locate the option to: - Rebuild a project - Rename a project - Debug a program - Create a new folder or file - Nominate a program as the "Entry Point" into an application - Extra Credit – What do you think: Nominate as Entry Point does - Show the dependencies necessary to build a project or program - Extra Credit – what does "Show Dependencies" do? 4. From what View (and how) do you open a file (i.e. how do you load a file into) the Editor Area for editing or browsing? 5. With a program loaded into the Editor Area, what View exposes (shows) COBOL or PL/I variables, divisions and paragraphs (procedures), and allows you to navigate within the source code quickly and easily? 54 Lab Assignment – RDz Workbench “Test Drive” – 1 of 2 Do the following: 1. Launch RDz and select your workspace 2. Find (by opening folders in z/OS Projects and opening files in the Editor Area) and describe the contents of the following resources (files): Printapp.lst Startapp.lst Startapp.cbl Double-Click: Startapp.exe – follow the on-screen instructions, and finish the run by entering: Q Click (set focus to … select or choose) each of the three open files Make the files in the Editor Area full-screen, then size them back down – Do this several times (get comfortable with this, it's a key to your productivity) Close the files in the Editor Area Close an individual file Close all files at once (using a single mouse-click) 3. Find and close the Outline view then re-open the Outline view 4. From z/OS Projects Explorer – explore your first z/OS Project • Open and close several of the folders: cobol and BuildOutput 55 Lab Assignment – RDz Workbench “Test Drive” – 2 of 2 Do a bit more test driving: 5. From the RDz/Eclipse Menu System – find (locate or navigate to) the following: (Note: Cancel after you've arrived at each of these destinations): • • • • • • File menu > New > Other > Examples File menu > Import > General > File System Edit menu (Glance at each of the Edit menu options ) Search menu (Again, just get an idea about the Search menu options ) Window menu • Show View > Other > COBOL Perform Hierarchy • Show View > General > Book Marks • Show View > General > Tasks Help menu > Samples > Tours > • Rational Developer for System z User Assistance Features • Click the above link, and listen to some of the narrative 6. From the Window menu, open the Debug Perspective • Using the icons (top right hand corner of Workbench) switch from the Debug to the z/OS Perspective • Close the Debug perspective • Reset your “current” (should be the z/OS) Perspective • Close any open files in the Workbench 56 Optional Workshop – Doing Two Things at a Time Note that you can: Open Rename Copy Delete … multiple source files at once Steps: Select a file, then holding down either the: Ctrl key Shift key … Select additional files Right-click Select Open Note – Please don't delete or rename these files. You'll need them for future workshops in this course. 57 Workshop – Create a COBOL Program Using Customized Templates 1. 2. From Preferences, modify the default COBOL templates. Add a comment "flower box" as follows: Select Program Comment Click Edit… Enter COBOL comments – space over 6X to start each * in column 7 – Note that you can feel free to embellish – adding your company name, etc. And optionally add ID and Procedure Division comments Press OK Following the steps on the prior slide (3 of 4) create a new COBOL program using your modified Template in your project's cobol folder. Name it anything you'd like (but a valid COBOL name) 58 Unit Summary Now that you have completed this unit, you should have: Navigated the eclipse IDE, Opened project folders and files Set Workspace properties Defined and used the following eclipse views and perspectives: Views – – – – – – – Editor Area z/OS Project Explorer Outline Remote Systems Remote Error List Properties Window/Preferences/Capabilities Perspectives – z/OS – Debug 59 UNIT The RDz Workbench Topics: The RDz Workbench – Terms and Concepts Editing COBOL Programs Debugging COBOL Programs Appendices - ISPF / LPEX Comparison 60 Topic objectives After completing this topic, you should be able to: Contrast and compare the two different RDz COBOL source editors List the features of the ISPF editor, and point out the LPEX-equivalent editing function Set your preferences to choose one editor vs. another List the standard (common) COBOL source-editing techniques, and perform them using either of the RDz editors Customize the LPEX editor and extend its functionality Workshops As mentioned previously, for most of the slides in this topic, you should experiment with the editing technique shown with either: Your own COBOL programs (if available) The code in the Slide Notes (where marked on the slide) – Sometimes you will find explicit Workshop steps – but in many cases the techniques are straightforward enough that you can just try them out by viewing the screen captures and working through the few mouse-clicks or wizards without separate defined workshops. 61 See Notes The RDz Source Editors RDz provides different editors for developing applications: LPEX Editor – a high-end, graphical editor with features specific to mainframe development requirements ISPF Editor – an emulation of IBM's mainframe editor, integrated into the RDz/Eclipse Workbench Both provide the common editing requirements: Insert/Delete/Copy/Paste/Repeat/Find/Change Command line editing options Extensive list of Hot-Key combinations for short-cut editing (ex. Ctrl+S = save, Ctrl+D= repeat line, etc.) Both have context-sensitive features: File-type-sensitive source columns and tabs (i.e. JCL ..vs.. COBOL and PL/I) File-type-sensitive context menu options LPEX oriented towards mouse-based, graphical editing techniques ISPF is oriented towards line-based/mainframe style editing Your choice But, if you're a mainframe-veteran, don't just bail on the LPEX editor It's more extensible And in-line with all contemporary editing products and tools We will learn how to use both of these editors, and start out, by seeing what features are common… 62 RDz Source Code Editing – Basics Getting started… * Means this file has been changed, and not yet saved COBOL A – B margins, *comment column, column #s up to 80 Information on your cursor position Edit line Double-Click – to load a file into the Editor Scroll Up & Down in the file Command line 63 Full-Screen Edit View Double-Click – to toggle from normal to fullscreen to normal view You will want to work in both normal and full-screen mode, while doing COBOL development Normal-screen mode gives you access to: Your code The Context Menu All of the tools in the various RDz Workbench Views: – Outline view – Perform hierarchy – Many others Full-screen permits access to the Context menu, while allowing you to see and work on much more code at-a-glance The number of lines depends on your screen resolution: 1024 X 768 – 31 lines 1280 X 1024 – 46 lines 1600 X 1200 – 60 lines You can also split screen vertically to access a LOT more code at-a-glance Note the vertical lines marking the A and B margins 64 Workshop – Editor Preferences – Enabling the A and B Editor Margins These margins are optional, but if you like them enable as follows: From Preferences, expand: LPEX Editor > System z LPEX Editor > COBOL Parser - Check the three boxes shown below - Click OK 65 Hover (mouse-over) Variable and Paragraph Name To see the declaration of a variable, paragraph or section name: Move your mouse-pointer over the identifier – and just hover Notes: You can hover anywhere (not just on the "current line") Hover works even if the declarations are contained in a copybook (although you have to configure the SYSLIB property in your project) Workshop – Open test1.cbl in the Editor. Scroll down in the source and hover over variables, file names and fields within a record. 66 More Hover Help – Delete or Moved Lines If you d or move program lines during edit, the place where the lines were originally is marked by a small thin rectangle in the edit border. You can mouse-over the rectangle to see the original statement(s) Notes: Ctrl+Z can un-do edit operations Once you save (Ctrl+S) your source, the deleted/moved lines markers are gone 67 The Outline View – Revisited The Outline View allows you to collapse and expand program: Divisions Sections Paragraphs Group-level data items Very useful for: Understanding or visualizing the structure of a program Navigating within a program Note – You don't have this program yet. It's shown here to demonstrate the Outline View 68 Real-Time Syntax Validation Validation Markers When the COBOL Validator does not understand what you've coded, a yellow warning triangle appears in the prefix column on the far left of the editor If you mouse over the column you can get context-specific language coding "hints" You can enable/disable Validation from the Preferences menu Windows > Preferences > LPEX Editor > System z LPEX Editor > COBOL LPEX Editor 69 See Slide Notes Workshop – Syntax Validation Optional workshop: 1. With StartApp.cbl open in the editor 2. Scroll to line 53 3. Change the until to unti 4. Move the cursor to see the yellow syntax validation triangle 5. Move your cursor directly over the validation triangle to view the validation message text 6. Then correct unti back to until 7. Note that the validation triangle disappears If time permits find out what else validation works for: • Misspell variable name references inside the Procedure Division • (in test1.cbl) misspell paragraph names in PERFORM statements Do not save your changes 70 Different Content Assist options Content Assist (Ctrl+Spacebar) Content Assist allows you to code statements by selecting values from a list after typing partial text and pressing: Ctrl+Spacebar The process: Partially type a: COBOL keyword Variable (including 88-level) Paragraph name Move your cursor immediately at the end of the text you wish to use Content Assist to complete "immediately" = the very next byte after the text Press Ctrl + Spacebar Select the completion identifier from the list – which is sorted alphabetically within type Benefits: Improves productivity Reduces typos and syntax errors Particularly helpful with lengthy COBOL identifiers 71 Workshop – Content Assist Refactor the 300-WRAP-UP paragraph in test1.cbl using Content Assist – and move the file close statement into a new Performed paragraph. 1. 2. 3. 4. 5. 6. 7. Type in a new Paragraph name at the end of the program Enter a new blank line below the paragraph name Type: cl and press Ctrl+Spacebar Select CLOSE Use content assist to select both file names (one at a time) Add a period at the end of the CLOSE statement Enter a blank line in place of the current CLOSE statement in 300-WRAP-UP Use Content Assist to select: 7a. PERFORM 7b. Your new paragraph name 3. 4. 7a. 7b. When finished: Save your changes and using the Context Menu do a Local Syntax Check. Remove any syntax errors 72 Hot-Key Combinations Show complete list by pressing: Ctrl+Shift+L Black entries are activated Gray are unavailable in the current editing context Entries are case-IN-sensitive Select Text Shift+End – Select text to end of line Shift+Home – Select text to start of line Ctrl+Shift+Right – Select next word of text Ctrl + Shift + L Both the LPEX and ISPF editors provide an extensive collection of hot-keys or keystroke shortcuts Copy/Paste Text Ctrl+C – Copy selected text Ctrl+X – Delete selected text Ctrl+V – Paste selected text Alt/U – De-select selected text Line Options Alt+L – Select current line Ctrl+D – Repeat (duplicate) current line Ctrl+Backspace – Delete current line Enter – Insert new line (below current line) Miscellaneous Ctrl+Z – Undo last change (one at a time) Ctrl+Y – Redo last un-done change Ctrl+F – Find and replace text 80/20 list of Hot-Keys includes: Navigation Ctrl+Home – Top of file Ctrl+End – Bottom of file Ctrl+L – Opens go to line number feature Ctrl+2 – Open same file in new view Ctrl+T – Make current line top line in editor Escape – Cursor jumps to command line Home – Cursor moves to current line/1st character position End – Cursor moves to last character position, of current line 73 Hot Key Example – Source File Navigation Ctrl+Home – top of file Ctrl+End – bottom of file Ctrl+L (or Esc) – places your cursor inside the LPEX Command Line – where you can: Type in a line #: Press Enter 74 Workshop – Source File Navigation Load test1.cbl into the editor Do the following: Press: Ctrl+L Type: 77 Press: Enter Press: Ctrl+T Press: Ctrl+2 Close the additional source view Press: Ctrl+End Press: Ctrl+Home What do the following hot-key combinations do? Position your cursor at the beginning of any line with COBOL source and press: Shift+End Position your cursor at the end (to the right) of any line with COBOL source and press: Shift+Home Press: Ctrl+Shift+L 75 Context Menu – Overview Both the LPEX and ISPF editors provide a powerful set of editing tools from a Context Menu, which is activated using the rightmouse button – and is meaningful "in the context" of something you've selected in your code, or something you are doing with RDz (i.e. selecting a file from the z/OS Project Explorer) Options exist for: Text editing Copy/Cut/Paste selected lines Comment/Uncomment selected lines Refactor (rename) paragraphs, sections or variables Running and Debugging programs Filtering out areas of your source, to view specific elements Submitting JCL (if you're editing a JCL file) Syntax checking your source locally or remotely (on z/OS) Opening and browsing copy members Comparing and replacing changed versions of your code with "local history" – copies of your source maintained during your edit session Opening (jumping to) a paragraph or variable declaration Viewing the Perform chain of a program All of these options can be useful, and when worked into your editing repertoire, can improve your development productivity. 76 Open Declaration Often, you will be editing code in the PROCEDURE DIVISION and need to verify something about a specific declaration: Variable, Paragraph or Section Besides hover, the easiest way to jump to the declaration is to: Set the cursor-focus in the variable, paragraph or section identifier Right-click Select: Open Declaration Open Declaration to jump to a variable definition "Jump" back to the line you started from, by clicking the back arrow on the menu bar Notes: This feature works, even if the declaration you are opening is in a Copybook or Include The bigger and more complex the program – the more you will use Open Declaration If you finished the workshop at the end of the last topic, F5 should also open the declaration 77 Open Declaration to jump to a Paragraph Workshop – Open Declaration 1. Load test1.cbl into the editor Go to line 74 – or whatever line shows: PERFORM 300-WRAP-UP Double-click and select: 300-WRAP-UP Press F3 – or use the Context Menu 2. From within the 300-WRAP-UP paragraph Double-click and select: CTR-STUDENTS Press F3 – or use the Context Menu 3. Click the back arrow (in the menu bar) several times to back-trace your steps 78 Working With Copybooks Similarly, you may want to open a Copybook or Include file from within a program: Set your mouse-focus inside the variable Right-Click Select: Open Copy Member You do not have these files in your project 79 Other Copybook Development Facilities – Show Dependencies Shows the copybook/include file "build dependencies" necessary for your COBOL program to compile successfully From z/OS Project Right-Click over the file you want to run the report against Select: Show Dependencies… 80 Enabling Your Project for Copybooks Copybook and Include files are found by RDz searching in a SYSLIB property – a project attribute set by doing the following: From the Window menu: Show View > z/OS Project Views > Property Group Manager From the Property Group Manager View 1. Expand LOCAL 2. Right-click COBOL Sample Property Group, select: Edit… In the SYSLIB setting, enter the fully-qualified directory structure of where you will store your project's copybooks The SYSLIB directory must be within your project The SYSLIB setting is case-sensitive to directory and folder names In this example: d: - drive RDZProjectNew – my workspace folder chapter1 – my project folder in the workspace copy – a folder inside of the chapter1 project 81 Workshop – Enabling Your Project for Copybooks (Part 1 of 2) 1. From the z/OS Projects explorer, create a new folder named copy, in the chapter1 project 2. Following the five steps (on this and the previous slide) enable your chapter1 project for copybooks by setting the SYSLIB property to your copy folder, under chapter1 (remember, that SYSLIB is case-sensitive) 3. Create the copybook source file in your SYSLIB directory • Select and copy (Ctrl+C) all of the COBOL 01-record statement declaration code in the Slide Notes • Right-click over your new copy folder in your chapter1 project, and select: New > File A. Name your new file: cobtable.cpy B. Paste (Ctrl+V) the copied source code into your new file C. Save (Ctrl+S) the file 82 Slide Notes Workshop – Enabling Your Project for Copybooks (Part 2 of 2) 4. From the slide notes – select all (Ctrl+A) then copy (Ctrl+C) the large COBOL program source file 5. From Project Explorer – Create a new file under the \cobol\ folder, named: cntrlbrk.cbl 6. Paste the copied source code into this new file – starting at line1/position 1 7. Save (Ctrl+S) your new COBOL program 8. Experiment with all of the Copybook development techniques discussed – starting from five slides prior in this unit: With cntrlbrk.cbl loaded into the editor: find the copy statement in the program source Press: Ctrl+F Type copy in the find area and press <Enter> Double-click (to select) cobtable Right-click and from the Context Menu, select the options to: Browse Copy Member Open Copy Member Close the copybook Find a copybook variable in the Procedure Division: Ctrl+F Type CUSTOMER-NAME in the find area and press <Enter> Double-click to select CUSTOMER-NAME Right-click and from the Context Menu select: Open Declaration Close the copybook From z/OS Project Explorer: Right-click over cntrlbrk.cbl Select: Show Dependencies… 83 Program Code in Slide Notes Split Screen Edit – Vertical Views Let's assume you want to view that copybook in one screen, and your main program source in another. To split your editing view: Hold down the left-mouse button over the file tab. Drag to the left until your cursor turns into a west-facing cursor Drop (release the mouse button) Note that you can: Maximize your editor view (Double-click the tab) Resize each of the vertical panes (Left-click, Drag & Drop) 84 Vertically-split edit views Split Screen Edit – Horizontal Views To split your editing view horizontally: Hold the left-mouse button over file tab. Drag downwards (until your cursor turns south-facing) Drop (release the mouse) Note that you can: Maximize your editor view Horizontally-split edit views 85 Double-click the tab Resize each of the horizontal panes Left-click & Drag to size Split Screen Editing a Single Program To split your screen while editing a single program: From inside the source, press Ctrl+2 This allows source edit (not only browse) in either window Consider maximizing your view Double-click the tab Close and return to a single source view by clicking the X in the right-hand corner Double-click the tab (again) to return to normal Workbench view Workshop Load StartApp.cbl into the editor Press Ctrl+2 Make some changes DO NOT SAVE YOUR CHANGES (please) 86 Second edit-able view of a program Can I Combine Multiple Views? You bet! Simply combine the Drag & Drop techniques discussed on the previous slides (op-ed) Consider the benefits of this level of display and edit flexibility Especially for: Large programs Programs with many Copybooks & Includes Applications you are learning to maintain or support 87 An even "BIGGER PICTURE" – View 174 Lines of source code in three programs – Fully edit-able and tooling-enabled (can maximize any program view, etc.) fdfds 88 What can you do with all that "real estate"? Examine and analyze the program logic that does screen handling… While you're reviewing the screens I/O area definitions… Correlating with the actual screen layout (source or design views) 89 It's Windows, right? (If you don't like the fonts you can scale them to any resolution) What else can I do with all this extra screen real estate? 90 More Ideas (on what do with all that screen real estate) Reconcile record layout and picture clause mismatches 91 Work with Database Applications 92 Workshop Split Screen Edit – 1 of 2 Open StartApp.cbl and PrintApp.cbl in the Editor Area Select one of the program's tabs. Hold-down the left-mouse button and drag to the right to create a Split View Double-click to maximize Note the utility of seeing programs that call one another, passing parms etc. Close All Edit Areas 93 Workshop Split Screen Edit – 2 of 2 Load cntrlbrk.cbl into the Editor Area. Press Ctrl+2 to split screen. The open the cobtable.cpy copybook into the editor. This will create three frames. Left-click-hold and drag the cobtable.cpy down so that it becomes a horizontal split view. Consider how useful it would be to be able to analyze programs like this. 94 Consider how helpful it would be to analyze, or learn code when you need to see specific areas of a program – or several programs at a glance… File Compare – Source Programs – 1 of 3 It's often necessary to compare two different releases of the same program source. RDz makes this VERY easy to do – from the z/OS Projects explorer: Select the different .CBL files – note that they could be in the same or in a different project Right-click – select: Compare With > Each Other 95 File Compare – Source Programs – 2 of 3 Results are displayed in side-by-side windows (Maximized for best viewing). Notes: Lines changed and new lines from either source file shown in different shades Can click on the right-hand column border to navigate – and/or use the toolbar 96 File Compare – Source Programs – 3 of 3 Can use Compare With/Each Other - with any ASCII file – even ASCII data files 97 Workshop File Compare This workshop will demonstrate the file compare functionality. 1. 2. 3. 4. 5. 6. 7. Open StartApp.cbl into the Editor Area Press: Ctrl+A - to select all lines Press: Ctrl+Insert (or use the Context Menu) - to copy all lines Right-click over your project's \cobol\ folder, and select: New > File Name the file: StartAppNew.cbl Paste: Ctrl+V - all of the copied source lines in your new program Make a few changes to the source: Delete line(s) Add line(s) Modify line(s) 8. Save your changes 9. From z/OS Projects: Select both programs Right-click and select: Compare With > Each Other 10. Experiment with: The toolbar icons The scrolling options Close all files 98 Find/Replace Dialog – 1 of 2 Multiple ways to search for text throughout source in your Workspace. We will cover them over the next few slides. Standard find: From anywhere inside your source, press: Ctrl+F …or… Ctrl+f Brings up the following dialog with find options 1. Enter Find and/or Replace value 2. Check one or more search refinement options 3. Press a Find button Find option checkboxes: Case sensitive – case sensitive search Whole word – finds your text delimited by spaces or dashes Regular expression – powerful search meta-language – for complex search Wrap – if starting mid-way through source, continue find from the top Select found text – shows and selects found element Peek: Shows specified number of lines of source after the found element Restrict search to columns – search between start and end columns only (covered on the next slide) 99 See Notes Find/Replace Dialog – 2 of 2 Find option buttons: Next – Find forward in the source – Does not find text inside copy or include files – Ctrl+n – finds next Previous – Find upwards (back) in the source from your current cursor position All – Finds all lines within the source – Acts to exclude or filter source – Press Ctrl+W to "show all" excluded lines …and/or to close the find dialog box – Clicking anywhere in the main body of your source file also closes the Find dialog – Click the pluses in the left-hand border as well – show filtered source Replace – Adheres to COBOL columns – If replace would push text past column 73 you will receive a warning Replace all – Changes "found" to replacement values throughout file 100 Find All (Exclude) Search Within File Common ISPF editing technique: Exclude various source lines Find (within) excluded lines Used extensively on giant production program source files Command ====> F (or C) 'xxx' X To perform this using LPEX: 1. Do a Ctrl/F Search 2. Then another search Subsequent searches will only look within the found (displayed) source lines until you: – Press Ctrl/W – Or press the All button, which searches all source lines 101 Find All (Not Exclude) Search Another common ISPF technique Exclude various source lines Find within (not) excluded lines Command ====> F (or C) 'xxx' X To perform this using LPEX: 1. Select (something) 2. Exclude the selection 3. Search (Ctrl/F) – and the search will (again) run against the displayed lines 102 Workshop Find/Replace Dialog Load test1.cbl into the editor Do a Find All: 01 Note that it found a bunch of comment lines Why? Restrict the column search to between 8 and 20 Find All: 01 (again) Expand some of the plus-signs and un-filter the code Press: Ctrl+W … What does that do? Experiment with most of the Find/Replace options and option buttons covered on the last two slides – but make sure to try out at least these options: Case sensitive Whole word Replace Next Replace Please do not save your changes 103 Workshop Find/Replace Dialog – with Highlight all occurrences Many developers prefer to have all "found text" highlighted. To do this: From the Window menu Select Preference LPEX Editor System z LPEX Editor Find Text Check: Highlight all occurrence Click OK Return to the previous slide, and redo the exercises 104 (Optional Topic) Find/Replace Dialog – Regular Expressions Given the size of production COBOL source, the number of variables and complexity of your work, often you'll need powerful text search capabilities, beyond simple Find operations. Enter Regular Expressions. Regular Expressions (sometimes called: regex) are a meta-language that is interpreted by RDz's LPEX editor and allow for powerful and rich text search constructs. Regular Expressions are activated when you check the Regular expression box in the Find/Replace dialog: With Regular expressions you can search for: Hexadecimal data (embedded binary values in your source) Complex text patterns that defy simple Find operations: Find all variables that end in: -OUT Find all variables that start with: HIPAA Find all lower case values, upper case values, special characters, alphabetic characters Combinations of the above and more 105 (Optional Topic) Find/Replace Dialog – Regular Expressions The Regular Expression meta-language is based on a few simple constructs 106 Regular Expressions Can Be Used in All Search Contexts You can use Regular Expressions to search for text: In a program Throughout all programs in a project On the mainframe: Across all members n a PDS Across multiple PDSs of different types: .COBOL, .BMS, .JCL, etc. 107 Regular Expressions – Used to Support ISPF Find "Picture Strings" ISPF Editor LPEX Editor Simple String Y Previous String Find Previous / F5 Delimited String Y Text string Y Picture Strings – special characters Y – with regular expressions P'=' – any character Ctlr+F, Regular Expression, P'-' – any non-blank character Ctlr+F, Regular Expression, P'.' – any non-displayable character Ctlr+F, Regular Expression, P'#' – any numeric character Ctlr+F, Regular Expression, P'-' – any non-numeric character Ctlr+F, Regular Expression, P'@' – any alphabetic character Ctlr+F, Regular Expression, P'<' – any lower-case character Ctlr+F, Regular Expression, P'>' any upper-case alphabetic character Ctlr+F, Regular Expression, P'$' – any special character (not alphanumeric) Ctlr+F, Regular Expression, ^ Ctrl+F 108 . Dot, any single character \ logical NOT . special Expression \x Hexadecimal [^\x20] [^\x20-\x7E] [0-9] [^0-9\x20] [A-Za-z] [a-z] [A-Z] [^A-Za-z0-9] Workshop Find/Replace With Regular Expressions Expression Load test1.cbl into the editor Check Regular expression Enter the following Regular expressions, and click All after each: Expression What it does [0-9] All numeric characters [a-z] All alphabetic characters [a-z] Check: Case sensitive in the dialog, and reissue this regular expression. Then un-check Case sensitive before continuing DL.C Find all variables with "DL" – any character – then the letter C [^\s] Find all characters except for white space (blanks: \s ) [^a-z] Non-alphabetic characters [^A-Z\x20] Non-alphabetic characters and no white spaces [^A-Z0-9\x20] Non-alphanumeric characters and no white spaces [^A-Z0-9\x20-] Non-alphanumeric characters, no white spaces, no dashes [^A-Z0-9\x20\(\)..-] Non-alphanumeric characters, no parenthesis and no white spaces [^*A-Z0-9\x20\(\)..-] Non-alphanumeric characters, no parenthesis, no asterisks, no white spaces .*(data) Find all variables that end in "data" PIC .9|PIC 9\( Find all numeric variables 109 See Notes findText / replaceWith – LPEX Editor Commands Much of what you can do with Ctrl+F and the Find/Replace options can also be done from the command line To find and replace text within a program: Press the Esc key – to jump to the command line Enter: findText <textValue> Press Enter There are a number of useful options from the command line for finding and replacing text Notes: If you are a "keyboard-oriented" developer, you may want to try LPEX commands such as findText There are many other LPEX Editor Commands (see next slide) findText – the command, is case sensitive LPEX command line find/replace options findText all – finds all occurrences and filters extraneous lines findText up – finds up in the source, from the current line findText columns – search between start and end columns only findText replaceWith <replaceText> <findText> – find and replace occurrences of the <findText> with the <replaceText> Sample combined command: findText all columns 8 72 replaceWith Temp-name-2 Temp-name 110 Other Useful LPEX Editor Commands and Command Line Usage The LPEX command line (press escape key to access in one keystroke) can be used to enter LPEX commands and actions. Some useful LPEX line commands are: help (or ?) – which brings up LPEX help help lpex – hot-keys, LPEX commands, actions help ispf – hot-keys, ispf prefix commands, actions submit (to submit JCL from the editor) arrow keys can be used in the command line to recall commands /text Finds the next occurrence of the specified text. Precede with minus sign to search backward -/text 'text (apostrophe text – ex. 'Temp-name ) - Finds the next occurrence of the specified text <lineNumber> - Locates the specified line get – copies an external file into the current cursor-focus point print – prints the file top – jump to the top of file bottom – jump to the bottom of the file TIP - all LPEX Command Line commands are case sensitive 111 Workshop LPEX Commands Load test1.cbl into the editor Type in, and execute the following LPEX search and command line options (don't forget that you can use the up arrow key to return the previous LPEX command): bottom top findText perform findText all perform findText all 01 findText all columns 8 12 01 help ispf help lpex 10 /program get printapp.cbl Do NOT save changes! 112 RDz Search Menu – 1 of 2 (From the Search menu) RDz has powerful search facilities for finding text: In Local z/OS Projects In Remote z/OS Projects (on the mainframe) Filtered by: Text Wildcard text Filename wildcard text Search can be scoped to: Your entire Workspace A subset of your Workspace (Selected resources) You can open and go to the source by clicking the "found" text Extremely useful for Initial application discovery and understanding Impact analysis Maintenance activities Defect and ABEND resolution activities 113 See Notes RDz Text > File Search – 2 of 2 This is a very fast and efficient way to search for text: In a file In your project Throughout your workspace (multiple projects) | Steps: Set your cursor focus inside the word you wish to search on Open the Search menu and select: Text > File Right-click, Remove … matches clears tags From the matches view Double-click the found results to select specific text 114 Selective Find/Replace – from File/Project Search Often you will want to selectively replace found text. There are number of ways to do this, but you might try the following as a "best practice" Start from the File or Project search – to create a list of statements or lines that are replace candidates From the Search view, use Ctrl/Left-click to select specific instances to be Replace Right-click and choose: Replace Selected… Specify the Replacement value and Preview > or click OK 115 Workshop – Search Menu Exercise #1 – File Search: Open the Search menu 1. From the Remote Search tab – enter Search string: WS-*-SW 2. File name patterns: *.cbl 3. Folder: Use the Browse… button to locate your chapter1 project Check: Search subfolders When the results come back, Expand the lines in the Remote Search tab on the bottom of the Workspace – and click the Note – you will need cntrlbrk.cbl in your project for this exercise Exercise #2 – Text Search: Edit cntrlbrk.cbl Double-click (to select) any piece of text on the program. Then from the Search menu select: Text > File Examples: an FD: MI-INPUT-FILE A variable: PAID-DATE-IN-NUM A paragraph name: 210-PRSS-INPUT-RECORDS A COBOL keyword: READ 116 Paragraph Control Flow Analysis 1. Often you will need to discover a program's control flow by tracing through a PERFORM chain or following some GO TO statements This is a straightforward process with RDz 1. Select (double-click) your starting paragraph name Perform Hierarchy Paragraph Name List 2. Right-click and select: Open Perform Hierarchy 2. Paragraph relationships (nested PERFORM chain) shown through indentation 117 Paragraph Control Flow Analysis – continued If you wish to navigate to the paragraphs declaration in the source: 1. Double-click (to select) the paragraph in editor 2. Press F3 – or use the Context menu to Open Declaration You can return to your original source position in the paragraph control flow analysis by: • Clicking a paragraph in the Perform Hierarchy …or… Perform Hierarchy Paragraph Name List • Pressing: Alt+Left arrow • Expand the Hierarchy Name List - to see the nesting of the PERFORM chain paragraph relationships (GO TO as well) • Click a Paragraph name in the Perform Hierarchy view to navigate to that line within the source (Editor View) 118 Workshop – Paragraph Flow Analysis 1. 2. 3. 4. 5. Open TRMTRDZ.cbl in the editor From the Outline view, click on the 100-MAINLINE paragraph Double-click on the 100-MAINLINE paragraph name in the editor Right-click and select: Perform Hierarchy Expand all paragraphs displayed in the Perform Hierarchy 6. Scroll up to the top of the Perform Hierarchy Paragraph Names List 7. Double-click five or six of the paragraph names in the Perform Hierarchy – and note how the editor window code synchronizes with the paragraph name reference in the Perform Hierarchy view 8. To view the source-level declaration for one of your selected paragraphs from the Perform Hierarchy In the source editor: Double-click (to select) a paragraph name Press F3 – or use the Context menu and Open Declaration 9. To return to your place in the Perform Hierarchy and analyze more of the program's procedural flow, double-click another paragraph name entry in the Perform Hierarchy Paragraph Name list Alternatively, you can trace backwards/forwards through your code by pressing: Alt-Left - to go back up through previously selected source lines Alt-Right – to go forward through selected lines 119 Data Flow Analysis – Technique Data Flow analysis is an iterative complex process, that involves expanding the scope of searching, as new variables in the data flow are discovered On the mainframe, you either: Utilize listing files/SX-REF entries – or – Using ISPF you access option 3.4, or =3.14 and issue a series of manual text FIND operations – saving or writing down interim results. This is: Typing-intensive Error-prone With lots of time spent loading programs into the editor in split-screen, etc. Using RDz you: This is: Find your starting Search variable Pin the Search View and double-click each found-reference Not typing-intensive Less error-prone With RDz, all Search results are: Fixed Hyperlinked 120 Data Flow Analysis – RDz Using RDz you will do the following: From your starting variable: 1. Select the field and search (using a menu) for all occurrences 2. "Pin" the search results 3. Double-click each result line – which co-locates the line in the editor 4. Analyze the statements operation 5. If another variable is indicated as being part of the Data Flow, return to Step 1 and search on the next variable We'll do a workshop on this, using a new program… 121 Data Flow Analysis Workshop – New Program File Steps: From this PowerPoint's Slide Notes: Select all (Ctrl+A) then Copy (Ctrl+C) all of the statements in the program – If you don't remember how to access Slide Notes return to slide#5 in this PowerPoint From z/OS Projects Right-click over the cobol folder and select: – New > File – Name the file: DFLOWRDZ.cbl Click your mouse-pointer into the new file in the top-left hand corner (column 1, row 1) and press Ctrl+D to paste the program statements you copied in step 1 Save the file (Ctrl+S) 122 Workshop – Data Analysis With DFLOWRDZ.cbl open in the Editor 1. 2. From the command line, type: F WS-PHARM and press <Enter> In the Editor source, Double-click (to select) WS-PHARMACY-CHARGES From the Search menu, select, Text > File This will launch a search for WS-PHARMACY-CHARGES throughout your program, and save the search results in a new persistent view 3. From the Search View, click: Pin the Search View – This keeps the view intact, when you launch additional searches 123 Workshop – Data Analysis – continued 4. Double-click each line in the Search View 5. Analyze each COBOL statement. If the operation would alter the value of some other variable – the source code will synchronize in the Editor (through a MOVE or COMPUTE statement) return to Step 1 on the previous slide, and search on the next variable in data flow Double-click to select another variable - in this example, double-click: PATIENT-PHRM-PER-DAY-O Pull down the Search Menu, and select, Text > File From the (new) Search results click: Pin the Search View 124 Workshop – Data Analysis – continued Again analyze each COBOL statement in the pinned Search view. If the operation would alter the value of some other variable (through a MOVE or COMPUTE statement) return to Step 1 and search on the next variable in data flow Double-click to select another variable From the Search Menu select, Text > File From the (new) Search results click: Pin the Search View Analyze the next variable's usage and continue If the operations for a COBOL variable do not modify the contents of storage, return to a previously pinned view, and double-click the next line Additional pinned Search Views for other variables 125 Data Flow Analysis – Review Data Flow analysis is an iterative complex process, that involves expanding the scope of searching, as new variables in the data flow are discovered On the mainframe, you either: Utilize listing files/SX-REF entries – or Using ISPF you access option 3.4, or =3.14 and issue a series of manual text FIND operations – saving or writing down interim results. This is: Typing-intensive and error-prone With lots of time spent loading programs into the editor in split-screen, etc. Using RDz you: 1. Find your starting Search variable 2. Pin the Search View and double-click each reference There are static analysis tools from IBM that are dedicated to providing this information, through ultra-quick and simple techniques (ask about Rational Asset Analyzer) 126 Other Context Menu Items – Filter View Large complex programs can be more easily understood, viewed modified and maintained if certain details are filtered out From the Context Menu click Filter view > and select Divisions – collapse and expand filters by COBOL Divisions Code – filters out comments Comments – filters out code Outline – shows high-level abstraction of your source (very useful) Embedded SQL/CICS/DLI – show only SQL statements, or EXEC CICS Errors – show only syntax errors To show all of the lines of source in your editor: Press Ctrl+W – or use the Context Menu's "Show All" option 127 Filter Example – Show Only CICS and SQL Statements Filter all statements except for Screen EXEC CICS Database EXEC SQL Note the plus signs Expand/Collapse filtered code Press Ctrl/W to un-filter and return to normal program view 128 See Notes Another Example of Useful Filtering Options – Selected/Filter Selection Double-click to select a: COBOL Keyword Literal Variable Label (Paragraph or Section name) Right-Click Selected Filter selection Note the plus signs Expand/Collapse filtered code Press Ctrl/W to un-filter and return to normal program view 129 Workshop – Filtering and Isolating for Code Understanding Exercise #1 – Context Menu filtering 1. Copy the COBOL program below into a new file named: CADDDB2.cbl … inside your \cobol\ folder in your chapter1 project Ensure that the IDENTIFICATION DIVISION line is in the A margin Save the file 2. Try each of the filters out on this and the next slide – even Comments and Code Be sure to expand the filtered source lines by clicking the plus signs in the Editor's left-hand border Exercise #2 – Filtering selected text Open test1.cbl in the editor Use the technique of: a. selecting some text, b. Using Selected > Filter selection to isolate and display: Statements: – WRITE, IF, MOVE Variables: – CTR-COURSES, SR-NAME Literals (with single quotes): – 'Y' Paragraphs: – 230-READ-A-RECORD 130 Optional Workshop – Filtering for Documentation Exercise #3 – With CADDDB2.cbl loaded into the editor: Filter the program into an Outline view Select all (Ctrl+A) and copy all of the source Open Notepad or MS-Word Paste the source 131 Other Context Menu Items – Perform Hierarchy – Revisited RDz views that allow you to understand a program from a higher level of abstraction Open Perform Hierarchy displays a view of your PROCEDURE DIVISION paragraph chaining, through SECTION or paragraph PERFORM statements You can: Start anywhere in the Procedure Division – and drill up or down Navigate: From the code: Select different paragraphs or PERFORM statements the Hierarchy View changes From the Perform Hierarchy View: Select a paragraph or SECTION label in the Perform Hierarchy and navigate to that line in the program source Particularly helpful with large, complex PROCEDURE DIVISION code – composed of hundreds of paragraphs/sections 132 Workshop – Perform Hierarchy Exercises: 1. With test1.cbl open in the editor: Find, and set your cursor-focus (note that you do NOT have to double-click) in 200-PROCESS-RECORDS Right-click and select: Open Perform Hierarchy Navigate using the Perform Hierarchy 2. With cntrlbrk.cbl open in the editor: Find, and set your cursor-focus in 300-SRT-OUTPUT-PROCD Right-click and select: Open Perform Hierarchy Navigate using the Perform Hierarchy 3. With CADDDB2.cbl open in the editor: Find, and set your cursor-focus in 0500-EDIT-SCREEN Right-click and select: Open Perform Hierarchy Navigate using the Perform Hierarchy 133 1. Other Context Menu Items – Refactor – 1 of 2 Renaming variables and paragraph or SECTION labels can have farreaching and sometimes unintentional consequences Refactor allows you to Preview the impact of a change before deciding to go through with it 2. To Refactor/Rename: 1. 2. 3. 4. Select the variable or Paragraph name you wish to change Right Click, and from the Context Menu select Refactor > Rename Overtype the old name with the new name Click Preview > 3. 4. 5. Preview automatically scopes the change. Click Continue 5. Scope of changes for this variable Refactor 134 Refactor continued – 2 of 2 6. Finally, the Refactor wizard displays the deltas between your original and Refactored source side-by-side, allowing you to verify before proceeding. Refactor Source Deltas Click OK to rename (if you press Cancel no changes are made to your source) Refactor > Remove Noise Words You can also Refactor "noise words" – COBOL clauses that if removed, could make your programs easier to understand, without impacting program behavior 135 Workshop – Refactor Steps: 1. Create a new COBOL program in the \cobol\ folder of your chapter1 project (using either of the techniques shown earlier in this course) – name it testRefactor.cbl 2a. Edit test1.cbl 2b. Press Ctrl+A 2c. Press Ctrl+Ins (insert key – this copies all of the source statements) 2d. Paste the copied source into testRefactor.cbl 3. In testRefactor.cbl Refactor: CTR-LINES - change it to WS-CTRLINES 4. Refactor: 200-PROCESS-RECORDS - change it to: 201-PROCESS-RECORDS After you've finished, Syntax Check testRefactor – to make sure everything worked as expected 136 Other Context Menu Items – Syntax Check and File Save Periodically during development, you will want to save and syntax check your code To Save: From the Context Menu select Save Or, with edit-focus in your program source, press: Ctrl+S Or click the disk file icon - in the top left-hand corner of the Workbench To Syntax Check From the Context Menu select: Save and Syntax Check (if your file has outstanding changes that have not been saved yet) Local Syntax Check – if all the changes have been saved (and there is no asterisk next to the file's name in the editor tab) Remote Syntax Check – which runs a compile-only syntax check on z/OS (i.e. this does not create binaries (Load Modules) – so it is relatively inexpensive and fast) Note that Remote Syntax Check is only available for MVS Sub-Projects not Local z/OS Projects. We'll learn how to use these later in the course If there are no syntax errors, Local Syntax Check will populate the BuildOutput folder with temporary object code and listing files. 137 Hint – you can't be in fullscreen mode, in order to see the error messages view, Fixing Syntax Errors Even with Content Assist and copy/paste between multi-screen views you will sometimes end up with syntax errors To correct syntax errors in your source: From the Remote Error List View 1. Look at each syntax error …or…Mouse-over the error to see an explanation in "hover-help" …or… 2. Double-Click the error – to bring up the line in question in the editor 3. Use Content Assist to fix the error Mouse-over the Red-X 1. Ctrl + Spacebar (Content Assist) 3. 2. 138 Double-Click to open the error line in the editor Workshop – Fixing Syntax Errors Steps: Open PrintApp.cbl in the editor Scroll to the bottom of the file Make these three mistakes - change: 1. Char-Count Char-cout 2. Inspect Inspet 3. Tallying Tallig Right-click and from the Context Menu select: Save and Syntax Check From the Remote Error List – for each error (red-x): Double-click the line (to position your cursor) Backspace and use Content Assist (Ctrl+Spacebar) to select and fix the error With all errors fixed, Right-click and from the Context Menu select: Save and Syntax Check 139 What if I'm Just Learning COBOL? – 1 of 2 Fear not! Select the COBOL word you're unfamiliar with, and press: F1 Help F1 The F1 Help session is opened up in a separate Windows frame. Try F1 (help) out on the Printapp.cbl program: • Inspect • Compute • Linkage 140 What if I'm Just Learning COBOL? (Model Statements – 2 of 2) Content Assist (Ctrl+Spacebar) can also help you build new COBOL statements: Workshop: With test1.cbl open in the editor Enter a few new blank lines Enter the beginnings of some COBOL statements: if perfo compu div Experiment with the Ctrl+Spacebar statement models Please do not save changes Note that you can combine model statement building, with content assist to select declared COBOL variables from the DATA DIVISION into the statements. 141 Other Context Menu Items – Source Options: Comment/Uncomment When you have selected a line or some text in a line there are two useful options under Context Menu: Source > Comment selected lines Comments out – with an asterisk in column 7 one or more lines of COBOL source Uncomment selected lines Will uncomment all selected lines that are comments 142 Other Context Menu Items – Source Options: Hex edit line Other Context menu Source option: Source > Hex edit line Note that the "selected byte" shows in gray Click in the main body of the source, to close hex view When opening files remote (on the host) Hex edit line also gives you EBCDIC encoding 143 LPEX Text Editing Options** So – what more do you have to learn about, in order to edit COBOL program source? We've already covered a good bit of ground. However, it's time to learn how to: Select lines and/or blocks of code Copy/Cut/Paste selected lines Shift selected text right or left Make the selected text upper or lower case Note: All of these text editing techniques have Hot Key combinations – for "power typing" Most are standard, Windows text editing operations you may have used on your PC with MSWord, MS-Notepad, etc. ERGO - We will not describe much about these techniques – assuming you already understand what they do But instead, we will just show examples using COBOL code 144 ** See Note on ISPF Editing Select – Copy – Cut – Paste Text 1. Select something: Drag with your mouse Left-to-Right/Top-to-Bottom Or select a: Single line – Alt+L Rectangle: Alt+R (see next slide for details) Character – Alt+B 2a. Copy selected code – Ctrl+C 2b. Cut selected code – Ctrl+X To copy, move or to delete 3. If copy or move, paste the selected code – Ctrl+V Notes: Be aware of language (COBOL) source margins Cursor insert-point is where text will flow Left-to-Right/Top-to-Bottom from Can clear selection (de-select) with Alt+U 145 Working with Text Rectangles – Shift a Block of Text Rectangle selection provides some convenient operations: 1. Set cursor to 1st character of rectangle: Top left – or bottom right corner 2. Press Alt+R – or use Context Menu to enter Rectangle copy/paste edit mode 3. Left-click, hold and drag the cursor to the opposite corner and select a text block 4. Use Alt keys or Context menu to manipulate text …or Alt/F8 shifts right one character 146 See Notes Working with Code Blocks – Upper/Lower Case, Comments, Uncomment 1. Select a block of text and use the Context Menu …or… 2a. Press Alt+K to make all letters in the block upper-case 2b. Press Alt+I to make all letters in the block lower-case 2c. Press to Ctrl+/ to comment out, a block of code 2d. Press Ctrl+\ to un-comment the block 147 See Notes Copying a Partial Line of Text A common requirement/technique is to fill in a portion of a repeated line. Example – need to copy same or similar PIC clauses to multiple records: 1. 2. 3. Set cursor to beginning character of copy text Press Shift+End – to select rest of line Press Ctrl+C – copy selected portion of line 4. Position cursor at beginning of paste/area 5. Press Ctrl+V – to paste copied text. 6. Repeat steps 4 & 5 148 Workshop – LPEX Editing Options 1. Hex Edit Open StartApp.cbl in the Edit Area Add a value clause to Input-name's PIC Place your cursor over the variable line From the Context Menu select: – Source – Hex edit line 2. Select/Copy/Cut/Paste text Open PrintApp.cbl in the editor Select some code and use any/all of the editing techniques in the Context Menu – but definitely try at least the following common source modification operations: Alt+L – to select a line Ctrl+C Ctrl+V Ctrl+X Alt+U – to de-select 3. Working with Code Blocks Open StartApp.cbl in the Edit Area. Using your mouse, drag and select a block of source lines Open the Context Menu and try the Selected menu options: – – Uppercase Lowercase From the Context Menu use the Source option to: – – Comment the selected lines Uncomment the selected lines From the Context menu – Deselect the selected block of lines 149 Do NOT save your edits/changes Reusable Source Code – Snippets and Templates Reusing code has been a "holy grail" of software development for decades. While there is no silver bullet solution, there are a number of innovative and useful options in RDz for this: Program Templates Code Snippets We've already seen in previous slides that you can create new programs using templates, which allows you to create and enforce standards, and simplify development. Snippets allow you to create smaller, "packets" of reusable code – from single statements to routines. We'll first look at customizing the program templates: To access their defaults: From Window > Preferences > COBOL > Code Templates 150 Custom Templates – Comments You can create a custom Code Template for COBOL comments or the base program code itself. To add or customize comments: Click the comment option you wish to modify Code an asterisk in position 7 (you'll have to space over 1-6) You can insert Variables that are filled in when new "templatized" programs are created 151 Custom Templates – Program Code And you can add your own entries, common files, databases, variables, routines etc. to either: An entire program Separate program divisions When a new program is created using the templates all of the custom comments and code are inserted. 152 Code Snippets Sometimes, instead of entire programs you might want to: Save some code temporarily for reuse Create a paragraph, computation, complex conditional – that can be re-purposed in other programs Provide a library "standard" routines – using your shop's coding conventions Provide a library of syntactically-correct and infrequently used/high-value statements: Database routines Complex COBOL code: UNSTRING etc. Snippets are the preferred way of doing this. You access them through a Snippets view, which you get to by: From Window > Show View > other… Type: snippets – and select the Snippets view On the right are a group of custom Snippets that we have created. You will see a subset of these. Individual Snippets are contained in "drawers" which are the accordion menus that collapse/expand on-click. Snippets can be Exported and Imported (for sharing among team members) 153 Using Code Snippets To use an existing code Snippet follow the steps below: 1. Place your cursor at the exact focal point (position in the source) where you want a code snippet inserted 2. Find your Code Snippet in the snippet drawers 3. Double-Click the Snippet 4. If there are variables in the snippet, you can: 5. Accept the defaults Over-ride the values before the code is inserted Click Insert 154 Creating Code Snippets – 1 of 2 To create a new code Snippet follow the steps below: 1. Create a new Snippet category Right-click over the Snippets view Select Customize From Customize Palette, under New Select: New Category 2. 3. Name the Category Add a description Click OK Select and copy the code you wish to Snippet-ify Expand the category you wish to add the Snippet to, and select Paste as Snippet… 155 Creating Code Snippets – 2 of 2 4. 5. Rename the Snippet and give it a Description Optionally add Variables to be filled in by Snippet users (or they can accept the defaults) 156 The IMS Code Snippets If you are using RDz v7.6 or later, a number of very useful IMS Code Snippets are shipped with the product These snippets go beyond simple text-based insertion to read your Data Division entries, and offer options for building statements using combo-boxes 157 Changing Your Editor Profile – From LPEX to ISPF Open the Window menu, and select Preferences From Preferences: Select LPEX Editor Select your Editor profile Select: ispf Click: OK Note: We will cover both editors in this section – starting with the ISPF editor. If you're not interested in learning the ISPF editor, skip ahead to the slide titled: Introduction to the LPEX Editor 158 RDz ISPF Editor Your Program Source Standard-issue ISPF Prefix Area, Command Line, and source editing options ISPF Command Line ISPF Prefix Area 159 See Slides Notes ISPF Prefix Commands 80/20 ISPF edit commands supported with same functionality as on the mainframe For a complete list of supported prefix commands: Place your cursor in the prefix area Press F1 160 ISPF Command Line Commands 80/20 ISPF edit commands supported with same functionality F – Find (first, last, all, etc.) C – Change RES – reset (clear edit view) Num on/off UNNUM X - exclude Other – check the product help Combined commands as well Example: x all ; f all '<literal>' 161 ISPF Command Line Commands – Example with Excludes/Expand up or Down Note: To show n excluded lines within an excluded block: Position your cursor on the excluded marker Type: F n … or L n - in the prefix area – Where n is a number of lines to show F – shows the first n lines L – shows the last n excluded lines 162 Keyboard Editing versus Mouse-based You're probably getting the picture that there are two distinct editing "modes" using a graphical workbench like RDz: 1. Using your mouse for: Navigation Highlighting Selection Accessing RDz tools and your keyboard for content editing 2. Using the keyboard for: Navigation Highlighting Selection Accessing RDz tools Content editing Most developers feel as though it's worth going through the skills-transition, to master mouse-oriented development – as this pays dividends for z/OS and moderndevelopment workflow (Services, contemporary U.I. work, etc.) But, on the next few slides we present Hot-Key combinations available in the RDz editor for those that are ISPF power-typists, who want to ease into things gradually 163 Common ISPF Key Editing Techniques Split and Join lines: 1. Split lines: Position Cursor Press Alt+S …or… Press: Ctrl+Enter 2. Join lines: Position Cursor Press Alt/J Leading blanks can cause line joining to shift to the right (sometimes past column 80). A better solution for joining lines is to Select and cut the text to join Paste the text 164 Common ISPF Key Editing Techniques - continued You're probably used to the Erase (EOF) key. Using RDz you substitute Ctrl+Delete Ctrl+Delete Other useful PC-key combos 1. Select to the end-of-line Shift+End 2. Move your cursor to the end and beginning of a statement Position your cursor inside a statement Press End Home 165 Common ISPF Keys Workshop – New Program File Steps: From this PowerPoint's Slide Notes: Select all (Ctrl+A) then Copy (Ctrl+C) all of the statements in the program – If you don't remember how to access Slide Notes return to slide#5 in this PowerPoint From z/OS Projects Right-click over the cobol folder and select: – New > File – Name the file: SANDBOX.cbl Click your mouse-pointer into the new file in the top-left hand corner (column 1, row 1) and press Ctrl+D to paste the program statements you copied in step 1 Save the file (Ctrl+S) 166 Workshop - Common ISPF Key Editing Techniques From z/OS Projects With SANDBOX.cbl open in the editor Using the Outline view, find the beginning of the PROCEDURE DIVISION Find the MOVE "000-HOUSEKEEPING" TO PARA-NAME. Statement Using Ctrl+Enter, split the line before the TO Using the mouse Cut & Paste technique, rejoin the lines Under the * DATE VALUES comment line, split the next four MOVE statements after the TO operand Scroll to the top of file and using Ctrl+Delete erase to end of line five of the comments Using the Outline view, return to the 000-HOUSEKEEPING paragraph, and re-join two of the MOVE statement lines you split in the above steps (again use the Cut & Paste technique) Using the command line, Find the first occurrence of : INPATIENT-TREATMENT-REC-DATA in the source Place your cursor on that line at column 22 Press the Home and End keys a few times Press Shift+Home and Shift+End Scroll down to the PROCEDURE DIVISION and practice/experiment using: Ctrl+Enter, Joining Lines, Ctrl+Delete, Shift+End, Home and End for five minutes Close the editor and do NOT save your changes 167 Hot-Key Combinations The ISPF editor actually supports an extensive collection of Hot-Key combinations: You can see the complete list of Hot-Keys at any time during your edit session by pressing: Ctrl+Shift+L Black entries are activated Gray entries are unavailable in the current editing context Hot-Keys are case-IN-sensitive Alt+C Alt+c We will cover the essential Hot-Keys starting on the next slide: Navigation Select Text Copy/Paste Text Line Options Miscellaneous Ctrl + Shift + L 168 Hot-Key Combinations – Source Navigation + Miscellaneous Keys RDz Hot Keys Description ISPF Equivalent Ctrl+Home Top of file Max PF7 Ctrl+End Bottom of file Max PF8 Ctrl+2 Open same program in split-screen view PF2 - then open the source member Ctrl+0 (zero) Close edit session PF3 (or CAN on the command line) Ctrl+S Save edit session Save Ctrl+P Print current file N/A Ctrl+T Make current line top line in the editor PF7/PF8 with CSR as your paging option PgUp Page up one physical page of source at a time PF7 PgDn Page down one page of source at a time PF8 PF7/PF8 Page up/down one page of source at a time PF7/PF8 Up/Down – Right/Left Arrows Scroll one character at a time through your source: Up/Down – Right/Left Up/Down/Right/Left Arrows Ctrl+PgDn Page Right PF11 Ctrl+PgUp Page Left PF10 Ctrl+L Open Line Number feature N/A Ctrl+G Filters out all COBOL code except the four divisions Prefix area exclude Ctrl+W Show all filtered lines RES Shift+F10 Show the Context (popup) menu N/A Ctrl+Shift+L Show the list of all Hot-Key Combinations N/A Escape Cursor jumps to the command line N/A 169 Workshop – Source File Navigation and Hot-Key Combinations Load test1.cbl into the editor. Press the following Hot-Key combinations. (Optional) Type or write down what happens after you press the Hot-Key combination Ctrl+L - Type: 77 and Press: Enter ________________________________________ Ctrl+T ________________________________________ Ctrl+2 ________________________________________ Ctrl+0 ________________________________________ Ctrl+0 ________________________________________ Ctrl+End ________________________________________ Ctrl+Home ________________________________________ Ctrl+Shift+L ________________________________________ PF8 ________________________________________ PF7 ________________________________________ PgDn ________________________________________ PgUp ________________________________________ Ctrl+PgUp ________________________________________ Ctrl+PgDn ________________________________________ Ctrl+G ________________________________________ Ctrl+W ________________________________________ Ctrl+F10 ________________________________________ Ctrl+P- You can decide if you want to print the file ________________________ Down Arrow - Continually press the down arrow ______________________ Up Arrow - Continually press the up arrow ___________________________ 170 Hot-Key Combinations – Line and Statement Editing Options RDz Hot Keys Description ISPF Equivalent Ctrl+F Opens Find/Replace Dialog Find/Change ISPF Commands Ctrl+Z Undo last change UNDO (if Recovery On) Ctrl+Y Redo last change N/A Shift+Down Arrow Select text from the current cursor position downward in the source file Prefix Area Command: CC … CC PF7 Shift+Up Arrow Select text from the current cursor position upward in the source file Prefix Area Command: CC … CC PF7 Ctrl+Shift+Right Arrow Open same program in split-screen view PF2 + navigate to source member Shift+End Select text from cursor position to end of line N/A Shift+Home Select text from cursor position to beginning of line N/A Ctrl+A Select all text in the source file Prefix Area Command: C99999 Alt+U Unselect selected text N/A Ctrl+C Copy currently selected source lines Prefix Area Command: C or CC Ctrl+X Cut currently selected source lines Prefix Area Command: M or MM Ctrl+V Paste currently copied source lines Prefix Area Command: A or B Ctrl+J Find previous edit change N/A Ctrl+Right Locates cursor at the beginning of the next COBOL word N/A Ctrl+Backspace Delete Current line Prefix Area Command: D Ctrl+D Repeat Current line Prefix Area Command: R Ctrl+/ or Ctrl+\ Comment or Uncomment current line N/A Ctrl+Enter Insert new line Prefix Area Command: TS or I Ctrl+Delete Delete (Truncate) to end of line Erase (EOF) key F5 and F6 Find and Repeat Find, Change and Repeat Change PF5 / PF6 F2 Delete COBOL word to the right of the cursor position N/A 171 Workshop – Line and Statement Editing Hot-Key Combinations Load test1.cbl into the editor. Press the following Hot-Key combinations. Type or write down what happens after you press the Hot-Key combination (Optional) Ctrl+A ________________________________________ Alt+U ________________________________________ Ctrl+Backspace ________________________________________ Ctrl+Z ________________________________________ Ctrl+Y ________________________________________ Ctrl+D ________________________________________ Shift+Right arrow ________________________________________ (Repeat with Shift+Left Arrow) Shift+Down arrow ________________________________________ (Repeat with Shift+Up Arrow) (With your mouse cursor at the beginning of a line) Shift+End _______________________________ (With your mouse cursor at the END of a line) Shift+Home _______________________________ Ctrl+X ________________________________________ Ctrl+Home ________________________________________ Ctrl+V ________________________________________ Ctrl+End ________________________________________ Ctrl+J ________________________________________ (With your mouse cursor in the middle of a line) Ctrl+Delete _______________________________ (Multiple times) Ctrl+Shift+Right arrow _______________________________ (Holding these keys down) Ctrl+Right arrow _______________________________ (Holding these keys down) Ctrl+Left arrow _______________________________ If time permits, spend some time working with the combination of the Navigation and Line and Statement Editing Hot-Keys 172 ISPF PF-Keys PF1 – Help PF5 – Repeat Find PF6 – Repeat Change PF7 – Page Up PF8 – Page Down See tables on next slides for complete side-by-side comparison Can combine ISPF functionality with: Context menu RDz menu 173 Workshop – ISPF Editor Open the file: testRefactor.cbl – and using the information on the previous slide, try the following ISPF editing techniques out If you haven't already done so, from: Window > Preferences > Lpex Editor, select ispf as your edit profile Try out these prefix area commands and command combinations: Try out the following command line, ISPF commands and PF-Key combinations: • I • D • I4 • D4 • R8 • C/A • M/B • X • X 999 • XX XX • CC CC – A • MM MM – B • DD DD • RR RR Try combining several commands into one operation • res • Find • PF5 • Change • PF6 • eXclude • Help ispf • num / num off • Split and join a line Try combining several commands into one operation: • x all ; f all '<literal>' 174 RDz – ISPF Comparison Chart – Find Commands – Picture Strings ISPF Editor LPEX Editor Simple String Y Previous String Find Previous / F5 Delimited String Y Text string Y Picture Strings – special characters Y – with regular expressions P'=' – any character Ctlr+F, Regular Expression, P'-' – any non-blank character Ctlr+F, Regular Expression, P'.' – any non-displayable character Ctlr+F, Regular Expression, P'#' – any numeric character Ctlr+F, Regular Expression, P'-' – any non-numeric character Ctlr+F, Regular Expression, P'@' – any alphabetic character Ctlr+F, Regular Expression, P'<' – any lower-case character Ctlr+F, Regular Expression, P'>' any upper-case alphabetic character Ctlr+F, Regular Expression, P'$' – any special character (not alphanumeric) Ctlr+F, Regular Expression, ^ . Dot, any single character \ logical NOT . \x Hexadecimal [^\x20] [^\x20-\x7E] [0-9] [^0-9\x20] [A-Za-z] [a-z] [A-Z] [^A-Za-z0-9] Ctrl+F Note: for more Regular expression searches: http://en.wikipedia.org/wiki/Regular_expression 175 special Expression ISPF versus LPEX Editor ISPF benefits: Reuse of your ISPF skills Well-adapted to COBOL line-oriented code style Excellent for "pure development" Keyboard-engaged work Useful column-prefix commands Recommended default for experienced developers who started with ISPF LPEX benefits: Note that the More code view/real estate <Enter> key opens a new line Copy/paste Persistent Partial text Context Menu editing options remain the same for both – Statements – Variables and paragraphs – Fragments Code blocks (no need to create temp PDS members) Recommended default for developers who started with Windows text editors Recommendation: Try both, giving each a fair bake-off 176 Review Questions – Be able to answer and to demonstrate your understanding through RDz Workbench use Eclipse and the Workbench tools: How do you open files for editing … and switch from one open file to another? What is the “Editor Area”? What is z/OS Explorer? Is there a way to close all files that are open in the Editor Area? How do you maximize the Editor Area? And resize it back to see the Eclipse tools? What two keys (when pressed simultaneously) give you Content Assist for editing? What does Content Assist do? 6. What are the two methods of creating a new COBOL program? 7. Where is the option for running or debugging a local (Workstation) COBOL program? 8. How do you open a second copy of your program for edit in another window? 9. How do you open a view if you inadvertently (or “advertently”) close it? 10. What is the Outline View – and where is it located? 11. What is the Perform Hierarchy view – and how do you access it? 12. What is the Context Menu – and what key combination do you press to bring it up? 13. How do you syntax check a program? 14. Speaking of syntax, what does that little yellow triangle mean when it appears in the border of your source file during a COBOL editing session? 15. What editing option allows you to (in one keystroke) – find the declaration of a variable or paragraph in your COBOL source? 16. What view shows you the characteristics or attributes of a selected COBOL program? 17. Why are some of the Context Menu options grayed out at certain times? 18. What Context Menu option allows you to isolate (within your source file) all of the: Comments, Code (no comments), Errors, SQL statements, an outline of the Divisions and 01 variables, etc.? 19. What Context Menu option allows you to isolate a single keyword, variable or text selection throughout your source code? 1. 2. 3. 4. 5. 177 Topic Summary In this topic you have seen a number of editing techniques: Native LPEX ISPF Emulation Hopefully you've done some workshops throughout, but if not, at this point in time it would be helpful to return to follow the directions on the "do it" slides If you've followed, and have changed your editor to ISPF, you can: Leave it as ISPF for next unit Switch back to LPEX mode, from: Windows Preferences LPEX Be sure to close RDz 178 UNIT The RDz Workbench Topics: The RDz Workbench – Terms and Concepts Editing COBOL Programs Debugging COBOL Programs Appendices - ISPF / LPEX Comparison 179 Topic objectives After completing this topic, you should be able to: Describe the configuration model for running and/or debugging local COBOL applications Create a Launch Configuration – for running and/or debugging local COBOL application Define COBOL ENVIRONMENT DIVISION entries compatible with Windows PC COBOL work Run local COBOL applications – that respond to ACCEPT/DISPLAY UI Debug local COBOL applications and use the majority of the RDz COBOL source debugging features successfully Workshops – As mentioned previously, note that for most (at least where marked on the slide with the: symbol ) of the slides in this topic, you should experiment with the editing technique shown. The COBOL source in the Slide Notes might not always match the screen capture, but should be usable for the technique. 180 Local COBOL Application Executable Resource Model You can run and/or debug your COBOL applications as standalone Windows executables. To do this, you will need the following: Clean compile of your entire project (Note – not just the COBOL program you wish to run or debug, there can be no syntax errors above warning-level in the project) A Launch Configuration – which defines parameters, and other settings needed to debug or run your application as an executable, on Windows Your source available Your input files and output files specified in PC-COBOL SELECT/ASSIGN syntax Parms Launch Configuration + COBOL .exe Running – or Debugged UDB Local DB2 Database Sequential Input/Output Files Output Reports 181 A Tale of Two Perspectives – z/OS Projects Perspective and the Debug Perspective "Perspectives" - Recall that a "Perspective" is a convenient grouping for a collection of views organized around a given role or task So far in this unit you've used the z/OS Projects Perspective – to learn: About RDz Understand the use of Projects, Views and other eclipse facilities How the editor works – features, typical development workflow, etc. In this section we will introduce you to the Debug Perspective – which allows you to do source-code (line-by-line) testing of your COBOL logic We will start by showing you how to debug local (Workstation-based) COBOL programs In subsequent units we'll learn how to debug mainframe applications (batch and online) Both local and mainframe debug facilities are almost 100% identical Learning how to do local debugging will set you up for learning the mainframe debugging features 182 Steps in Debugging Local Workstation Projects You will need the following: 1. A project – that compiles clean 2. One or more COBOL programs to debug 3. A Debug Configuration Let's start by creating a new project. But – in order to save time and focus on debugging per se' – we'll use one of the example projects that ships with RDz Debug Configuration UDB Local DB2 Database Sequential Input/Output Files RDz Debug Perspective COBOL.exe + Called modules Output Reports 183 Create a new Workstation COBOL Project Open the File menu and select: New > Example… Expand Workstation COBOL Select COBOL Sample 1 and click: Next From Example Project Name your project, and click: Finish 184 Load a COBOL Program into the Editor Area (Editor) From z/OS Projects, Double-click StartApp.cbl (to load the source into the editor) Browse (scroll) in the file and view some of the code – note that this is not a mainframe application. It is a PC-COBOL program to be debugged on your Workstation Double-click: PrintApp.cbl and have a look at some of the statements Note: Please don't change any of the code in the programs, yet 185 Prepare Your Application for Debug – Rebuild From z/OS Projects, Expand the BuildOutput folder Note that this example project comes already-compiled. How can we tell? Because there is a: BuildOutput folder Executable (in this case, StartApp.exe) in BuildOutput Sadly, your custom projects will not come ready-made like this, so we'll have to learn how to create executables Note also that icon to the left of StartApp.cbl has a purple background This denotes that StartApp is the "entry point" into the application. Basically StartApp's PROCEDURE DIVISION is where the operating system begins execution – If you're an ex-Java or C/C++ developer think of StartApp as "main" Build a project (optional but a Best Practice) – Select (Right-Click) and delete the entire BuildOutput folder … really - it's okay - go ahead At the warning-confirmation prompt, click: Delete Note – the reason for doing this, is that you will easily be able to tell if your project build is successful (if there are compile errors, BuildOutput is not created by the Rebuild step) Right-Click again over your project, and from the Context Menu, select Rebuild Project (note that it is at the bottom of the Context Menu options list) This should re-create the BuildOutput folder including StartApp.exe 186 Create your Debug Configuration Recall that you will need to define a configuration file for debugging. This is a one-time-per-project step, and is very simple: Right-Click over your Project From the Context-Menu select: Debug As > Debug Configurations… From the Debug Configurations dialog: Double-Click: Compiled Application This will create a new configuration, named (appropriately enough): New_configuration See Notes 187 Specify the Configuration Properties 1. Name your configuration 1. 2. Select the Program name: 2. click the Browse… button (as shown) and from the Open dialog: -Expand BuildOutput -Double-Click StartApp Note that if your StartApp shows as: StartApp.exe – that's the one you want 3. The Open dialog will close, and from the Configuration Properties dialog, click: Debug 188 Debug – Initial Prompts Two small prompts will popup: Click Yes to Confirm Perspective Switch To enter the Debug Perspective, and use better views for your work A DOS window appears (briefly) and becomes a Windows background task. This DOS window is still available from your PC's toolbar, and in fact represents the operator's console (all COBOL ACCEPT/DISPLAY statements pipe their input/output to this window) 189 The Debug Perspective – Views and Facilities Toolbar Debugger Breakpoints View Program Variables View Your code Program Outline View 190 The Debug Perspective – Debug Toolbar Icons There are a few different ways of stepping through your code One of the simplest is to use the icons on the Debug view toolbar Resume – Run from break-point to breakpoint in your code, or until your program ends Suspend – Stop running your code (the Debugger will wait for you to do something) Terminate – Stop your debug session Animated step – Debug through your code line-by-line. Stop at breakpoints Step into – Execute the current instruction (one COBOL statement at a time) Step over – Execute the current instruction. If the current instruction is a CALL or PERFORM, resume (run through) all of the statements in the procedure being called and stop: On the next sequential instruction On a break point inside the CALL or PERFORM procedure If the debug session (or your application Entry Point program) ends Step return – (used within a called module or performed paragraph) – resume (run) through the rest of the statements and stop (debug) on the next sequential instruction after the CALL or PERFORM statement Use Step filters – Filters out Assembly-language instructions - Be sure this icon is clicked on as shown. If filtering is not clicked on you will see assembly language code Enable/Disable Step by step debug Debug daemon – Displays status and properties of the debug listener 191 Debug – Simple Stepping From the Debug toolbar: Click the Step into icon (see below) or press F5 (Remember to click Step Filters if it isn't enabled) Your program will debug line by line Note that as variable values change the Variables view display turns bright yellow for the fields that have been modified by the statement 192 Debug – Console IO When your code reaches an Accept or Display statement: From the toolbar, click the Windows DOS box and answer the prompt For Accept – type in a value and press Enter For Display – you can see what the statement IO does in the DOS box In either case, your Debug session goes into a "wait state" until you respond to the prompt 193 Debug – Variable Values Can be seen from the: Variables view Monitor List view Right-click inside view Select – Add variable to Monitor List Hover-help (mouse-over) in the Source code view 194 Change Variable Values Dynamically (on the fly) During Debug From the Variables view Select a variable value Over-type the value Press Enter To see the variable value in Hex Select the variable Right-click From the context-menu, select 1 Hexadecimal 195 Additional Features from the Variables (Right-Click) Context Menu From the Variables view Select a variable value Right-Click and try: Find Filter Find by keying in text Very useful for large programs Also Right-Click Copy Variables Paste to Notepad 196 Debug – Passing Execution from Program to Program When a call is made to another program in your application The called program is dynamically loaded into the debugger 197 Debug – Passing Execution from Program to Program When the called program's GOBACK instruction is executed: The called program is flushed from the Debugger Control returns to the calling program Please finish debugging this application (Note: you will have to enter Q to quit/end) 198 Ending a Debug Session and Starting Over When your "main" program's GOBACK or STOP RUN is executed (or if there's a program execution failure) your debug session will terminate Click OK and: Return to the z/OS Projects perspective – to continue analyze/edit/compile (top right-hand corner of your workbench) …or… Start another Debug session: Press F11 …or… Click the green bug on the toolbar 199 To Set and Debug with Unconditional Breakpoints From within a Debug Session Scroll to the line you wish to stop at Double-click in the left-hand margin of the source code area Double-click again to unset a previously-set Breakpoint Press F8 or click the Resume icon to run to your Breakpoint 200 What Other Kinds of Breakpoints Exist All of the major types of Breakpoints are available Try experimenting with: Entry Breakpoint Zoom through StartApp Debug through PrintApp 201 What Other Debug Options are Available? Actually, quite a few During Debug, Right-click over the left-hand margin Add Breakpoint Jump to location – Causes immediate unconditional branch to the line your mouse is pointing to Like a GOTO – and does not alter program storage (variable values) Run to location – Executes all code between the current line, and the line your mouse is pointing to Like a PERFORM – and could alter program storage Add Bookmark… Add Task… Animated Debug Using default speed Altered animation speed 202 Iterate Over Complex Code (Debug Option) While in PrintApp.cbl Debug to the GOBACK Change the value of IN-NAME Right-click over the margin Jump to line 46 Debug (step) through code again 203 Absolutely Through Debugging? Best Practice to remove Debugger modules from storage Right-click over <terminated> Select Remove All Terminated Return to z/OS Projects 204 Workshop Debugging – 1 of 6 From the File menu, select: New > Example… Expand Workstation COBOL Select COBOL Sample 1 Click Next > Name the project: Click Finish DebugLab 205 See Notes Workshop Debugging – 2 of 6 From z/OS Projects Right-click over the project and select: Rebuild Project Expand BuildOutput Right-click over StartApp.exe, and select: Debug As > Debug Configurations From Debug Configurations Select Compiled Application Click the New launch configuration icon Name the Debug Configuration Instructions continue on the next slide… 206 Workshop Debugging – 3 of 6 In the Program name: area: Click Browse… Use the Windows dialog to find and select the directory for your Workspace\Project\ BuildOutput folder and StartApp.exe file Note that the icon might not show the file suffix – select the run icon as shown Click Open From the Debug Configuration window click: Apply Debug Click "Yes" at the Confirm Perspective Switch prompt 207 Workshop Debugging – 4 of 6 Apply the Debugging techniques you learned in this section: Breakpoints: Entry to PRINTAPP On specific lines Remove breakpoints (you've added) Step into the code Use the various step options Run to your breakpoints If you run past the breakpoints and would like to start again, use the toolbar to restart your Debug session: If you'd like to just stop, hit the Terminate sign, on the toolbar: 208 Workshop Debugging – 5 of 6 From the Variables and Monitors tabs: Modify values on the fly Monitor variables Detach the Monitored variable list 209 Workshop Debugging – 6 of 6 Other techniques: Mouse-over hover value Jump to/Run to Location Add Tasks and Bookmarks Use the Context Menu Terminate and remove all terminated debug sessions when done Return to the z/OS Perspective 210 Enterprise Modernization for IBM System z: Local IBM z/OS application development with IBM Rational Developer for System z Final Workshop – Optional In order to pull together all of the edit, compile and debug techniques described in this section, if time permits at work: Please go to the Enterprise Modernization Sandbox http://www.ibm.com/developerworks/downloads/emsandbox/systemz_applications.html Select and print out the following PDS http://download.boulder.ibm.com/ibmdl/pub/software/dw/rational/emz/Local_IBM_zOS_application_development.pdf Follow the Sandbox Slides to: Register Download and install the Citrix client (first-time only) Use the Sandbox And follow the detailed Instructions in the IBM Proof of Technology lab 211 Topic Summary After having completed this topic, you should now be able to: Describe the configuration model for running and/or debugging local COBOL applications Create a Launch Configuration – for running and/or debugging local COBOL application Define COBOL ENVIRONMENT DIVISION entries compatible with Windows PC COBOL work Run local COBOL applications – that respond to ACCEPT/DISPLAY UI Debug local COBOL applications and use the majority of the RDz COBOL source debugging features successfully 212 ® IBM Software Group Rational Developer for System z – Introduction Appendices © 2009 IBM Corporation UNIT RDz Introduction Topics: • The RDz Workbench – Terms and Concepts • Editing COBOL Programs • Debugging COBOL Programs Appendix – Additional RDz Knowledge Transfer Creating a new Workstation Project Appendix – ISPF/LPEX Editor Comparison 214 The IBM Education Assistant The Education Assistant has a number of detailed and useful Camtasias that show use cases for both RDz (standalone) and RDz integrated with other tools (such as Rational Team Concert) http://publib.boulder.ibm.com/infocenter/ieduasst/rtnv1r0/index.jsp 215 The RDz Café IBM's RDz and COBOL Cafés contain white papers, links to additional learning resources and Q&A forums. The forums are reviewed by the RDz development team – who send out responses first-hand to technical questions. http://www-949.ibm.com/software/rational/cafe/community/cobol/rdz?view=overview 216 UNIT RDz Introduction Topics: • The RDz Workbench – Terms and Concepts • Editing COBOL Programs • Debugging COBOL Programs Appendix – Creating a New Workstation Project Appendix – ISPF/LPEX Editor Comparison 217 Installation Verification Procedure – 1 of 5 From the File menu, select: New > Example… Expand Workstation COBOL Select COBOL Sample 1 Click Next > Name the project: Click Finish chapter1 218 See Notes Installation Verification Procedure – 2 of 5 From z/OS Projects Double-click StartApp.cbl This will load the program source into the COBOL editor Scroll around in the source file – and have your first look at a COBOL program (not so scary… ) Don't change any of the source (yet) But you can size the editor window to see more source Note that in the next course unit ("RDz Workbench") – we will cover the tools and development facilities you're looking at. 219 Installation Verification Procedure – 3 of 5 From z/OS Projects Expand BuildOutput Right-click over StartApp.exe, and select: Run As > Run Configurations Note that if you do not see a BuildOutput folder: Right-click over the chapter1 project From the context menu select: Rebuild Project From Run Configurations Select Compiled Application Click the New launch configuration icon Instructions continue on the next slide… 220 Installation Verification Procedure – 4 of 5 In the Project area, type: chapter1 In the Program name: area: Click Browse… Use the Windows dialog to find and select the directory for your Workspace\Project\ BuildOutput folder and StartApp.exe file Note that the icon might not show the file suffix – select the run icon as shown Click Open From the Run Configuration window click: Apply Run 221 Installation Verification Procedure – 5 of 5 This will launch a DOS application that prompts you for either a name, or a Q (upper or lower-case) to quit Enter a few names – after each name, press the Enter key Enter: Q to quit Optional: Browse through the StartApp and PrintApp program source. If you're an experienced COBOL programmer taking this course to learn RDz, note the differences between these two programs and the COBOL datasets you typically work with 222 ® IBM Software Group Appendix – ISPF RDz Editor Cheat Sheets © 2009 IBM Corporation © 2009 IBM Corporation RDz – z/OS Comparison Concepts and Products and TSO TSO/ISPF RDz – Integrated Development Environment Mainframe – z/OS PC – Windows/Linux JCL JCL. If doing offloading from z/OS. Shell scripts – on AIX machines Manually analyze code RDz (see slides in this PowerPoint), and RAAi - http://www-01.ibm.com/software/awdtools/raa/ Edit Code - ISPF LPEX editor. Native LPEX or ISPF profile Compile/Compiler Options Validation, Syntax Check (Local or Remote) – Compiler options under RDz Property Groups Submit Job Edit JCL and submit job, or just use the Context menu and Submit Unit Test – DISPLAY/READY Trace, Xpeditor Debug Perspective – for z/OS (batch and online) applications – as well as Local COBOL projects Integration Test – Xpeditor IBM Debug Tool Integration QA – Regression Test - WinRunner Remote Systems Testing utilizing Rational Function Tester and Rational Performance Tester ABEND-AID/IBM Fault Analyzer RDz – Integrated Fault Analyzer from the IBM Problem Determination Tools File-Aid/IBM File Manager RDz – Integrated File Manager from the IBM Problem Determination Tools PDS (library) Folders - For Remote/SCM-based Projects and Local (z/OS) Projects JES Remote Systems View / JES functionality Endevor/ChangeMan – or Your SCLM 3rd Party SCMs utilize RDz's CARMA feature. RTCz and SCLM utilizing the SCLM provide their own RDz views. And there is Local History and source compare in native RDz ISPF Option 0 Window, Preferences ISPF Option 1 and Option 2 RDz Editor ISPF Option 3.1 (Library Utilities) Remote Systems view (Context Menu options) ISPF Option 3.2 (Dataset Utilities) Remote Systems view (Context Menu options) ISPF Option 3.3 (Move and Copy) Remote Systems view (Context Menu options) ISPF Option 3.4 (DSList) Project Explorer and Filters and Context Menu in Remote Systems Explorer and LPEX Editor ISPF Option 3.8 (Outlist) Remote Systems View – JES/My Jobs ISPF Option 3.11 3.15 (Extended Search) Search menu – covered in another RDz Distance Learning module ISPF Option 4 (Foreground) Context Menu, Run ISPF Option 6 TSO Command Shell – with some functional limitations (e.g. cannot issue Host Execs) ISHELL Remote Systems Explorer - USS files/filters + Context menu OMVS USS Command Shell 224 RDz – ISPF Comparison Chart – PF-Keys ISPF Editor LPEX Editor PF 1 = Help F1, Help Menu*** See slide notes PF 2 = Split: Split the session (lets you use two functions of TSO at the same time.) Ctrl/2 or Context Menu – Open New View. Note that you can open an unlimited number of views PF 3 = End Ctrl+F4, Ctrl + 0, or close the Content Area PF 4 = Return Ctrl+F4, or close the Content Area PF 5 = RFind (repeat last find ) F5 or Ctrl/F – and /<text> from LPEX command PF = 6 RChange (repeat lst change) F6 or Ctrl/N PF = 7 Page Backward F7 or PgUp key – or slider in window PF = 8 Page forward F8 or PgDn key – or slider in window PF = 9 Switch between screens during a split session; goes with PF 2 Mouse – or Alt + Shift + Right/Left arrows PF = 10 Page left Ctrl+PgUp or, the Home key, or slider in window PF = 11 Page right Ctrl+PgDn or, the End key, or slider in Window PF 12 Retrieve For LPEX commands, the Up Arrow Use ISPF Option 0 to customize PF-Keys Use Preferences to customize and extend Function key behavior The LPEX Context Menu can be accessed from the Right-mouse button – and from the Windows Menu key (on the keyboard between the right Alt & Ctrl keys) It should be noted that with the LPEX editor, it is not necessary for most of the above functions to actually press Ctrl/Key combinations, as the functionality is available from a context menu (right-mouse) 225 RDz – ISPF Comparison Chart – Primary Edit Commands ISPF Editor LPEX Editor Home key – Jump to the Command Line Escape key – jumps to the LPEX command line AUTOSAVE/REC Prompt for Save on exit, and Autosave (Preferences), and the asterisk – next to unsaved file names BOTtom LPEX command: bottom / Ctrl+End CANcel Close Content Area w/Save no (Ctrl CHANGE – All – NEXT, CHARS, X, ALL PREFIX, FIRST, SUFFIX, LAST, WORD, PREV, [col-1] [col-2] Supported using Change All, Next, PREV, Prefix and Suffix (with wildcards), Prev, Word, [col1][col-2], …or… Find/Replace menu (Ctrl+F), ISPF or the Search/Replace dialog: Copy Member Name LPEX command: Get filename CREATE Save file as…, or use Snippets View FIND – NEXT, CHARS, X, ALL PREFIX, FIRST, SUFFIX, LAST, WORD, PREV, [col-1] [col-2] http://www.felgall.com/tso2.htm Supported using findText, Ctrl+F, or the Search window: Find All, Next, PREV, Prefix and Suffix (with wildcards), Prev, Word, [col-1][col-2], P Not supported: First, Last HEX – Displays all lines in Hexadecimal Display one individual lines in Hex ISPF Macros Not available – but can be re-written using Java for LPEX. Also, note that with the LPEX functionality some of the Macro functionality may not be necessary LOCATE Ctrl+L, or use the Outline View MODEL Snippets and Templates (both options) MOVE Member Name LPEX Get command, in a different way, the Snippets View NUMBER LPEX command: number std (columns 7380), or number cob PRINT – from ISPF 3.4 LPEX command: print, or Ctrl+P PROFILE – are the changes made to your profile Preferences Replace Member Name Snippets functionality RESet RES command, or: Ctrl+W, or expandAll, or: action showAll Save Ctrl/S or LPEX: save command Sort LPEX command: sort STATS – updates statistics Windows updates file statisticsautomatically SUBmit LPEX command: Submit, or edit JCL/Context Menu/Submit, or use Context Menu/Submit option TABS Set margins in Preferences, LPEX Editor, Tabs TOP LPEX command: top / Ctrl+Home TSO SUB LPEX command: submit, and edit JCL/Context Menu/Submit, or use Context Menu/Submit option UNNUM LPEX command: 226 unnum RDz – ISPF Comparison Chart – Find Commands – Picture Strings ISPF Editor LPEX Editor Simple String Y Previous String Find Previous / F5 Delimited String Y Text string Y Picture Strings – special characters Y – with regular expressions P'=' – any character Ctlr+F, Regular Expression, P'-' – any non-blank character Ctlr+F, Regular Expression, P'.' – any non-displayable character Ctlr+F, Regular Expression, P'#' – any numeric character Ctlr+F, Regular Expression, P'-' – any non-numeric character Ctlr+F, Regular Expression, P'@' – any alphabetic character Ctlr+F, Regular Expression, P'<' – any lower-case character Ctlr+F, Regular Expression, P'>' any upper-case alphabetic character Ctlr+F, Regular Expression, P'$' – any special character (not alphanumeric) Ctlr+F, Regular Expression, ^ . Dot, any single character \ logical NOT . \x Hexadecimal [^\x20] [^\x20-\x7E] [0-9] [^0-9\x20] [A-Za-z] [a-z] [A-Z] [^A-Za-z0-9] Ctrl+F Note: for more Regular expression searches: http://en.wikipedia.org/wiki/Regular_expression 227 special Expression RDz – ISPF Comparison Chart – Edit Line Commands ISPF Editor LPEX Editor – ISPF Mode LPEX Editor – lpex Mode A, An – After A, An Context menu B, Bn – Before B, Bn Context menu COLS – show columns Columns always shown Columns always shown C, Cn, CC – Copy C, Cn, CC Context menu D, Dn, DD D, Dn, DD Context menu or Ctrl+Backspace F, Fn – First (used with eXclude) F, Fn (used with eXclude) N - Find excludes lines of code I, In – Insert lines I, In Press <Enter>, or LPEX command: insert LPEX command: add L, Ln – Last (used with eXclude) N - Find excludes lines of code N - Find excludes lines of code M, Mn, MM – Move M, Mn, MM-Move, and Context menu Context menu R, Rn, RR, RRn – Repeat lines R, Rn, RR, RRn, and Context menu, Ctrl+D Context menu – or Ctrl+D S, Sn – Show (used with eXclude) S, Sn – Show (used with eXclude) and Filter Filter TABS – used with TAB On Set with Preferences Set with Preferences X, Xn, XX eXclude X, Xn, XX Filter O, On, OO – Overlay O, On, OO Use Rectangle Copy/Paste TS, TSn – Text Split Ctrl+<Enter> <Enter> <, <n, <<N Shift Data Left <, <n, <<n Use Rectangle Select – shift >, >n, >>n Shift Data right >, >n, >>n Use Rectangle Select – shift (, (n, ((, ((N – columns left – Used with COBOL (, (n, ((n Use Rectangle Select – shift ), )n, )), ))n – Columns Right ), )n, ))n Use Rectangle Select – shift 228 RDz – ISPF Comparison Chart – LPEX Editing Operations – 1 of 2 LPEX Editor ISPF Editor Refactor – Remove Noise Words: - IS, THEN, PROCEED TO N/A Multiple Line Comment/Uncomment N/A Virtual margins – in the editor N/A Code completion (Content Assist) N/A Open Copybook N/A Open Declaration – of variable or PERFORM'd paragraph from anywhere in the Procedure Division N/A Perform Hierarchy N/A Refactor – wizard for intelligent variable name changes N/A Outline View N/A Filter View – Show only Divisions, SQL,CICS,DL/I, Code (no comments), etc. N/A COBOL, PL/I and HLASM keyword / language help N/A Show lines that have been changed during edit (before save) N/A Find and Change against multiple file types N/A Block Marking (Ctrl+Down, Ctrl+Up, Ctrl+Home, Ctrl+End) N/A Virtual 'A' and 'B' Column lines in the source code N/A Allocate Like N/A Remote System Filters N/A Side-by-side Compare and/or Restore from Local History N/A Close all split screens in one operation (context menu) N/A See file attributes and statistics at all times (in a View) N/A 229 RDz – ISPF Comparison Chart – LPEX Editing Operations LPEX Editor ISPF Editor See file attributes and statistics at all times (in a View) N/A Wizard-driven approach to creating Web Services (WSDL files) from: CICS and IMS TM applications N/A Wizard-driven approach to creating, testing and deploying DB2 Stored Procedures N/A Copy files from one LPAR to another N/A Edit/Compile/Unit Test if the mainframe is offline N/A Syntax error – automatically select line with problem N/A See 46 76 lines of source at once N/A Templatized program development N/A Regular expression searches – including across Filtered files of different file types N/A Keystroke recorder (useful for repetitive tasks and online testing) N/A Bookmark and Tasks (both lines of source and filtered views) N/A Find "Last Changed" line of source code / Ctrl+J N/A Mark lines – including individual names N/A Find Marked Lines / Find named Marked Lines N/A Syntax errors as you type N/A Syntax check in the editor N/A 230 The COBOL Café and Rational - z/OS Product Training from IBM http://www-949.ibm.com/software/rational/cafe/community/cobol To become more innovative and more competitive, companies know that education – in all forms is necessary - today more than ever. To help, IBM has implemented solutions that feature community-based knowledge sharing - that give your developers instant, secure access to shared content, and expertise in: COBOL / IMS / CICS / DB2 and z/OS Technologies Rational Developer for System z (RDz) Rational Application Analyzer (RAA) Check out the COBOL Café http://www-949.ibm.com/software/rational/cafe/community/cobol And check out upcoming free, self-paced IBM training in: RDz / RAA / COBOL / IMS / CICS / DB2 231 © Copyright IBM Corporation 2009. All rights reserved. The information contained in these materials is provided for informational purposes only, and is provided AS IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, these materials. Nothing contained in these materials is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software. References in these materials to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates. Product release dates and/or capabilities referenced in these materials may change at any time at IBM’s sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way. IBM, the IBM logo, Rational, the Rational logo, Telelogic, the Telelogic logo, and other IBM products and services are trademarks of the International Business Machines Corporation, in the United States, other countries or both. Other company, product, or service names may be trademarks or service marks of others. 232