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: 

Creating character variable with dynamic length

Former Member
0 Kudos

Hello Experts,

I need to send contents of an internal table via FTP in character mode,

the entire contents of a internal table is concatenated in a string(v_string) which needs to be moved to the character variable of same size say l_count = strlen( v_string ).

can anyone help me to define the character variable say of length l_count.

I have already tried creating a dynamic character variable using CREATE DATA.

eg DATA: dref TYPE REF TO DATA.

CREATE DATA dref TYPE c LENGTH l_count.

but this is not working.

Any response will be helpful.

Thanks & Regards,

Sumukh Kapoor.

2 REPLIES 2

MarcinPciak
Active Contributor
0 Kudos

This is correct approach to create dynamic char variable of string length. For proof execute the below


DATA: r_cdata TYPE REF TO data,
      l_len TYPE i,
      l_string TYPE string.

l_string = 'asdfghjklz'.
l_len = STRLEN( l_string ).
WRITE: 'String lenght', l_len.

CREATE DATA r_cdata TYPE c LENGTH l_len.
FIELD-SYMBOLS <cdata> TYPE ANY.
ASSIGN r_cdata->* TO <cdata>.

WRITE: / 'Character length:', l_len.

Anyhow I am curious why you need that in char variable. Usually string should be converted to table string, which can be achieved by SCMS_STRING_TO_FTEXT . Then you can pass such table further.

Regards

Marcin

0 Kudos

Hi Marcin,

Thanks for your response,

Reason i need character variable of dynamic length is because the requirement is to send data to client's Windows terminal . We already have FTP code in place and suddenly client has asked to send us data of an internal table in a single line.

I have concatenated the entire table into a string and then thought of moving the entire data from string to that character.. as the size in character goes beyond 60000 characters in many cases....

It seems this is not possible as the string cannot be converted to the data type of variable newly declared.

anyways your input was of great help.

Thanks & Regards,

Sumukh Kapoor.

Edited by: Sumukh Kapoor on Jul 26, 2010 7:56 AM