Table
» See all 4 related threads
May 11 05

Incorrect data length - CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME  

17:36 // Saurabh shrivastava

CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME method gives incorrect length. In my case, i am trying to prepare dynamic internal table for KNKA table.

For all the fields i am getting double the length

My code looks like this :

DATA : REF_TABLE_DES TYPE REF TO CL_ABAP_STRUCTDESCR. DATA :  INT_DETAILS TYPE ABAP_COMPDESCR_TAB, * Get the structure of the table.     REF_TABLE_DES ?=         CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME( DB_TABLE ).     INT_DETAILS[] = REF_TABLE_DES->COMPONENTS[].

Any suggestions/advice appreciated. Also, if there is any other way of declaring a internal table, let me know. Thanks.

 
May 11 05

Re: Incorrect data length - CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME  

18:09 // Naimesh Patel

It should be corrected by this OSS Note: [1481107 - BRF+ 702SP4: Wrong DDIC length for binded elements https://service.sap.com/sap/support/notes/1481107].

Regards,

Naimesh Patel

May 11 05

Re: Incorrect data length - CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME  

19:46 // Saurabh shrivastava

Thanks Naimesh. Unfortunately, this note is not valid for my release.

its valid for SAP_BASIS - from 701 to 702.  I am on SAP_BASIS 700.

May 11 06

Re: Incorrect data length - CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME  

09:17 // Marcin Pciak

I think that this method evaluates field based on its internal memory occupation (so the length is expressed in bytes ). If you i.e. describe SFLIGHT structure

 REF_TABLE_DES ?=  CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME( SFLIGHT ). 

You will get:

- all characters' length are doubled - this is Unicode system with encoding UTF-16 so 1 char = 2 bytes

- all INT4 data type fields get length 4, although field length (i.e. SFLIGHT-SEATSMAX_B) is 10. Internally INT4 occupies 4 bytes

- all P types fields, get length halfed (i.e. SFLIGHT-PAYMENTSUM), is of length 17 decimals 2, but internally it is 9 - this is due to simple equation 17 bdc digits (including decimals) * 0,5 byte each + 0,5 byte for sign = 9 bytes

So you get correct lengths, there are simply expressed in different unit (bytes not chars).

Regards

Marcin

May 11 06

Re: Incorrect data length - CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME  

09:31 // Muralii immadisetty

Hi,

Using the below u can create the dynamic internal table wt ever u pass that table like SFLIGHT

DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

P_TABLE LIKE DD02L-TABNAME, " SAP Tables - Table name

DY_TABLE TYPE REF TO DATA.

                              • Field symbol declaration *******************************

FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE.

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

      EXPORTING

        IT_FIELDCATALOG  = LVC1

        I_LENGTH_IN_BYTE = 'X'

      IMPORTING

        EP_TABLE         = DY_TABLE.

    ASSIGN DY_TABLE->* TO <DYN_TABLE>.

Thanks & Regards,

Muralii

May 11 06

Re: Incorrect data length - CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME  

15:51 // Tomasz Mackowski

Have you looked at output_length?

You have to downcast to cl_abap_elemdescr first:

Data: lr_elem_descr TYPE REF TO cl_abap_elemdescr. lr_elem_descr ?= component-type. WRITE lr_elem_descr->output_length.
May 11 06

Re: Incorrect data length - CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME  

16:29 // Saurabh shrivastava

Thank you all for your responses.

I guess you are correct that CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME gives us length in bytes. In other words, we can call it as Internal length. We can look at it in table DD03L-INTLEN i.e Internal Length in Bytes .

So i guess using CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME will not give us output length. Instead it will always give us Internal length which in turn will give us wring internal table when passed through following code

P_TABLE LIKE DD02L-TABNAME, " SAP Tables - Table name DY_TABLE TYPE REF TO DATA. *************** Field symbol declaration ******************************* FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE. CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE EXPORTING IT_FIELDCATALOG = LVC1 I_LENGTH_IN_BYTE = 'X' IMPORTING EP_TABLE = DY_TABLE. ASSIGN DY_TABLE->* TO <DYN_TABLE>.

So i have a workaround to declare a dynamic internal table from a database table/structure.

DATA: DY_TABLE  TYPE REF TO DATA,             DY_LINE   TYPE REF TO DATA.  DATA: P_TABLE  TYPE TABNAME FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE.   CREATE DATA DY_TABLE TYPE TABLE OF (P_TABLE).   ASSIGN DY_TABLE->* TO <DYN_TABLE>.   CREATE DATA DY_LINE LIKE LINE OF <DYN_TABLE>.   ASSIGN DY_LINE->* TO <DYN_WA>.

Thanks.

Date Views Headline Answers
11.12.2012 102 APPSEARCH Standard Report 6
30.09.2011 74 Lso - Course - Delivery Method - Location 3
24.04.2009 999 T&EM data in transparent tables 6
26.07.2007 274 TEM - Location Table and Field - Urgent please 8

Feedback