Right justifying numerical input in a character

Sometimes we need to right justify a numerical input in a character field. We can use four lines in RPG/400 to do so. Assuming the length of FIELD is 8. Its value is '1234 '. And the number of '9' in the second line is the length of FIELD + 1. The final result of FIELD is ' 1234' after user press Enter.

   
C           ' '       SCAN FIELD     X       20     99 
C           9         SUB  X         Y       10        
C                     CAT  FIELD:Y   RESET   8 P       
C                     MOVE RESET     FIELD     P   

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.


This was first published in August 2001

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.