Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Character Size

Former Member
0 Kudos

Hi,

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

Thanks,

Smitha.

9 REPLIES 9

0 Kudos

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

0 Kudos

Hi Siva,

I tried filed-symbols. But it did'nt help me.

The requirement is:

Iam trying to output a DME file by changing the Std.Prog as per the requirement. Each record is transfred to a memory buffer which is a long string with line feed at the end of the string. I have declared the string as 100 char. Considering that we have only 50 char to ouput with a line feed at the end of 50 char. It works well, but leaving the other 50 char as spaces which I dont want to display.

I hope Iam clear in explaing you the requirement. If no please let me know.

Thanks,

Smitha.

0 Kudos

Hi Smitha,

While passing the string to the file compress the string and pass it to the file.

I think it will help you.

Reward if useful.

Sastry.

0 Kudos

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

0 Kudos

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..

0 Kudos

Hi,

Please see this link

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

I not aware of system functions...

Thanks,

Siva.

0 Kudos

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.

Former Member
0 Kudos

Solved my self!

0 Kudos

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