Trimming leading zeros in as/400

635 pts.
Tags:
AS/400 Fields
OS/400
RPG Code
Hi, I have a character input parameter of length 8. I have a customer number which may vary according to a query that user enters. This customer number is searched in an input file where the key field is numeric. I want to change this input parameter to numeric without any trailing zeros/blanks. Anyone who can shed some light on this. I am doing the coding on RPG-3. Thanks, Siddharth

Software/Hardware used:
os400
ASKED: June 15, 2010  8:17 AM
UPDATED: June 18, 2010  1:38 AM

Answer Wiki

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

Hi,

Please comfirm me what is the length your input numoric field?

Venky.

Discuss This Question: 10  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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Teandy
    Look at the %EDITC BIF. You said that you are using RPGIII but did not say what version of the OS you are using so, I don't know if the BIF is available to you. See example below. NUMBER_OF_COPIES = %TRIM(%EDITC(SCRCOPIES:'Z'));
    5,860 pointsBadges:
    report
  • TomLiotta
    I want to change this input parameter to numeric without any trailing zeros/blanks. Why? Do you really want a numeric field? Or do you only want to restrict the value to include digits? As a numeric field, it will always have eight digits. The value will be right-justified and leading zeros will be supplied on the left. It will never be any length other than eight digits. There won't be any blanks in the field when it is sent to your program. But a character field can have less than eight characters and the value will be left justified. You can restrict what can be typed into the field by specifying a keyboard shift of 'D' so that only digits may be entered. Tom
    125,585 pointsBadges:
    report
  • Sangay
    hi, my input length is 8 and the parameter is character. Like i said that i want to use this as key to a file that has a key field of numeric field of length 8. Before posting this answer i have come up with the solution which according to me is running completely fine. //Free C MOVE PADDNO WADDNO 80 (Parameter field moved to numeric field) C MOVE WADDNO WADNO1 168 (numeric value moved to packed field of lenght 16 and decimal points 8) C ' ' CHEKRPADDNO POS 10 (scan the last position for blanks and store the value is POS) C DO POS C MULT 10 WADNO1 C ENDDO C Z-ADDWADNO1 WADNO2 80 (the value is right justified) //Free Please let me know if anyone have any doubts on this, Siddharth
    635 pointsBadges:
    report
  • Splat
    I have to wonder why you're putting in such involved code when you could either do as Tom suggested and change the input character field shift attribute or change the input field to numeric. The code obviously works, but it's chewing up resource to no particular purpose. If you insist on converting a character input to numeric in your program, the following has the advantage of being a bit more straightforward:
    Monitor;                                                 
     number = %dec(character): 81: 0);
     On-error;                                               
      Clear number;                                          
    EndMon;                                                  
    6,255 pointsBadges:
    report
  • TomLiotta
    my input length is 8 and the parameter is character. Like i said that i want to use this as key to a file that has a key field of numeric field of length 8. That helps to clarify your situation. It doesn't fit completely with your original question, but that's probably because of misinterpretation by me. At the moment, I still don't see why you don't simply make the input parameter numeric instead of character. I don't yet see why the input parameter is character in the first place. That just opens extra chances for problems. Make it numeric at the beginning and skip all of the potential problems. Tom
    125,585 pointsBadges:
    report
  • Sangay
    thank you all but what i am using is RPGIII not ROG/ILE. As per my understanding there are not BIF as %DEC in RPGIII....please let me know if i am in correct.. Siddharth
    635 pointsBadges:
    report
  • Splat
    Siddharth, you're correct in that BIFs aren't available in RPGIII. Thing is, Tom's suggestion about changing the display file shift attribute is not dependent on the version of the programming language and has the advantage of being the simplest approach. FYI, the code I included had mistake. It should have read:
    Monitor;
     number = %dec(character): 8: 0);
     On-error;
      Clear number;
    EndMon;     
    
    6,255 pointsBadges:
    report
  • Sangay
    ok...seems like i am not clear somewhere......i saw that we can change the input parameter as numeric. But i believe that the parameter is passed as character. I have one more doubt. is anybody aware how to handle more than 9999 records in subfile in JD edwards....i know there is some catch but i am not able to figure it. Please any suggestion would be appreciated. Thanks, Siddharth
    635 pointsBadges:
    report
  • TomLiotta
    seems like i am not clear somewhere…… It is just as likely that we are not clear or we are misunderstanding. What sends the parameter to the program? Is there any chance of changing it to send it as a numeric value? At first, the impression was that the value was input through a display file as part of a request. That no longer seems to be the case. If it must be numeric, can you change the name of your RPG III program? You could create a small RPG IV program that accepts a character parameter and converts it to numeric. It would then call your re-named RPG III program with the new numeric value. You already know one way to convert it to numeric in RPG III. I would do it differently, but your way works. If it works, you might as well use it. Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    how to handle more than 9999 records in subfile You can't handle more than 9999 records in a subfile. Period. That's all there is to it. The alternative is called a 'page-at-a-time' subfile. You define the subfile to handle exactly as many rows will fit on a single page. Whenever the user scrolls up or down, you load the next (or previous) group of records into the subfile and display the page again. You should never load more than a couple hundred or so records into a subfile. There is no reason to load more than that because no one will want to scroll through that many screens. Tom
    125,585 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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following