Skip to main content

Posts

Showing posts from 2015

Working with IBM i Exit Programs

What is an Exit Program? An Exit program is a named unit of programming code that is executed when a particular condition occurs, such as one that requires some screening for authorization. This may be part of an operating system or part of an application program. In IBM i OS, an exit program is a supplemental security measure that controls user access to applications, and prevents access outside of authorized applications. An AS/400 exit program (so called because the system exits to the program in the middle of a request from the user) is not used - as might be expected - to exit from a program, but to process user requests: it monitors user activity, checks to see if user requests comply with installation rules, and rejects those requests that contravene those rules. How to Register Exit Programs? To register an exit program with the registration facility, use the Work with Registration Information (WRKREGINF) command. In addition to registering an exit program, it is necessary to r

Data Structures

Date Structures: Data Structure in general means ‘Structure of Different Data Types’. The ILE RPG compiler allows you to define an area in storage and the layout of the fields, called subfields, within the area. Data Structure can be defined by specifying DS in positions 24 through 25 on a definition specification. Uses of Data Structure:     Define the same internal area multiple times using different data formats     Define a data structure and its sub fields in the same way a record is defined.     Define multiple occurrences of a set of data.     Group non-contiguous data into contiguous internal storage locations.     Operate on all the sub fields as a group using the name of the data structure.     Operate on an individual sub field using its name. Special Data Structures: A data area data structure (identified by a U in position 23 of the definition specification) A file information data structure (identified by the keyword INFDS on a file description specification) A program-st

Date Formats in IBM i

Format name Date-format parameter Date format and separator Field length Example Job default *JOB Month/Day/Year *MDY mm/dd/yy 8 06/21/90 Day/Month/Year *DMY dd/mm/yy 8 21/06/90 Year/Month/Day *YMD yy/mm/dd 8 90/06/21 Julian *JUL yy/ddd 6 90/172 International Standards Organization *ISO yyyy-mm-dd 10 1990-06-21 IBM ® USA Standard * USA mm/dd/yyyy 10 06/21/1990 IBM European Standard *EUR dd.mm.yyyy 10 21.06.1990 Japanese Industrial Standard Christian Era *JIS yyyy-mm-dd 10 1990-06-21

What is Subsystem?

What is Subsystem? Subsystem is an operating environment, defined by subsystem description, where the system coordinates processing and resources. These can be used to control how different jobs run on your system and how much resources are allocated to different jobs. Here are simple examples on how subsystem can be used. E.g.1: For instance – in a mostly interactive environment you may want all your batch jobs to run in a batch subsystem which has 25% of your systems memory allocated to it, while your interactive jobs run in a subsystem which has 75% of your systems memory allocated to it. In a mostly batch processing environment you may want more memory allocated to your batch jobs and less for your interactive. E.g.2: If you have several customers that use your AS/400 with different agreements on how many users can access the system – you can allocate subsystems based on device IDs and you can use different subsystems to limit the number of active jobs per subsystem. So if all cust

Debug Batch Job

When you are working with Production Support, You will get a scenario where you would need to debug a job for analyzing unforeseen errors. Here are few simple steps for debugging a Batch Job. 1. Service the Specific Job by using STRSRVJOB Command. STRSRVJOB JOB(<Job Number>/<Job User>/<Job Name>) 2. If the Batch Job is currently running, You can check the Call Stack to see what program is currently running. WRKJOB JOB(000000/JOBUSER/JOBNAM) Option – 11 to See Call Stack. 3. Start the Debug of the program that is currently running. STRDBG PGM(TESTLIB/TESTPGM) UPDPROD(*YES) Job will change to debug mode and will show the source in debug whatever the step that is currently being executed. If you are submitting a new job and would like to debug it. Below are the steps. 1. Submit the job with HOLD(*YES) parameter on SBMJOB Command. Or, you could consider HLDJOBQ <JOBQNAME> and Submit the Job. 2. Retrieve the Job Details and Service the Specific Job by using STRSRVJO

Logical File vs OPNQRYF

1. The main difference between Logical file and OPNQRYF is that, Logical file is a permanent object and OPNQRYF is not. Therefore a logical file almost always (depending on your AS400 setup) will have usable access path to sort the records. i.e. access path will be permanent for a logical file. 2. An OPNQRYF will always need to determine what access path to use based on the sort order and filtering set in the command call. If an access plan exists that it can use it will, otherwise it will copy the data and do what is called a table scan to find the records. 3. QRYSLY keyword can be used on OPNQRYF command to setup Record Selection process. Key fields can be mentioned on a File using KEYFLD keyword. 4. Since a LF is a permanent object it will incur permanent storage needs which will also affect overall system performance. 5. If you are always going the same sort order and sequence again and again, then a LF is the best way to go, because it will be almost a readily available access pat

Service Program, Binder Source & Binding Directory

Service Program: A service program (object type *SRVPGM) is a set of procedures that can be bound into ILE RPG programs. Basically when the service program is referenced any of its procedures might then be called. These callable procedures that are defined to the service program are referred to as exports which can be any ILE module, program, or even other service programs. Service programs do not have a program entry procedure and therefore are non-callable. When bound the service program code is only referenced by linkages. That is, unlike other bound programs, the service program exports are not directly copied into the compiled program. The benefit of using a service program is easier maintenance, consistent performance, and more efficient processing. As you know many software packages will have some global APIs. A date manipulation/validation API is a prime example of when a service program, full of date validation and conversion sub procedures, could be used. Other common example

Journals & Retrieve Data from Journals

Journaling on IBM i: On IBM i, Journaling means process of recording an object's activity. When it comes to journaling of Physical file, It records Open/Close/Write/Update/Delete Operations on Physical file. How to Start Journaling: 1.      Use the Create Journal Receiver (CRTJRNRCV) command to create a journal receiver. The journal receiver is where the journal entries are actually recorded. The journal "connects" the receiver to the file. Also, you should put journal receivers in the same library as the file. 2.      Create a journal. Use the Create Journal (CRTJRN) command to create a journal and specify the receiver created in step 1. Although you can journal multiple files to the same journal, you will generally want to have a journal "serving" a single file. 3.      Start journaling the file. This is done by using the Start Journal Physical File (STRJRNPF) command. This is how you associate a file to a journal. Once the association i

Advantage of Using Sub-Procedures over Sub-routines in RPGLE

Need for Sub-Procedures or Sub-Routines: The main advantage of using subroutines is intellectual manageability. That is, I can think of a program as a group of related small tasks, all of which are simple enough for me to understand, rather than as one gargantuan task that is more than I can handle. This gives ease in modifying/bug fixing of a program. Debugging seems to be easier because I can often determine which subroutine most likely contains an error. Finding a logic error in a program of sub-procedures/sub-routines is easier when compared against the program which has complete logic in single routine. Sub-Procedures/Sub-Routines also promotes the re-usability of code. Limitations of Sub-Routines: 1.     Sub-Routines use global variables only. That is, any variable or constant or indicator that I use in a subroutine may be used anywhere else in the program--in the main calculations, in any subroutine, in output specs. This can lead to undesirable side effects. Changi

Track the Submitted Job Details

If you are using CL Program to Submit the Jobs, You can be able to Track the Details by using RCVMSG Command. RCVMSG: The Receive Message (RCVMSG) command is used by a program to receive a message previously sent to a message queue. The RCVMSG command receives messages from a job message queue (a message queue associated with a call stack entry or the external message queue (*EXT)), or from a named message queue. The program can receive a message from a message queue associated with its own call stack entry or from a message queue associated with another call stack entry. This command copies a message received in the specified message queue into control language (CL) variables within the program. You can specify the message being received by indicating the message type, the reference key of the message, or both. The program receiving the message can also specify, on the RCVMSG command, whether a message is removed from the message queue or left there as an old message. If t

Load All Subfile

Subfile: Subfile is one of the most used concept in IBM i. There are three different types of Subfiles. Load All Sub File Expandable Sub File ( Click Here to see more about Expandable Subfile with an Example) Single Page Subfile Message Subfiles are used to display the messages on the screen. Click Here to see more about Message Subfiles. We will see about Load All Subfile in this post. Click Here for Full Free Format RPGLE code for this example.  Load All Subfile: In Load-All subfile all the records are written to the subfile buffer at once and then the data in the subfile loaded from the buffer.   In this case SFLSIZ should be at-least 1 greater than the SFLPAG.   If we are writing more records in the subfile buffer than the SFLSIZ declared and SFLSIZ<9999, then the SFLSIZ is extended to accommodate all records till the size of 9999. 9999 is the buffer limit.   In this case PAGEUP AND PAGEDOWN is taken care by system. SFLPAG should be less than SFLSIZ.