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

how to convert a column number(eg.127) into an excel column (eg.AA)

How do you convert a numerical number to an Excel column name in Sap, eg. 26 -> Z

I need your helps,thanks.

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 May 23, 2013 at 05:40 PM

    It was an interesting problem.

    Here is a working snippet using recursion.

    DATA gv_output TYPE string.

    PARAMETERS p_num TYPE i.

    PERFORM get_data USING p_num

    CHANGING gv_output.

    WRITE:/ gv_output.

    * FORM to determine output in a recursive manner

    FORM get_data USING pv_input TYPE i

    CHANGING cv_output TYPE string.

    DATA lv_div TYPE i.

    DATA lv_rem TYPE i.

    CHECK pv_input GT 0.

    lv_div = pv_input DIV 26.

    lv_rem = pv_input MOD 26.

    IF lv_rem IS INITIAL.

    lv_rem = 26.

    SUBTRACT 1 FROM lv_div.

    ENDIF.

    SUBTRACT 1 FROM lv_rem.

    CONCATENATE sy-abcde+lv_rem(1) cv_output INTO cv_output.

    PERFORM get_data USING lv_div

    CHANGING cv_output.

    ENDFORM. "get_data

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 23, 2013 at 02:42 PM

    Hi Arvin,

    Do you want to convert numbers to base 26?

    Eg : 27 - AA

    52 - AZ.

    Do clear the Question.

    Thanks,

    Ankit.

    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.