Results 1 to 7 of 7

Thread: Decimal to CHAR

  1. #1
    Code400 Newbie
    Join Date
    May 2007
    Location
    India
    Posts
    20
    Rep Power
    0

    Decimal to CHAR

    hi all,

    i need to convert a decimal field to a char field..

    here is the need for that.

    i am having a PF named PF01 and FLD1 is one of the field having field attribute of 5P 0. i want to convert the datas stored in the FLD1 of PF01 to the table TAB01 which is having a field FLD2 with attribute of char 10 not null with default.

    -------------------------------------------------
    PF's Desired o/p of o/p of
    DATA Output using using
    (5P 0) CHAR 7 DIGITS CHAR
    -------------------------------------------------
    -100.00 -100.00 10000 -100.00
    100.00 100.00 10000 100.00*
    20.00 020.00 02000 20.00**
    3.00 003.00 00300 3.00***
    0.40 000.40 00040 .40****
    0.05 000.05 00005 .50****
    ---------------------------------------------------

    where * indicates blanks.

    is there is any way simple way to get the desired output?

    thanks in advance..

  2. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Posts
    1,000,000
     

  3. #2
    Code400 Newbie
    Join Date
    May 2007
    Location
    India
    Posts
    20
    Rep Power
    0

    Re: Decimal to CHAR

    sorry to post the table as a text there..

    here is the deatailed one..

    Code:
    -------------------------------------------------
       PF           Desired    o/p of     o/p of
     DATA        OUTPUT     using     using
     (5,2)             10 A     DIGITS    CHAR  
    -------------------------------------------------
    -100.00	  -100.00    10000    -100.00
     100.00	   100.00    10000    100.00*
       20.00	   020.00    02000    20.00**
         3.00	   003.00    00300    3.00***
         0.40	   000.40    00040    .40****
         0.05	   000.05    00005    .50****
    --------------------------------------------------
    thanks

  4. #3
    Analyst Zdenko's Avatar
    Join Date
    Jun 2005
    Location
    Ziri, Slovenia
    Age
    57
    Posts
    195
    Rep Power
    1174

    Re: Decimal to CHAR

    Hi

    Maybe this will help you. Try it.

    Code:
    DnNum             S              5  2 inz(-,20)                 
                                                                    
    DcNew             S             10                              
                                                                    
    C                   EVAL      cNew = %TRIM(%EDITC(nNum:'O'))
    For different editing, yust change edit code in apostrophes
    Last edited by Zdenko; July 12th, 2007 at 04:29 AM.
    LP Zdenko

  5. #4
    Moderator littlepd's Avatar
    Join Date
    Mar 2005
    Location
    Lewisville, TX
    Age
    50
    Posts
    1,111
    Rep Power
    3349

    Re: Decimal to CHAR

    Quote Originally Posted by Zdenko View Post
    For different editing, yust change edit code in apostrophes
    And if you want it right-justified, as your example shows, use EVALR instead of EVAL.
    "Time passes, but sometimes it beats the <crap> out of you as it goes."

  6. #5
    Code400 Newbie
    Join Date
    May 2007
    Location
    India
    Posts
    20
    Rep Power
    0

    Re: Decimal to CHAR

    Hi Zdenko & littlepd.,

    Thank you for your reply to my query. And i know that with BIF %editc we can do that in RPG ILE.. but i need a sql statement to excute the same..

    I need to run a sql statement that converts a numeric field in a PF to a Character field as like in the desire format specified in my previous post..

  7. #6
    Analyst
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    1,590
    Rep Power
    9580

    Re: Decimal to CHAR

    Hi,

    if you need it in SQL, its a little more trickier:
    Assumed you want to right adjust your converted numeric value into a 15A column, you may use the following SQL-Statement:

    PHP Code:
    select Space(15 Length(RTrim(Char(MyNum)))) concat Char(MyNum) as RightAdj
    From MyTable 
    Birgitta

  8. #7
    Code400 Newbie
    Join Date
    May 2007
    Location
    India
    Posts
    20
    Rep Power
    0

    Re: Decimal to CHAR

    hi B.Hauser,

    Thanks a lot.. it works.. you are a gein.. man..

  9. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Posts
    1,000,000
     

Facebook Comments


Similar Threads

  1. Decimal point
    By casporov in forum RPG/RPGLE
    Replies: 10
    Last Post: June 15th, 2007, 01:54 AM
  2. Store procedure keeping lock on PF
    By Devarshi in forum SQL
    Replies: 25
    Last Post: March 10th, 2007, 12:52 AM
  3. problem char to decimal
    By dmredd in forum RPG/RPGLE
    Replies: 3
    Last Post: November 7th, 2006, 11:38 AM
  4. Replies: 1
    Last Post: September 16th, 2005, 04:36 AM
  5. Replies: 6
    Last Post: October 1st, 2004, 08:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •