query 400

download query 400

of 27

description

AS400 Query

Transcript of query 400

  • In This Unit

    Agenda

    Overview

    Designing the QueryCreating the Query

    File Selection

    Specifying How to Join Files

    Selecting and Sequencing Fields

    Selecting Records

    Defining Results Fields

    Creating Blank Columns within the QuerySelecting Report Summary FunctionsFormatting Report Breaks

    Exiting, Saving, and Running the Query

    Running Saved Queries

    Special Tips for Using Queries

    RUNQRY CommandCreating a Library for Your Queries

    CRTLIB CommandFinding a File While in a Program

    Using SysRq 3

  • Using AS1400 Query

    Objective

    AS1400 Query Training

    - to gain the ability to use Query/400 in order to generate customized reports based on single or multiple files

    Getting into Query - Go Query - Wqry - Query/400

    Creating the Query - Selecting the files - Selecting the sequencing fields - Selecting the records - Defining the results fields

    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 Query Utilities System: S1014B5R

    Select one of the following:

    Query/400 1. Work with queries 2. Run an existing query 3. Delete a query

    DB2/400 IO. Start DB2/400 Query Manager

    Query management 20. Work with query management forms 21. Work with query management queries 22. Start a query 23. Analyze a Query/400 definition

    More... Selection or command v-e> me-

    F3=Exit F4=Prompt F9=Retrieve FlZ=Cancel Fl3=Information Assistant Fl6=AS/400 Main menu (C> COPYRIGHT IBM CORP. 1980, 1997.

    Page 1 - 2

  • Using AS/400 Query

    The option you will be using in this class is option I- Work with Queries. When option number 1 has been selected the following screen will display:

    Work with Queries

    Type choices, press Enter.

    Option . . . . . . l=Create, 2=Change, 3=Copy, 4=Delete S=Display, &Print definition 8=Run in batch, 9=Run

    Query . . . . . . . Name, F4 for list Library . . . . . QGPL Name, *LIBL, F4 for list

    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 5 = Display - This will display the query but will not allow any changes to the query.

    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. This may be helpful if the query is large and takes a significant amount of time to run.

    Option = Run - The query will run interactively. Your screen will be tied up while the query runs.

    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 the Query

    Wery . . . . . . : YTDSOLD Option . . . . . : CREATE Library . . . . : TRAINING CCSID . . . . s . : 65535

    rype options, press Enter. Press F21 to select all. l=Select

    3Pt Query Definition Option 1 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 report breaks

    Select output type and output form Specify processing options

    F3=Exi t F5=Repor t F13=Layout FlEJ=Fi les

    F 12=Cance 1 F;Zl=Select 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 File Selections

    Type choices, press Enter. Press F9 to specify an additional file selection.

    File.... a . . . . KSALP Name, F4 for list Library = . . . . . MBS24DB Name, *LIBL, F4 for list

    Member . . m . . . . . *FIRST Name, *FIRST, F4 for list Format . . . . . . . . KSALR Name, *FIRST, F4 for list File ID II . . . e . . TO1 A-299, *ID

    File......... KSKUP Name, F4 for list Library . . . . . . MBS24DB Name, *LIBL, F4 for list

    Member . . . . . . . . *FIRST Name, *FIRST, F4 for list Format . . . . . . . . KSKUR Name, *FIRST, F4 for list File ID . . . . . . . TO2 A-299, *ID

    F3=Exit F4=Prompt F12=Cancel F13=Layout

    FS=Report F24=More keys

    F9=Add file Bottom

    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. In 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 files, as this example does, the function key F9 will have to be pressed in order to add those additional files. When multiple files are used there will be the need for a join relationship. This means there will have to be at least one field in each file that is common to both files.

  • Using AS/400 Query

    Men joining more than one file, you will see the following screen:

    , Specify Type of Join

    Type choice, press Enter.

    Type of join . . . (I . . . . 2 l=Matched records 2=Matched records with primary file 3=Unmatched records with primary file

    F3=Exit F5=Report F12=CanceC 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 How to Join Files

    Type comparisons to show how file selections are related, press Enter. Tests: EQ, NE, LE, GE, LT, GT

    Field Test Field TOl.SKUSH EQ TOZ.SKUSK

    Bottom

    Field Text Len Dee T01.008SH STATUS CODE 1 TOl.ST#SH STORE NUMBER 3 0 TOI.SKUSH SKU NUMBER 11 T01.038SH TYPE SUB CODE A 3 T01.039SH TYPE SUB CODE B 3

    More... F3=Exit Ffi=Report FlO=Process/previous Fll=Display names only FlZ=Cancel F13=Layout F18=Files F24=More 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 of the screen that appears:

    Select and Sequence Fields

    Type sequence number (O-9999) for the names of up to 500 fields to appear in the report, press Enter.

    -I Field Text Len Dee 10 TOl.CLSSH CLASS NUMBER 3 20 TOl.SKUSH SKU NUMBER 11 30 TOZ.ESKSK SKU DESCRIPTION 25 40 T02.B34SK PRICE / CURRENT RETAIL 7 2 50 TOl.FO2SH FISCAL WEEK 2 0 60 TOl.U52SH SALES WTD UNITS 5 0 70 TOl.VN#SH VENDOR NUMBER 6

    T01.008SH STATUS CODE 1 TOl.ST#SH STORE NUMBER 3 0 T01.038SH TYPE SUB CODE A 3 T01.039SH TYPE SUB CODE B 3 T01.071SH TYPE SUB CODE C 3

    F3=Exit F5=Report F13=Layout F20=Renumber Press Enter to confirm.

    More... Fll=Display names only F12=Cancel F21=Select ali F24=More keys

    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

    . . ...+.. .-: >-

    w i

    the item. It is suggested that the numbers are used in increments f,. ,. ._.,. . _:. . . . . . f __ ,;,. &gZ . . . .,. . . :.:* i . . . . . . . _...__ .z:: .:.V : .3 ..:;yp: . . . . . . . . . . . ..$ J. ,.,...,. :.j: .,...: . . . . . . . . . j .,.,. .$

    of IO so that if a field needs to be inserted at later point, there ,...,.: .,,,., .,. ., ,.,. :...:...:.5 : > f ~:...1..:.::...1...................~., are still available numbers between the fields that were originally :. . 5 :. . i.. . . . . .; .;>. . . . . ._. i.. . . . . . . A,.. . .I.$ z -.....................................t

    selected. The lowest number will appear first in the report. In this 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 have been made press enter and then enter your choices.

    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 Sort Fields

    Type sort priority (O-999) and A (Ascending) or D (Descending) for the names of up to 32 fields, press Enter.

    Sort Prty A/D Field

    10 A TOl.CLSSH 20 D TOl.SKUSH

    TOZ.ESKSK T02.B34SK TOl.FO2SH TOl.U52SH TOl.VN#SH

    Text Len Dee CLASS NUMBER 3 SKU NUMBER 11 SKU DESCRIPTION 25 PRICE / CURRENT RETAIL 7 2 FISCAL WEEK 2 0 SALES WTD UNITS 5 0 VENDOR NUMBER 6

    F3=Exit FS=Report

    F13=Layout F18=Files

    Bottom Fll=Display names only F12=Cancel

    F20=Renumber 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 Records

    Type comparisons, press Enter. Specify OR to start each new group. Tests: EQ, NE, LE, GE, LT, GT, RANGE, LIST, LIKE, IS, ISNOT...

    AND/OR Field Test Value (Field, Number, 'Characters', or . ..> T02.634SK CT 0

    AND TOl.ST#SH EQ 001 AND TOl.FO3SH EQ 98 AND TOl.FO2SH RANGE 01 52

    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 RETAIL FISCAL WEEK

    F5=Report F13=Layout

    F9=Insert FZO=Reorganize

    Len Dee 3

    11 25

    7 2 2 0

    More... Fll=Display names only FZ+=More keys

    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:

    1 st field - T02.B34SK (Current Price) 2nd Field - TO1 .ST#SH (Store Number) 1 st Test - GT 2nd Test - EQ 1 st Value - 0 2nd Value - 001

    3rd Field - TO1 .FO3SH (Current Year) 4th Field - TO1 .F02SH (Fiscal Week) 3rd Test - EQ 4th Test - RANGE 3rd Value - 98 4th Value - 01 52

    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 IS = Null NE = Not Equal ISNOT = Null GT = Greater Than LIST = List of Values (must be specific with LT = Less Than match) GE = Greater Than or Equal To NLIST = Not List LE = Less Than or Equal To LIKE = Like (filed startswith, ends with, or RANGE = Range 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 Result Fields

    Type definitions using field names or constants and operators, press Enter. Operators: +, -, *, /, SUBSTR, 1 I, DATE...

    Field Expression

    GRSMG t02.b34sk-t02.a32sk Column Heading Gross Margin

    Len Dee

    Bottom

    Field TOl.CLSSH TOl.SKUSH T02.ESKSK T02.B34SK

    F3=Exit F12=Cancel

    Text Len Dee CLASS NUMBER 3 SKU NUMBER 11 SKU DESCRIPTION 25 PRICE / CURRENT RETAIL 7 2

    More... FS=Report F9=Insert Fll=Display names only F13=Layout F20=Reorganize F24=More keys

    Fill in the fields with the following information:

    Field - 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.

    Expression - 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.

    Page 1 - 12

  • Len -

    Dee -

    Using AS/400 Query

    Column Heading - 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.

    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 counts on the report.

    Expression - Enter the report.

    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.

    Any result fields must then be added on the Select and Sequence option in order to see these fields on the query when printed or displayed.- See below.

    Select and Sequence Fields

    Type sequence number (O-9999) for the names of up to 500 fields to appear in the report, press Enter.

    S eq Field Text Len Dee 10 TOl.CLSSH CLASS NUMBER 3 20 TO1 . SKUSH SKU NUMBER 11 30 T02.ESKSK SKU DESCRIPTION 25 40 T02.B34SK PRICE / CURRENT RETAIL 7 2 50 TOl.FO2SH FISCAL WEEK 2 0

    60 TO1 . U52SH SALES WTD UNITS 5 0

    70 TO1 .VN#SH VENDOR NUMBER 6 80 GRSMG t02.b34sk-t02.a32sk 8 2

    T01.008SH STATUS CODE 1

  • 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 Report Column Formatting

    Type information, press Enter. Column headings: *NONE, aligned text lines

    Field TOl.CLSSH

    Column Spacing Column Heading Len Dee Edit

    1 CLASS 3 NUMBER

    TOl.SKUSH 1 SKU 11 NUMBER

    TOZ.ESKSK 1 SW 25 DESCRIPTION

    F3=Exit F5=Report F13=Layout Flb=Edit

    More... FlO=Process/previous F12=Cancel F18=Files 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 Report Summary Functions

    Type options, press Enter. l=Total 2=Average 3=Minirnum 4=Maximum 5=Count

    ---Options--- Field Text Len Dee

    TOl.CLSSH CLASS NUMBER 3

    TOl.SKUSH SKU NUMBER 11

    TO2.ESKSK SKU DESCRIPTION 25

    T02.B34SK PRICE / CURRENT RETAIL 7 2

    TOl.FO2SH FISCAL WEEK 2 0

    1 TOl.lJ52SH SALES WTD UNITS 5 0

    TOl.VN#SH VENDOR NUMBER 6

    GRSMG t02.b34sk-tO,2.a32sk 8 2

    Bottom

    F3=Exit F5=Report F10=Process/previous Fll=DispLay names only

    F12=Cancel F13=Layout FlEl=Files F23=Long comment

    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 Report Breaks

    Type break Level (l-6) for up to 9 field names, press Enter. (Use as many fields as needed for each break level.)

    Break Sort

    Level Prty Field 1 10 TOl.CLSSH 2 20 TOl.SKUSH

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

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

    Len Dee 3

    11 25

    7 2 2 0 5 0 6

    8 2

    Bottom F3=Exit F5=Report FlO=Process/previous Fll=Display names only

    F12=Cancel F13=Layout F18=Files F23=Long comment

    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. The Format Report Break screen will appear.

    Format Report Break

    Break level. . . . . . . . : 0

    Type choices, press Enter. (Type &field in text to have break values inserted.)

    Suppress summaries . . . . N Y=Yes, N=No

    Break text . . . . . . . . FINAL TOTALS

    Level Field 1 TOl.CLSSH 2 TOl.SKUSH

    F3=Exit FS=Report F13=Layout Fl8=Files

    FlO=Process/previous F12Xancel F23=Long comment

    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 Report Break

    Break level . . . . . . . : 1

    Type choices, press Enter. (Type &field in text to have break values inserted.)

    Skip to new page . . . . . N Y=Yes, N=No

    Suppress summaries . . . . N Y=Yes, N=No

    Break text . . . - . . - .

    Level Field 1 TOl.CLSSH 2 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 Output Type and Output Form

    Type choices, press Enter.

    Output type . . . . . . . . . . . 1 l=Display 2=Printer 3=Database file

    Form of output . . . . . . . . . . 1 l=Detail 2=Summary only

    Line wrapping . . . . . . . . . . N Y=Yes, N=No Wrapping width . . . - . . . . . Blank, l-378 Record on one page . . . . . . . N Y=Yes, N=No

    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. Press F3 to bring up the Exit this Query screen. An example of that screen follows:

    Exit this Query

    Type choices, press Enter.

    Save definition . . . Y

    Run option . . . . . . 1

    Y=Yes, N=No

    l=Run interactively 2=Run in batch 3=Do not run

    For a saved definition: Query . . . . . . . YTDSOLD Name

    Library . . . . . TRAINING Name, F4 for list

    Text . . . . . . . .

    Authority . . . . . "LIBCRTAUT *LIBCRTAUT, authorization list name, *CHANGE, *ALL, *EXCLUDE, *USE

    F4=Prompt F5=Report F14=Define the 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

    The runqry command can be run from a command line in order to either run an existing query or to just query into an existing file to look at the data. This is one way to see if a file does contain the information you need before creating a query or you can use it to just quickly view what data is in a file. Also, the runqry command can be used on a system which does not have the full IBM Query application installed.

    To use this command type runqry on the command line and press F4. Below is an example of the screen that will be displayed:

    Run Query (RUNQRY)

    Type choices, press Enter.

    Query =............ Library . . . . ., . e . . . D

    Query file: *LIBL

    Name, *NONE Name, *LIBL, *CURLIB

    File............. Library . . . . . . . . . .

    Member . . . . . . . . . . . . + for more values

    *LIBL *FIRST

    Name, *SAME Name, *RUNOPT, *LIBL, *CURLIB Name, *RUNOPT, *FIRST, *LAST

    Report output type . . . . . . . "RUNOPT "RUNOPT, *DISPLAY... Output form e . . - . (I . . . . *RUNOPT *RUNOPT, *DETAIL, *SUMMARY Record selection . . . . . . . . *NO *NO, *YES

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

    F24=More keys

    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 line and press F4. The following screen will display:

    Create Library (CRTLIB)

    Type choices, press Enter.

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

    F3=Exit F4=Prompt F5=Refresh F13=How to use this display

    trainqry Name *PROD *PROD, *TEST Library for Training Query's

    Bottom FlO=Additional parameters F?Z=Cancel F24=More keys

    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

    SKU: 04154090004 DYNAGRIP

    Class subclass --: 430 / Primary vendor --: 600004 Vendor style ----:

    SKU List cost ---: 4.50 SKU landed cost -: 4.50 Current retail --: 7.00 Original retail -: 7.09

    LOGO group ----: Ticket type --*em : 1st event --..-F--. .

    TESTING COMPANY SKU Inquiry

    DATE: 9/11/98 MENU:

    Department ---: 43 Division -----I . 4 2nd vendor ---: 3rd vendor ---: Buyer code ---: Defalt U/M ---:

    Royalty % ------------: .oo

    Gross margin % -------: 40.06 Mfg. sug. retail --we-. m .oo

    COLOR -: group SIZE -: group -m--w. SKU type . Season -------m I

    2nd event ----: 3rd 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 with Job System: S1014BSR

    Job: QPADEV0005 User: PAT Number: 327140

    Select one of the following:

    1. Display job status attributes 2. Display job definition attributes 3. Display job run attributes, if active 4. Work with spooled fites

    IO. Display job log, if active or on job queue

    11. Display call stack, if active

    12. Work with locks, if active 13. Display library list, if active

    14. Display open files, if active

    15. Display file overrides, if active

    16. Display commitment control status, if active

    More...

    Selection or command

    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 Open Files

    Job . - : QPADEVOOOS User . . : PAT Number of open data paths . . . . . . , . . . :

    Number m . I : 327140 23

    File Library AVNL2 MBS24DB KSK3L MBS24DB KSKUP MBS24DB KSKULS MBS24DB KSKULI MBS24DB KSKUL3 MBS24DB KSKUL2 MBS24DB KSKUL 1 MBS24DB KSKUL MBS24DB

    RI IQ36FM

    QDUI 132

    MBSMCOB J

    QSYS

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

    QPADEVOOOS

    QPADEVOOOS

    Scope Activation Group ACTGRPDFN 0000000002 DFTACTGRP *ACTGRPDFN 0000000002 *DFTACTGRP *ACTGRPDFN 0000000002 *DFTACTGRP *ACTGRPDFN 0000000002 DFTACTGRP *ACTGRPDFN 0000000002 DFTACTGRP *ACTGRPDFN 0000000002 DFTACTGRP *ACTGRPDFN 0000000002 DFTACTGRP *ACTGRPDFN 0000000002 *DFTACTGRP ACTGRPDFN 0000000002 *DFTACTGRP

    ACTGRPDFN 0000000002 DFTACTGRP

    *ACTGRPDFN 0000000002 DFTACTGRP

    Press Enter to continue.

    F3=Exi t 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

    AS/400 QueryIn This UnitAgendaOverviewDesigning the QueryCreating the Query

    File SelectionSpecifying How to Join Files

    Selecting and Sequencing FieldsSelecting Records

    Defining Results FieldsCreating Blank Columns within the QuerySelecting Report Summary FunctionsFormatting Report Breaks

    Exiting, Saving, and Running the QueryRunning Saved QueriesSpecial Tips for Using QueriesRUNQRY CommandCreating a Library for Your QueriesCRTLIB Command

    Finding a File While in a ProgramUsing SysRq 3

    Title: blank: