Skip to Content

add charecter

Hi Guys:

I have to add one charecter inthe existing filed.

example:

data : begin of itab,

string_a(10) type c,

end of itab.

string_a = '1234567890'.

now i want to add X after 12345 it mean string_a = 12345X67890.I need exactly in 6th postion X and then modify the internal table.

Advanced Thanks

Suresh Babu Karanam

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Posted on Jan 11, 2005 at 03:00 PM

    but here string_a must be at least 11 characters.

    data:

    zi type i

    zi = strlen( string_a ).

    right = zi - 7.

    string_a7(right) = string_a7.

    string_a+6(1) = 'X'.

    -


    if it helps please give points.

    Message was edited by: Fuat Ulugay

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 11, 2005 at 03:07 PM

    now out is like string_a = 12345X7890. I am loosing actuval 6 number in the string.

    Add a comment
    10|10000 characters needed characters exceeded

    • I modified it try it again with new code.

      and tested it.

      The code below works.

      DATA:

      zi TYPE i,

      right TYPE i.

      string_a = '1234567890'.

      zi = strlen( string_a ).

      right = zi - 6.

      string_a7 = string_a6(right) .

      string_a+6(1) = 'X'.

      Message was edited by: Fuat Ulugay

  • Posted on Jan 11, 2005 at 03:19 PM

    Thanks Fuat Ulugay. You are right i have increased string length.

    loop at itab.

    REPLACE FIRST OCCURRENCE OF '6' IN itab-string_a WITH 'X6'.

    modify

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2005 at 03:22 PM

    Hi Suresh,

    Check the below code. It will give the exact result you need,

    REPORT zc1test_string .

    DATA : old_str(10) TYPE c,

    new_str(11) TYPE c.

    old_str = '1234567890'.

    • This moves 5 characters to new_str

    MOVE old_str TO new_str PERCENTAGE 50.

    *now removing the first 5 chars in old_str

    SHIFT old_str BY 5 PLACES LEFT.

    *joining them together

    CONCATENATE new_str 'X' old_str into new_str.

    write:/ new_str.

    In your program make sure the final field should be of size 11 to hold the extra value.

    Thanks and Regards,

    Kathirvel.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2005 at 03:25 PM

    Hi Suresh,

    You can use the coding below.It is an example for both string and char variables :

    DATA : lv_str TYPE string VALUE '1234567890',

    lv_char TYPE char11 VALUE '1234567890'.

    CONCATENATE lv_str+0(5)

    'X'

    lv_str+5(5)

    INTO lv_str.

    WRITE / lv_str.

    CONCATENATE lv_char+0(5)

    'X'

    lv_char+5(5)

    INTO lv_char.

    WRITE / lv_char.

    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.