Skip to Content
author's profile photo Former Member
Former Member

regarding the printing of numeric value

data :A type i,

B type n,

C type d,

D type c.

C = '20071220'.

A = 100.

D = 'a'.

B = '20a'.

write :/'A = ', A, 'B = ', B, 'C = ', C, 'D= ', D.

the output is giving as

B=0

what is the wrong i did here

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2008 at 08:01 AM

    Hi,

    Do like this

    data :A type i,

    B(10) type n,

    C type d,

    D type c.

    C = '20071220'.

    A = 100.

    D = 'a'.

    B = '20a'.

    write :/'A = ', A, 'B = ', B, 'C = ', C, 'D= ', D.

    Regards,

    Satish

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Itz your conception that type N takes both Digits and Alphabets.

      As explained in your other thread, Type N takes only Digits. These digits are treated as Characters.

      Check this from SAP Help:
      
      Type        Explanation         SL   Initial value 
      
      C    Text (Character)        1      space 
      N    Numeric text            1      '00...0' 
      D    Date (YYYYMMDD)         8      '00000000' 
      T    Time (HHMMSS)           6      '000000' 
      X    Hexadecimal (HeX code)  1      X'00' 
      I    Integer                 4      0 
      P    Packed number           8      0 
      F    Floating point number   8      0 
      STRING Character sequence (string)  variable-length empty string 
      XSTRING Byte sequence (X string) 
      variable-length empty hexadecimal string 
      

      N Numeric text 1 '00...0'

      Regards

      Eswar

  • author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2008 at 07:54 AM

    Check the declaration:

    >B type n,

    This specifies B is of Data Type N and length 1.

    Increase the length to have more visibility.

    Say

    >B(3) type N,

    This will take Numerical characters of the value assigned and display i.e the output will be 020.

    If you need it including the alpha characters, you need to use datatype C.

    >B(3) type C

    Output will be 20a

    Regards

    Eswar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2008 at 08:05 AM

    in this code u declaring B as n data type , and Type N is a text type, not a numeric data type (although its values are strings of digits) (number string) so u must specify lenth of B as for ex.

    B(2) type n,

    or any size in place of 2, than interprter can only able to read upto 2 places . otherwise if u don't give any thing by default it will takes it's length 1 and print only last digit of string .

    thanks

    if u clear reward points.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.