AS400Query Manual

You might also like

You are on page 1of 27

Using AS/400 Query

In This Unit
Agenda Overview
Designing the Query Creating the Query

File Selection
Specifying How to Join Files

Selecting and Sequencing Fields


Selecting Records

Defining Results Fields


Creating Blank Columns within the Query Selecting Report Summary Functions Formatting Report Breaks

Exiting, Saving, and Running the Query Running Saved Queries Special Tips for Using Queries
RUNQRY Command Creating a Library for Your Queries
CRTLIB Command

Finding a File While in a Program


Using SysRq 3

Using AS1400 Query AS1400 Query Training

Objective - to gain the ability to use Query/400 based on single or multiple files Getting into Query - Go Query - Wqry - Query/400 the Query Selecting the files Selecting the sequencing fields Selecting the records Defining the results fields

in order to generate

customized

reports

Creating -

Formatting the Report - Column formatting - Summary functions - Report breaks End Results - Output type and form Exiting the Query - Saving the definition - Saving the data

pecial Tips - Runqry - Crtlib creating a library for your queries - Finding the file while in a program

Using AS/480 Query

Query/400 will allow the user to extract information from a database file or files on the AS1400 and generate reports, screen displays, or new database files. Query/400 for the most part is a very simple program to use. Programming skills are not needed and once users have gained some experience with Query/400 it will take very little time to create a new query. This class will start with designing of the query and flow through to the end product. we will design reports with the use of one file as well as multiple files. The following is a step by step procedure of creating a query;

Designing the Query. the first step in designing a query is to actually decide information is needed on the report. Once that has been decided, the database files that hold that information will then have to be identified. the process of identifying the correct files will probably be the most difficult part of the entire query. MBS has provided for you a listing of all Text-Aid and Merchandise files in this manual. Additionally, the final section of this manual includes some special tips which can help in identifying the files you need to use. The support staff will also be available to help in finding the correct database files. After the files have been identified the query is now ready to be built. Creating the Query. The next major step to building the query is to define it or actually create it. To get to the query menu type either go query or strqry on a command line and press enter. the following screen will display:
QUERY Select one of the following: Query Utilities System: S1014B5R

Query/400 1. Work with queries 2. Run an existing 3. Delete a query DB2/400 IO. Query 20. 21. 22. 23. Selection v-e> me-

query

Start

DB2/400

Query

Manager

management Work with query management Work with query management Start a query Analyze a Query/400 definition or command

forms queries

More...

F3=Exit F4=Prompt F9=Retrieve Fl6=AS/400 Main menu (C> COPYRIGHT IBM CORP. 1980,

FlZ=Cancel 1997.

Fl3=Information

Assistant

Page 1 - 2

Using AS/400
The option you will be using in this class is option I- Work with Queries. number 1 has been selected the following screen will display:
Work Type choices, press Enter. l=Create, 2=Change, 3=Copy, S=Display, &Print definition 8=Run in batch, 9=Run Name, F4 for list Name, *LIBL, F4 for list 4=Delete with Queries

Query

When option

Option

. . . . . .

Query . . . . . . . Library . . . . .

QGPL

F3=Exit

F4=Prompt

FS=Refresh

F12=Cancel

After selecting any of these options, your cursor will move to the Query field where you can enter the name and library for the query you will be working with. AS shown on the screen, there are several options that can be selected. The following is a list of all the valid options: Option I = Create - This will allow the creation of a new query. Give the query a unique name, using up to 10 characters. Next, key in the library that the query should reside in and then press enter to create. You may create libraries on your system to hold your queries. Refer to the Special Tips section at the back of this manual. Option 2 = Change - After a query has been created a user can recall the query by placing a2 on the option line, keying in the query name and library and pressing enter. If the user cannot remember the query name, out the cursor on the query line and press F4 for a list of all existing queries in that library. Option 3 = Copy - Allows an existing query to be copied to a new query. If there is a need for several queries that are similar but have one or two differences this option will serve that purpose well. Only on query will have to be created and then the cop option can be used to create the remaining queries. Simple edits can be made to give you the desired end results.

Page 1 - 3

Using

AS/400

Query

Option 4 = Delete - Purges the query from the system. If there is not a need for an existing query, it can be deleted by selecting option number 4. Option query. 5 = Display - This will display the query but will not allow any changes to the

Option 6 = Print Definition - Without running the query, this option wil print the definition of the query selected. In other words, it will list the files you have selected, the fields selected, the join test used, etc. Option = Run in Batch - This will submit the selected query to a batch job queue. may be helpful if the query is large and takes a significant amount of time to run. Option = Run - The query will run interactively. query runs. This

Your screen will be tied up while the

From this point forward, we will follow through the steps to create a query When option number 1, Create, has been selected and you have entered a query name and library, the following screen will display:

Define Wery . . . . . . : Library . . . . : rype options, l=Select 3Pt 1 press YTDSOLD TRAINING Enter. Press F21

the

Query Option . . . . . : CREATE

CCSID . . . . s . :
to select all.

65535

Query Definition Option Specify file selections Define result fields Select and sequence fields Select records Select sort fields Select collating sequence Specify report column formatting Select report summary functions Define Select Specify report breaks output type and output processing options F5=Repor t FlEJ=Fi les form

F3=Exi t F13=Layout

F 12=Cance F;Zl=Select

1 all

Page I - 4

Using

AS/400

Query
--

The first item to address will be the file selection process. AS you can see, the number I will automatically default on the option line for Specify file selections. Press enter and the following screen will display:

Specify Type choices, press file selection. File.... Library = Member . . m Format . . . File ID II . File......... Library . Member . . . Format . . . File ID . . a . . . . . . . . . . . . . e Enter. Press

File F9 to

Selections specify an additional

. . . . .

. . . . .

KSALP MBS24DB *FIRST KSALR TO1 KSKUP MBS24DB *FIRST KSKUR TO2

Name, Name, Name, Name, A-299, Name, Name, Name, Name, A-299,

F4 for *LIBL, *FIRST, *FIRST, *ID F4 for *LIBL, *FIRST, *FIRST, *ID

list F4 for list F4 for list F4 for list

. . . .

. . . .

. . . .

. . . .

. . . .

list F4 for F4 for F4 for

list list list

Bottom F3=Exit F12=Cancel F4=Prompt F13=Layout FS=Report F24=More F9=Add keys file

Here you will enter the database file name and the library on which the query will be based. After the file has been keyed in, press enter and then enter again to confirm. this example, the files KSALP (Weekly Sales History Master File) and KSKUP ( SKU Master File) are selected. If the query will require information from multiple function key F9 will have to be pressed in order multiple files are used there will be the need for will have to be at least one field in each file that files, as this example does, the to add those additional files. When a join relationship. This means there is common to both files.

In

Using

AS/400

Query

Men ,

joining more than one file, you will see the following
Specify Type of Join

screen:

Type Type

choice, of join

press

Enter. 2 l=Matched 2=Matched 3=Unmatched records records with primary records with primary

. . . (I . . . .

file file

F3=Exit F12=CanceC

F5=Report F13=Layout

FlO=Process/previous FlIJ=Files

There

are three types of available

joins (in the diagrams

A= Primary File TOI):

Option I, IMatched records, is used when there is an exact key match for the files that have been selected. There is no primary file with this option, as all files selected must have matching fields to create a joined record. This join type will only include the records that match between the selected files. Option 2, Matched records with primary file, will select all records from the primary file (the first file selected) and only those records from the secondary files that match the join specification field. Output is sequences according to the primary file.

Option 3, Unmatched records with primary file, takes only primary file records that have no specified field matches in the secondary file. Once again, the primary files used to sequence the output.

age 1 - 6

Using AS1400 Query


The maximum number of files that can be joined is 32. When using options 2 and 3, the order in which the files are chosen is very important, as the order determines the sequence of the output. If you need the output to appear in a different sequence, the sort option allows you to change the order. When a join option has been chosen press enter. The Specify How to Join Files screen appears:

Specify Type comparisons to show how file Tests: EQ, NE, LE, GE, LT, GT Field TOl.SKUSH Test EQ

How to selections

Join

Files are related, press Enter.

Field TOZ.SKUSK

Bottom Field T01.008SH TOl.ST#SH TOI.SKUSH T01.038SH T01.039SH F3=Exit FlZ=Cancel Text STATUS CODE STORE NUMBER SKU NUMBER TYPE SUB CODE A TYPE SUB CODE B Ffi=Report F13=Layout FlO=Process/previous F18=Files Fll=Display F24=More Len Dee 1 3 0 11 3 3 More... names only keys

Enter the names of the fields on which the join relationship is based. Men joining two or more files the system automatically adds the TO2 or TO2 to the field names in order to distinguish which file to which they belong. On the bottom half of the screen is a listing of the existing field names. I there are more fields than can be viewed on the screen, move the cursor to the bottom half of the screen and use the Page Down (Roll Up) key to see the other fields. For our example, we wil be joining on the SKU Number file; TO1 .SKUSH in the primary file and T02SKUSK in the secondary file. Since we specified a join type of 2, and the test type of EQ, the query will pull all SKU numbers from the primary file, and those from the secondary file that equal records in the primary file. The test type is what is used to establish the relationship between the fields for the join section. The valid operators are EQ = Equal, NE = Not Equal, LT = Less Than, GT = Greater Than, LE = Less than or Equal to, and GT = Greater than or Equal to. Up to 100 different join tests can be defined. If there are more than 6 join tests, press the Page Down (Roll-Up) key to get more blank lines. Press enter when you have typed in all the application tests. l?age 1 - 7

Using AS/400

Query

The next process that needs to be done will be the selection and sequencing of the fields. Again key in the number I next to the Select and Sequence Fields option on the Define the Query screen and press enter. The following is an example
Select Type sequence number (O-9999) appear in the report, press -I Field TOl.CLSSH TOl.SKUSH TOZ.ESKSK T02.B34SK TOl.FO2SH TOl.U52SH TOl.VN#SH T01.008SH TOl.ST#SH T01.038SH T01.039SH T01.071SH

of the screen that appears:


and for the Enter. Sequence names of Fields up to 500 fields to

10 20 30 40 50 60 70

Text CLASS NUMBER SKU NUMBER SKU DESCRIPTION PRICE / CURRENT RETAIL FISCAL WEEK SALES WTD UNITS VENDOR NUMBER STATUS CODE STORE NUMBER TYPE SUB CODE A TYPE SUB CODE B TYPE SUB CODE C

Len 3 11 25 7 2 5 6 1 3 3 3 3

Dee

2 0 0

More... F3=Exit F13=Layout Press Enter F5=Report F20=Renumber confirm. Fll=Display F21=Select names ali only F12=Cancel F24=More keys

to

On this screen select the fields that you want to appear on the report. Select by placing a number between 0 and 9999 next to the item. It is suggested that the numbers are used in increments .f.....+.. .-: >f,. ,. ._.,. . _:. .....z:: ,;,. &gZ .: ...,. ...3 :.:* i __ .:.V of IO so that if a field needs to be inserted at later point, there i......._...__ ..:;yp: ............$ ..$ w J. ,...,.: .,,,., ,.,...,. :.j: .,...: . . . . . j .,.,. .,. ., ,.,. :...:...:.5 > are still available numbers between the fields that were originally : f ~:...1..:.::...1...................~., 5 :. . :. .i.......;.;>. ...._. i.. ..... .A,.. ..I.$ selected. The lowest number will appear first in the report. In this z -.....................................t query class number will appear first, followed by SKU number , SKU description, and so forth. Fields that are left blank will not show on the report. After all selections your choices. have been made press enter and then enter again to confirm

el-8

Using AS/400 Query


If the query will need to be sorted in any particular manner the Select sort fields option will be selected from the Define the Query screen. When this option is selected the following will display:

Select Type sort priority (O-999) and the names of up to 32 fields, Sort Prty 10 20

Sort

Fields or
D (Descending) for

A (Ascending) press Enter.

A/D A D

Field TOl.CLSSH TOl.SKUSH TOZ.ESKSK T02.B34SK TOl.FO2SH TOl.U52SH TOl.VN#SH

Text CLASS NUMBER SKU NUMBER SKU DESCRIPTION PRICE / CURRENT FISCAL WEEK SALES WTD UNITS VENDOR NUMBER

RETAIL

Len 3 11 25 7 2 5 6

Dee

2 0 0

Bottom F3=Exit F13=Layout FS=Report F18=Files Fll=Display F20=Renumber names only F12=Cancel F24=More keys

To sort, place a number between 0 and 999 in the sort priority field. The lower the number the higher the priority. The fields that are sorted can also be sorted in either ascending or descending order simply by placing an A or D in the field labeled A/D. In this example, the major sort field is Class Number in ascending order and the minor sort field is Sales Week-To-Date Units in descending order. After entering the numbers and the order type, press enter and enter again to confirm. If you do not enter an order type, the system defaults to ascending.

Page 1 - 9

Using

AS1400

Query

Selecting records will allow the user to decide how much information will be pulled into the report. When the Select Records option is chosen the following screen is displayed. An example of the information needed follows:
Select Type comparisons, Tests: EQ, NE, AND/OR AND AND AND Field T02.634SK TOl.ST#SH TOl.FO3SH TOl.FO2SH press Enter. LE, GE, LT, Records start LIKE, Number, each IS, new group. ISNOT... 'Characters', or . ..>

Specify OR to GT, RANGE, LIST, Value (Field, 0 001 98 01 52

Test CT EQ EQ RANGE

Bottom Field TOl.CLSSH TOl.SKUSH T02.ESKSK T02.B34SK TOl.FO2SH F3=Exit Fl2=Cancel Text CLASS NUMBER SKU NUMBER SKU DESCRIPTION PRICE / CURRENT FISCAL WEEK F5=Report F13=Layout Len Dee 3 11 25 7 2 2 0 More... names only keys

RETAIL

F9=Insert FZO=Reorganize

Fll=Display FZ+=More

If the query required a report that included records with a price greater than 0, for Store 001 m for all fiscal periods of 1998 then this screen would be filled in as follows: 1st field - T02.B34SK 1st Test - GT 1st Value - 0 (Current Price) 2nd Field - TO1 .ST#SH (Store Number) 2nd Test - EQ 2nd Value - 001 4th Field - TO1 .F02SH (Fiscal Week) 4th Test - RANGE 4th Value - 01 52

3rd Field - TO1 .FO3SH (Current 3rd Test - EQ 3rd Value - 98

Year)

The existing fields are listed on the lower half of the screen. Move the cursor to the bottom of the screen and use the page down (roll up) key to see more field names.

age 3 - 10

Using AS1400 Query


Valid Test values are shown at the top of the screen. These values define how the query checks the contents of the field on the left. They are defined as : EQ = Equal NE = Not Equal GT = Greater Than LT = Less Than GE = Greater Than or Equal To LE = Less Than or Equal To RANGE = Range IS = Null ISNOT = Null LIST = List of Values (must be specific with match) NLIST = Not List LIKE = Like (filed startswith, ends with, or matches the value) NLIKE = Not Like

If multiple test are used, AND and OR values are used to indicate how the comparison tests can be relate to each other. Up to 100 tests can be defined to determine whether a record is selected for the query or not. To define more than six comparison tests, press the Page Down (or Roll Up) key to get more lines of entry fields. If no test are defined, all records available for the query are included on the report. If the AND/OR column is left blank, a value of AND defaults.

To verify the comparison test, the F5 key can be used to run the query as it is currently defined and display the report on your screen. To see what the layout of the report is looking like you also can use the F13=Layout key.

age 1 - 11

Using AS/400 Query


Selecting the option Define results fields from the Define the Query screen will allow the entry of a new field within the query. For example, if we wanted a new field showing the margin between cost and retail, based on the information in the secondary file, the following would supply that information:
Define Type definitions Operators: Field GRSMG using -, *, field names /, SUBSTR, Result or 1 I, constants DATE... Fields and operators, press Enter.

+,

Expression t02.b34sk-t02.a32sk

Column Gross

Heading Margin

Len

Dee

Bottom Field TOl.CLSSH TOl.SKUSH T02.ESKSK T02.B34SK F3=Exit F12=Cancel Text CLASS NUMBER SKU NUMBER SKU DESCRIPTION PRICE / CURRENT FS=Report F13=Layout Len Dee

3
11 RETAIL F9=Insert F20=Reorganize Fll=Display F24=More

25 7
More... names only keys

Fill in the fields with the following Field -

information:

This should be a unique field name for the value that will result from the expression, You can not use any of the existing field names that appear on the lower half of the screen. Also, the field name has to begin with an alpha character and can be no longer than 0 characters In this case, we would fill in GRSMG. On this line, the necessary fields are combined with the appropriate operators (+, -, *, /) so that the correct result is computed. You may also use as many fields and operators as needed to get the correct figure, up to three lines provided on the screen. Field names and constants may be split across the line ending, but no extra spaces are allowed. For this example, fill in T02.B34SK - T02.A32SK. T02.B34SK is the current retail and T02.A32SK is the current cost.

Expression

Page 1 - 12

Using
Column Heading

AS/400

Query

- This will appear on the report as the heading for the results column. In this case, you would type in Gross Margin. If you did not want a title to appear on the column, fill in *NONE, and if you leave the field blank, the system will use the result field name (GRSMG) as the heading. This is the actual length of the field within the report. If left blank the system will automatically calculate it. If you want to know what the length will be for this report as it is defined now, press the F13 key to show the layout of the report and count the number of Xs appearing in the corresponding field. The system uses 9s to represent character sets. The number if decimal positions to the right of the decimal point in numeric result fields. if left blank this will automatically be calculated based on the fields used in the computation.

Len -

Dee -

To create blank columns within the query: Use the Define Results option and answer the fields as follows to insert blank columns in your query. Field Name field such as Count for writing inventory the report. Enter the report. counts on

Expression

for as long as you want the field to be on

Column

Heading

VVhat you want the column heading to print as on the report, such as Inventory Count. in order

Any result fields must then be added on the Select and Sequence option to see these fields on the query when printed or displayed.See below.
Select Type sequence number (O-9999) appear in the report, press S eq 10 20 30 40 50 60 70 80 Field TOl.CLSSH TO1 . SKUSH T02.ESKSK T02.B34SK TOl.FO2SH TO1 . U52SH TO1 .VN#SH GRSMG T01.008SH and Sequence names Fields of up to 500 fields to

for the Enter.

Text CLASS NUMBER SKU NUMBER SKU DESCRIPTION PRICE / CURRENT FISCAL WEEK SALES WTD UNITS VENDOR NUMBER t02.b34sk-t02.a32sk STATUS CODE

RETAIL

Len 3 11 25 7 2 5 6 8 1

Dee

2 0 0 2

Using AS/400 Query


The next step is to begin formatting the layout of the report. This begins with the following Specify report column formatting option. When you select this option the following screen appears:
Specify Type information, Column headings: press Enter. *NONE, aligned Column Spacing 1 Report Column Formatting

text

lines

Field TOl.CLSSH

Column CLASS NUMBER

Heading

Len 3

Dee

Edit

TOl.SKUSH

SKU NUMBER

11

TOZ.ESKSK

SW DESCRIPTION

25

More... F3=Exit F13=Layout F5=Report Flb=Edit FlO=Process/previous F18=Files F12=Cancel F23=Long comment

With this option you can alter the spacing before the report columns, the headings above the columns, and the report field lengths. However, if you make changes to the field lengths, you may get unexpected results from your query. To change the spacing before columns, enter a number from 0 to 99 to show the number of spaces to appear in front of that column on the report. The default column spacing is no spaces in format of the first column and 2 spaces in front of all other columns. Before you make any changes , make sure of the possible results throughout the rest of the report. Whatever is input in the Column Heading field is exactly what will appear on the report. The default for the field is the name of the field itself if no heading was defined in the file. If a heading should not appear on the report, then *NONE needs to be typed in the field. All characters are valid for a heading and it can be as long as the three 20 character lines will allow. The Len and Dee fields may also be changed, but again, the end results should be determined before any change is made. Changes in this area can cause query results to appear different from the intended results. The F5 Report option can be used here to see the effect of any changes. After making al of the changes needed for the report format, press enter to accept the changes.

Page I - 14

Using AS/400 Query


Queries can also be setup with report summaries through the Select report summary functions option. These summaries can be for totals, averages, minimums, maximums or the actual count. For each field included in the query the user can select all of the summary functions, one of the summary functions, or any combination of the summary functions.

The Following

is an example

of the report summary

screen:

Select Type options, l=Total ---Options--press 2=Average Enter. 3=Minirnum

Report

Summary

Functions

4=Maximum Text CLASS NUMBER SKU NUMBER SKU DESCRIPTION PRICE / CURRENT FISCAL WEEK SALES WTD UNITS VENDOR NUMBER t02.b34sk-tO,2.a32sk

5=Count Len 3 11 25 7 2 5 6 8 Dee

Field TOl.CLSSH TOl.SKUSH TO2.ESKSK T02.B34SK TOl.FO2SH TOl.lJ52SH TOl.VN#SH GRSMG

RETAIL

2 0 0 2

F3=Exit F12=Cancel

F5=Report F13=Layout

F10=Process/previous FlEl=Files

Fll=DispLay F23=Long

names comment

Bottom only

Simply type in the correct option number in one of the blanks. For this query, there be a total line for Sales WTD Units as is shown by the 1 entered on the option line for TO1 .U52Sl-l. When you have entered all the options needed, press enter to save the information.

Using AS/400 Query


The next process is the definition of the report breaks. The Define report breaks options allows the report to be broken down by the fields that have been selected in the query but only the fields that have also been selected as sorts represented by the Sort Prty column. The report breaks can be used for up to 9 fields and levels I through 6 are the valid break levels. You can only have a total of nine fields defined. For example, you can have one break level for nine fields, or three break levels defined with three fields each. Also, a break at one level forces a break at all lower levels. Level 6 is the lowest level break. Break level 0 occurs at the end of the report and does not need to be defined. It shows totals for the entire report. The following is an example of the report break screen:
Define Type break (Use as Break Level 1 2 Level (l-6) many fields Sort Prty 10 20 for up as needed to Report 9 field for each Breaks names, break press level.) Enter.

Field TOl.CLSSH TOl.SKUSH TO2.ESKSK T02.B34SK TOl.FOZSH TOl.lJ52SH TOl.VN#SH GRSMG

Text CLASS NUMBER SKU NUMBER SKU DESCRIPTION PRICE / CURRENT FISCAL WEEK SALES WTD UNITS VENDOR NUMBER t02.b34sk-t02.a32sk

Len 3 11 25 7 2 5 6 8

Dee

RETAIL

2 0 0 2

F3=Exit F12=Cancel

F5=Report F13=Layout

FlO=Process/previous F18=Files

Fll=Display F23=Long

names comment

Bottom only

With the example above, we have entered two break levels, one at 1 and one at 2. Since there is a limit of 9 fields, only 7 more break levels could be defined at this point, either at level 1 or 2, or at a lower level. The important break level here is the Level I for Class number. This will cause a total line to appear on the report for all items that belong to the same class.

Page 1 - 16

Using ASMOO Query


Men you have entered the correct break levels press enter. Break screen will appear.
Format Break level. . . press in . . . Enter. text to have break values inserted.) . . : 0 Report Break

The Format

Report

Type choices, (Type &field

Suppress Break text

summaries . . . .

. .

. .

. .

. .

N FINAL TOTALS

Y=Yes,

N=No

Level 1 2

Field TOl.CLSSH TOl.SKUSH

F3=Exit F13=Layout

FS=Report Fl8=Files

FlO=Process/previous F23=Long comment

F12Xancel

The Break Level you are currently formatting appears at the top of the screen. The first one you will work with is level 0. Answer the Suppress summaries option Yes or No depending on whether the summary functions selected earlier should be displayed. Break text should include the text you want to appear at this break level in the report and is limited to 40 characters. Press enter as you finish formatting each break level. VVhen formatting break levels other than 0, another question will appear asking if the report should skip to a new page for this break level. Answer Yes or No accordingly. Press enter when you have formatted each break level correctly. Press enter when finished to save the information. Below is the screen for report breaks other than level 0:
Format Break level . . press in page . . . Enter. text . . . . . to . . . . . have . . . break N N values inserted.) Y=Yes, Y=Yes, N=No N=No . . : 1 Report Break

Type choices, (Type &field Skip Suppress Break text to new

summaries . .

Level 1 2

Field TOl.CLSSH TOl.SKUSH

age 1 - 17

Using AS/400 Query

The final option that will be discussed is the Specify output type and output form. This option is where the user can determine where the query output is to go, and what form it should appear in. The default is a displayed report in detailed form.

Seiect Type Output choices, type press . . . Enter. . . . .

Output

Type

and

Output

Form

l=Display 2=Printer 3=Database l=Detail 2=Summary Y=Yes, Blank, Y=Yes, N=No l-378 N=No

file

Form

of

output

only

Line

wrapping Wrapping width Record on one

. . . . page

. . .

. .

. . .

. . .

. . .

. . .

. . .

N N

F3=Exit

FS=Report

FlO=Process/previous

Fill out the fields for the type and form of output needed and press enter.

Page 1 - 18

Using AS1400 Query


We are not covering the Specify processing options and Select collating sequence options from the Define the Query screen in this class. If you find that you need help with these selection please call MBS Systems Support for assistance.

s,

The final step is to exit, save, and run the query. Query screen. An example of that screen follows:

Press F3 to bring up the Exit this

Exit Type Save Run choices, definition option . . . press . . Enter. . . . . Y 1

this

Query

Y=Yes, l=Run 2=Run 3=Do

N=No interactively in batch not run

For

a saved Query . Library . . .

definition: . . . . . . . . . . . . .

. . . .

. .

YTDSOLD TRAINING

Name Name,

F4

for

list

Text Authority

"LIBCRTAUT

*LIBCRTAUT, *CHANGE,

*ALL,

authorization *EXCLUDE,

list *USE

name,

F4=Prompt F14=Define

the

F5=Report query

F12=Cancel

F13=Layout

If at this point you decide that you are not read to exit and save, press either FIT! key to cancel or the Fl4 key to back to defining the query. The F5 key is also available to check the appearance of the report on the screen as it is currently defined.

age 1 - 19

Using

AS/400

Query

If this query is to be saved for future use, answer the Save definition Yes. With the run option it is determined whether the job is run interactively, in batch, or not at all upon exiting. if you chose not to run the query but you save it, then the query can always be run at a later time. There are some restrictions to running the query in batch. If the query has not been saved or has been saved to QTEMP, it can not be run in batch. The query name and library as defined when the query was started appears on this screen. The text field allows you to type a description, up to 50 characters, of this query to reference in the future. The Authority field is designed to give specific authorities to other users of this query. The valid values are: *LIBCRTAUT, *ALL, *CHANGE, *USE, *EXCLUDE, and authorization list name. A table of what can be done with the query with each type of authority is available through the help command. Once the fields are entered correctly, press enter. How the query will appear will depend on how the answers for the display, output, and run options were answered.

Page I-20

Using

AS/400

Query

So far we have covered the major and minor steps to making a query: designing, creating, saving, and running the query. once you have completed all these steps there are several options available to run the query again at a later date. First, form the Query Utilities Menu, option 2 can be taken to run an existing query. Simply enter the na e of the query on the Run Query screen and press enter. Another way to run a saved query is to use option 1 form the Query Utilities Menu to Work with Queries. There are a couple of ways to run a query with this option. One is to type an 8 or 9 on the option line to either run the job in batch or interactively, enter the query name and press enter. The other way is to take option 2 to change the query, type the query name and press enter. Using this method allows the user to view the report form of the query on the screen before running it again. You may then also make any changes that might be needed before running the query. When done making changes or reviewing , press F3 and repeat the procedure discussed earlier for exiting, saving, and running a query.

Using AS1400 Query

Special Tips to Help when Using IBM Query


RUNQRY Command can be run from a command line in order to either run an query into an existing file to look at the data. This is one contain the information you need before creating a query quickly view what data is in a file. Also, the runqry on a system which does not have the full IBM Query

The runqry command existing query or to just way to see if a file does or you can use it to just command can be used application installed.

To use this command type runqry on the command an example of the screen that will be displayed:
Run Query Type choices, press Enter. Name, Name, Name, Name, Name, *NONE *LIBL, *SAME *RUNOPT, *RUNOPT, (RUNQRY)

line and press F4. Below is

Query =............ Library . . . . Query file: File............. Library . . . Member . . . . . + for Report output type Output form e . . Record selection .

., . e . . . D

*LIBL

*CURLIB

. . . . . . more . . . - . (I . . .

. . . . . . values . . . . . . . . .

. . . . .

*LIBL *FIRST "RUNOPT *RUNOPT *NO

*LIBL, *FIRST,

*CURLIB *LAST

"RUNOPT, *DISPLAY... *RUNOPT, *DETAIL, *NO, *YES

*SUMMARY

Bottom F3=Exit F24=More F4=Prompt keys FtS=Refresh FlZ=Cancel F13=How to use this display

To run an existing query on your system type the name on the field labeled Query and then the library where is resides in the field beneath. You may then change the Reporf oufpuf type and Output form or leave as *RUNOPT to run as defaulted in the query definition. To look at a file in the system, enter the name of the file in Query file: We field and the library for that file in Library. If you just press enter, the screen will display all of the records in the selected file. You can use the Reporf oufpuf fype to change the output to a report by changing to *PRINTER. Also, if you have IBM Query, you may change the Record selecfion parameter to *YES. Then you will get another screen which will be the same as the Selecting records screen on page IQ.

l-

Using AS/400 Query

Creating a Library for Your Queries


cCF3TLlB Command Men creating queries you have to enter a library for the query to reside in. In order to keep the system more organized, it is best to create at least one library on your system which will contain the queries created for your store. It is very easy to do this. To create a library, type in crtlib on the command following screen will display: line and press F4. The

Create Type choices, press Enter.

Library

(CRTLIB)

Library . . . . . . . . . . . . Library type . . . . . . . . . . Text sdescriptioni . . . . . . .

trainqry *PROD Library

for

Name *PROD, Training

*TEST Query's

Bottom F3=Exit F13=How F4=Prompt to use this F5=Refresh display FlO=Additional F24=More keys parameters F?Z=Cancel

Key in the name you want for the Library and then enter a description of the library in the Text description field. Press enter and the library will be created. You now can create a query and key this new library as the library name.

age 1 - 23

Using

AS/400

Query

Finding a File While in a Program


Using SysRq 3

Here is a hint on finding what file you need that contains the information you are looking for a query. Lets say you know that there is a particular field that displays when you are in SKU Inquiry but you do not know what file it is in. The following shows the SKU Inquiry screen in Merchandise Control:

USR: PAT STN : QPADEV0005

TESTING COMPANY SKU Inquiry

DATE: MENU:

9/11/98

SKU:

04154090004

DYNAGRIP

Class Primary Vendor

subclass --: vendor --: style ----:

430 / 600004

Department 2nd vendor Buyer code 4.50 4.50 7.00 7.09


Royalty

---: ---: ---:

43

Division -----I . 4 3rd vendor ---: Defalt U/M ---: .oo 40.06 m .oo SIZE group -: Season -------m I 3rd event ----:

SKU List cost ---: SKU landed cost -: Current retail --: Original retail -: LOGO group ----: --*em Ticket type --..-F--. 1st event

% ------------:

Gross margin % -------: --we-. Mfg. sug. retail COLOR group -: -m--w. . SKU type 2nd event ----:

: .

1 Enter

for

more

detail

Roll

to

next/previous

record

More

data...

To see what files the system is using to display the information, press the Shift key and the SysRq key at the same time and then release them. You will now see a dotted line on the bottom of your screen. Type a 3 on that dotted line and press enter.

age 1 - 24

Using AS/400 Query


The following menu will display:
Work Job: Select QPADEV0005 one of the User: following: PAT with Job System: Number: 327140 S1014BSR

1. Display job status attributes 2. Display job definition attributes 3. Display job run attributes, if 4. Work with spooled fites IO. 11. 12. 13. 14. 15. 16. Selection Display job log, if active or

active

on job

queue

Display call stack, if active Work with locks, if active Display library list, if active Display Display Display or open file files, overrides, control if active if active status, if active More... command

commitment

Now you will select option # 14 - Display open files, if active. The screen will then display the files that are being used in order to display the information in the program you are currently accessing, in the example, SKU Inquiry.

Using AS/400

Query

Display Job . - : QPADEVOOOS Number of open data paths

Open

Files Number 23 m . I : 327140

User . . : PAT . . . . . . , . . . :

File AVNL2 KSK3L KSKUP KSKULS KSKULI KSKUL3 KSKUL2 KSKUL 1 KSKUL RI IQ36FM QDUI 132 Press F3=Exi Enter t

Library MBS24DB MBS24DB MBS24DB MBS24DB MBS24DB MBS24DB MBS24DB MBS24DB MBS24DB MBSMCOB J QSYS to continue.

Member/ Device AVNL2 KSK3L KSKUP KSKUL5 KSKUL4 KSKUL3 KSKUL2 KSKUL 1 KSKUL QPADEVOOOS QPADEVOOOS

Scope ACTGRPDFN *ACTGRPDFN *ACTGRPDFN *ACTGRPDFN *ACTGRPDFN *ACTGRPDFN *ACTGRPDFN *ACTGRPDFN ACTGRPDFN ACTGRPDFN *ACTGRPDFN

Activation 0000000002 0000000002 0000000002 0000000002 0000000002 0000000002 0000000002 0000000002 0000000002 0000000002 0000000002

Group DFTACTGRP *DFTACTGRP *DFTACTGRP DFTACTGRP DFTACTGRP DFTACTGRP DFTACTGRP *DFTACTGRP *DFTACTGRP DFTACTGRP DFTACTGRP

F5=Refresh

Fll=Display

I/O

details

F12=Cancel

Fl6=Job

menu

The files that actually contain data are the physical files which end in the letter P. In the previous file listing, the KSKUP file is a physical file and also happens to be the file containing the SKU master file information. The files listed that end in either just the letter II or the letter L and a number are logical files. In the above listing KSKUL, KSKULI, KSKUL2, KSKUL3, KSKUL4, and KSKULS are all logicals on the KSKUP physical file. Logical files are built over the physical to give the user multiple ways to access the information in the physical file when in the MBS application software. They do not contain the actual data but only access keys to the physical file, therefore, they are not used in creating a query.

age 1 - 26

You might also like