‎2010 Apr 27 7:38 AM
Hi,
I am getting unicode error : gt_ftp must be a character type (c.n,d,t ).
gt_ftp is a structure .
vl_len = STRLEN( gt_ftp ).
‎2010 Apr 27 7:43 AM
What vikranth said is correct ,
There is no SAP Defined variable to calculate teh length of Structure
Just check what values you require and add them.
Regards
Sas
‎2010 Apr 27 7:42 AM
Can you show us the declaration of gt_ftp ? May be you will have to use specific fields to calculate the strlen instead of the whole structure
Vikranth
‎2010 Apr 27 11:26 AM
Hi,
what is the way , which type of fields need to be considered for finding length of structure
DATA: BEGIN OF gt_ftp OCCURS 0,
kunnr LIKE kna1-kunnr,
hx01(1) TYPE x ,
name1 LIKE kna1-name1,
hx06(1) TYPE x ,
hx25(1) TYPE x ,
END OF gt_ftp .
‎2010 Apr 27 11:32 AM
Hello,
Change the structure definition as below and try
DATA: BEGIN OF gt_ftp OCCURS 0,
kunnr LIKE kna1-kunnr,
hx01(1) TYPE c ,
name1 LIKE kna1-name1,
hx06(1) TYPE c ,
hx25(1) TYPE c ,
END OF gt_ftp .
and use cl_abap_char_utilities=>horizontal_tab or the corresponding attribute the hx* fields.
After changing all the fields to Type c, use the solution suggested by Marcin. That will place the whole structure value into the string after which you can calculate the length
Vikranth
‎2010 Apr 27 12:08 PM
what is the way , which type of fields need to be considered for finding length of structure
In your case you can't check character length of the components of this structure. This is because some of them are of type x not c . So basically you need to determine the internal length of the structure (meaning in bytes not in chars ). For this you can use the following
DATA: str_bytes TYPE i.
DATA: r_compdescr TYPE REF TO cl_abap_structdescr.
FIELD-SYMBOLS: <comp> TYPE abap_compdescr.
START-OF-SELECTION.
r_compdescr ?= cl_abap_typedescr=>describe_by_data( gt_ftp ).
LOOP AT r_compdescr->components ASSIGNING <comp>.
ADD <comp>-length TO str_bytes.
ENDLOOP.
WRITE:'Structure has ', str_bytes, ' bytes'.
Regards
Marcin
‎2010 Apr 27 1:21 PM
Can we not use a DESCRIBE DISTANCE IN BYTE MODE instead ? Refer: [http://help.sap.com/abapdocu_70/en/ABAPDESCRIBE_DISTANCE.htm]
‎2010 Apr 27 1:30 PM
Sure we can, I was thinking of that initially, but the one above is just I like more as it provides additional information about our structure like components name, type etc.
Regards
Marcin
‎2010 Apr 27 7:43 AM
What vikranth said is correct ,
There is no SAP Defined variable to calculate teh length of Structure
Just check what values you require and add them.
Regards
Sas
‎2010 Apr 27 7:47 AM
Hi Ranjna,
STRLEN works only with character-type fields (C, N, D, T) and not with structure type fields. Check this link: [Finding Length of fields|;.
Instead, you could copy your structure into a STRING type variable and find the length using the STRLEN statement. Here is a short example:
concatenate gt_ftp-field1
gt_ftp-field2
gt_ftp-field3
into gv_string.
lv_length = strlen( gv_string ).
Hope this helps! Do let me know if you need anything else!!
Cheers,
Shailesh.
‎2010 Apr 27 7:53 AM
Assuming gt_ftp corresponds to a strucutre you can try this way
data: container(1000) type c.
call method CL_ABAP_CONTAINER_UTILITIES=>FILL_CONTAINER_C
exporting IM_VALUE = gt_ftp
importing EX_CONTAINER = CONTAINER
exceptions ILLEGAL_PARAMETER_TYPE = 1
others = 2.
vl_len = STRLEN( CONTAINER ).
Regards
Marcin