Add leading zeros to numeric value in a character filed

2,410 pts.
Tags:
AS/400
I have a display file field which is of type 7A. I am entering value as 18 to that field. Now I need to go to a file with this field as the keyfield. But in the file the value is stored as '00000018'. So if I chain with ' 18' it says value is not in file. Please help
ASKED: December 6, 2012  9:48 AM

Answer Wiki

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

You can do KEY = %xlate(“YourField : ‘ ‘ : ’0′), then use KEY to change

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.

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
  • TomLiotta
    Why define it as 7A if all numeric digits are significant? Define it as a 7-digit zoned decimal instead of characters. -- Tom
    125,585 pointsBadges:
    report
  • BigKat
    display file allows field to be as right-adjust, zero-filled
    7,565 pointsBadges:
    report
  • ToddN2000
    Looks like you display has it as alpha as well as your database file. If you do not want the leading zeros in the alpha field use the CHECK(RB) in the dspf. If you want to preserve the leading zeros the  use CHECK(RZ). Then you just match your key field to the format you select.
    6,360 pointsBadges:
    report
  • harith
    step1: Move the screen field(lets assume Dsvar (7A)) to standalone Field (lets               assume Wkvar (7s0))          Ex: Wkvar = %char(Dsvar);   // Wkvar = 0000080Step2: Move the standalone Field to Screen field using Editc and chain to file         Ex:  Dsvar  = %EditC(Wkvar : 'X');  //Dsvar ='0000080' 
    170 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