08-13-2010 6:51 AM
Dear Experts,
Am trying to create a Dynamic Internal Table where the length of each field is getting DOUBLED in the output.
I mean to say, for example CLIENT output length is 6 instead of 3. All fields are exactly getting doubled the length
which is causing me a trouble for the below code:
If i divide the length by 2, it works. I know its not a right way to do. please suggest whats the problem here.
DATA : xdetails TYPE abap_compdescr.
DATA : idetails TYPE abap_compdescr_tab.
DATA : idetails_tmp TYPE abap_compdescr_tab.
DATA : ref_table_des TYPE REF TO cl_abap_structdescr.
DATA : ref_table_des_tmp TYPE REF TO cl_abap_structdescr.
ref_table_des ?= cl_abap_typedescr=>describe_by_name( 'ztab' ).
refresh idetails[].
refresh ifc.
idetails[] = ref_table_des->components[].
LOOP AT idetails INTO xdetails.
CLEAR xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.----
>
xfc-decimals = xdetails-decimals.
APPEND xfc TO ifc.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
Regards,
Sampath
08-13-2010 7:01 AM
This is because your are passing the value to incorrect fiels INTLEN => Internal Length in Bytes.
Try passing the length to the fields OUTPUTLEN and DD_OUTLEN.
Edited by: Suhas Saha on Aug 13, 2010 11:37 AM
If 'ZTAB' is a DDIC structure, you can skip this lengthy process & try this code:
DATA: dy_table TYPE REF TO data.
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE.
CREATE DATA dy_table TYPE STANDARD TABLE OF ( 'ZTAB' ).
ASSIGN dy_table->* TO <dyn_table>.
BR,
Suhas
08-13-2010 7:01 AM
This is because your are passing the value to incorrect fiels INTLEN => Internal Length in Bytes.
Try passing the length to the fields OUTPUTLEN and DD_OUTLEN.
Edited by: Suhas Saha on Aug 13, 2010 11:37 AM
If 'ZTAB' is a DDIC structure, you can skip this lengthy process & try this code:
DATA: dy_table TYPE REF TO data.
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE.
CREATE DATA dy_table TYPE STANDARD TABLE OF ( 'ZTAB' ).
ASSIGN dy_table->* TO <dyn_table>.
BR,
Suhas
08-13-2010 7:21 AM
Thanks Suhas,
It didnt work the first way as you said the reason being the length when getting populated by the method into details table
is itself multiplied by 2. That was the reason i was dividing by 2.
Any idea why from the method itselt it would return doubled values?
However, the alternative simplest way you suggested to create a dynamic table helped me a lot.
Regards,
Sampath
08-13-2010 7:32 AM
>
> Any idea why from the method itselt it would return doubled values?
I remember this discussion regarding the attribute COMPONENTS of the RTTS class CL_ABAP_STRUCTDESCR. And if i remember correctly Sandra Rossi had given a good explanation. Search in SDN for the thread.
The attribute is populated by internal statement [SYSTEM-CALL |http://help.sap.com/abapdocu_70/en/ABAPSYSTEM-CALL.htm] This is calling some Kernel method to populate the COMPONENTS table.
Need to see if there are any OSS nortes addressing this issue.
BR,
Suhas