Skip to Content
avatar image
Former Member

Replace Comma with Space Not Working

Any idea why the following code prints "SAPInc" on my system? I was expecting "SAP Inc".

Thanks for any help.

REPORT zz_temp.

DATA: l_v_char2(30)  TYPE c VALUE 'SAP,Inc'.

REPLACE FIRST OCCURRENCE OF ',' in l_v_char2 with space.

WRITE: / l_v_char2.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Nov 05, 2007 at 07:22 PM

    Jerry,

    Use this

    REPORT zz_temp.
    
    DATA: l_v_char2(30)  TYPE c VALUE 'SAP,Inc'.
    
    TRANSLATE l_v_char2 USING ', '.
    
    
    WRITE: / l_v_char2.

    Cheers

    Aneesh.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 05, 2007 at 07:27 PM

    Hi,

    Can you try with LENGTH len addition

    REPLACE FIRST OCCURRENCE OF ',' in l_v_char2 with space LENGTH 1.

    As per SAP REPLACE is Obsolete in laltest version

    http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb33cc358411d1829f0000e829fbfe/content.htm

    Regards,

    Atish

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 05, 2007 at 07:49 PM

    Hi,

    Just use TRANSLATE statement instead.

    DATA: L_V_CHAR2(30)  TYPE C VALUE 'SAP,Inc'.
                                                                            
    TRANSLATE L_V_CHAR2 USING ', '.
                                                                            
    WRITE: / L_V_CHAR2.
    

    Regards,

    Ferry Lianto

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 05, 2007 at 07:52 PM

    Check below code. it is printing as you need.

    REPORT zz_temp.

    DATA: l_v_char2(30) TYPE c VALUE 'SAP,Inc'.

    replace ',' with space into l_v_char2.

    WRITE: / l_v_char2.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 05, 2007 at 07:20 PM

    There should be a space after comma.

    DATA: l_v_char2(30) TYPE c VALUE 'SAP, Inc'.

    Thanks,

    Srinivas

    Add comment
    10|10000 characters needed characters exceeded