Você está na página 1de 34

WHENEVER NOT FOUND = IF SQLCODE = 100 WHENEVER SQLERROR ER SQLWARNING = IF SQCOD > *ZERO and SQLCOD <> 100

= IF SQLCOD < *ZERO WHENEV

If SQLCODE = 0 and SQLWARN0 is blank, execution was successful. If SQLCODE = 100, no data was found. For example, a FETCH statement returned no data, because the cursor was positioned after the last row of the result tab le. If SQLCODE > 0 and not = 100, execution was successful with a warning. If SQLCODE = 0 and SQLWARN0 = 'W', execution was successful with a warning. If SQLCODE < 0, execution was not successful. Level Check Error - CPF4131 / CHGPF FILE() LVLCHK(*NO) / The RPG compiler always provides the information required by level checking when an externally describe d DISK, WORKSTN, or PRINTER file is used. The level-check function can be reques ted on the create, change, and override file commands. The default on the create file command is to request level checking. Level checking occurs on a record-fo rmat basis when the file is opened unless you specify LVLCHK(*NO) when you issue a file override command or create a file. If the level-check values do not matc h, the program is notified of the error. If you have ever modified a physical fi le (e.g., added a new field or changed the length of an existing field) and you didn't recompile the programs that use that file, you probably found out the har d way about file level-checking. If level-checking is active for that file (whic h is the default), any program that has not be recompiled will receive an escape message when called. The process of level-checking for a file is to ensure that programs using that file always use the current definition of the file, hence e nsuring data integrity. Record format level identifier You can use the Display Program References command (DSPPGMREF) to view the *FILE , *PGM, *DTAARA, *SRVPGM used by a program and the associated level-identifiers / You can use Generic names EOF error - CPF0864 End of records in SQL = SQLCODE 100 Record Lock - Use chain(e) and check for status 1218. Command line - CALL PGM(QCMDEXC) PARM('QSYS/CRTLIB LIB(TEST)' 22) - Length must be a packed decimal value of length 15 with 5 decimal positions. C/Exec SQL - C/End-Exec CPF9999 will also catch other messages that are not prefixed with CPF. MCH messa ges might occur and CPF9999 will catch those whereas CPF0000 will not. Message subfile format R MSGSFL MSGKEY PGMQ R MSGCTL SFL SFLMSGRCD(24) SFLMSGKEY SFLPGMQ(10) SFLCTL(MSGSFL) OVERLAY SFLDSP SFLDSPCTL SFLINZ SFLEND SFLSIZ(0002) SFLPAG(0001) SFLPGMQ(10)

PGMQ

SFLINZ is used to initialize the subfile for use across the screen display in AS 400 and can also be used to change the subfile settings just before display SFLPAG keyword is used for subfile page size SFLDSP keyword is used for subfile display SFLDSPCTL keyword is used for subfile display controls Create Table EMPPHOT ( empno decimal(5, 0) , photo blob(4M) allocate(0), primary key (empno) ); ----------------HI - LO - EQ NR - ER - EOF/EQ +ve - -ve - ZERO OFF ON EQUAL ----------------Field length Range of Allowed Values 3-digit integer -128 to 127 5-digit integer -32768 to 32767 10-digit integer -2147483648 to 2147483647 20-digit integer -9223372036854775808 to 9223372036854775807 Packed fields can be up to 32 bytes long. Table 26 shows the packed equivalents for zoned-decimal fields up to 63 digits long: V5R3-63 digit/decimalpos packed/zoned -----------X - F/D Leading Zeroes Y - Date / Z - removes the sign (plus or minus) from a numeric field and suppresses leading zeros. editc and editw There are times when programmers need to convert numbers to characters. I use %EditC built in function using edit code 'X'. Example: 1. Time 34233 (say 3.42.33 am); TextFd = %EditC(Time:'X') Returns '034233' when TextFd is 6A. test field is 6 alpha 2. Number 123; TextFd = %EditC(Number:'X') Returns '000123' If you have editing requirements that cannot be met by using the edit codes desc ribed above, you can use an edit word. An edit word is a character literal or a named constant specified in positions 53 - 80 of the output specification. It de scribes the editing pattern for an numeric and allows you to directly specify: v Blank spaces v Commas and decimal points, and their position v Suppression of u nwanted zeros v Leading asterisks v The currency symbol, and its position v Addi tion of constant characters v Output of the negative sign, or CR, as a negative indicator. Edit Word Source Data Appears in Edited Result as: 'bbbbbb0.bb' 000000001 bbbbbbb.01 'bbbbbb0.bb' 000000000 bbbbbbb.00 'bbb,b0b.bb' 00000012 bbbbbb0.12 'bbb,b0b.bb' 00000123 bbbbbb1.23 'b0b,bbb.bb' 00000123 bb0,001.23

-----------Main procedure HFDICOP / HFELICO Sub procedure PDCP procedures Pgm data / Compile time data CTDATA -----------There are four keywords required in the subfile control record format: The subfile control (SFLCTL) keyword identifies the subfile control record forma t--again, like the record (RECORD) keyword does for a typical display record for mat. The SFLCTL keyword also identifies the subfile record format that must imme diately precede it. The subfile size (SFLSIZ) keyword specifies the number of records that the subfi le may contain. The subfile page (SFLPAG) keyword specifies the number of records that one scree n of data may contain. The subfile display (SFLDSP) keyword specifies under which condition the subfile may be displayed. SFLSIZ 9999 Load-All & Expanding (ROLLUP) - Same 9999 Page-at-a-time ROLLUP / ROLLDOWN ----------------Create Procedure MyProcY ( InOut Parm1 Int ) Language RPGLE Parameter Style SQL Modifies SQL Data External Name MyPgmY Parameter declarations in MyPgmY: ....1....+....2....+....3....+....4....+....5....+....6....+ * Parameters * - - - - - - - - - - - - - - - - - - - - - - - - - - - - D Parm1 S 10I 0 D Parm1NullInd S 4B 0 D ParmSqlState S 5A D ParmProcName S 517A Varying D ParmSpecName S 128A Varying D ParmMsgText S 70A Varying . . . * Entry point * - - - - - - - - - - - - - - - - - - - - - - - - - - - - C *Entry Plist C Parm Parm1 C Parm Parm1NullInd C Parm ParmSqlState C Parm ParmProcName C Parm ParmSpecName C Parm ParmMsgText

Create Procedure MyProcX ( In Parm1 Int, InOut Parm2 Char( 10 ), Out RtmMsgId Char( 7 ) ) Language RPGLE Parameter Style General Reads SQL Data External Name MyPgmX Parameter declarations in MyPgmX: ....1....+....2....+....3....+....4....+....5....+....6....+ * Parameters * - - - - - - - - - - - - - - - - - - - - - - - - - - - - D Parm1 S 10I 0 D Parm2 S 10A D RtnMsgId S 7A . . . * Entry point * - - - - - - - - - - - - - - - - - - - - - - - - - - - - C *Entry Plist C Parm Parm1 C Parm Parm2 C Parm RtnMsgId --------------------------DSPLY has a lousy 52-byte max CVTDAT DATE(&WORKDATE) TOVAR(&OUTDATE10) FROMFMT(&XFORMAT) TOFMT(*ISO) TOSEP(*NO NE) TEST(DTZ) TESTN for testing (NUMBER BLANKS+NUMBER ALLBLANKS) There is a special binding directory on your AS/400 named QC2LE. It contains a l ist of modules and service programs needed for the C language runtime environmen t. BNDDIR('QC2LE') DFTACTGRP(*NO) EVAL RESULT = (2 + 3 * 2) ** 2 / 2 = (2+6)**2 / 2 = 8**2 / 2 = 64 / 2 ans - 32 **CTDATA UDPATES2 **CTDATA UDPATES1 CTDATA complie time data for arrays pre-runtime / compile time / runtime arrays Creating a CL program to start FTP OVRDBF FILE(INPUT) TOFILE(GERRYLIB/QCLSRC) MBR(FTPCMDS) OVRDBF FILE(OUTPUT) TOFILE(GERRYLIB/QCLSRC) MBR(FTPLOG) FTP RMTSYS(LOOPBACK) DLTOVR FILE(INPUT OUTPUT) a) The Local Data Area is associated with the current job only (it s a charac ter data area of 1024 bytes length). b) The Program Initialized Parameter Data Area is associated with a pre-sta rt job (max. length 2000 bytes)

c) The Group Data Area is associated with the group job (character data are a with 512 bytes length). d) General Data Area created by the users (can be of type character, decima l or logical). 2000 SELECT COUNT(DISTINCT WORKDEPT) SQL - CURRENT_DATE Passing a pointer by value is the same thing as passing a variable by reference user: owner group other access: R W X R W X R W X bit: 9 8 7 6 5 4 3 2 1 In an RPG program, where is the information available to determine which member of a multiple-member physical file is currently being processed? in the file inf ormation data structure The logical partition on AS/400 is called as Auxiliary Storage Pool (ASP). The ASP is like C drive D drive etc on Personal Computers except that the ASPs on AS /400 are numbered. Within ASP are what are called as Libraries. file processing in RPG/400 - rrn,consecutive,sequential by key,keyed There cannot be more than one H spec. in an RPG/400 program. /FREE etc begin at position 7 The /COPY and /INCLUDE directives have the same purpose and the same syntax, but are handled differently by the SQL precompiler. There is no *INZSR associated with subprocedures. If your program does not contain a primary file, you must specify a way for the program to end: 1.By setting the LR indicator on 2.By setting the RT indicator on 3.By setting an H1 through H9 indicator on 4.By specifying the RETURN operation code CNTFLD(width of column) Use this field-level keyword to define a field as a continued entry field. Conti nued-entry fields are sets of associated entry fields that are treated by the wo rk station controller as a single field during field-data entry and editing. ENTFLDATR Use this field-, record-, or file-level keyword to define the leading attribute of the field that changes to a specified attribute whenever the cursor is locate d in the field. When defined at both the field- and record-level, the field-leve l specification is used for the field. The ENTFLDATR keyword is ignored when the workstation is not attached to a controller that supports an enhanced data stre am. The format of the keyword is: ENTFLDATR[([color] [display attribute] [cursor visible])] CRTDUPOBJ vs. CPYF The OS/400 command called CPYTOIMPF can be used to create a stream file in CSV f ormat without us having to write any code to do it. DSPSIZ (27 132 *DS4 24 80 *DS3)

the prompt options are: ?? displayed and changeable ?* displayed but not changeable ?- not even displayable (default value used if () is used) Parameters not specified are available either immediately or by pressing F10. *TCAT < *BCAT > ----An indicator is a one byte character field All indicators except MR, 1P, KA through KN, and KP through KY can be set on wit h the SETON operation code; all indicators except MR and 1P can be set off with the SETOFF operation code. 1stPage-1P Overflow-OA-OG,OV 01-99 Halt-H1-H9 Control-L1-L9 External-U1-U8 Match-M1-M9 FuncKeys-KA-KN,KP-KY LR,RT,MR All lower level indicators are set on when a higher level indicator is set on as the result of a control break. For example, if L8 is set on by a control break, L1 through L7 are also set on. The LR (last record) indicator is set on when th e input files are at end of file. LR is considered the highest level indicator a nd forces L1 through L9 to be set on. ----------TABLES vs ARRAYS table - can be searched sequentially only, array - can be searched randomly compile/preruntime tables, compile/preruntime,runtime arrays The major difference between an Array and a Table is that an array can be proces sed by the index and its individual elements can be accessed using the index, wh ereas, in case of a table it is not possible, the LOKUP operation has to be perf ormed and the elements can be accessed only sequentially. ---------D P D D D c c P @__errno PR * ExtProc('__errno') errno B errno PI 10I 0 p_errno S * retval S 10I 0 based(p_errno) eval p_errno = @__errno return retval E

--------------CL does not support zoned decimal numbers. parameters are passed by reference So instead of "call step3cl <address of &FILENAME>" you get "CALL QCMD PARM(call step3cl 'test.txt')" (not really but why add request message processing to the muddle?) QCMD parses out the string that it received and realises that it has to

create some storage for the parameter 'test.txt' Because it is a character cons tant, QCMD creates a 32 byte storage area, initialises it to blanks and loads th e constant into it, left-justified. QCMD then does a "call STEP3CL <address of i nternal storage area>" The SBMJOB results in "cvttopdf filename('test.txt') When QCMD does his thing, h e sees that he needs to run a command (not CALL) so the command processor checks the command definition for each parameter, initialises the defined amount of st orage (here it's 50 bytes) loads the internal storage areas up and away we go. W hen STEP3CL gets called as a result of processing CVTTOPDF, his definition of 50 bytes exactly matches the caller's definition of 50 bytes and All Is Well. ------------IFS Checking existence and permissions to files - access() / CHKOBJ Changing permissions on an existing IFS Object - chmod() Retrieving Stream File Stats - stat() Deleting IFS objects (links) - unlink() Renaming IFS objects - rename() Positioning to a given point in the file - lseek() -----------DSPF The P-field @CUST# is declared as a one-byte field with a P in position 38, and it needs to be inside the record I am displaying. The P-field @CUST#, when used by the keyword DSPATR, must be preceded by an ampersand (&) for your DSPF to com pile. Your program will use P-field @CUST# to control the display of I/O field C UST# on the panel. How do you position the cursor over a field in error without resorting to indica tors? There is a keyword in DDS called CRSLOC (see Figure 4). This keyword has t wo 3-byte fields, which are both zoned-decimal hidden fields that control the ro w and column positioning of the cursor. First, you should have all of the function key keywords (such as CF01 and CF02) coded in the file or record section of the DDS for this method to work (see Figu re 4). Next, there is a byte in the INFDS at position 369 called AID, or Attenti on Indicator. After the panel has been read, the AID byte will contain a hexadec imal number corresponding to a function or editing key (such as Enter or Print). ---------The RESET operation is used to restore a variable to the value held at the end o f the *INIT phase. This value is called the reset value. If there is no *INZSR s ubroutine, the reset value is the same as the initial value (either the value sp ecified by the INZ{(initial value)} on page 311, or the default value). If there i s a *INZSR subroutine, the reset value is the value the variable holds when the *INZSR subroutine has completed. The RESET operation can also be used to restore all the fields in a record format to their reset values. The CLEAR operation sets elements in a structure (record format, data structure, array, or table) or a variable (field, subfield, array element or indicator), t o their default initialization value depending on field type (numeric, character , graphic, UCS-2, indicator, pointer, or date/time/timestamp). For the default i nitialization value for a data type, see Chapter 10, Data Types and Data Formats, on page 169.

------Difference between ODP and Access path? Open Data Paths (ODPs) provide a way for more than one program in the same job t o share the same file status information (I/O feedback areas), file pointer posi tions, and storage area. ODP's are quite useful as they can improve performance, reduce the amount of main storage needed by the job, and reduces file opens/clo ses. For native I/O access you can set up ODP's by specifying SHARE(*YES) on the CRTP F, CHGPF, or OVRDBF commands. However, SQL based I/O access is not influenced by the SHARE (*YES) setting. The DB2 SQL engine is solely responsible for creating and reusing ODP's for I/O performed from SQL-based interfaces (and does so auto matically). An access path (also known as a keyed logical file or an index in SQL terms) is data structure that represents the order in which data will be retrieved from a file. It provides a quick way of locating data. Without an access path, a progra m would be forced to read every row in the table to find the particular rows of interest. This technique (known as a full table scan), can be a lengthy process, depending on the size of the table and how many rows are being retrieved. A sca n using an access path tends to be more efficient than a full table scan when a small percentage of rows are selected since the length of the access path key va lue is usually shorter than the length of the table row. ---------------What does Seton LR do? If I have two programs, PGMA and PGMB, PGMA calls PGMB. PGMB returns to PGMA, an d then PGMB is removed from the call stack since it has returned instead of SETO N LR. How will the file used remain opened when the program is not in the call s tack still? You are correct in that when you do a return, some of the resources associated t o that job stay allocated even though the program no longer exists in the call s tack. If you are calling a program repeatedly, using a RETURN instead of a SETON LR has big performance advantages because the files are already open and ready to use when you call the program repeatedly from the same job. Here are a couple of things to watch out for when using RETURN instead of LR: 1. Your program variables are left in the state they were in the last time you c alled the program. If you use a RETURN, proper variable initialization is import ant. 2. If you are using an *INZSR to initialize your program variables, that is only executed the first time the program is called and not on subsequent calls to th e program. If that's the case, you'll probably want to make a separate subroutin e to initialize your variables and control the execution in your program. ------------CCSID CCSID is an abbreviation used by IBM to mean "Coded Character Set Identifier". I t is a 16-bit number that represents a specific encoding of a specific code page . For example, Unicode is a code page that has several encoding forms, like UTF8, UTF-16 and UTF-32. 819 - iSeries IFS ASCII 367 - HTTP ASCII 37 - North American EBCDIC EBCDIC - This the the original form of the data on the iSeries. ------

RCLRSC LVL(*/*CALLER) OPTION(*NORMAL/*ABNORMAL) the Reclaim Resources (RCLRSC) command can be used for programs running in the d efault activation group. These can be either OPM programs or ILE programs compil ed with the option DFTACTGRP(*YES). The two parameters on the RCLRSC command are used to define the call level at which the cleanup should occur and to indicate whether an abnormal close notification should be sent to open communication fil es. RCLACTGRP ACTGRP(*ELIGIBLE/Act Grp Name) OPTION(*NORMAL/*ABNORMAL) The ACTGRP parameter is used to specify the name of the activation group to be r eclaimed. The optional special value *ELIGIBLE can be specified to reclaim all e ligible activation groups (that is, activation groups that are no longer in use) . The OPTION parameter on this command not only handles sending an abnormal clos e notification to open communication files, but also determines whether to commi t or roll back pending changes for an activation group level commitment definiti on. -----rpg cycle The ILE RPG compiler supplies part of the logic for an RPG program. The logic th e compiler supplies is called the program cycle or logic cycle. The program cycl e is a series of ordered steps that the main procedure goes through for each rec ord read. No cycle code is generated for a module when NOMAIN is specified on th e control specification. -------STRPGMEXP PGMLVL(*CURRENT) EXPORT SYMBOL(PROC1) EXPORT SYMBOL(PROC2) EXPORT SYMBOL(PROC3) ENDPGMEXP As I mentioned, the binder source language has only three op codes: STRPGMEXP, E XPORT, and ENDPGMEXP, and they are always used in that order, so let's go over e ach one STRPGMEXP (or Start Program Export) signifies the beginning of an EXPORT list. ( You can have more than one, which I'll discuss later.) It has three options: PGM LVL, LVLCHK, and SIGNATURE. PGMLVL is required and has two possibilities, *CURRENT and *PRV. There must alwa ys be one, and only one, *CURRENT, which is the default. The *PRV allows you to maintain multiple export lists (more on this later). LVLCHK has two options, *YES and *NO. No means your service program will have a signature value of 0, and for the life of me I cannot conceive of a scenario whe n I would be even remotely interested in using *NO. The default is *YES, and I r ecommend you leave it as such. The last option, SIGNATURE, is really the heart of what makes binder source so c ool. The default value is *GEN and will serve you just fine. Remember the funky 16-byte signatures I talked about earlier? Well, *GEN is what creates them. The cool thing is that, in conjunction with *PRV mentioned above, you can have multi ple signatures per service program. As a result, the list can grow, meaning that the *CURRENT signature will change, but programs created with a *PRV signature can still run without modification. This backward compatibility is, after all, t he whole point of using binder source. The next code, EXPORT, tells the service program to export this procedure. There

are two ways to do so, either with or without quotation marks. With the quotati on marks, the procedure name will be searched for in the case it is entered, so EXPORT('myProc') is not the same as EXPORT('MYPROC'). I'm not a C programmer, bu t since we are dealing with ILE here, I'm sure this feature is to allow mixed-ca se procedure names. Not using quotes will automatically search for the name in u ppercase, so EXPORT(myProc) does equate to EXPORT(MYPROC). For RPG IV procedures , there is no reason not to use the non-quotes approach. CRTSRVPGM SRVPGM(MYLIB/MYSRVPGM) MODULE(MYLIB/PROC1 MYLIB/PROC2 MYLIB/PROC3 MYLIB/PROC4) EXPORT(*SRCFILE) SRCFILE(MYLIB/QSRVSRC MYSRVPGM) STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('MYNAME 20031001') EXPORT SYMBOL(PROC1) EXPORT SYMBOL(PROC2) EXPORT SYMBOL(PROC3) EXPORT SYMBOL(PROC4) ENDPGMEXP STRPGMEXP PGMLVL(*PRV) SIGNATURE('MYNAME 20030425') EXPORT SYMBOL(PROC1) EXPORT SYMBOL(PROC2) EXPORT SYMBOL(PROC3) ENDPGMEXP STRPGMEXP PGMLVL(*CURRENT) EXPORT SYMBOL(PROC1) EXPORT SYMBOL(PROC2) EXPORT SYMBOL(PROC3) EXPORT SYMBOL(PROC4) EXPORT SYMBOL(PROC5) EXPORT SYMBOL(PROC6) EXPORT SYMBOL(PROC7) EXPORT SYMBOL(PROC8) ENDPGMEXP STRPGMEXP PGMLVL(*PRV) EXPORT SYMBOL(PROC1) EXPORT SYMBOL(PROC2) EXPORT SYMBOL(PROC3) EXPORT SYMBOL(PROC4) EXPORT SYMBOL(PROC5) EXPORT SYMBOL(PROC6) ENDPGMEXP STRPGMEXP PGMLVL(*PRV) EXPORT SYMBOL(PROC1) EXPORT SYMBOL(PROC2) EXPORT SYMBOL(PROC3) EXPORT SYMBOL(PROC4) ENDPGMEXP STRPGMEXP PGMLVL(*PRV) EXPORT SYMBOL(PROC1) EXPORT SYMBOL(PROC2) EXPORT SYMBOL(PROC3) ENDPGMEXP ---------

SQL term - iSeries term Table - Physical file View - Non-keyed logical file Index - Keyed logical file Column - Field Row - Record Schema - Library, Collection, Schema Log - Journal Isolation level - Commitment control level STRPCO STRPCCMD PCCMD(NOTEPAD.EXE) ---SQL stored procedures External procedures SQL Triggers External triggers SQL UDFs External UDFs Sourced UDFs 1.Reusing code from one program to another, cutting down on program development time 2.Hiding the SQL details, allowing database developers to worry about SQL and ap plication developers to deal only in higher-level languages 3.Centralize maintenance, allowing you to make business logic changes in a singl e place that automatically affect all dependent applications 4.The advantage of a stored procedure is that when it is run, in response to a u ser request, it is run directly by the database engine, which usually runs on a separate database server. As such, it has direct access to the data it needs to manipulate and only needs to send its results back to the user, doing away with the overhead of communicating large amounts of data back and forth. 5.Stored procedures improve performance by reducing network traffic and CPU load SP Vs UDF 1.Stored procedures are called independently, using the SQL CALL/EXEC command, w hile functions are called from within another SQL statement 2.Stored procedure allow you to enhance application security by granting users a nd applications permission to use stored procedures, rather than permission to a ccess the underlying tables. Stored procedures provide the ability to restrict u ser actions at a much more granular level than standard SQL Server permissions. For example, if you have an inventory table that cashiers must update each time an item is sold (to decrement the inventory for that item by 1 unit), you can gr ant cashiers permission to use a decrement_item stored procedure, rather than al lowing them to make arbitrary changes to the inventory table. 3.Functions must always return a value (either a scalar value or a table). Store d procedures may return a scalar value, a table value or nothing at all. 4.UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT sect ion where as Stored procedures cannot be. The invocation of a stored procedure is treated as a regular external call. The application waits for the stored procedure to terminate, and parameters can be p assed back and forth. Stored procedures can be called locally (on the same syste m where the application runs) and remotely on a different system. The CREATE PROCEDURE statement differs from the DECLARE PROCEDURE since it adds procedure and parameter definitions to the system catalog tables (SYSROUTINES an

d SYSPARMS). Use the DROP PROCEDURE statement to delete the stored procedure catalog informat ion entry. This section shows you how to view the stored procedure information using the SY SROUTINES PF catalog, the SYSPROCS view, and the SYSPARMS view, SYSFUNCS view. DB2 Universal Database for iSeries supports the concept of procedure overloading . This means that you can have two or more procedures with the same name in the same library, schema, or collection, provided they have different signatures. Th e signature of a procedure can be defined as a combination of the qualified name and the number of parameters in the procedure. No two procedures in the library can have the same signature. Therefore, no two procedures with the same name an d the same number of parameters can coexist in the same library. For example, th e following two stored procedures can coexist in the same library: MyStorProc( char(5), int) MyStorProc( int) However, these two procedures cannot exist in the same library: MyStorProc( char(5)) MyStorProc( int) Important: The stored procedure signature differs from the UDF signature. The UD F signature consists of a name, number, and types of parameters. The following t wo UDFs can coexist in the same library: myUDF( char(5) ) myUDF ( int ) In *SQL naming convention, "select * from qsys2.sysroutines " In *SYS, "select * from qsys2/sysroutines" if you want to re-create or delete an existing procedure, use the DROP PROCEDURE statement. To drop the second procedure, you need to use one of the methods listed here: Specify the specific procedure name: drop specific procedure spintchar; Include the parameter types on the DROP PROCEDURE statement: drop procedure myStorproc( int, char ); For Creation/Deletion/Testing of Stored Procedures, use iSeries Navigator "Run a SQL Script" option DB2 UDB for iSeries passes a number of parameters to the procedure in addition to those specified on the parameter list . The number and type of additional parameters passed depends on the parameter style. You can specify the required parameter style when the procedure is created. DB2 UDB for iSeries supports four parameter styles: SQL parameter style DB2SQL parameter style GENERAL WITH NULLS parameter style GENERAL parameter style The DB2 UDB for iSeries stored procedures support the following SQL statements f or the transaction management: COMMIT SAVEPOINT ROLLBACK and ROLLBACK TO SAVEPOINT

RELEASE SAVEPOINT SET TRANSACTION ------AS/400 Starter Kit notes ---------------------------------------------Figure 5. RPG IV Program Logic Cycle (1) All heading and detail lines (H or D in position 17 of the output specificat ions) are processed. (2) The next input record is read and the record identifying and control level i ndicators are set on. (3) Total calculations are processed. They are conditioned by an L1 through L9 o r LR indicator, or an L0 entry. (4) All total output lines are processed. (identified by a T in position 17 of t he output specifications). (5) It is determined if the LR indicator is on. If it is on, the program is ende d. (6) The fields of the selected input records are moved from the record to a proc essing area. Field indicators are set on. (7) All detail calculations are processed (those not conditioned by control leve l indicators in positions 7 and 8 of the calculation specifications) on the data from the record read at the beginning of the cycle. S/36 S/38 AS/400 Programming Development Manager PDM AS/400's S/36 environment When a S/38 object is restored onto the AS/400, the system attaches the suffix " 38" to the object attribute (CLP38, RPG38, PF38) *ALLOBJ special authority special QSECOFR profile The AS/400 provides five levels of security: 10(0-security), 20(user+pwd+allobj) , 30(user+pwd-allobj), 40(-MI+OpSysIntg), and 50(+DOD C2 security) CHGSYSVAL SYSVAL(QSECURITY) VALUE(XX) IPL the system = PWRDWNSYS OPTION(*IMMED) RESTART(*YES) CHGSYSVAL SYSVAL(QPWDMINLEN) VALUE(7) CHGSYSVAL SYSVAL(QPWDMAXLEN) VALUE(10) CHGSYSVAL SYSVAL(QPWDRQDDGT) VALUE('1') CHGSYSVAL SYSVAL(QPWDLMTREP) VALUE('1') CHGSYSVAL SYSVAL(QPWDLMTAJC) VALUE('1') CHGSYSVAL SYSVAL(QPWDEXPITV) VALUE(60) WRKSYSVAL

Some user profiles do not have passwords, you cannot sign on as that user profil e, some have same passwords as name QSECOFR (security officer) QPGMR (programmer) QUSER (user) QSYSOPR (system operator) QSRVBAS (basic service representative) QSRV (service representative) CHGUSRPRF USRPRF(profile_name) PASSWORD(password) PWDEXP(*YES) RTVUSRPRF GO SETUP, option 11 CHGSYSVAL SYSVAL(QAUTOCFG) VALUE('0') WRKSYSSTS CHGSYSVAL SYSVAL(QCTLSBSD) VALUE('QCTL QGPL') CRTSBSD RTVCLSRC PGM(QSYS/QSTRUP) SRCFIL(QGPL/QCLSRC) CRTUSRPRF (Create User Profile), CHGUSRPRF (Change User Profile), and DLTUSRPRF (Delete User Profile) = QSECOFR or *SECADM (security administrator) DspLibD QSys System Service Tools to trace communication lines and data QINTER, QBATCH, QCMN, and QSPL Memory is divided into the machine pool, subsystem QBASE, and subsystem QSPL. Th e system uses the machine pool to interface with the hardware. Subsystem QBASE i s a memory pool used to execute all the interactive, batch, and communications j obs. QSPL is the spooling subsystem that provides the operating environment (mem ory and processing priorities and parameters) for programs that read jobs onto j ob queues to wait for processing and write files from an output queue to an outp ut device. assign each user to one of the following classes SECOFR (security officer) grants the user all authorities: all object, security administrator, save system, job control, service, spool control, and audit autho rities (each of these special authorities is explained below). SECADM (security administrator) grants security administrator, save system, and job control authorities. PGMR (programmer) grants save system and job control authorities. SYSOPR (system operator) grants save system and job control authorities. USER (user) grants no special authorities. The AS/400 provides six special authorities: ALLOBJ (all object authority) lets users access any system object. This authorit y alone, however, does not allow the users to create, modify, or delete user pro files. SECADM (security administrator authority) allows users to create and change user profiles. SAVSYS (save system authority) lets users save, restore, and free storage for al l objects. JOBCTL (job control authority) allows users to change, display, hold, release, c ancel, and clear all jobs on the system. The user can also control spooled files in output queues where OPRCTL(*YES) is specified. SERVICE (service authority) means users can perform functions from the System Se rvice Tools, a group of executable programs used for various service functions ( e.g., line traces and run diagnostics). SPLCTL (spool control authority) allows users to delete, display, hold, and rele ase their own spooled files and spooled files owned by other users. AUDIT (audit authority) allows users to start and stop security auditing as well as control security auditing characteristics.

auxiliary storage pool (ASP) = group of disk units A save file is a special type of physical file to which you can target your back up operation disk-mirroring, RAID Redundant Array of Independent Disks, direct address storag e drive DASD workstations and printers cumulative Program Temporary Fix (PTF) release STRS36E or CALL QCL command to enter the S/36 or S/38 environment QUSRSYS QSYS QGPL QTEMP three categories of authority to an object Object authority Data authority Field authority V4R4M0 V6R0M0 DSPNETA CHGMSGQ QSYSOPR *BREAK SEV(95), CLRMSGQ, CLRSAVF GO LICPGM, GO DISKTASKS DLTPTF RCLSPLSTG reclaim spool storage, RCLSTG, WRKSYSSTS (Work with System Status) GO SAVE, SAVSYS, SAVLIB LIB(*IBM) WRKCMTDFN JOB(*ALL) STATUS(*RESYNC) WRKHLDOPTF (Work with Held Optical Files) WRKACTJOB PTF, or program temporary fix ANZPRB GO PTF, SNDPTFORD (Send PTF Order), DSPPTF (Display Program Temporary Fix), LODP TF DSPLOG LOG(QHST) PERIOD((start_time start_date)) Deleted records continue to occupy disk space until you execute a RGZPFM (Reorga nize Physical File Member) send user-to-user messages, SNDMSG (Send Message), SNDBRKMSG (Send Break Message ), or SNDNETMSG (Send Network Message) *INFO or *INQ (with reply) WRKDIR (Work with Directory), CRTDSTL (Create Distribution List), ADDDSTLE (Add Distribution List Entry) System Network Architecture Distribution Services (SNADS) be active message processing: the system reply list, break handling programs, and default replies BCHJOB (Batch Job), SBMJOB (Submit Job), CHGJOB (Change Job), CRTJOBD (Create Jo b Description), CHGJOBD (Change Job Description) WRKRPYLE (Work with Reply List Entries), ADDRPYLE (Add Reply List Entry), CHGRPY LE (Change Reply List Entry), RMVRPYLE (Remove Reply List Entry) DSPMSGD (Display Message Descriptions) The system reply list handles only inquiry messages, while a break handler can p rocess any type of message, such as a completion message or an informational mes sage CHGMSGQ MSGQ(library/msgq_name) DLVRY(*BREAK) PGM(program_name) SEV(severity_cod e) ADDMSGD (Add Message Description), CHGMSGD, DSPMSGD, WRKMSGD print files = QSYSPRT QSUPPRT QQRYPRT CRTPRTF (Create Print File), OVRPRTF, CHGSPLFA, CHGPRTF FILE(library_name/file_n ame) PAGESIZE(51 132) OVRFLW(45) DSPFD QSYSPRT DSPJOB (Display Job) or the DSPJOBLOG (Display Job Log)

msg severity 00 = info 99 = critical CRTOUTQ (Create Output Queue), CLROUTQ (Clear Output Queue) QEZJOBLOG QEZDEBUG, output queues contain spooled files WRKOUTQ QPRINT, WRKWTR (Work with Writer) , WRKSPLF (Work with Spooled Files) status of spooled file = OPN CLO HLD RDY SAV WTR EDTOBJAUT (Edit Object Authority), GRTOBJAUT (Grant Object Authority), RVKOBJAUT (Revoke Object Authority) STRPRTWTR WRITER(writer_name) OUTQ(QPRINT) CRTOUTQ and CHGOUTQ commands let you associate a data queue with an output queue so that when a spooled file becomes ready on the output queue, OS/400 will send an entry to the associated data queue. QRCVDTAQ QSNDDTAQ CLRJOBQ WRKJOBQ only 1 *JOBSCD job schedule object, ADDJOBSCDE CHGJOBSCDE HLDJOBSCDE RLSJOBSCDE RMVJOBSCDE WRKJOBSCDE userspace QUSCRTUS QUSRTVUS DSPOBJD OBJ(QSYS/QHST*) OBJTYPE(*FILE) = list of files Display source - DSPOBJD OBJ(A) OBJTYPE(*ALL) DETAIL(*SERVICE) SavChgObj (Save Changed Objects) command to save only changed objects since a li brary or group of libraries was last saved or since a particular date and time SavSys SavDLO (Save Document Library Objects) Sav (Save) SavLib (Save Library) S avObj (Save Object) SavSecDta SavCfg PrtSysInf (Print System Information) Backup, Recovery and Media Services BRMS DspRcyAP DspHdwRsc DspSbsD DspSfwRsc DspObjD WrkJrnA DspUsrPrf DspJobD CpySplF, spooled file APIs, QUSLSpl (List Spooled Files), QUSRSplA (Retrieve Spo oled File Attributes), QSpOpnSp (Open Spooled File), QSpCrtSp (Create Spooled Fi le), QSpGetSp (Get Spooled File Data), QSpPutSp (Put Spooled File Data), QSpCloS p (Close Spooled File) An access path describes the order in which the records in a database file are p rocessed. backup media devices = save file, tape, diskette, and optical routing entries / autostart job, workstation, job queue, communications + presta rt main storage = machine pool (*MACHINE) and base pool (*BASE) controlling subsystem QCTL instead of QBASE STRSBS DSPSBSD CRTJOBQ ADDJOBQE ADDCMNE ADDPJE ADDAJE ADDRTGE job name, user profile name, and job number = unique job CHGCMDDFT Change Command Default RRTJOB (Reroute Job) TFRJOB (Transfer Job) 5 file types and 10 sub-types : Database - PF LF, Source - PF, Device - DSPF PRTF TAPF DKTF ICFF, Save - SAVF, D DM - DDMF files described at 4 levels = object-level *FILE DSPOBJD, file-level DSPFD, reco rd-level DSPF, field-level DSPFFD ADDPFM OVRDBF PF, TYPE(*FILE) and ATTR(PF), one record format, relative record number, DSPPFM LF, TYPE(*FILE) and ATTR(LF), key fields, select/omit logic, field selection, or field manipulation PF-DTA and PF-SRC, CRTSRCPF, DDMF access remote files call stack = ordered list of active programs, reflects depth of program calls, c all level-1 2 3 4 TfrCtl (Transfer Control) Activation groups, introduced with ILE, are further division of jobs into smalle

r substructures Scoping an Override = Call level, Activation group level, Job level all jobs = 1 default activation group + optional named activation groups Original Program Model (OPM) programs can run only in the default activation gro up Within a single call level, only the most recent override is in effect Because the call level doesn't change, the overrides aren't combined Protecting an Override = Secure(*Yes) on the override command Call level: DltOvr File(File1) OvrScope(*), Activation group level: DltOvr File( File2) OvrScope(*ActGrpDfn), Job level: DltOvr File(File3) OvrScope(*Job) OvrMsgF logical file rcd fmt = pf rcd fmt (PFILE) OR new rcd fmt / key fields (K) / prim ary key(UNIQUE) Select/Omit (S, O, Blank position)= COMP, VALUES, RANGE = must have Keys (or *NO NE) OR DYNSLT keyword ALL keyword with Select/Omit When you use DYNSLT, all records in the physical file are indexed, and the selec t/omit logic is not performed until the file is accessed. ALCOBJ = exclusive sharing of objects ODP = file status and file pointer SHARE(*YES) = When a program opens a file, the options specified on the OPNDBF ( Open Data Base File) command or by the high-level language definition of the fil e determine the open options. The open options are *INP (input only), *OUT (outp ut only), and *ALL (input, output, update, and delete operations). These options are significant when you use shared ODPs. If you specify SHARE(*YES) for a file , the initial program's open of the file must use all the open options required for any subsequent programs in the same job. when you specify SHARE(*YES), the first open establishes the open options Record locking, on the other hand, is not controlled by the open options, but by the RPG compiler CHGOBJOWN MONMSG

-------------Sample pgm on PUB1 AS400 system MQ library is MQMQ Display MQ Version Name . . . Version . CMVC level BuildType ------CMDMQM Select one of the following: Queue 1. 2. 3. Manager Commands Change Message Queue Manager Connect Message Queue Manager Create Message Queue Manager CHGMQM CCTMQM CRTMQM . . . . . . . . . . . . . . . . . . . . . . . . : : : : WebSphere MQ 6.0.2.5 p600-205-080922 IKAP - (Production)

WebSphere MQ Commands

4. 5. 6. 7. 8. 9. 10. 11.

Delete Message Queue Manager Disconnect Message Queue Manager Display Message Queue Manager Display Message Queue Manager Status End Message Queue Manager Start Message Queue Manager Start WebSphere MQ Trigger Monitor Work with Message Queue Managers

DLTMQM DSCMQM DSPMQM DSPMQMSTS ENDMQM STRMQM STRMQMTRM WRKMQM DSPMQMCSVR More...

Command Server Commands 12. Display WebSphere MQ Command Server Selection or Command ===> F3=Exit F4=Prompt F9=Retrieve F12=Cancel ------CMDMQM WebSphere MQ Commands Select one of the following: 13. End WebSphere MQ Command Server 14. Start WebSphere MQ Command Server Queue 15. 16. 17. 18. 19. 20. 21. 22. 23. Commands Change WebSphere MQ Queue Clear WebSphere MQ Queue Copy WebSphere MQ Queue Create WebSphere MQ Queue Delete WebSphere MQ Queue Display WebSphere MQ Queue Work with WebSphere MQ Messages Work with WebSphere MQ Queues Work with WebSphere MQ Queue Status

ENDMQMCSVR STRMQMCSVR CHGMQMQ CLRMQMQ CPYMQMQ CRTMQMQ DLTMQMQ DSPMQMQ WRKMQMMSG WRKMQMQ WRKMQMQSTS More...

Selection or Command ===> F3=Exit F4=Prompt F9=Retrieve F12=Cancel ------CMDMQM WebSphere MQ Commands Select one of the following: Process Commands 24. Change WebSphere MQ Process 25. Copy WebSphere MQ Process 26. Create WebSphere MQ Process 27. Delete WebSphere MQ Process 28. Display WebSphere MQ Process 29. Work with WebSphere MQ Processes Namelist Commands 30. Change WebSphere MQ Namelist 31. Copy WebSphere MQ Namelist 32. Create WebSphere MQ Namelist 33. Delete WebSphere MQ Namelist 34. Display WebSphere MQ Namelist 35. Work with WebSphere MQ Namelists CHGMQMPRC CPYMQMPRC CRTMQMPRC DLTMQMPRC DSPMQMPRC WRKMQMPRC CHGMQMNL CPYMQMNL CRTMQMNL DLTMQMNL DSPMQMNL WRKMQMNL More...

Selection or Command ===> F3=Exit F4=Prompt F9=Retrieve F12=Cancel ------CMDMQM WebSphere MQ Commands Select one of the following: Cluster Commands 36. Refresh WebSphere MQ Cluster 37. Reset WebSphere MQ Cluster 38. Resume WebSphere MQ Cluster Queue Manager 39. Suspend WebSphere MQ Cluster Queue Manager 40. Work with WebSphere MQ Clusters 41. Work with WebSphere MQ Cluster Queues Authority Commands 42. Display WebSphere MQ Object Authority 43. Grant WebSphere MQ Object Authority 44. Revoke WebSphere MQ Object Authority 45. Refresh WebSphere MQ Object Authority 46. Work with WebSphere MQ Authority 47. Work with WebSphere MQ Authority Data Selection or Command ===> F3=Exit F4=Prompt F9=Retrieve F12=Cancel ------CMDMQM WebSphere MQ Commands Select one of the following: Channel Commands 48. Change WebSphere MQ Channel 49. Copy WebSphere MQ Channel 50. Create WebSphere MQ Channel 51. Delete WebSphere MQ Channel 52. Display WebSphere MQ Channel 53. End WebSphere MQ Channel 54. Ping WebSphere MQ Channel 55. Reset WebSphere MQ Channel 56. Resolve WebSphere MQ Channel 57. Start WebSphere MQ Channel 58. Start WebSphere MQ Channel Initiator 59. Work with WebSphere MQ Channels 60. Work with WebSphere MQ Channel Status Selection or Command ===> F3=Exit F4=Prompt F9=Retrieve F12=Cancel ------CMDMQM WebSphere MQ Commands Select one of the following: Listener Commands 61. Change WebSphere MQ Listener Object 62. Copy WebSphere MQ Listener Object 63. Create WebSphere MQ Listener Object CHGMQMLSR CPYMQMLSR CRTMQMLSR CHGMQMCHL CPYMQMCHL CRTMQMCHL DLTMQMCHL DSPMQMCHL ENDMQMCHL PNGMQMCHL RSTMQMCHL RSVMQMCHL STRMQMCHL STRMQMCHLI WRKMQMCHL WRKMQMCHST More... RFRMQMCL RSTMQMCL RSMMQMCLQM SPDMQMCLQM WRKMQMCL WRKMQMCLQ DSPMQMAUT GRTMQMAUT RVKMQMAUT RFRMQMAUT WRKMQMAUT WRKMQMAUTD More...

64. 65. 66. 67. 68.

Delete WebSphere MQ Listener Object Display WebSphere MQ Listener Object Start WebSphere MQ Listener End WebSphere MQ Listener Work with WebSphere MQ Listeners

DLTMQMLSR DSPMQMLSR STRMQMLSR ENDMQMLSR WRKMQMLSR CHGMQMSVC CPYMQMSVC CRTMQMSVC DLTMQMSVC More...

Service Commands 69. Change WebSphere MQ Service 70. Copy WebSphere MQ Service 71. Create WebSphere MQ Service 72. Delete WebSphere MQ Service Selection or Command ===> F3=Exit F4=Prompt F9=Retrieve CMDMQM Select one of the following: Listener Commands 61. Change WebSphere MQ Listener Object 62. Copy WebSphere MQ Listener Object 63. Create WebSphere MQ Listener Object 64. Delete WebSphere MQ Listener Object 65. Display WebSphere MQ Listener Object 66. Start WebSphere MQ Listener 67. End WebSphere MQ Listener 68. Work with WebSphere MQ Listeners Service Commands 69. Change WebSphere MQ Service 70. Copy WebSphere MQ Service 71. Create WebSphere MQ Service 72. Delete WebSphere MQ Service Selection or Command ===> F3=Exit F4=Prompt F9=Retrieve F12=Cancel ------CMDMQM WebSphere MQ Commands Select one of the following: 73. 74. 75. 76. Display WebSphere MQ Service Start WebSphere MQ Service End WebSphere MQ Service Work with WebSphere MQ Services

F12=Cancel

WebSphere MQ Commands

CHGMQMLSR CPYMQMLSR CRTMQMLSR DLTMQMLSR DSPMQMLSR STRMQMLSR ENDMQMLSR WRKMQMLSR CHGMQMSVC CPYMQMSVC CRTMQMSVC DLTMQMSVC More...

DSPMQMSVC STRMQMSVC ENDMQMSVC WRKMQMSVC ENDMQMCONN WRKMQMCONN STRMQMBRK ENDMQMBRK DSPMQMBRK CLRMQMBRK DLTMQMBRK More...

Connection Commands 77. End WebSphere MQ Connection 78. Work with WebSphere MQ Connections Broker Commands 79. Start WebSphere MQ Broker 80. End WebSphere MQ Broker 81. Display WebSphere MQ Broker 82. Clear WebSphere MQ Broker 83. Delete WebSphere MQ Broker

Selection or Command ===> F3=Exit F4=Prompt F9=Retrieve F12=Cancel ------CMDMQM WebSphere MQ Commands Select one of the following: Authentication Information Commands 84. Change WebSphere MQ Authentication Information 85. Copy WebSphere MQ Authentication Information 86. Create WebSphere MQ Authentication Information 87. Delete WebSphere MQ Authentication Information 88. Display WebSphere MQ Authentication Information 89. Work with WebSphere MQ Authentication Information Trace Command 90. Trace WebSphere MQ Name Command 91. Display WebSphere MQ Object Names CHGMQMAUTI CPYMQMAUTI CRTMQMAUTI DLTMQMAUTI DSPMQMAUTI WRKMQMAUTI TRCMQM DSPMQMOBJN More... Selection or Command ===> F3=Exit F4=Prompt F9=Retrieve F12=Cancel ------CMDMQM WebSphere MQ Commands Select one of the following: Media 92. 93. 94. Recovery Commands Record WebSphere MQ Object Image Recreate WebSphere MQ Object Work with WebSphere MQ Transactions RCDMQMIMG RCRMQMOBJ WRKMQMTRN RUNMQSC STRMQMMQSC CVTMQMDTA STRMQMDLQ More... Selection or Command ===> F3=Exit F4=Prompt F9=Retrieve F12=Cancel ------CMDMQM WebSphere MQ Commands Select one of the following: WebSphere MQ Version Details 99. Display WebSphere MQ Version WebSphere MQ Route Information DSPMQMVER

WebSphere MQSC Commands 95. Run WebSphere MQSC Commands 96. Start WebSphere MQSC Commands Data Conversion Exit Command 97. Convert WebSphere MQ Data Type WebSphere MQ Dead-Letter Queue Handler 98. Start WebSphere MQ Dead-Letter Queue Handler

100. Display WebSphere MQ Route Information

DSPMQMRTE

Bottom Selection or Command ===> F3=Exit F4=Prompt F9=Retrieve ------F12=Cancel

# iSeries or AS/400 System Name. You can look this up on your sign-on screen or with the WRKLICINF command. # iSeries or AS/400 Serial Number. You can look this up using the WRKLICINF comm and. # Processor group. You can look this up using the WRKLICINF command. Maximum number of records that can be edited is 32764 in SEU PDM. http://www.rpgnext.com/tutorials.php If you want to know what an SQLCOD value means you can display them by concatena ting the last four digits of the SQLCOD value to 'SQL' and using the DSPMSGD com mand to display the associated message. For example, if SQLCOD = 0000030 the equivalent error message would be SQL0030. DSPMSGD SQL0030 MSGF(QSQLMSG) gives first level text of 'Number of host variables less than result values.' with the option of viewing more information about the error. If SQLCOD > 10000 use 'SQ' instead of 'SQL' for the concatenation. What is the SQL equivalent of CHAIN to see if a single record exists? SELECT 1 FROM QSQPTABL WHERE EXISTS (SELECT * FROM ITEMMASTER WHERE ITEMNUMBER = 8) how can I find or delete a procedure in SQL select * from sysprocs will allow you to locate all the procedures on the system . drop procedure will allow you to delete a procedure. Birgitta Hauser adds the following tip: Because a procedure can be overloaded (you can have several procedures with the same name in the same schema with a different number of parameters), you should either use the specific name of the procedure or list the parameter description in the DROP PROCEDURE statement. 1. DROP SPECIFIC PROCEDURE SpecificName 2. DROP PROCEDURE MyProcedure(Dec(5, 2), Char(10) ...); You can create logical files that point to a particular member or use the SQL CR EATE ALIAS function. Here's an example: CREATE ALIAS mylib/SALESJAN for prodlib/ SALESFIL(JAN). BINARY(4) means a 4-byte binary number. In RPG III, this means a subfield of a data structure that is defined with 4 byt

es, and has the 'B' type. In RPG IV, there are two kinds of 4-byte binary number: the 10-digit integer or the 9-digit binary. The 10-digit integer is better when dealing with APIs. If you define an integer or binary number using length notation (no from-positio n), you give the number of digits. 10I-0 or 9B-0. A very common error is to define a BINARY(4) field or parameter using length not ation as 4B-0. This always causes problems calling the API. The value 21544 cannot be represented in a 2-byte binary field even though it on ly uses bits in the loworder two bytes. A 2-byte binary field can only hold up to 4 digits, and 21544 has 5 d igits. Retrieve current job type RTVJOBA TYPE(&JOBINFO) Submit job if currently interactive IF COND(&JOBINFO = '1') THEN(DO) (job-number/user-name/job-name) RMVMSG PGMQ(*SAME) CLEAR(*ALL) RCVMSG PGMQ(*SAME *) MSGTYPE(*ANY) MSG(&msg) MSGDTA(&msgdta) MSGID(&msgid) RTNTYPE(&rtntyp) MSGF(&msgf) MSGFLIB(&msgflib) How can I send files to the PC from a CL pgm?? Create a profile in client access. Save your profile somewhere on your hard driv e (e.g. c:\). Then create a CL like this: STRPCO PCTA(*YES) MONMSG MSGID(IWS4010) STRPCCMD PCCMD('RTOPCB C:\profile.dft') PAUSE(*YES) You could also send files from your PC to the AS400 by creating a "*.dtt" profil e and use RFROMPCB in place of the RTOPCB. SELECT SUBSTR(CUSTFLAT,4,30), UNPACK(CUSTFLAT,1,3,0) FROM CUSTFLAT ----> CREATE FUNCTION UNPACK(Rcd VarChar(1000), Start Integer, Len Integer, Dec Integer) RETURNS VARCHAR(30) LANGUAGE SQL DETERMINISTIC BEGIN Declare Data Char(30); Declare ULen Integer; Declare Sign Integer; Set Ulen = Len *2-1; Set Data = SUBSTR(HEX(SUBSTR(Rcd,Start,Len)),1,Ulen); Set Sign = CASE WHEN SUBSTR(HEX(SUBSTR(Rcd,Len,1)),2,1) ='F' THEN 1 ELSE -1 END; IF Dec = 0 Then Set Data = Char(Decimal(Data,30,0)*Sign); ELSEIF Dec = 1 Then Set Data = Char(Decimal(Decimal(Data)/10,30,1)*Sign); ELSEIF Dec = 2 Then Set Data = Char(Decimal(Decimal(Data)/100,30,2)*Sign); ELSEIF Dec = 3 Then Set Data = Char(Decimal(Decimal(Data)/1000,30,3)*Sign);

ELSEIF Dec = 4 Then Set Data = Char(Decimal(Decimal(Data)/10000,30,4)*Sign); ELSEIF Dec = 5 Then Set Data = Char(Decimal(Decimal(Data)/100000,30,5)*Sign); ELSE Set Data = Char(Decimal(Decimal(Data)/1000000,30,6)*Sign); END IF; RETURN Data; END select * from TABLE (getcustf()) as CUSTFLAT ----> A Table Function CREATE FUNCTION GETCUSTF () RETURNS TABLE(CUSTNO CHAR(7), CUSTNAM CHAR(30)) LANGUAGE SQL READS SQL DATA NO EXTERNAL ACTION NOT DETERMINISTIC DISALLOW PARALLEL RETURN SELECT UNPACK(CUSTFLAT,1,3,0), SUBSTR(CUSTFLAT,4,30) FROM CUSTFLAT List ILE Program Information (QBNLPGMI) API CRTPF FILE(QTEMP/SPOOLPF) RCDLEN(132) MAXMBRS(*NOMAX) SIZE(*NOMAX) AUT(*ALL) CPYSPLF FILE(&MBR) TOFILE(QTEMP/SPOOLPF) SPLNBR(*LAST) MBROPT(*REPLACE) CHGCMDDFT RUNSQLSTM SRCFILE(MCSD027UTL/MPTOOLSRC) SRCMBR(MPQRY) COMMIT(*NONE) RUNQRY *N QTEMP/FILEPF RUNQRY QRY(MCSD027UTL/RESULT8) * New line constant D C_CRLF C CONST(x'0d25') All source files have three fields: SRCSEQ -The sequence number length: 6,2 SRCDAT -The change date off to the right length: 6,0 SRCDTA -Where the C-specs/D-specs/F-specs reside length: 100 DIndicators DS Based(IndicatorP) D SFLNXTCHG 8 8 DIndicatorP S * Inz(%Addr(*IN)) Data Types in DB2/400A alphanumeric 32766 characters P packed decimal 31 digits, 30 decimal positions S zoned decimal - 31 digits, 30 decimal positions L Long date 4 bytes Z Time stamp 10 bytes T Time 6 bytes F Floating point 1 9 digits in single precision & 1 n H Hexadecimal 32766 bytes

17 digits in double precisio

ADDPFM,DSPPFM,RMVM,CHGPFM,CLRPFM,CHGPF,CRTPF,DLTF-File/Record/Field/KeyField key words ADDPFCST To copy the PF object the command used is CPYF which has got various options for specifying the source and the destination files and also to create/replace the file and its members and also to map/drop the fields. In the IFS, many different file systems can be accessed using a common interface

. WRKLNK,RMVLNK,EDTF,DSPF. Type of STMF. Stream files./QSYS.LIB/qgpl.lib/qrpgles rc.file/proof.mbr. BNDDIR('QC2LE') But, if we use a pointer by value, and we use "options(*string)", the RPG compil er will automatically allow any length string, and will automatically convert it to C's format by adding the terminating "null" character at the end. A job's life To understand the basics of iSeries work management, follow a simple batch job a s it moves through the system. The life of a simple batch job begins when you su bmit it to the system. The job is then sent to a job queue where it waits to ent er a subsystem where it can run. Once the job moves to the subsystem it is alloc ated memory in which to run. When the job is complete, it is sent to a printer o utput queue to await further instruction on what to do (for example, printing). Not every job follows this exact path; however, you can better understand how ot her work is completed on the system by learning more about the topics below: 1. Submit a job On submitting a job to an iSeries server, it (the job) is created and enters the system. At this time, the properties of a job are given to the job. Once the pr operties have been defined, the job moves to the job queue where it waits to ent er the subsystem. Once the job receives its job description and defines its prop erties, it moves to the job queue where it waits to enter the subsystem. The job description holds properties the job will use to go through the work management life-cycle. These properties include the user profile the job will start to run under, the request data (which tells the job what it will do), and the initial user portion of the library list, as well as others. 2. The job enters a job queue Job queues are work entry points for batch jobs to enter the system. They can be thought of as "waiting rooms" for the subsystem. A number of factors affect whe n the job is pulled off the job queue into the subsystem, like job priority on t he job queue, the sequence number of the job queue, and the maximum active jobs. When all of these factors work together, the job will be pulled off the job que ue to start running in the subsystem. 3. The job enters the subsystem When the job enters the subsystem it becomes active. Until a job gets its activi ty level and memory from a memory pool, it cannot run. The job uses several piec es of information before it can receive memory to run. The subsystem description , like the job description, carries information, such as the memory pool to use, the routing entry, the maximum active jobs, and the number of active jobs curre ntly in the subsystem. 4. The memory pool allocates memory to the subsystem Memory is a resource from the memory pool that the subsystem uses to run the job . The amount of memory from a memory pool, as well as how many other jobs are co mpeting for memory affect how efficiently a job runs. Subsystems use different m emory pools to support different types of jobs that run within them. The subsyst em gives the memory pool the information it needs to process the order in which jobs are allocated memory, and the memory pool allocates memory for the job to r un to completion. 5. The job finishes and moves to the output queue\ When a job finishes, the printer output from that job is sent to an output queue where it waits to be sent to a printer device or file. The output queue is like the job queue, in that it controls how the output is made available to the prin t devices. The output queue allows the user to control what files are printed fi rst. The simplest rule is the one that handles decimal literals. All decimal literals will be converted to packed decimal format with a length of (15 5), where the v alue is 15 digits long, of which 5 digits are decimal places. Therefore, any pro gram that you expect to call from the command line, or SBMJOB etc., needs to dec lare it's numeric input parameters as *DEC(15 5).

Character literals are a little bit more complicated, but still fairly straightf orward. There are two rules to remember. The first is that any character literal up to 32 characters in length will be converted to a 32 byte variable. The valu e is left justified, and padded on the right with blanks. The second rule is that character literals longer than 32 bytes are converted to a variable of the same length as the literal value itself, as in the following Things to Remember always match the type/size of parameters on your pgm to pgm calls. remember that the system converts literals to variables in the background. remember that decimal literals are always converted to *DEC(15 5). and that char literals less than or equal to 32 bytes are converted to *CHAR(32) . and that char literals greater than 32 bytes are converted to variables of equiv alent size. and last, but not least: the called program "sees" as much storage as it declares for an input parameter, regardless of whether or not the caller actually allocated that much storage fo r it.

ON_HAND = * * * * Opening Balance (for the fiscal month) plus month-to-date Receipts minus month-to-date Issues plus month-to-date Adjustments

Available Inventory = On hand minus allocations -----BPCS All BPCS programs begin with a module name, like ORD (customer orders) or SFC ( Shop floor control). These are also the menu names. If you type ORD in the men u screen, you'll see ORD programs. You are correct when doing changes in existing programs, You have to modmark whe n commenting a line and adding new line. But this is a new program you can add t he line without any mod mark, regarding old lines you can keep them until testin g after completing all you changes and testing you have to remove them. I asked to keep them only for reference. Otherwise for tasks like this (new Programs)we donot keep commented code in the source When you are working on a client that uses version 8 of BPCS, the commands are d ifferent than using option 14, and these commands will take care of all of the p arameters for you. The commands to use are RPGLE, CRTPRTFILE, and CRTDSPLY. CL' s can still be compiled using option14 and no parms are needed to be changed. On clients who When compiling When compiling Display files: BPCS don't have version 8 of BPCS, the parms to change are: SQLRPG or SQLRPGLE, commitment control *NONE SQLRPGLE or RPGLE, debugging view = *SOURCE. restore display *YES.

ZMM ZMO

Menu Master Menu Options

Changed the exit points through BPCS menu option Product Interface Maintenance SYS635D1 Created/Changed records in ZPA using System Parameters Maintenance SYS100D1 from SYS menu ZPA file System Table Maintenance SYS105D1 from SYS03 menu ZCC file ZMO menu options file Menu Print using F13 and then 10=Menu Print BPCS Entry Key generation = CALL PGM(SYS664) PARM(SYS664) -----MKS Implementer Menu ADDLIBLE MKSIM STRIM Implementation: 1. My Workbench 2. Check Out 3. Create Promotion Request 4. Compile Promotion Requests 5. Move Promotion Requests 6. Move Promotion Requests by System/Environment Other 11. 12. 13. 14. 15. 16. common tasks: Work with Objects Request Inquiry Request Maintenance Manage Concurrent Development Work with Projects Job Log Inquiry

Emergency handling: 21. Emergency Check Out 22. Emergency Create Request 23. Archive Recovery 24. Archive to Tape Reports: 31. Activity 32. Lock 33. Concurrent Development 34. Archive History 35. Request 36. User 37. Environment 38. Object Code Administration: 41. Users 42. Environments 43. Environment Groups 44. Object Codes 45. System Control 46. Network Configuration 47. MKS Integrity Setup

48. MKS Source Setup 49. Implementer Server 50. Function Keys Release Control: 51. Products 52. Release Types 53. Release Status 54. Release Deployment Menu Commands: 81. Check Out command (ICHKOUT) 82. Create Request command (ICRTRQS) 83. Compile Requests command (ICMPRQS) 84. Move Requests command (IMOVRQS) 85. Compare Member (ICMPMBR) 86. Merge Member (IMRGMBR) 87. Workbench Compile (ICOMPILE) 88. Set to Environment Library List (ISETLIBL) --------------BPCS Configurable Enterprise Financials Multi-Mode Manufacturing Supply Chain Management Cross-Product Application Cost Accounting Accounts Payable Processing Accounts Receivable Processing Multiple Currencies Cash Management Fixed Assets Advanced Remittance Processing Credit and Deduction Management Configurable Ledger Trade Funds Management Configurable Enterprise Accounting Cartera Receivable Management Manufacturing Data Management Shop Floor Control Capacity Planning Master Production Scheduling Material Requirements Planning JIT/Repetitive Manufacturing Advanced Process Industries Performance Measurement Quality Laboratory Management Configuration Management Lean Manufacturing Process Electronic Signature MDM SFC CAP MPS MRP JIT API PRF QMS CFG LMP ESG CST ACP ACR MLT CSH FXA ARP CDM CLD TFM CEA CAR CEF MMM SCM XPA

Inventory Management Purchasing Management Order Management Billing Sales Analysis Distribution Resource Planning Forecasting Management Promotions and Deals Warehouse Management Outbound Logistics Management Configuration Management Release Management Inbound Logistics Management System Functions Documentation Electronic Commerce Manager C / C++ / SQLCPP on iSeries. Generate C/C++ Source Create Bound C Program Create Bound C++ Program Create C Module Create C++ Module Create SQL ILE C++ Object Create SQL ILE C object GENCSRC CRTBNDC CRTBNDCPP CRTCMOD CRTCPPMOD CRTSQLCPPI CRTSQLCI

INV PUR ORD BIL SAL DRP FOR PRO WHM OLM CFG RMS ILM

SYS DOC ECM

C CPP C CPP SQLCPP SQLC

Source Headers in QSYSINC/H files http://translate.google.com/translate?u=http://www.as400-net.com/tips/c400/index .html&hl=nl&ie=UTF-8&sl=ja&tl=en (READ THIS, BIG ARTICLE on C/400)

*********************************************************** ** RPGTOOLS ** ** (c) 2000 - The RPG IV Network ** ** ----------------------------------------** ** Program . . . . . . . FKEY_CONST ** ** Description . . . . . Function key named constants ** ** ** ** Features . . . . . . . All attention identification ** ** byte codes for each ** ** function key. ** ** in this include. ** ** ** *********************************************************** D F1 C CONST(X'31') D F2 C CONST(X'32') D F3 C CONST(X'33') D F4 C CONST(X'34') D F5 C CONST(X'35') D F6 C CONST(X'36') D F7 C CONST(X'37') D F8 C CONST(X'38') D F9 C CONST(X'39')

D D D D D D D D D D D D D D D D D D D D D D D

F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 CLEAR ENTER HELP ROLLDN ROLLUP PRINT RCBKSP AUTENT

C C C C C C C C C C C C C C C C C C C C C C C DS 369 369

CONST(X'3A') CONST(X'3B') CONST(X'3C') CONST(X'B1') CONST(X'B2') CONST(X'B3') CONST(X'B4') CONST(X'B5') CONST(X'B6') CONST(X'B7') CONST(X'B8') CONST(X'B9') CONST(X'BA') CONST(X'BB') CONST(X'BC') CONST(X'BD') CONST(X'F1') CONST(X'F3') CONST(X'F4') CONST(X'F5') CONST(X'F6') CONST(X'F8') CONST(X'3F')

D WSDS D functionKey

DMYPSDS SDS D PROC_NAME *PROC * Procedure name D PGM_STATUS *STATUS * Status cod e D PRV_STATUS 16 20S 0 * Previous status D LINE_NUM 21 28 * Src list line num D ROUTINE *ROUTINE * Routine name D PARMS *PARMS * Num passed parms D EXCP_TYPE 4 0 42 * Exception type D EXCP_NUM 43 46 * Exception number D PGM_LIB 81 90 * Prog ram library D EXCP_DATA 91 170 * Exception data D EXCP_ID 171 174 * Exception Id D DATE 191 198 * Date (*DATE fmt) D YEAR 199 200S 0 * Year (*YEAR fmt) D LAST_F ILE 201 208 * Last file used D FILE_INFO 209 243 * File error info D JOB_NAME 24 4 253 * Job name D USER 254 263 * User name D JOB_NUM 264 269S 0 * Job number D JOB_DATE 270 275S 0 * Date (UDATE fmt) D RUN_DATE 276 281S 0 * Run date (UDATE) D RUN_TIME 282 287S 0 * Run time (UDATE) D CRT_DATE 288 293 * Create date D CRT_ TIME 294 299 * Create time D CPL_LEVEL 300 303 * Compiler level D SRC_FILE 304 3 13 * Source file D SRC_LIB 314 323 * Source file lib D SRC_MBR 324 333 * Source file mbr D PROC_PGM 334 343 * Pgm Proc is in D PROC_MOD 344 353 * Mod Proc is in -----Table 23. Contents of the Program Status Data Structure From (Pos. 26-32) To (Pos. 33-39)

Format Length Keyword Information 1 10 Character 10 *PROC Name of the main procedure, if there is one; otherwise, the name associated with the main source section. 11 15 Zoned decimal 5,0 *STATUS Status code. For a description of these codes, s ee Program Status Codes. 16 20 Zoned decimal 5,0 Previous status code. 21 28 Character 8 RPG IV source listing line number or statement number. The so urce listing line number is replaced by the source listing statement number if O PTION(*SRCSTMT) is specified instead of OPTION(*NOSRCSTMT). The full statement n umber is included when it applies to the root source member. If the statement nu mber is greater than 6 digits (that is, it includes a source ID other than zero) , the first 2 positions of the 8-byte feedback area will have a "+ " indicating that the rest of statement number is stored in positions 354-355. 29 36 Character 8 *ROUTINE Name of the RPG IV routine in which the exception or error occurred. This subfield is updated at the beginning of an RPG IV routine o r after a program call only when the *STATUS subfield is updated with a nonzero value. The following names identify the routines: *INIT Program initialization *DETL Detail lines *GETIN Get input record *TOTC Total calculations *TOTL Total lines *DETC Detail calculations *OFL Overflow lines *TERM Program ending *ROUTINE Name of program or procedure called (first 8 characters). Note: *ROUTINE is not valid unless you use the normal RPG IV cycle. Logic that takes t he program out of the normal RPG IV cycle may cause *ROUTINE to reflect an incor rect value. 37 39 Zoned decimal 3,0 *PARMS Number of parameters passed to this program from a calling program. The value is the same as that returned by %PARMS. If no infor mation is available, -1 is returned. 40 42 Character 3 Exception type (CPF for an operating system exception or MCH for a machine exception). 43 46 Character 4 Exception number. For a CPF exception, this field contains a CPF message number. For a machine exception, it contains a machine exception num ber. 47 50 Character 4 Reserved 51 80 Character 30 Work area for messages. This area is only meant for internal use by the ILE RPG compiler. The organization of information will not always be

consistent. It can be displayed by the user. 81 90 Character 10 Name of library in which the program is located. 91 170 Character 80 Retrieved exception data. CPF messages are placed in this s ubfield when location *STATUS contains 09999. 171 174 Character 4 Identification of the exception that caused RNX9001 excepti on to be signaled. 175 184 Character 10 Name of file on which the last file operation occurred (up dated only when an error occurs). This information always contains the full file name. 185 190 Character 6 Unused. 191 198 Character 8 Date (*DATE format) the job entered the system. In the case of batch jobs submitted for overnight processing, those that run after midnight will carry the next day's date. This value is derived from the job date, with t he year expanded to the full four years. The date represented by this value is t he same date represented by positions 270 - 275. 199 200 Zoned decimal 2,0 First 2 digits of a 4-digit year. The same as the fir st 2 digits of *YEAR. This field applies to the century part of the date in posi tions 270 to 275. For example, for the date 1999-06-27, UDATE would be 990627, a nd this century field would be 19. The value in this field in conjunction with t he value in positions 270 - 275 has the combined information of the value in pos itions 191 -198. Note: This century field does not apply to the dates in positions 276 to 281, or posit ions 288 to 293. 201 208 Character 8 Name of file on which the last file operation occurred (upd ated only when an error occurs). This file name will be truncated if a long file name is used. See positions 175-184 for long file name information. 209 243 Character 35 Status information on the last file used. This information includes the status code, the RPG IV opcode, the RPG IV routine name, the sourc e listing line number or statement number, and record name. It is updated only w hen an error occurs. Note: The opcode name is in the same form as *OPCODE in the INFDS The source listing line number is replaced by the source listing statement numbe r if OPTION(*SRCSTMT) is specified instead of OPTION(*NOSRCSTMT). The full state ment number is included when it applies to the root source member. If the statem ent number is greater than 6 digits (that is, it includes a source ID other than zero), the first 2 positions of the 8-byte feedback area will have a "+ " indic ating that the rest of statement number is stored in positions 356-357. 244 253 Character 10 Job name. 254 263 Character 10 User name from the user profile. 264 269 Zoned decimal 6,0 Job number. 270 275 Zoned decimal 6,0 Date (in UDATE format) the program started running in the system (UDATE is derived from this date). See User Date Special Words for a description of UDATE. This is commonly known as the 'job date'. The date repres ented by this value is the same date represented by positions 191 - 198. 276 281 Zoned decimal 6,0 Date of program running (the system date in UDATE for mat). If the year part of this value is between 40 and 99, the date is between 1 940 and 1999. Otherwise the date is between 2000 and 2039. The 'century' value i n positions 199 - 200 does not apply to this field. 282 287 Zoned decimal 6,0 Time (in the format hhmmss) of the program running. 288 293 Character 6 Date (in UDATE format) the program was compiled. If the yea r part of this value is between 40 and 99, the date is between 1940 and 1999. Ot herwise the date is between 2000 and 2039. The 'century' value in positions 199 - 200 does not apply to this field. 294 299 Character 6 Time (in the format hhmmss) the program was compiled. 300 303 Character 4 Level of the compiler. 304 313 Character 10 Source file name. 314 323 Character 10 Source library name. 324 333 Character 10 Source file member name.

334 344 354 356 . 358 368 372 380

343 353 355 357 367 371 379 429

Character Character Binary 2 Binary 2

10 Program containing procedure. 10 Module containing procedure. Source Id matching the statement number from positions 21-28. Source Id matching the statement number from positions 228-235 Current user profile name. External error code XML elements set by operation Unused.

Character 10 Integer 10,0 Integer 20,0 Character 50

COLOR HEX CODES D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D White C CONST( X'22' ) White_UL C CONST( X'26' ) White_RI C CONST( X'23' ) White_RI_CS C CONST( X'33' ) PR_White C CONST( X'A2' ) PR_White_UL C CONST( X'A6' ) PR_White_RI C CONST( X'A3' ) PR_White_RI_CS C CONST( X'B3' ) Green C CONST( X'20' ) Green_RI C CONST( X'21' ) Green_UL C CONST( X'24' ) Green_UL_RI C CONST( X'25' ) PR_Green C CONST( X'A0' ) PR_Green_RI C CONST( X'A1' ) PR_Green_UL C CONST( X'A4' ) PR_Green_UL_RI C CONST( X'A5' ) Red C CONST( X'28' ) Red_RI C CONST( X'29' ) Red_HI C CONST( X'2A' ) Red_HI_RI C CONST( X'2B' ) Red_UL C CONST( X'2C' ) Red_UL_RI C CONST( X'2D' ) Red_UL_BL C CONST( X'2E' ) PR_Red C CONST( X'A8' ) PR_Red_RI C CONST( X'A9' ) PR_Red_HI C CONST( X'AA' ) PR_Red_HI_RI C CONST( X'AB' ) PR_Red_UL C CONST( X'AC' ) PR_Red_UL_RI C CONST( X'AD' ) PR_Red_UL_BL C CONST( X'AE' ) Turq_CS C CONST( X'30' ) Turq_CS_RI C CONST( X'31' ) Turq_UL_CS C CONST( X'34' ) Turq_UL_RI_CS C CONST( X'35' ) PR_Turq_CS C CONST( X'B0' ) PR_Turq_CS_RI C CONST( X'B1' ) PR_Turq_CS_UL C CONST( X'B4' ) PR_Turq_CSULRI C CONST( X'B5' ) Yellow_CS C CONST( X'32' ) Yellow_CS_UL C CONST( X'36' ) PR_Yellow_CS C CONST( X'B2' ) PR_Yellow_CSUL C CONST( X'B6' ) Pink C CONST( X'38' ) Pink_RI C CONST( X'39' ) Pink_UL C CONST( X'3C' ) Pink_UL_RI C CONST( X'3D' ) PR_Pink C CONST( X'B8' ) PR_Pink_RI C CONST( X'B9' )

D D D D D D D D

PR_Pink_UL C CONST( X'BC' ) PR_Pink_UL_RI C CONST( X'BD' ) Blue C CONST( X'3A' ) Blue_RI C CONST( X'3B' ) Blue_UL C CONST( X'3E' ) PR_Blue C CONST( X'BA' ) PR_Blue_RI C CONST( X'BB' ) PR_Blue_UL C CONST( X'BE' )

Você também pode gostar