Library
& Object Concepts:
Overview:
This module
enables the student to understand the concept of Library & File object to
store programming source.
Outline:
Topics covered,
· Library creation
- Library list
- Parts of Library List
- Source Physical files.
Objective:
By the end of this module,
the student should be able to:
- Create a Library
- Understand the concept of Library
List.
- Understand the part of
Library List.
- Commands related to Library.
- Create the source Physical
files.
Library:
Definition:
An AS/400 object
used to group objects within it.
Usage:
Library object
helps to group various AS/400 objects. Any object is created with reference to
a Library object. Library helps to run AS/400 commands like SAVOBJ, RSTOBJ to
run on group of objects referred to a library. Assigning rights at Library
object can manage user authorization to objects.
Types/Values:
PROD - This
library is containing programs and related data needed for license program that
are installed on your system. The product library part is changed by the system
as users runs commands or menus to include the library where the library code
is used.
TEST - This is a test library. All objects
in a test library can be updated during testing, even if special protection is
requested for production libraries.
System supplied libraries:
QSYS - This library is containing objects such as
user profiles that are used by the system. This part is defined by the system
values QSYSLIBL and is usually the same for all jobs. For a specific job
however a library can be added or removed from the system part by entering the
change system library list (CHGSYSLIBL) commands from within the job. The list
can contain as many as 15 names.
QGPL - It
is General Purpose Library. It is similar to root directory in PC. By default
the system will create the file in QGPL.
QTEMP - It is system library. Every job has
its own QTEMP library. The library gets cleared and deleted when a new job
starts. QTEMP library cannot be renamed or deleted.
Notes:
Library objects cannot
be nested.
Library
List:
Definition:
Library list stores the
names of libraries, which will be searched by system for a object.
Usage:
Search Object:
It defines the order of
libraries that the operating system uses to find objects. (similar to the
"path" on PC's.)
When you execute a
command or call a program, the AS/400 must know where to find the command or
program. Sometimes, you specify the library explicitly.
But if you don't, the AS/400 will find your command or program by looking in each
library in your library list. It will use the first one that it finds.
Testing:
This is very handy for
testing. If you are testing a version of a program, you can put it in a test
library, which is at
the top of your library list. Then, whenever you specify a program or refer to
a file, the system will use any object it can find in the test library. If it
can't find it there, it will look further through your library list until it
finds it.
So, setting up a test
environment is as simple as:
1) Create a test library.
2) Put objects that you want to test in the library. These can be files,
menus, programs or any AS/400 object.
3) Insert the test library name in your library list before your
production libraries.
Now you can execute test
programs and modify test data. The best part is that you don't need to copy
production programs or files into the test library unless they will be affected
by the test. That is, all those supporting database files that you need to run
a program, but that are used for input only, do not need to be copied to the
test library. Of course, if you are unsure if a file will be modified during
your test procedure, copy it to the test library anyway.
Once you have inserted the
test library name in your library list, you will want to make sure everything
is in the proper order. Use the DSPLIBL command to see your library list. You
will probably see three types of list entries:
1) The SYS libraries have operating system objects. This is where the
AS/400 commands and menus live.
2) The CUR library is your current library. This is your first user
library and is where objects are created if you don't specify which library to
use.
3) The USR libraries list your other user
libraries.
Use EDTLIBL to change your
user libraries. You can rearrange the list, remove libraries or add libraries.
Notice that you can't see the SYS or CUR libraries when you use EDTLIBL. The only way to change the current library is with the
CHGCURLIB command.
Command
related to library:
Command
|
Description
|
Usage
|
CRTLIB
|
Create
Library
|
Create new library object
|
DLTLIB
|
Delete
library
|
Delete
a library object
|
CLRLIB
|
Clear
library
|
Delete
all objects in a library
|
DSPLIB
|
Display Library
|
Displays
contain of a library
|
EDTLIBL
|
Edit
library list
|
Define
list of libraries for object search. (Only user libraries can be defined by
user)
|
DSPLIBL
|
Display
library list
|
Show
list and sequence of libraries used for object search. This includes system
libraries and current library
|
ADDLIBLE
|
Add
library list entry
|
Add
one library-to-library list. User can define in which position in search
sequence the library should be added.
|
RMVLIBLE
|
Remove
library list entry
|
Specifies
the name of the library that is remove from the user portion of the library
list.
|
CHGLIBL
|
Change
library list
|
Changes
the user portion of the current job’s library list with the list of libraries
specified by the user. This command does not affect the system of the library
list, nor does it affect any other job’s library list.
|
Lab Tasks:
1.
Create 3 libraries as following
a.
PB01U01S - Program source library for student PB01U01
b.
PB01U01O -
Program/Screen/Printer Object library for student PB01U01
c.
PB01U01D - Data object library for student PB01U01
2.
Define the above libraries in
library list
3.
Display library list
4.
Add one library to library list
using command ADDLIBLE
Follow steps to complete the tasks:
1.
Create Library
a.
At command line type CRTLIB
b.
Press F4
c.
Type Library name (e.g.
PB01U01O)
d.
Type Text description (e.g.
‘Program Source Library for user PB01U01’ or User name). Its in single cote
only.
e.
Press Enter
f.
Repeat steps for creating
libraries PB01U01D.
MAIN OS/400 Main
Menu
System: S653278B
Select one of the following:
1. User tasks
2. Office tasks
4. Files, libraries, and folders
6. Communications
8. Problem handling
9. Display a menu
10. Information Assistant options
11. Client Access/400 tasks
90. Sign off
Selection or command
===> CRTLIB
F3=Exit
F4=Prompt F9=Retrieve F12=Cancel F13=Information Assistant
F23=Set initial menu
Create Library
(CRTLIB)
Type choices, press Enter.
Library
. . . . . . . . . . . . PB01U01O
Name
Library type . . . . . . . . . . *PROD
*PROD, *TEST
ASP number . . . . . . . . . . . 1
1-32, *ASPDEV
ASP device . . . . . . . . . . . *ASP
Name, *ASP, *ASPGRPPRI...
Text 'description' . . . . . . . 'Program Source Library for User
PB01U01’
F3=Exit F4=Prompt
F9=Retrieve F12=Cancel F13=Information Assistant
PRESS ENTER TO CREATE THIS
LIBRARY. USING ABOVE COMMAND CREATE ANOTHET LIBRARY ‘PB01U01D’
Define library list
a.
Type command EDTLIBL at command line
b.
Press F4 or Enter
c.
Type names of your libraries as per
the screen below
d.
Press Enter
Above process gives you
following screen- WHERE you are able to add your screen in Library list.
Edit Library
List
System: S653278B
Type new/changed information, press
Enter.
Sequence Sequence Sequence
Number
Library Number Library Number Library
0 150 300
10
QGPL 160 310
20
QTEMP 170 320
30
PB01U01S 180 330
40
PB01U01D 190 340
50 200 350
60 210 360
70 220 370
80 230 380
90 240 390
100 250 400
110 260 410
120 270 420
130 280 430
140 290 440
More...
F3=Exit
F5=Refresh F12=Cancel
2.
Display library list
a.
Type command DSPLIBL and press Enter
Display Library
List
System: S653278B
Type options, press Enter.
5=Display objects in library
ASP
Opt
Library Type Device Text
QSYS SYS System Library
QSYS2 SYS System Library for
CPI's
QHLPSYS SYS
QUSRSYS SYS System Library for
Users
QPDA PRD
SHEET CUR
QGPL USR General Purpose Library
QTEMP USR
SHEET USR
Bottom
F3=Exit
F12=Cancel F17=Top F18=Bottom
(C) COPYRIGHT IBM CORP. 1980, 2002.
Notes: Observe QSYS, QGPL and QTEMP included in
library list by default. You can remove or change position for QTEMP, QGPL.
3.
Add one library to library
list using command ADDLIBLE
a.
At command line type ADDLIBLE
b.
Press F4
c.
Type library name PB01U01D
d.
Enter position *LAST
e.
Press Enter
Add Library List Entry
(ADDLIBLE)
Type choices, press Enter.
Library
. . . . . . . . . . . .
Name
Library list position:
List position . . . . . . . . *FIRST
*FIRST, *LAST, *AFTER...
Reference library . . . . . . Name
Bottom
F3=Exit
F4=Prompt F5=Refresh F12=Cancel
F13=How to use this display
F24=More keys
To add libraries in library
list add name of libraries which makes add your library in library list.
Source
physical File:
In AS/400 source for
RPG/CL/COBOL programs, PF/LF structures are stored in a object having type
File. This file will have attribute as “PF-SRC”. The object is called as Source
Physical File.
When AS/400 is shipped from
the factory it has few Source Physical File in library QGPL (General Purpose
Library). The few of these Source files are, QDDSSRC, QRPGSRC, QCLPSRC (this is
not a complete list) in which the characters DDS, RPG, CLP denotes Data
Definition Source, RPG program Source, CL program source respectively.
Programmer can use the
factory shipped Source Physical files for storing the program, PF/LF sources.
But this is not a recommended method. Sources should be stored in different
Files as per the Project. This gives better manageability of the source.
LAB
Session:
1.
Create source physical file
MYCLP in library PB01U01S for storing “CL program Source”
2.
Create source physical file
MYRPG in library PB01U01S for storing “RPG program Source”
3.
Create source physical file
MYDDS in library PB01U01D for storing “PF/LF program Source”
4.
Create source physical file
MYSCR in library PB01U01O for storing “Display screen program Source”
5.
Create source physical file
MYPRT in library PB01U01O for storing “Printer file program Source”
6.
Create source physical file
MYRPGLE in library PB01U01S for storing “RPG ILE program Source”
Steps:
1.
Type command “CRTSRCPF” at
command line and press Enter
MAIN OS/400 Main
Menu
System: S653278B
Select one of the following:
1. User tasks
2. Office tasks
3. General system tasks
4. Files, libraries, and folders
5. Programming
6. Communications
7. Define or change the system
8. Problem handling
9. Display a menu
10. Information Assistant options
11. Client Access/400 tasks
90. Sign off
Selection or command
===> CRTSRCPF
F3=Exit
F4=Prompt F9=Retrieve F12=Cancel
F13=Information Assistant
F23=Set initial menu

2.
Type File Name, library
Name and File description as shown and press Enter
Create Source Physical
File (CRTSRCPF)
Type choices, press Enter.

Library
. . . . . . . . . . .
PB01U01D Name, *CURLIB

Member, if desired . . . . . . . *NONE
Name, *NONE, *FILE
Text 'description' . . . . . . . *BLANK
Bottom
F3=Exit
F4=Prompt F5=Refresh F10=Additional parameters F12=Cancel
F13=How to use this display F24=More keys
NOTE : The record length is
92. The source sequence number contains 6 bytes, the date contains 6
bytes, and the source statement contains
80 bytes.
MAIN OS/400 Main
Menu
System: S653278B
Select one of the following:
1. User tasks
2. Office tasks
3. General system tasks
4. Files, libraries, and folders
5. Programming
6. Communications
7. Define or change the system
8. Problem handling
9. Display a menu
10. Information Assistant options
11. Client Access/400 tasks
90. Sign off
Selection or command
===>
F3=Exit
F4=Prompt F9=Retrieve F12=Cancel
F13=Information Assistant
F23=Set initial menu


You will receive the
message as displayed above after creating of a MYDDS source physical file.
1.
Repeat the steps for other
libraries.
After successful creation
of your libraries and source physical file you have to work with following
command to work with members.
MAIN OS/400 Main
Menu
System: S653278B
Select one of the following:
1. User tasks
2. Office tasks
3. General system tasks
4. Files, libraries, and folders
5. Programming
6. Communications
7. Define or change the system
8. Problem handling
9. Display a menu
10. Information Assistant options
11. Client Access/400 tasks
90. Sign off
Selection or command
===> strpdm
F3=Exit
F4=Prompt F9=Retrieve F12=Cancel
F13=Information Assistant
F23=Set initial menu
STRPDM : START PROGRAM DATA MANAGER, which
displays following screen.
AS/400 Programming
Development Manager (PDM)
Select one of the following:
1. Work with libraries
2. Work with objects
3. Work with members
9. Work with user-defined options
|

Selection or command
===> 3
F3=Exit
F4=Prompt F9=Retrieve F10=Command entry
F12=Cancel
F18=Change defaults
(C)
COPYRIGHT IBM CORP. 1981, 2002.
Press ENTER
Specify Members to Work
With
Type choices, press Enter.
File
. . . . . . . . . . MYDDS Name, F4 for list
Library . . . . . . . . PB01U01D
*LIBL, *CURLIB, name
Member:
Name
. . . . . . . . . *ALL *ALL, name, *generic*
Type
. . . . . . . . . *ALL *ALL, type, *generic*, *BLANK
F3=Exit
F4=Prompt F5=Refresh F12=Cancel
Press enter which gives you
following screen
Work with Members
Using PDM S653278B
File .
. . . . . MYDDS
Library . . . . PB01U01D Position to . . . . .
Type options, press Enter.
2=Edit
3=Copy 4=Delete 5=Display 6=Print 7=Rename
8=Display description 9=Save
13=Change text 14=Compile 15=Create module...
Opt
Member Type Text
(No members in file)
Parameters or command
===>
F3=Exit F4=Prompt F5=Refresh F6=Create
F9=Retrieve F10=Command entry F23=More options F24=More keys
Now you have to start
creation of member. Its in next session. Press ‘F3’ to exit.
Questions
on above session:
·
Using the command CRTLIB, create a Library TEST suffixed by your
user name.
·
Check whether your library has been created using following commands:
WRKLIB or DSPLIB. Add the created library to the library list using
commands ADDLIBLE or EDTLIBL
·
Check your current library using DSPLIB and DSPLIBL.
·
Display libraries of all the users using command DSPLIB with *ALL as
the value for the parameter LIB.
·
Using the command CHGCURLIB change your current library to library
which you have created and check whether it has been changed by using the
command DSPLIBL.
·
Try WRKSPLF and WRKUSRJOB commands.
·
Print all the libraries in your library list to a spooled file using
the command DSPLIBL OUTPUT (*PRINT) and view the spool file.
·
Display all the commands starting with ‘CRT’ by using the command
SLTCMD CMD (CRT*).
·
Using the command DLTLIB, delete the library, which you have created
above.
No comments:
Post a Comment