AS400 Mid Range/alpha to numeric

Advertisement


Question
QUESTION: does this look ok?
fdanserl  if  f   8    disk
fdanserlx o   f   8    disk
idanserl  ns  01
i          1   30nnn
i          4   8 alpha
c  01          move   *zeros  onex
c  01          move   *blanks num
c  01          eval   onex =  nnn
c  01          eval   num = %trimr(alpha)
c  01          move   num     numx
c  01          write  danselrx
c n01          seton          lr
odanserlx  d  01
o          onex          3
o          numx         z8



ANSWER: It looks generally OK to me. I'm not certain off the top of my head whether the EVAL NUM = %TRIMR(ALPHA) will produce a left-justified or right-justified result. But try it and see!

- Laird

---------- FOLLOW-UP ----------

QUESTION: i want to run a qry on a cl with record select, are you familiar with that?  and how is it done

Answer
I normally avoid the use of QRY in my software, partly because it is a 'hog' when it comes to response time, and partly because I have better control over what happens if I design a work file, then write a program to select data and create the work file records.

I know you can use the OPNQRYF command with a Query-Select statement to do record selection. The details of how to do this with a prompt screen in a CL program are beyond what is really practical to instruct by e-mail. You  have to use variables from the prompt screen with the *CAT functions to create the Query-Select statement.

Or you can create a Query definition, then call it from a CL program using the RUNQRY command.

- Laird

AS400 Mid Range

All Answers


Answers by Expert:


Ask Experts

Volunteer


Concise Systems/Laird Scranton

Expertise

General AS/400, RPG/400, SDA and CL programming questions. AS/400 performance tuning.

Experience


Past/Present clients
CB Sportswear
Coca-Cola of New York
Encore Paper Company
Golub Corporation
HBO Home Video
Imperial Pools
Kaiser Permanente of NE New York
Mallinckrodt Medical
Marigold Foods
Manpower & Associates
National Datacomputers
New York State Easter Seals Society
New York State Food Merchants Association
Pepsi-Cola Allied Bottlers
Petricca Construction
Taconic Telephone Corporation
TOMRA Recycling
Unistress Corporation

©2012 About.com, a part of The New York Times Company. All rights reserved.