RPG Move command

20 pts.
Tags:
AS/400
RPG
RPGLE
DDEC1 S 15p 5 INZ(23.345)
DDEC2 S 15p 5

* MAIN ROUTINE

C MOVE 46.2 DEC2

Result :-

DEC1 = 0000000023.34500

DEC2 = 0000000000.00462
When INZ used to move data it moves the data with correct base and decimal positions the same when done with MOVE OPCODE moves all data in decimal places (right justified). Is this expected?


Software/Hardware used:
AS400
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

INZ initializes a variable, it intelligently move values according to data types. Secondly I have seen Z-ADD or ADD to move numeric values in numeric variables rather then just MOVE. MOVE is more suitable to move character data. 

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • philpl1jb

    The answer .. do not use MOVE in RPGLE/RPG IV..

     Use EVAL

    C     EVAL   DEC2 = 46.2


    54,090 pointsBadges:
    report
  • philpl1jb
    Basically the Move command converts input to the receiver field type. Move right justifies the data. Move doesn't clear entries to the left of the data. There was lots of move and movel magic but none of it is necessary to program in RPGLE and most of it is a bad idea because it might confuse maintenance programmers.
    54,090 pointsBadges:
    report
  • ToddN2000
    MOVE was an old school way of moving data from a field into another with a different type. Think I last saw it in RPG III. Sometimes numeric data was stored in an alpha field (don't know why). This opcode gave you a way to put it into a numeric field for calculations. It was messy and risky, sometimes you would get decimal data errors when moving fields. In my opinion this was an easy way to compensate bad database design.
    133,645 pointsBadges:
    report
  • yvaditya
    Thank you all for your valuable comments and explanations!

    20 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: