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

ABAP question..

Hello,

I have a requieremnt where I have makde data two characters. For ex: If I enter 23, the output should be 23, if I enter 2 in paramater, the output should be 02. But following code gives one digit when input is one digit.

Parameter: p_num(10) TYPE c.

Data: l_code TYPE char2.

If p_num < 99.

l_code = p_num(2).

endif.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 09, 2008 at 03:22 PM

    Hi,

    Move it to a Numc field.

    Ex.

    DATA: V_NUMC(2) TYPE N.
    DATA: V_CHAR(2) TYPE C.
    
    V_CHAR = '2'.
    V_NUMC = V_CHAR.
    V_char = V_numc.
    
    WRITE: / v_char.

    THanks

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 09, 2008 at 03:22 PM

    Hi,

    Parameter: p_num(10) TYPE c.

    Data: l_code(2) TYPE n.

    If p_num < 99.

    l_code = p_num(2).

    endif.

    write :/ l_code.

    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.