Skip to Content
avatar image
Former Member

Dynamic Character Size

Hi,

Can we assign the size of the character field dynamically at run time?

Thanks,

Smitha.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Oct 07, 2007 at 06:23 AM

    Yes.

    Using field symbol you can achieve this.

    EX:

    FIELD-SYMBOLS: <l_field> TYPE ANY.

    <l_field> = <Your dynamic value>.

    please reward if this is useful.

    Regards,

    Siva

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 07, 2007 at 08:35 AM

    Hi,

    I think you have declared like

    DATA : l_text(100) TYPE C.

    declare as a string like

    Data : l_text TYPE STRING.

    if you store l_text = ' Test '.

    the l_text will hold 'Test' only. the traling space will be eliminated.

    Reward if this is useful.

    regards,

    Siva

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Siva,

      Thanks for the response and was close to the solution and rewarded 6 points too..

      Unfortunately STRING is not supported when Iam storing the data in buffer.

      It gives SY-SUBRC as 16. Any suggestion why does it do like that? Here is the code that fails. Here (buffer) is the place where I store the STRING as you said:

      It was working for CHAR type. I donno why it fails for STRING. Can you throw some light on what is 'C_RSTS_WRITE' and how buffer works????

      ****************************************************************************

      FORM temse_schreiben USING value(buffer).

      DATA: _rc(5),

      _errmsg(100).

      CALL 'C_RSTS_WRITE'

      ID 'HANDLE' FIELD hlp_handle

      ID 'BUFF' FIELD buffer

      ID 'RC' FIELD _rc

      ID 'ERRMSG' FIELD errmsg. "#EC CICCALL

      IF sy-subrc NE 0. "Fehler beim Schreiben

      IF sy-batch EQ space.

      MESSAGE a229.

      ELSE.

      MESSAGE s229.

      STOP.

      ENDIF.

      ENDIF.

      ENDFORM. "TEMSE_SCHREIBEN

      ****************************************************************************

      Smitha..

  • avatar image
    Former Member
    Oct 07, 2007 at 03:14 PM

    Hi,

    Please see this link

    info-regarding-a-system-function

    here you question what is 'C_RSTS_WRITE'??? answered.

    I not aware of system functions...

    Thanks,

    Siva.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      Iam still confused.

      Is that the (buffer) parameter always expects CHAR type? If not why it fails for STRING format. Can anyone please explain?

      Thanks,

      Smitha.

  • avatar image
    Former Member
    Oct 23, 2007 at 02:15 AM

    Solved my self!

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Smitha,

      Can you share with me how you solved?

      I think I am having same problem. If my datatype is char40 and I am passing 'Test', then 'Test' (and then 34 spaces) and then next comma (delimiter) is appearing.

      Thanks,

      Ashish