You are here:

AS400 Mid Range/left adj alpha to numeric field right adj

Advertisement


Question
i want this input record ............. type 5 alpha to become
to be numeric, some records have 1, some have 11, some have 111, so a z-add does not work, i get the replacable character
msg. what is the easiest  code to make imput 5 alpha to output 5 numeric?

Answer
Here is an example of a subroutine to right-justify an alphameric field and move it to a numeric field.

- Laird

C                     MOVELALPHA     LJFLD  80
C                     EXSR @RIGHT
C                     MOVE RJFLD     NUM     50
C*******************************************************
C* SUBROUTINE RIGHT-JUSTIFIES A FIELD
C*******************************************************
CSR         @RIGHT    BEGSR
C** DEFINE FIELDS
CSR                   MOVE *BLANK    RJBLKS 80        
CSR         *LIKE     DEFN RJBLKS    LJFLD            
CSR         *LIKE     DEFN RJBLKS    RJFLD           
C** FIND END OF DATA IN FIELD TO BE RIGHT-JUSTIFIED
CSR         RJBLKS    CHEKRLJFLD     RJEND   30       
C** CALCULATE RIGHT-JUSTIFIED START-POSITION
CSR         81        SUB  RJEND     RJ      30       
C** RIGHT-JUSTIFY FIELD
CSR                   MOVE *BLANK    RJFLD
CSR         RJ        IFLT 81
CSR                   MOVE *BLANK    WK1
CSR                   MOVEALJFLD     WK1,RJ
CSR                   MOVEAWK1       RJFLD
CSR                   END
C** CLEAR FIELDS
CSR                   MOVE *BLANK    LJFLD
CSR  @RIGHZ   ENDSR

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.