CL programming (with Display Files)

Slides:



Advertisements
Similar presentations
CL programming (with Display Files). Review Display Files Constants Input/Output fields Attributes Activating Function keys.
Advertisements

Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive.
COMPUTER PROGRAMMING I Essential Standard 5.02 Understand Breakpoint, Watch Window, and Try And Catch to Find Errors.
CL Programming with Database Files Updated Fall 2010.
1 Kevin Forsythe DMC Consulting What’s New In CL Programming.
CMPUT 101 Lab # 5 October 22, :00 – 17:00.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
Chapter 5: Loops and Files.
1 Intro to the AS/400 Chapter 5 - CL Programming Copyright 1999 by Janson Industries.
Understanding SAS Data Step Processing Alan C. Elliott stattutorials.com.
Introduction to Query Part 2. Query Topics Joining Files Defining Result Fields Complex Record Selection Formatting Output Creating Reports Using Multiple.
Any Questions!. Agenda Fun with Functions –how to get the system date Condition Names INDARA and SI Iteration Logical Files Positioning the file pointer.
Introduction To PHP 20 * Introducing the basics of programming * Discovering variables, loops, arrays and conditions * Integrating HTML and PHP Stations.
What is Sure BDCs? BDC stands for Batch Data Communication and is also known as Batch Input. It is a technique for mass input of data into SAP by simulating.
1 Operating Systems Lecture 3 Shell Scripts. 2 Shell Programming 1.Shell scripts must be marked as executable: chmod a+x myScript 2. Use # to start a.
1 Operating Systems Lecture 3 Shell Scripts. 2 Brief review of unix1.txt n Glob Construct (metacharacters) and other special characters F ?, *, [] F Ex.
13&14-2 Know the forms of loop statements in C (while,do/while,for). Understanding how data conversion occurs. Read/Write data in files using Unix redirection.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
While Loops Indefinite Iteration. Last lesson we looked at definite loops using the ‘For’ statement. The while loop keeps going while some condition is.
Data Types and RunSQLSTM. Agenda Lab 1 demo this week –Bring your lab notes! Create your own Data Types Label on Authority RunSQLstm.
Set path vs current schema. Set Current Schema ‘The CURRENT SCHEMA special register specifies a VARCHAR(128) value that identifies the schema name used.
IBC233 Calling Programs Updated Summer Agenda Assignments are mandatory Assignment 2 due on July 13, 2007 Display files – lower case Display files.
Chapter 05 (Part III) Control Statements: Part II.
IBC233 Lecture 2 Updated Winter 2008 Agenda Test next Week – Jan 23 ISeries Architecture CL (Control Language) Library Lists Operations Navigator.
Week 4 presentation! This week we will cover editing and the use of the on-board tools provided, SEU and PDM.
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
Loops and Files. 5.1 The Increment and Decrement Operators.
Agenda Perform Quiz #1 (20 minutes) Loops –Introduction / Purpose –while loops Structure / Examples involving a while loop –do/while loops Structure /
IBC233 Lecture 2 Updated Summer 2006 Agenda Review What’s ODIN doing? Library List Websphere –Filters.
© The McGraw-Hill Companies, 2006 Chapter 3 Iteration.
Shell script – part 2 CS 302. Special shell variable $0.. $9  Positional parameters or command line arguments  For example, a script myscript take 2.
1 Week # 4 Introduction to PDM PDM is a workbench environment that lets programmers and system operators navigate the three levels of the AS/400’s object-based.
IBC233 Lecture 2 Updated Summer 2007 Agenda Real Estate Issues Review System Values What’s ODIN doing? Library List Websphere –Filters –Writing a CL.
IBC233 Week 2 Updated Fall 2011 Homework? Finish Lab 1 – Due Today! Send me an with your userid when you are done! Download and install software.
1 Week # 5 Agenda CL Programming CL Commands Job Logs Review for test # 1.
Introduction to Loop. Introduction to Loops: The while Loop Loop: part of program that may execute > 1 time (i.e., it repeats) while loop format: while.
CL Programming with Database Files Updated Summer 2007.
Messages, Logs, and Cleanup
Creating professional PDF documents from basic Spool Files, utilising report definitions, maps and dynamic use of images. (CVTSPLDBF & CVTSPLPDF)
How’s assignment 1 coming? Winter 2007
An Introduction to Programming with C++ Sixth Edition
Agenda Bash Shell Scripting – Part II Logic statements Loop statements
Chapter 10 Backup and Recovery.
Computer Programming I
Lecture 13 & 14.
A First Book of ANSI C Fourth Edition
Chapter 5: Looping Starting Out with C++ Early Objects Seventh Edition
IBC233 Week 2 Updated Winter 2011
Scripts & Functions Scripts and functions are contained in .m-files
Keyboard Input and Screen Display ––––––––––– Interactive Programming
Designing and Debugging Batch and Interactive COBOL Programs
Arrays, For loop While loop Do while loop
When I want to execute the subroutine I just give the command Write()
Tutorial 12 – Security Panel Application Introducing the Select Case Multiple-Selection Statement Outline Test-Driving the Security Panel Application.
Chapter 3 The DATA DIVISION.
Week 4 Updated Winter 2011.
Chapter 2.1 Repetition.
Objectives You should be able to describe: The while Statement
EECE.2160 ECE Application Programming
IBC233 Week 2 Updated Fall 2011.
Welcome to IBC233 Cindy Laurin.
Introduction to Bash Programming, part 3
Chapter 1 c++ structure C++ Input / Output
21st-Century CL Ted Holt Senior Software Developer, Profound Logic Software Senior Technical Editor, The Four Hundred
IBC233 Lecture 3 Updated Fall 2011
Introduction to SAS Essentials Mastering SAS for Data Analytics
Week 8! Any Questions?.
CHAPTER 6 Testing and Debugging.
Getting Started With Coding
What’s New In CL Programming
Presentation transcript:

CL programming (with Display Files) Updated Winter 2007

Agenda Assignment 1 Review Display Files CL Programming Use of Indicators CL Program Examples

Review Display Files Constants Input/Output fields Attributes Activating Function keys

How do we use the Display File? They are included in programs. The programs use them to communicate with the user ( i.e. information is passed back and forth between the program and the user via the display file.)

Program Flow Display the Screen While not F3 Exit Process Data

CL Programming Restrictions Only five *FILE per program Display file or Database File Can’t update Database Files Can’t create reports

CL Variables Datatypes = *CHAR , *DEC , *LGL, *INT, *UINT Variable names start with an ‘&’ e.g. &IN03, &CTR, &USER, &DATE, &MARK1, etc. DCL VAR(&varname) TYPE(*CHAR) LEN(8) variables must be declared before you can use them) variables from a display file will automatically be available to program. (passed in) CHGVAR VAR(&varname) VALUE(value)

Examples DCL VAR(&TOTAL) TYPE(*DEC) LEN(7,2) DCL VAR(&GRADE) TYPE(*CHAR) LEN(1) CHGVAR VAR(&GRADE) VALUE (‘A’) CHGVAR VAR(&TOTAL) VALUE(&TOTAL + 1)

Some File Commands DCLF - Declares a File (files must be declared before you can use them) e.g. DCLF FILE(MARKSDF) SNDRCVF - Sends a record to a screen and waits for the user to enter input, then reads it (only for Display Files) - used with input/output screens e.g. SNDRCVF(MARKSDF)

Selection and Iteration IF (condition) THEN (command) ELSE for conditions, *AND, *OR, *NOT, *LT, *GT, *EQ, *NL, *NG, etc DO and ENDDO - used when you need to execute several commands in an IF statement GOTO and labels

IF, THEN, ELSE example IF COND(&TIME *LE 120000) + THEN ( SNDMSG MSG('Good Morning') TOUSR(DC233A40) ) ELSE + CMD( SNDMSG MSG('Good Afternoon') TOUSR(DC233A40 ) )

DO, ENDDO example IF (&CHOICE = 'O' *OR &CHOICE = 'o') + DO CHGCURLIB IBC233LIB WRKOBJPDM IBC233LIB ENDDO ELSE (GOTO END) END: ENDPGM

Select Group SELECT WHEN COND(&TYPE *EQ *CMD) THEN(DO) (group of CL commands) ENDDO WHEN COND(&TYPE = *PGM) THEN(DO) OTHERWISE CMD(CHGVAR &BADTYPE ‘1’) ENDSELECT

DOWHILE Loop SNDRCVF DOWHILE(&IN03 *NE ‘1’) IF (&IN05 *EQ ‘1’) + DO CHGVAR VAR(&MARK1) VALUE(0) CHGVAR VAR(&MARK2) VALUE(0) ENDDO WRKOBJPDM This bit of code sends the display file to the screen and reads it back. If F3 is pressed, the loop exits and WRKOBJPDM is done. If not, It then checks to see if the user has pressed F5. If so, it initializes the 2 fields MARK1 and MARK2 and redisplays the screen.

DOUNTIL Loop SNDRCVF DOUNTIL(&IN03) /* the contents of loop is */ IF (&IN05) + /* always processed once */ DO CHGVAR VAR(&MARK1) VALUE(0) CHGVAR VAR(&MARK2) VALUE(0) ENDDO WRKOBJPDM This bit of code sends the display file to the screen and reads it back. If F3 is pressed, the loop exits and WRKOBJPDM is done. If not, It then checks to see if the user has pressed F5. If so, it initializes the 2 fields MARK1 and MARK2 and redisplays the screen.

DOFOR Loop DCL &LOOPCTL TYPE(*INT) LEN(4) DCL &LOOPLMT TYPE(*INT) LEN(4) DOFOR VAR(&LOOPCTL) FROM(1) TO(&LOOPLMT) BY(1) (group of commands run 0 or more times) ENDDO

Resulting Indicators Indicators are on/off switches used by programs. 2 possible values: 1 or 0 Response indicators: set by functions keys, used by programs to determine the appropriate response e.g. exit when F3 is pressed Option indicators: set by programs, used to control when/how info is displayed e.g. an indicator is set to on when an error is detected causing an data field to be displayed in red.

Program Flow using Screens and Indicators SNDRCVF Check response indicators DOWHILE (&IN03 *NE ‘1’) Exit Edit input, set option indictors If (&name = ‘ ‘) chgvar IN30 ‘1’ SNDRCVF

Examples of Response Indicator use If (&in03 *eq ‘1’) + goto cmdlbl(exit) If (&in05 * eq ‘1’) + do chgvar var(&assign1) value ( 0 ) chgvar var(&assign2) value ( 0 ) goto cmdlbl(read) enddo

Examples of Option Indicator Use IF (&ASSIGN1 *LT 0 *OR &ASSIGN1 *GT 5) + CHGVAR VAR( &IN30) VALUE (‘1’) IF (&ASSIGN2 *LT 0 *OR &ASSIGN2 *GT 10) + CHGVAR VAR (&IN31) VALUE (‘1’) IF (&IN30 *OR &IN31) + GOTO CMDLBL(SEND) /* REDISPLAY SCREEN */

/* sample */ DCLF FILE(ORDERDF) SNDRCVF DOWHILE (&IN03 *NE ‘1’) IF (&ORDERNO *LE 0) + CHGVAR VAR (&IN40 ) VALUE ( ‘1’ ) IF (&ORDDESC *EQ ‘ ‘) + CHGVAR VAR (&IN41 ) VALUE ( ‘1’) IF ( &IN40 *OR &IN41 ) + GOTO CMDLBL(NEXT) CALL CBLPGM ( &ORDERNO &ORDDESC ) NEXT: SNDRCVF ENDDO ENDPGM

Fix MarksCL

Exercise: Write a CL program which uses the following screen (HAPPYDF in IBC233LIB). The userid must not be spaces. It is controlled by indicator 55. When the userid is valid, send a happy birthday message to the userid entered. If the user presses F3, end the program Dd/dd/dd Happy Birthday tt/tt/tt userid: BBBBBBBBBB Must not be blank F3=exit

Resulting indicators and attributes 0000.20 A*%%EC 0000.30 A DSPSIZ(24 80 *DS3) 0000.40 A INDARA 0000.50 A CF03(03) 0000.60 A CF05(05) 0000.70 A CF12(12) 0000.80 A R TSTREC 0000.90 A*%%TS SD 20010306 204121 ABERNS REL-V4R4M0 5769-PW1 Key response result 0004.00 A FLD003 1Y 0B 9 45 0004.10 A 45 DSPATR(HI) 0004.20 A 45 COLOR(RED) 0004.30 A RANGE(1 4) 0004.40 A EDTWRD(' ') 0004.50 A 45 DSPATR(PC) 0004.60 A CHECK(ME) ****************** End of data ************************************** option result

Preparation and setting 0014.00 PGM /* Field and File Declaration Section */ 0015.00 DCLF FILE(CHAP11) RCDFMT(SCRNR) 0016.00 0017.00 /* Field Initialization Section */ 0018.00 CHGVAR VAR(&IN99) VALUE('0') 0019.00 0020.00 /* Start of iteration (Processing Loop) */ 0021.00 READ: SNDRCVF /* Program displays the screen and */ 0022.00 /* waits here for a response from */ 0023.00 /* the keyboard */ 0024.00 0025.00 /* Initialize Error Checking Indicators before */ 0026.00 /* validating input */ 0027.00 CHGVAR VAR(&IN99) VALUE('0') 0028.00 0040.00 /* Check for Invalid Option */ 0041.00 0042.00 IF COND((&OPTION *NE '1 ') *AND (&OPTION *NE '2 + 0043.00 ') *AND (&OPTION *NE ' 1') *AND (&OPTION + 0044.00 *NE ' 2') *AND (&OPTION *NE '01') *AND + 0045.00 (&OPTION *NE '02')) THEN(DO) 0046.00 CHGVAR VAR(&IN99) VALUE('1') 0047.00 GOTO CMDLBL(READ) 0048.00 ENDDO 0049.00

Debugging CL Programs Use start interactive source debug STRISDB Make sure the compile includes the SRCDBG option

Compile with debug option set (figure it out for WDSc) Create CL Program (CRTCLPGM) Type choices, press Enter. Program . . . . . . . . . . . . > MARKSCLMST Name Library . . . . . . . . . . . > ABIBC20071 Name, *CURLIB Source file . . . . . . . . . . > QCLLESRC Name Library . . . . . . . . . . . > ABIBC20071 Name, *LIBL, *CURLIB Source member . . . . . . . . . > MARKSCLMST Name, *PGM Text 'description' . . . . . . . *SRCMBRTXT Additional Parameters Source listing options . . . . . > *SRCDBG *SOURCE, *NOSOURCE, *SRC... + for more values *source Generation options . . . . . . . > *LIST *NOLIST, *LIST, *NOXREF... + for more values User profile . . . . . . . . . . *USER *USER, *OWNER Log commands . . . . . . . . . . *JOB *JOB, *YES, *NO More... !! How do we get to see these??

Messages MONMSG SNDBRKMSG Message Description files i.e. QCPFMSG Interactive Batch SNDMSG DSPMSG RCVMSG from a queue SNDPGMMSG to a queue WRKMSG MONMSG SNDBRKMSG Message Description files i.e. QCPFMSG DSPMSGD CPF0797 What are these messages? DSPMSGD CPF0881

To Do(s): Work on this lab and THE Assignment 1