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

how to concatenate a predefined-number spaces before a string?

Hi everyone,

How to concatenate some limited-number spaces before a string?

If I have: len type i,

How to concatenate the spaces whose length = len before a string?

Thanks!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Posted on Dec 23, 2008 at 10:44 AM

    HI

    Could you please elobarate your question clearly,so that some can give a proprer solution .

    Whether you mean to add some space before you actucal data in string start if so then

    v_len = 10.

    v_string = which has actual data .

    v_string1+v_len = v_string.

    Cheers

    Joginder

    Edited by: Joginder on Dec 23, 2008 11:45 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 10:46 AM

    Hi,

    Use

    DO Len times.

    str = str + ' '.

    Enddo.

    str1 = str + str1.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 10:49 AM

    hi,

    you need to use the offset for this..

    Example :

    data : len type i value 4.

    data : string type string.

    string+len = 'Test data'.

    Now the first 4 char holds the blank value.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 10:50 AM

    var = ' '

    CONCATENATE var TO String.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 10:51 AM

    do len times

    concatenate '$' str into str .

    enddo.

    REPLACE ALL OCCURRENCES OF '$' IN str WITH ` `.

    u need to append $ because concatenating blanks wont work.

    at the end u can replace $ with space.

    Edited by: kartik tarla on Dec 23, 2008 4:22 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 11:04 AM

    Hi,

    try this.

    DATA: v1 TYPE string.
    
    DO 10 TIMES.
      CONCATENATE v1 ';' into v1.
    ENDDO.
    REPLACE ALL OCCURRENCES OF ';' IN v1 WITH ` `.
    
    

    Sandipan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 11:04 AM

    Hi

    Do

    Concatenate ................. respecting blanks.

    Regards

    Aditya

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 11:18 AM

    Hi Wuyia Nata,

    try it like this:

    If you are working in ecc 6.0 or higher version, i guess below code will not work if its below ecc 6.0

    Data:
      w_string type string,
      w_lenght type i value 10.
    
    
    w_string = 'vhdskbvsdkbvdsvnsknvs'.
    
    Do w_lenght times.
    Concatenate ' ' w_string into w_string respecting blanks.
    Enddo.
    
    Write:/
      w_string.

    With luck,

    Pritam.

    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.