Home > AS/400 Tips > iSeries programmer tips > Six quick tips for working with DDS
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES PROGRAMMER TIPS

Six quick tips for working with DDS


Dwight Beech, Search400.com expert
09.25.2002
Rating: -4.27- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



Dwight Beech

Data description specifications (DDS) provide a powerful and convenient way to describe data attributes in file descriptions external to the application program that processes the data. People are always uncovering ways, however, for DDS do more than you thought was possible.

Drawing from his own expertise, site expert Dwight Beech offers a few DDS tips when working with logical files. They include resizing a field, renaming a function, and creating a key field for a joined logical using the SST function.

1. Resizing a field:
Have you ever been in the position where you wanted to rename a field or change the size of it for programming purposes? For example suppose you wanted to read a file that had packed fields sized 17,2 into a program that had a field size of 8,0. You can do this easily enough in your DDS file definition by building a logical file with the field a different size. The field will automatically be truncated and resized into the 8,0 field unless the field is too large fit. Then that will result in an error.

Physical File: TEST1

   A          R GLRXX                                              
  *                                                              
 A            TSTN01        17P 2       TEXT('PERIOD  1 AMOUNT') 
 A            TSTN02        17P 2       TEXT('PERIOD  2 AMOUNT') 
 A            TSTN03        17P 2       TEXT('PERIOD  3 AMOUNT') 
 A            TSTN04        17P 2       TEXT('PERIOD  4 AMOUNT')

Logical File: TEST2

   A          R GLRXX                     PFILE(TEST1)   
  *                                                    
 A            TSTN01         8P 0       
 A            TSTN02         8P 0       
 A            TSTN03         8P 0       
 A            TSTN04         8P 0      

2. RENAME function:
If you want to rename the field for RPG or CLP programming purposes, just create the field in DDS with the new name and use the RENAME function on the old field. The field can then be resized at the same time. Using the same physical file TEST1.

Logical File: TEST3

 A            R GLRBX                   PFILE(TEST1)   
   *                                                    
A            TSTN05         8P 0       RENAME(TSTN01) 
A            TSTN06         8P 0       RENAME(TSTN02) 
A            TSTN07         8P 0       RENAME(TSTN03) 
A            TSTN08         8P 0       RENAME(TSTN04)

3. Creating a key field for a joined logical using the SST function:
Another neat trick if you are building joined logical files is to use partial keys or a sub-stringed field for the join. Example: Say the secondary file has a field (CSTCTR) and you want to join it to your primary file but the key field to make the join execute doesn't exist in the primary file. The key portion is embedded within a field in the primary file (CTRACC). Use the SST function on the field containing the key data and extract what will be needed for the join (XXCC). The XXCC field is then used in the join to the secondary file CTRXRFP. The "I" field in the definition represents that it is used for input only.

 R GLRXX                       JFILE(GLPCOM CTRXRFP)     
J                         JOIN(1 2)                 
                               JFLD(XXCC CSTCTR)         
     WDCO                        RENAME(BXCO)              
     WDCOCT             I        SST(CTRACC 1 10)          
     WDEXP              I        SST(CTREXP 12 11)         
     WDACCT                      RENAME(CTRACC)            
     XXCC               I        SST(CTRACC 5 6)   

4. Concatenating fields using the CONCAT function:
Another trick for building a field that doesn't exist in your logical file is to use the CONCAT function. Example: You want to create a field FSTLST (first and last name) from 2 fields FIRST and LAST. This can be done as follows:

     FIRST    R                                            
      LAST     R                                            
   FSTLST                   CONCAT(FIRST LAST) 

5. Using the RANGE function:
In your logical file you may want to select a range of records rather than using the select function to select individual records. Example: You want only the records in your logical file where the selected field is in the range 100 and 900. This can be done as follows:

  S XXPG#                        RANGE('100' '900')   

You can also use the RANGE function on multiple ranges.

6. Using the VALUES function:
In your logical file you may want to select specific records that have certain values by using the VALUES function. Example: You want only the records in your logical file where the selected field has the values 'O', 'P', and 'E'. This can be done as follows:

  S RPTCTR                       VALUES('O     ' 'P     ' 'E     ')

-----------------------------------
About the author: Dwight is superintendent, application support, at Cameco Corp. in Saskatoon, Saskatchewan, Canada, where he manages the operation of the application support group supporting 35 business applications.

==================================
MORE INFORMATION
==================================

  • Add lots of info to your sign-on screen
    Although placing message fields on a sign-on display will allow you to modify the content displayed at sign on, needing a different message field for each line makes it irritating to work with. Fortunately, you can get the same display capability by using just a single message field.
  • Simple way to retrieve mixed-case data
    Follow this tip from site expert John Kohan to learn how to retrieve the key field and ignore the case it's currently in.
  • Physical file changes made easy
    When changing the DDS for a physical file with many logicals, Search400.com member Faithie Lewis says there's one simple way to implement the changes without going through the hassle of removing logicals, copying the file, recompiling the file empty, and mapping the data back in. Use CHGPF.


Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
iSeries ILE programming
Tracking data changes on IBM i with triggers
Introduction to SQLRPGLE on IBM i: Making a report
How to use an embedded SQL statement and display the result in a subfile
Eight steps for creating program documentation using AS/400 utilities
Searching fields for values
Searching part of a name or address in AS/400
Top 10 programmer tips YTD
How to use the binder language to manage service programs -- Part 3: Examples and pitfalls
Top 10 programmer tips of 2005
Understanding the binder language on AS/400

iSeries CL programming
A power-handling CL program for multiple IBM i servers
Taking advantage of CL advancements, starting with V5R3
Checking in on your IBM i authorization lists
Running PHP open source applications: NOBODY needs authority
Simplify the process of converting a spool file from iSeries into an Excel spreadsheet
CL program for daily backups
An automated CL method of moving a query from AS/400 to Excel
Changing user password expiration
Eight steps for creating program documentation using AS/400 utilities
DAYSPAST CLLE program for AS/400: Compares object creation date with today's date

iSeries programmer tips
A power-handling CL program for multiple IBM i servers
Enhancing RPG with external SQL stored procedures
Tracking data changes on IBM i with triggers
Introduction to SQLRPGLE on IBM i: Making a report
Implementing a browser interface in COBOL: Displaying database fields
Taking advantage of CL advancements, starting with V5R3
TAATOOL: Useful tools for programmers on IBM i
Implementing a browser interface in COBOL: Creating your graphic Web page
Implementing a browser interface in COBOL: Getting started
Making the most of RPG data handling on IBM i

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts