![]() |
|
|||||||
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Setting layout to a report in background job | Zoom | SAP ABAP | 2 | 11-29-2011 09:07 PM |
| Spilt GL setting in OKG8 | SAPMM | SAP PS - Project System | 2 | 11-08-2011 03:23 PM |
| Accepting 0 in Num field with Mandatory setting | ERP | SAP ABAP | 1 | 03-28-2011 11:42 PM |
| Delete decimal zeros from type menge or type packed while displaying in ALV | Ramma | SAP ABAP | 2 | 02-08-2011 11:05 PM |
| Call transaction iView dynamically | Micro | SAP Portal | 2 | 10-29-2010 12:33 AM |
| Aprenda SAP! |
|
|
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi All,
I'm trying to create a data with a type setted dynamically. I have 2 parameters : an internal table (p_reference) and the name (colonne, as a string) of one of its columns. My code doesnt work because the instruction : "create data: ty_type type (desired_type)" wont accept these desired_type : - P(8) DECIMALS 3 - P8 It can only accept 'P' Can I set the length and the decimals later Or should I change something else to make this code work? Code:
FIELD-SYMBOLS <table_reference> TYPE STANDARD TABLE.
ASSIGN p_reference TO <table_reference>.
FIELD-SYMBOLS <table_reference_fields> TYPE ANY.
DATA gs_fldname TYPE REF TO data.
CREATE DATA gs_fldname LIKE LINE OF <table_reference>.
ASSIGN gs_fldname->* TO <table_reference_fields>.
FIELD-SYMBOLS <lfs_comp_wa> TYPE abap_compdescr.
l_descr_ref ?= cl_abap_typedescr=>describe_by_data( <table_reference_fields> ).
LOOP AT l_descr_ref->components[] ASSIGNING <lfs_comp_wa>.
IF <lfs_comp_wa>-name = colonne.
exit.
endif.
endloop.
data desired_type type string.
" This CONCATENATE dont work but this is just an example
concatenate <lfs_comp_wa>-type_kind
<lfs_comp_wa>-length
' DECIMALS '
<lfs_comp_wa>-decimals
into desired_type.
data: ty_type type ref to data .
field-SYMBOLS <fs_data> type any .
create data: ty_type type (desired_type) . " crash :(
ASSIGN: ty_type->* TO <fs_data> .
Regards, Mirna |
| Sponsors |
|
#2
|
|||
|
|||
|
Hello Mirna,
Allowed syntax are: Code:
DATA dref TYPE REF TO data. CREATE DATA dref TYPE p LENGTH 11 DECIMALS 3. * or DATA: dref2 TYPE REF TO data, len TYPE i VALUE 11, dec TYPE i VALUE 3. CREATE DATA dref2 TYPE p LENGTH len DECIMALS dec. * or DATA: dref3 TYPE REF TO data, dataelem type c length 30 value 'WRBTR'. CREATE DATA dref3 TYPE (dataelem). Golfi |
|
#3
|
|||
|
|||
|
Hi Mirna,
Why not reading the data type of the table field? Code:
select single rollname into lv_type from dd03l
where tabname = lv_dbtab
and fieldname = ls_fld_except-fieldname.
if sy-subrc 0.
exit.
endif.
create data f_any type (lv_type).
assign f_any->* to <f_any>.
Regards, Lala |
| Entre a los Links relacionados |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|