Cl_abap_typedescr= describe_by_data
We've just upgraded from 4.6 to ECC 6.0 and found that the result from cl_abap_typedescr=>describe_by_data differs.
In 4.6 the result in field ABSOLUTE_NAME referes to the definition in the main program. In 6.0 we get the definition from the type-pool in which the type is created. Does anyone know of a way to get the 4.6 type of result in ECC 6.0
Thanks in advance,
Arthur
We've just upgraded from 4.6 to ECC 6.0 and found that the result from cl_abap_typedescr=>describe_by_data differs.
In 4.6 the result in field ABSOLUTE_NAME referes to the definition in the main program. In 6.0 we get the definition from the type-pool in which the type is created. Does anyone know of a way to get the 4.6 type of result in ECC 6.0
Thanks in advance,
Arthur
Similar Messages
-
Cl_abap_typedescr= describe_by_data( gt_table )
Afternoon all
I am using cl_abap_typedescr=>describe_by_data( <gt_table> ) to retrieve the fieldlist of my dynamically created ALV fieldcatalog. However, I have just switched to using some fields that are of type INT and now the method ignores them. Is this correct??? Is there another method that I should be using? I am on 46B.
Cheers
IanHere is a sample program which has 10 INT4 fields, works good for me.
report zrich_0002
no standard page heading.
type-pools: slis.
type-pools: abap.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: alv_fldcat type slis_t_fieldcat_alv,
it_fldcat type lvc_t_fcat.
selection-screen begin of block b1 with frame title text-001.
parameters: p_check type c.
selection-screen end of block b1.
start-of-selection.
perform build_dyn_itab.
perform build_report.
data : it_details type abap_compdescr_tab.
data : ref_descr type ref to cl_abap_structdescr.
ref_descr ?= cl_abap_typedescr=>describe_by_data( <dyn_wa> ).
it_details[] = ref_descr->components[].
* Write out data from table.
loop at <dyn_table> into <dyn_wa>.
do.
assign component sy-index of structure <dyn_wa> to <dyn_field>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <dyn_field>.
else.
write: <dyn_field>.
endif.
enddo.
endloop.
* Build_dyn_itab
form build_dyn_itab.
data: index(3) type c.
data: new_table type ref to data,
new_line type ref to data,
wa_it_fldcat type lvc_s_fcat.
* Create fields
clear index.
do 10 times.
index = sy-index.
clear wa_it_fldcat.
concatenate 'Field' index into
wa_it_fldcat-fieldname .
condense wa_it_fldcat-fieldname no-gaps.
wa_it_fldcat-datatype = 'INT4'.
wa_it_fldcat-intlen = 5.
append wa_it_fldcat to it_fldcat .
enddo.
* Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table.
assign new_table->* to <dyn_table>.
* Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.
endform.
* Form build_report
form build_report.
data: fieldname(20) type c.
data: fieldvalue(5) type c.
data: index(3) type c.
field-symbols: <fs1>.
do 10 times.
index = sy-index.
* Set up fieldname
concatenate 'FIELD' index into
fieldname .
condense fieldname no-gaps.
* Set up fieldvalue
fieldvalue = index.
condense fieldvalue no-gaps.
assign component fieldname of structure <dyn_wa> to <fs1>.
<fs1> = fieldvalue.
enddo.
* Append to the dynamic internal table
append <dyn_wa> to <dyn_table>.
endform.
Regards,
Rich Heilman -
Hi,
I have written the code as follows to get the components of the file uploaded.But it goes for dump at the statement written at subject line: And it says " However, the current content of the source variable does not fit into
the target variable." please help!!!
TYPES: BEGIN OF ttab_type,
rec(1000) TYPE c,
END OF ttab_type.
DATA:gt_tab TYPE TABLE OF ttab_type.
DATA: l_descr_ref TYPE REF TO cl_abap_structdescr,
g_line TYPE string,
gt_field TYPE crmt_mktimex_field_tab.
DATA: lt_table TYPE REF TO data,
lt_line TYPE REF TO data,
ls_xfc TYPE lvc_s_fcat,
ls_ifc TYPE lvc_t_fcat,
lt_details TYPE abap_compdescr_tab,
lw_details TYPE abap_compdescr.
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa>,
<dyn_field>.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = pfile1
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = gt_tab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
EXIT.
ENDIF.
l_descr_ref ?=
cl_abap_typedescr=>describe_by_data( gt_tab ).
lt_details[] = l_descr_ref->components[].
Edited by: Ginger on Jul 3, 2009 1:18 AMYa...as rightly said by Vamsi...
change your declaration as
l_descr_ref TYPE REF TO cl_abap_tabledescr,
It will work....and for your information you can also use the below codes for getting components..
DATA: lv_ref_table TYPE REF TO cl_abap_tabledescr,
lv_ref_struct TYPE REF TO cl_abap_structdescr,
lv_ref_table ?= cl_abap_tabledescr=>describe_by_data( et_data ).
lv_ref_struct ?= lv_ref_table->get_table_line_type( ).
lt_details[] = lv_ref_struct->components. -
CL_ABAP_TYPEDESCR - DESCRIBE_BY_DATA field length is doubled
I have a custom program developed on Non Unicode system, that is using CL_ABAP_TYPEDESCR -> DESCRIBE_BY_DATA to get field lengths of the fields in a structure. The code works perfectly file on Non Unicode system where it is developed, However when the same code is imported on a UNICODE system the field lengths of the fields in the same structure are exactly doubled. Anybody has any idea, why this may be happening?
> However when the same code is imported on a UNICODE system the field lengths of the fields in the same structure are exactly doubled. Anybody has any idea, why this may be happening?
Yes - because Unicode uses two bytes to represent ONE character.
Markus -
Dump at cl_abap_typedescr= describe_by_data
Hi ,
My code is as follows:
l_descr_ref ?= cl_abap_typedescr=>describe_by_data( gt_fldname ).
BREAK-POINT.
CLEAR : l_counter.
LOOP AT l_descr_ref->components[] ASSIGNING <lfs_comp_wa>.
l_counter = l_counter + 1.
ASSIGN COMPONENT l_counter OF STRUCTURE gt_fldname TO <lfs_comp>.
<lfs_comp> = <lfs_comp_wa>-name.
ENDLOOP.
But it goes for dump at l_descr_ref ?= cl_abap_typedescr=>describe_by_data( gt_fldname ).Can anyone tell why?Hi My code is as follows:
DATA : l_descr_ref TYPE REF TO cl_abap_structdescr,
l_counter TYPE sytabix.
FIELD-SYMBOLS:
<lfs_comp_wa> TYPE abap_compdescr,
<lfs_comp> TYPE ANY.
l_descr_ref ?= cl_abap_typedescr=>describe_by_data( gt_fldname ).
CLEAR : l_counter.
LOOP AT l_descr_ref->components[] ASSIGNING <lfs_comp_wa>.
l_counter = l_counter + 1.
ASSIGN COMPONENT l_counter OF STRUCTURE gt_fldname TO <lfs_comp>.
<lfs_comp> = <lfs_comp_wa>-name.
ENDLOOP.
And if I change the type, then it says there is no components[].
Edited by: Jjammy on Jul 14, 2009 3:24 PM -
Class CL_ABAP_TYPEDESCR's method DESCRIBE_BY_DATA
Hello!
How can I call CL_ABAP_TYPEDESCR's Method DESCRIBE_BY_DATA
with the CALL command ?
Many thanks in advance for your kindly efforts.
Reagards
IlhanHi Ilhan,
In the abap editor, place the cursor where you want to put the CALL.
1->click the "Pattern" button (CTRL F6)
2->choose the radio button "ABAP Object patterns", Click Enter
3->in then next popup, choose the first radio button "Call Method"
4->Enter "CL_ABAP_TYPEDESCR" in the class name field
5->Enter "DESCRIBE_BY_DATA" in the method field, click Enter
you have the pattern in the editor
OR
you may copy the following code, and pass the parameters
data: l_describe TYPE REF TO cl_abap_typedescr.
field-symbols: <field>.
data: field_name(15).
ASSIGN TABLE FIELD (field_name) TO <field>
call method cl_abap_typedescr=>describe_by_data
exporting
p_data = <field>
receiving
p_descr_ref = l_describe
Or Simply
ASSIGN TABLE FIELD (field_name) TO <field>.
l_describe = cl_abap_typedescr=>describe_by_data( <field> ).
Hope this helps,
Sajan Joseph. -
CL_ABAP_TYPEDESCR does not return integer or decimal field
Dear All,
I have an internal table for which I want to get dynamically list of fields.
I use class CL_ABAP_TYPEDESCR and method DESCRIBE_BY_DATA.
The list of field is then placed in table CL_ABAP_TYPEDESCR->KEY. The problem
is that fields with integer type (FIELD FACTOR) are not listed there. What do I do wrong?
TYPES: BEGIN OF t_table,
name(20) TYPE C,
period(10) TYPE C,
factor TYPE I,
END OF t_table.
DATA: it_table TYPE STANDARD TABLE OF t_table.
DATA: wa_table TYPE t_table.
wa_table-name = 'Brown'. wa_table-period = '2010'. wa_table-factor = 100. APPEND wa_table TO it_table.
wa_table-name = 'Brown'. wa_table-period = '2011'. wa_table-factor = 200. APPEND wa_table TO it_table.
wa_table-name = 'Fox'. wa_table-period = '2010'. wa_table-factor = 50. APPEND wa_table TO it_table.
wa_table-name = 'Fox'. wa_table-period = '2010'. wa_table-factor = 900. APPEND wa_table TO it_table.
TYPE-POOLS: ABAP.
DATA: L_REF TYPE REF TO CL_ABAP_TABLEDESCR.
l_ref ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( it_table ).
* TABLE l_ref->key DOES NOT SHOW FIELD "FACTOR" (TYPE I)....
FIELD-SYMBOLS: <KEY_COMP_WA> TYPE ABAP_KEYDESCR.
LOOP AT l_ref->key ASSIGNING <KEY_COMP_WA>.
WRITE:/ <KEY_COMP_WA>-NAME.
ENDLOOP.
Best regards,
MarkHi Mark,
if you want the fields you should consider attribute components, compare this snippet getting the field names of any structure or table (from the times when I still used FORM routines)
FORM getfields
USING px_data TYPE any
CHANGING pt_fields TYPE table.
DATA:
lt_comp TYPE abap_compdescr_tab,
lr_dat TYPE REF TO data,
** lv_kind TYPE abap_typecategory,
lr_typedescr TYPE REF TO cl_abap_typedescr,
** lr_tabledescr TYPE REF TO cl_abap_tabledescr,
lr_structdescr TYPE REF TO cl_abap_structdescr.
FIELD-SYMBOLS:
<fs> TYPE ANY,
<ft> TYPE ANY TABLE,
<comp> TYPE LINE OF abap_compdescr_tab.
lr_typedescr ?= cl_abap_typedescr=>describe_by_data( px_data ).
CASE lr_typedescr->kind.
WHEN 'S'.
lr_structdescr ?= lr_typedescr.
lt_comp = lr_structdescr->components.
WHEN 'T'.
ASSIGN px_data TO <ft>.
CREATE DATA lr_dat LIKE LINE OF <ft>.
ASSIGN lr_dat->* TO <fs>.
lr_structdescr ?= cl_abap_structdescr=>describe_by_data( <fs> ).
lt_comp = lr_structdescr->components.
WHEN OTHERS.
MESSAGE e241(00).
* Function is invalid in this environment
ENDCASE.
CLEAR pt_fields.
LOOP AT lt_comp ASSIGNING <comp>.
APPEND <comp>-name TO pt_fields.
ENDLOOP." at lt_comp assigning <comp>.
ENDFORM. " getfields
Regards,
Clemens -
Dynamic programming using cl_abap_typedescr
I have created a field catalog for an ALV grid dynamically using cl_alv_table_create=>create_dynamic_table (I am on 46B and cannot use the new version). How do I create the structure and therefore internal table to pass into the it_outtab parameter of the ALV grid set_table_for_first_display
method? I can create a blank table with the correct dynamic columns but now wish to populate it without much success! I am retrieving the type using cl_abap_typedescr=>describe_by_data and can cycle through the key but how do I just obtain the structure?
Cheers
Ian
cl_abap_typedescr to retrieve the column names of a dynamic table I have created for using with an ALV gridHi,
Use ASSIGN r_dyn_table->* TO <t_dyn_table> to get access to the dynamic table. To append rows to it, you should use ASSIGN COMPONENT idx/name OF STRUCTURE struc TO <fs>.
Example:
data: tab_fields like table of wa_fields,
r_dyn_table TYPE REF TO data,
r_wa_dyn_table TYPE REF TO data,
f_int type i.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = F_TAB_FCAT
IMPORTING
ep_table = r_dyn_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN r_dyn_table->* TO <t_dyn_table>.
CREATE DATA r_wa_dyn_table LIKE LINE OF <t_dyn_table>.
ASSIGN r_wa_dyn_table->* TO <wa_dyn_table>.
DESCRIBE TABLE tab_fields lines f_int.
do f_int times.
READ TABLE tab_fields INDEX sy-index into wa_fields.
ASSIGN wa_fields-field TO <w_field1>.
check1 = sy-subrc.
ASSIGN COMPONENT sy-index
OF STRUCTURE <wa_dyn_table> TO <w_field2>.
check2 = sy-subrc.
if check1 = 0 and check2 = 0.
<w_field2> = <w_field1>.
endif.
enddo.
Svetlin -
Hi,
I am using cl_abap_typedescr=>describe_by_name to get the length and field names of a table. But it is returning incorrect values for length. For example, all character fields and numc fields contain double the correct length
REPORT ZCA_BOB_CL_ABAP_STRUCTDESCR.
PARAMETERS P_TABNAM type TABNAME OBLIGATORY.
Data: wa_spfli type spfli,
r_descr type REF TO cl_abap_structdescr,
wa_comp TYPE abap_compdescr.
** Create references to the needed ALV Global Classes
data: lr_events type ref to cl_salv_events_table.
data: gr_table type ref to cl_salv_table.
Data: r_grid TYPE REF TO cl_salv_table.
data: r_title_text TYPE REF TO cl_alv_variant,
r_grid_title TYPE LVC_TITLE.
Data: abap_compdescr_tab TYPE STANDARD TABLE OF abap_compdescr
WITH KEY name.
START-OF-SELECTION.
** ?= means cast
** r_descr ?= cl_abap_typedescr=>describe_by_data( wa_spfli ).
r_descr ?= cl_abap_typedescr=>describe_by_name( P_TABNAM ).
Loop at r_descr->components into wa_comp.
* write:/ wa_comp-name, wa_comp-type_kind, wa_comp-length,
* wa_comp-decimals.
append wa_comp to abap_compdescr_tab.
EndLoop.Hello Bob
Below is the output of your report run on a 4.6c system:
Structure WA_SPFLI:
MANDT C 3 0
CARRID C 3 0
CONNID N 4 0
COUNTRYFR C 3 0
CITYFROM C 20 0
AIRPFROM C 3 0
COUNTRYTO C 3 0
CITYTO C 20 0
AIRPTO C 3 0
FLTIME I 4 0
DEPTIME T 6 0
ARRTIME T 6 0
DISTANCE P 5 4
DISTID C 3 0
FLTYPE C 1 0
PERIOD b 1 0
4.6c = non-Unicode
Your system = Unicode
Thus, the length is apprently the length in bytes.
Simply check and RFC destination (SM59) using button "Unicode Test". You will get the following message on an Unicode system:
Target is a unicode system (character size 2)
Regards
Uwe -
CL_ABAP_TYPEDESCR
If I create a user defined type with reference to a DDIC object I can obtain the list of fields in the user defined type and the obsolute name which contains the user defined type by calling method describe_by_data of class cl_abap_structdescr at run time.
Does anyone know how you can find the original ddic structure at runtime of the type TY_POHEADER.
TYPES: ty_poheader TYPE bapimepoheader.
DATA: dref TYPE REF TO data.
DATA: descr_ref TYPE REF TO cl_abap_structdescr.
FIELD-SYMBOLS: <fs_line2> TYPE ty_poheader.
Start-of-selection.
CREATE DATA dref TYPE ty_poheader.
ASSIGN dref->* TO <fs_line2>.
descr_ref ?= cl_abap_typedescr=>describe_by_data( <fs_line2> ).i am getting all the components of the original ddic structure. check out the program below.
REPORT zzorgdataget .
TYPES: ty_poheader TYPE bapimepoheader.
DATA: dref TYPE REF TO data.
DATA: descr_ref1 TYPE REF TO cl_abap_structdescr.
DATA : l_string TYPE string.
DATA : l_object TYPE dd_x031l_table.
DATA : l_true TYPE abap_bool.
DATA : l_desc TYPE REF TO cl_abap_typedescr.
FIELD-SYMBOLS: <fs_line2> TYPE ty_poheader.
START-OF-SELECTION.
TYPES: my_struct TYPE mepoheader.
DATA:
my_data TYPE my_struct,
descr_ref TYPE REF TO cl_abap_structdescr.
FIELD-SYMBOLS:
<comp_wa> TYPE abap_compdescr.
START-OF-SELECTION.
descr_ref ?= cl_abap_typedescr=>describe_by_data( my_data ).
WRITE: / 'Typename :', descr_ref->absolute_name.
WRITE: / 'Kind :', descr_ref->type_kind.
WRITE: / 'Length :', descr_ref->length.
WRITE: / 'Decimals :', descr_ref->decimals.
WRITE: / 'Struct Kind :', descr_ref->struct_kind.
WRITE: / 'Components'.
WRITE: / 'Name Kind Length Decimals'.
LOOP AT descr_ref->components ASSIGNING <comp_wa>.
WRITE: / <comp_wa>-name, <comp_wa>-type_kind,
<comp_wa>-length, <comp_wa>-decimals.
ENDLOOP. -
Dynamic types with CL_ABAP_TYPEDESCR
Hi,
I have a problem. I want to read out the output_length of dynamic types to evaluate inputs. I do something like the code below.
DATA type_ref TYPE REF TO cl_abap_typedescr.
DATA elem_descr TYPE REF TO cl_abap_elemdescr.
DATA struc_descr TYPE REF TO cl_abap_structdescr.
type_ref = cl_abap_typedescr=>describe_by_data( <fs_lsinto> ).
elem_descr ?= type_ref.
elem_descr->output_length
But sometimes type_ref give back a CL_ABAP_STRUCTDESCR and I get a dump at '?='.
How I can solve my Problem?
SinanHow about something like this.
report zrich_0001.
data type_ref type ref to cl_abap_typedescr.
data elem_descr type ref to cl_abap_elemdescr.
data struc_descr type ref to cl_abap_structdescr.
data comp_tab type abap_compdescr_tab.
data comp_wa like line of comp_tab.
parameters: p_name(30) type c.
type_ref = cl_abap_typedescr=>describe_by_name( p_name ).
if type_ref->type_kind = 'u'. " <- Structure
struc_descr ?= type_ref.
loop at struc_descr->components into comp_wa.
catch system-exceptions move_cast_error = 1.
data: tab_component type string.
concatenate p_name comp_wa-name into comp_wa-name separated by '-'.
elem_descr ?= cl_abap_typedescr=>describe_by_name( comp_wa-name ).
endcatch.
write:/ comp_wa-name, comp_wa-length, elem_descr->output_length.
endloop.
else.
elem_descr ?= type_ref.
write:/ p_name, elem_descr->output_length.
endif.
Regards,
Rich Heilman -
Problem about CL_ABAP_TYPEDESCR
Hi Buddies,
There was a strange problem which I encountered today.When I called the method cl_abap_typedescr=>describe_by_data to obtain the components of the table DD01T, the length of each component of this table was doubled.After I used this components table to create an internal table dynamically, the problem is occured due to doule length of the true lengh..
Suddently I realized that the problem was caused by UNICODE.Did anyone has the idea to get the right length?
DATA: structtype TYPE REF TO cl_abap_structdescr.
structtype ?= cl_abap_typedescr=>describe_by_data( u2018DD01Tu2019 ).Hello,
I used POSID instead of PSPNR.
Regards,
Pedro -
Resolving data-reference at runtime ( cl_abap_typedescr)
Hi all,
At runtime, I need to find out if a data-reference of created data
refers to a data-element or not.
In will give you an example of what I mean:
data: dummy TYPE bukrs,
descr_ref TYPE REF TO cl_abap_typedescr,
descr_datael TYPE REF TO cl_abap_elemdescr,
p_datael type string value ''.
descr_ref = cl_abap_typedescr=>describe_by_data( dummy ).
MOVE descr_ref ?TO descr_datael.
p_datael = descr_datael->help_id. "p_datael has now value BUKRS
How is this done, if we work with a datareferences?
I'm pretty sure it should be feasible - but I'm stuck here...
Task: same as above - find out data-element of dummy.
data: dummy TYPE ref to data,
descr_ref TYPE REF TO cl_abap_typedescr,
descr_datael TYPE REF TO cl_abap_elemdescr,
p_datael type string value ''.
create dummy type bukrs.
descr_ref = cl_abap_typedescr=>describe_by_data( dummy ).
"descr_ref->type_kind this time indicates, that we work with referenced data.
"How to progress from here on?
Thanks in advance. Points will be granted if issue can be solved!Hello Edwin
The sample report ZUS_SDN_RTTI_DATA_ELEMENT shows how to address your question.
*& Report ZUS_SDN_RTTI_DATA_ELEMENT
*& Thread: resolving data-reference at runtime ( cl_abap_typedescr)
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="770681"></a>
REPORT zus_sdn_rtti_data_element.
DATA: gdo_dummy TYPE REF TO data,
go_typedescr TYPE REF TO cl_abap_typedescr,
go_elemdescr TYPE REF TO cl_abap_elemdescr,
p_datael TYPE string VALUE ''.
PARAMETERS:
p_rolln TYPE rollname DEFAULT 'BUKRS'.
START-OF-SELECTION.
CREATE DATA gdo_dummy TYPE (p_rolln).
go_typedescr = cl_abap_typedescr=>describe_by_data_ref( gdo_dummy ).
go_elemdescr ?= go_typedescr.
IF ( go_elemdescr->kind = cl_abap_elemdescr=>kind_elem AND
go_elemdescr->help_id = 'BUKRS' ).
MESSAGE 'Is of TYPE BUKRS' TYPE 'S'.
ELSE.
MESSAGE 'Is not of TYPE BUKRS' TYPE 'S'.
ENDIF.
END-OF-SELECTION.
Regards
Uwe -
How to Get data into I_ table which is Created dynamically
Hi Guys ,
I created one dynamic internal table , now I am want to display same internal table in my ALV? , how can I populate data into this internal table from my internal table based on some condition.
My Requirement is?
I have to display like this
1.This is my heading (field_cat of my ALV in which pack size may varry based on the flavor).
Plant flavor pack_size1----
pack_size-n
2. I have internal table( itab2) with all the pack-sizes and plant details.
3. how can I pass the these data into (itab1) which going to display in ALV ?
I can loop at itab2.
How to pass this data into itab1 relevent fields ?
Looking for Val. Inputs
With Best Regards
Prabhu
TC-Team SAP
Pepsi India
[email protected]Hi,
This is a code snippet.
DATA: r_dyn_table TYPE REF TO data,
r_wa_dyn_table TYPE REF TO data,
l_fields_table type SOI_FIELDS_TABLE.
FIELD-SYMBOLS: <t_dyn_table> TYPE STANDARD TABLE,
<wa_dyn_table> TYPE ANY,
<w_field1> TYPE ANY,
<w_field2> TYPE ANY.
DATA: l_oref_structure TYPE REF TO cl_abap_structdescr,
l_abap_compdescr type abap_compdescr.
data: check1 type i,
check2 type i,
l_range(20).
r_dyn_table = IL_DYNDATA-r_dyn_table.
ASSIGN r_dyn_table->* TO <t_dyn_table>.
CREATE DATA r_wa_dyn_table LIKE LINE OF <t_dyn_table>.
ASSIGN r_wa_dyn_table->* TO <wa_dyn_table>.
l_oref_structure ?= cl_abap_typedescr=>describe_by_data(
wa_supl ).
loop at il_fill_itab into wa_supl.
loop at l_oref_structure->COMPONENTS into l_abap_compdescr.
ASSIGN COMPONENT l_abap_compdescr-name
OF STRUCTURE wa_supl TO <w_field1>.
check1 = sy-subrc.
ASSIGN COMPONENT l_abap_compdescr-name
OF STRUCTURE <wa_dyn_table> TO <w_field2>.
check2 = sy-subrc.
if check1 = 0 and check2 = 0.
<w_field2> = <w_field1>.
endif.
endloop.
APPEND <wa_dyn_table> TO <t_dyn_table>.
endloop.
You can access your dynamic internal table via a field symbol.
Svetlin -
Nested structure when using FM XXL_SIMPLE_API
I use this logic to fill in the headings before calling the FM xxl_simple_api in one of my programs. Is it possible to have nested structure(for <b>i_tab</b> in my code) and still use same kind of logic to fill in the headings? Not sure if this Fm would display data correctly when there is a component of strucutre type. I tried it, the field was blank with no contents in excel.
DATA : nlines TYPE i,
tempfile LIKE gxxlt_f-file,
descr_ref TYPE REF TO cl_abap_structdescr,
header LIKE gxxlt_v OCCURS 0 WITH HEADER LINE,
it_print LIKE gxxlt_p OCCURS 0 WITH HEADER LINE.
*data: keycol type i.
FIELD-SYMBOLS:
<comp_wa> TYPE abap_compdescr,
tempfile = file_name.
REFRESH header.
CLEAR header.
descr_ref ?= cl_abap_typedescr=>describe_by_data( i_tab ).
DESCRIBE TABLE descr_ref->components LINES nlines.
nlines = nlines + 1.
LOOP AT descr_ref->components ASSIGNING <comp_wa>.
IF sy-tabix = nlines.
EXIT.
ELSE.
header-col_no = sy-tabix.
header-col_name = <comp_wa>-name.
APPEND header.
ENDIF.
ENDLOOP.
CALL FUNCTION 'XXL_SIMPLE_API'
EXPORTING
filename = tempfile
N_KEY_COLS = keycol
TABLES
col_text = header[]
I appreciate your help. ThanksHi,
It's better to use another FM 'SAP_CONVERT_TO_XLS_FORMAT'
call function 'SAP_CONVERT_TO_XLS_FORMAT'
exporting
I_FIELD_SEPERATOR = seper
I_LINE_HEADER = 'X'
I_FILENAME = P_FILE
tables
I_TAB_SAP_DATA = itab
exceptions
CONVERSION_FAILED = 1.
Svetlin
Maybe you are looking for
-
Aborting from double while loops
Hi, I am trying to do a X-Y movement with one of my piezostage automatically. It would be required for it to move in x-y direction for a certain user defined steps. However, I have problem with trying to abort the motion at will. Previously I have us
-
Is there a way to set up a 'dial string' with a 'wait' function?
I'm trying to set up calling my work voicemail. On the blackberry i could set up a dial string with a wait function. So when i dialed the voicemail #, once it answered I could hit a button on the phone and it would send the next set of characters (in
-
Dynamic action to create ESI record
Friends I am using the following code to create ESI record in infotype 588 in Dynamic actions and working for a single payroll area. 0001 04 862 P T001P-MOLGA='40' 0001 04 863 P PSPAR-MASSN='S1' 0001 04 864 P P0001-ABKRS='P3' 0001 04 865 P P0001-PERS
-
Solaris 8 and PCMCIA on Toshiba Tecra 520 CDT
I am having problems with my pcmcia services with X86 on my Toshiba Tecra 520 CDT laptop. It will not recognize the network card(s) or any PCMCIA cards for that matter. Do I need to load a specific driver or turn on the PCMCIA service or something to
-
Hi, I need clarifications about R12 applied patches, we are in multi node, 1 node for applications and 1 node for database. we have successfully migrate R12 application to the new target server but since the new target server isn't fully ready we hol