TechTalk: Not All MOVEs Are Valid

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Q. I just can't figure this one out. I need to place a numeric field into a numeric array in an RPG/400 program, so that each digit of the original field goes into separate elements of the numeric array. The field I'm trying to move is named MSTDLR and is defined as packed decimal, 7 digits, 2 decimals. 3 shows what I'm trying to do.

Q. I just can't figure this one out. I need to place a numeric field into a numeric array in an RPG/400 program, so that each digit of the original field goes into separate elements of the numeric array. The field I'm trying to move is named MSTDLR and is defined as packed decimal, 7 digits, 2 decimals. Figure 3 shows what I'm trying to do.

The MOVEL operation is there to turn MSTDLR into a whole number. The MOVEA operation moves the whole number into array ARD. When I try to compile this, however, the compiler produces error message QRG7105 ("DOLAR and ARD are not the same type and length"). Am I doing something wrong? Please help!

A. The MOVEA operation has some restrictions when the data being moved is numeric. One such restriction is that both Factor 2 and the Result field must have the same length. Since DOLAR has five digits and each element of ARD has only one, the compiler chokes on this MOVEA and flags it as illegal.

To accomplish what you're attempting to do, convert the numeric data temporarily to character, MOVEA it into a character array, then MOVE this array into ARD, as shown in 4. Then it will work as you wanted. In particular, notice the MOVEL operation, which both truncates MSTDLR to a whole number and converts it to character in a single stroke.

To accomplish what you're attempting to do, convert the numeric data temporarily to character, MOVEA it into a character array, then MOVE this array into ARD, as shown in Figure 4. Then it will work as you wanted. In particular, notice the MOVEL operation, which both truncates MSTDLR to a whole number and converts it to character in a single stroke.


TechTalk: Not All MOVEs Are Valid

Figure 3 Incorrect code

 Figure 3: Incorrect Code ... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 E ARD 5 1 0 * C MOVELMSTDLR DOLAR 50 C MOVEADOLAR ARD 
TechTalk: Not All MOVEs Are Valid

Figure 4 Corrected code

 Figure 4: Corrected Code ... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 E ARD 5 1 0 E ARDC 5 1 * C MOVELMSTDLR DOLARC 5 C MOVEADOLARC ARDC C MOVE ARDC ARD 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: