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

finding length of variable at run time

Good Morning to all Guru's,

can anybody explains me how i can find out the total length of one field from the internal table at run time?

example.

i wanted to some thing like this.

TYPES:BEGIN OF text12,

text1 TYPE string,

num(4) TYPE n,

calc TYPE i,

off TYPE i,

off1 TYPE i,

END OF text12.

DATA:wa TYPE text12.

DATA:itab TYPE TABLE OF text12.

MOVE 'i know you know' TO wa-text1.

MOVE 1234 TO wa-num.

MOVE 5678 TO wa-calc.

APPEND wa TO itab.

LOOP AT itab INTO wa.

FIND 'you' IN wa-text1 MATCH OFFSET wa-off.

  • FIND (wa-num) MATCH OFFSET wa-off1 . "here i am strucked

SHIFT wa-text1 BY wa-off PLACES.

SHIFT wa-num BY 2 PLACES.

SHIFT wa-num BY wa-off1 PLACES.

WRITE:wa-text1,wa-num,wa-calc.

ENDLOOP.

Please help me out.

Thanks

Priyalatha

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 06:49 AM

    hi,

    Use DESCRIBE FIELD statement.

    Regards

    Gagan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 06:50 AM

    Hi,

    Use STRLEN() to find total data length of a field.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 07:03 AM

    Hi

    use strlen(fieldname) it will give you the length.

    you can also use describe fieldname for that just pass the itab field to a temp variable and say DESCRIBE on that

    reward if helpful

    vivekanand

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 07:13 AM

    Hi Priya,

    Try This code If it suffices ur requirement. Award Points if useful.

    TYPES:BEGIN OF text12,

    text1 TYPE string,

    num(4) TYPE n,

    calc TYPE i,

    off TYPE i,

    off1 TYPE i,

    END OF text12.

    DATA : l(5) TYPE n.

    DATA : t(5).

    DATA:wa TYPE text12.

    DATA:itab TYPE TABLE OF text12.

    MOVE 'i know you know' TO wa-text1.

    MOVE 1234 TO wa-num.

    MOVE 5678 TO wa-calc.

    APPEND wa TO itab.

    LOOP AT itab INTO wa.

    FIND 'you' IN wa-text1 MATCH OFFSET wa-off.

    FIND wa-num IN wa-num MATCH LENGTH l.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

    EXPORTING

    input = l

    IMPORTING

    output = l.

    FIND l IN wa-num MATCH OFFSET wa-off1.

    SHIFT wa-text1 BY wa-off PLACES.

    SHIFT wa-num BY 2 PLACES.

    SHIFT wa-num BY wa-off1 PLACES.

    WRITE:wa-text1,wa-num,wa-calc.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 08:42 AM

    hi priya

    try like this

    TYPES:BEGIN OF text12,

    text1 TYPE string,

    num(4) TYPE n,

    calc TYPE i,

    off TYPE i,

    off1 TYPE i,

    name type string,

    name1 type string,

    END OF text12.

    DATA:wa TYPE text12.

    DATA:itab TYPE TABLE OF text12.

    data: len type i,

    num type i.

    MOVE 'i know you know' TO wa-text1.

    len = strlen( wa-text1 ).

    num = 0.

    do len times .

    num = num + 1 .

    *MOVE wa-text1(num) TO name.

    move wa-text1(num) to wa-name .

    enddo.

    MOVE 5678 TO wa-calc.

    APPEND wa TO itab.

    LOOP AT itab INTO wa.

    FIND 'you' IN wa-text1 MATCH OFFSET wa-off.

    • FIND (wa-num) MATCH OFFSET wa-off1 . "here i am strucked

    SHIFT wa-text1 BY wa-off PLACES.

    SHIFT wa-num BY 2 PLACES.

    SHIFT wa-num BY wa-off1 PLACES.

    WRITE:wa-name ,wa-num,wa-calc.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 08:48 AM

    LOOP AT itab INTO wa.

    FIND 'you' IN wa-text1 MATCH OFFSET wa-off.

    • FIND (wa-num) MATCH OFFSET wa-off1 . "here i am strucked

    SHIFT wa-text1 BY wa-off PLACES.

    SHIFT wa-num BY 2 PLACES.

    SHIFT wa-num BY wa-off1 PLACES.

    WRITE:wa-name ,wa-num,wa-calc.

    ENDLOOP.

    in this wa-off is i so change the off type is c

    then its work fine.

    regard

    kk.

    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.