1,880 pts.
 Add leading zeros to numeric value in a character filed
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

Software/Hardware used:
ASKED: December 6, 2012  9:48 AM

Answer Wiki:
You can do KEY = %xlate("YourField : ' ' : '0'), then use KEY to change
Last Wiki Answer Submitted:  December 6, 2012  1:30 pm  by  CharlieBrowne   32,785 pts.
All Answer Wiki Contributors:  CharlieBrowne   32,785 pts. , RamvishakRamesh   1,880 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Why define it as 7A if all numeric digits are significant? Define it as a 7-digit zoned decimal instead of characters. — Tom

 107,735 pts.

 

display file allows field to be as right-adjust, zero-filled

 7,175 pts.

 

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.

 3,890 pts.

 

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 pts.