01-03-2014 7:33 AM
Hi ,
I am retrieving data from database table into main_internal_table and i need to divide this main_internal_table into 15 internal . i am writting this code but it is not working ,
DATA:
l_tab_name TYPE string,
lv_tab_no TYPE string.
FIELD-SYMBOLS : <matnr> TYPE matnr,
<fs1> TYPE table .
CONCATENATE 'IT_QT_MIC_K' lv_tab_no INTO l_tab_name.
ASSIGN (l_tab_name) to <fs1>. "on this line i am getting
You attempted to assign a field to a typed field symbol,
but the field does not have the required type.
IF <fs1> IS ASSIGNED.
APPEND wa_zqm_cto_arr_9024 TO <fs1> .
ENDIF.
UNASSIGN <fs1>.
i am getting this error.
Category ABAP Programming Error
Runtime Errors ASSIGN_TYPE_CONFLICT
ABAP Program SAPLZQM_REVIEW_PER_FG
Application Component PP
please correct me how to do it.
Regards,
Durga.
01-03-2014 8:48 AM
Hi Durga,
You can create internal table dynamically as follows:
PARAMETERS : p_table(10) TYPE C.
DATA: w_tabname TYPE w_tabname,
w_dref TYPE REF TO data,
w_grid TYPE REF TO cl_gui_alv_grid.
FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE.
w_tabname = p_table.
CREATE DATA w_dref TYPE TABLE OF (w_tabname).
ASSIGN w_dref->* TO <t_itab>.
Thanks and regards,
Ashish Kumar
01-03-2014 7:37 AM
Hi Durga,
Please assign below like this.
ASSIGN l_tab_name->* to <fs1>.
Arivazhagan S
01-03-2014 7:40 AM
Hi Durga,
please change your code as your needs, by seeing this code snippet,
It will work for you.
FIELD-SYMBOLS: <fs_itab> TYPE ANY TABLE.
DATA: wa TYPE REF TO data.
FIELD-SYMBOLS: <fs_wa> TYPE any.
01-03-2014 8:48 AM
Hi Durga,
You can create internal table dynamically as follows:
PARAMETERS : p_table(10) TYPE C.
DATA: w_tabname TYPE w_tabname,
w_dref TYPE REF TO data,
w_grid TYPE REF TO cl_gui_alv_grid.
FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE.
w_tabname = p_table.
CREATE DATA w_dref TYPE TABLE OF (w_tabname).
ASSIGN w_dref->* TO <t_itab>.
Thanks and regards,
Ashish Kumar
01-03-2014 9:22 AM
Hi,
when i am following your concept then i am getting following error
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_CREATE_DATA_ERROR', was not
caught in
procedure "ZQM_CTO_ARR_9002" "(FUNCTION)", nor was it propagated by a RAISING
clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
The dynamically specified type "IT_QT_MIC_K1" at CREATE DATA is no valid data
type.
01-03-2014 10:12 AM
Hi Durja Gupta,
CREATE DATA w_dref TYPE TABLE OF (w_tabname).
only works if w_tabname is the name of a data dictionary structure. Just use
CREATE DATA w_dref LIKE TABLE OF IT_QT_MIC_K for an existing internal table with headerline. If you declared your internal table without header line, then you don't need the TABLE OF addition, i.e.
CREATE DATA w_dref LIKE IT_QT_MIC_K or
CREATE DATA w_dref LIKE IT_QT_MIC_K[].
IF you need many internal tables, declare a table of references:
FIELD-SYMBOLS:
<tabref> TYPE REF TO DATA,
<table> TYPE TABLE
DATA lt_tabref TYPE TABLE OF REF TO data.
DO 1000 TIMES.
APPEND INITIAL LINE TO lt_tabref ASSIGNING <tabref>.
CREATE DATA <tabref> TYPE TABLE OF mseg. "just an example, create MSEG tables
ASSIGN <tabref>->* ro <table>.
* WORK with <table> number SY-INDEX
ENDDO.
Hope it helps!
Regards
Clemens
.
01-03-2014 8:54 AM
Hi Durga,
Declare <fs1> as
FIELD SYMBOLS: <fs1> TYPE ANY TABLE.
* or like <fs1> TYPE STANDARD TABLE.
and assign l_tab_name like
* Assign variable to field symbols
ASSIGN l_tab_name->* to <fs1>.
Regards,
Sheetal.
01-03-2014 9:41 AM
Hi,
when i am using type any table then i am getting error
l_tab_name is not a reference to a data object.
and you can not use explicit or implicit index operation on table with table hashed table or type any table .
and when i am using type satandard table then it is giving error
l_tab_name is not a reference o to a data object.
Regards,
Durga.
01-03-2014 10:31 AM
REPORT zpwtest .
*** Tables
DATA: lt_data TYPE REF TO data.
DATA: lt_fieldcatalog TYPE lvc_t_fcat.
*** Structure
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
*** Data References
DATA: new_line TYPE REF TO data.
*** Field Symbols
FIELD-SYMBOLS: <fs_data> TYPE REF TO data,
<fs_1> TYPE ANY TABLE,
<fs_2>,
<fs_3>.
ls_fieldcatalog-fieldname = 'MANDT'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'CARRID'. "Fieldname
ls_fieldcatalog-inttype = 'C'. "Internal Type C-> Character
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'CONNID'.
ls_fieldcatalog-inttype = 'N'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'FLDATE'.
ls_fieldcatalog-inttype = 'D'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'PRICE'.
ls_fieldcatalog-inttype = 'P'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'CURRENCY'.
ls_fieldcatalog-inttype = 'C'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ASSIGN lt_data TO <fs_data>.
CALL METHOD cl_alv_table_create=create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fieldcatalog
IMPORTING
ep_table = fs_data
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2
.
IF sy-subrc <> 0.
ENDIF.
*** So <FS_1> now points to our dynamic internal table.
ASSIGN <fs_data>->* TO <fs_1>.
*** Next step is to create a work area for our dynamic internal table.
CREATE DATA new_line LIKE LINE OF <fs_1>.
*** A field-symbol to access that work area
ASSIGN new_line->* TO <fs_2>.
*** And to put the data in the internal table
SELECT mandt carrid connid fldate price currency
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE <fs_1>.
*** Access contents of internal table
LOOP AT <fs_1> ASSIGNING <fs_2>.
ASSIGN COMPONENT 1 OF STRUCTURE <fs_2> TO <fs_3>.
WRITE: / <fs_3>.
ENDLOOP.
01-06-2014 6:57 AM
Hi Durga,
You can create dynamic internal tables using RTTC ( Runtime Type Creation ). Below is sample code.
DATA: lo_line TYPE REF TO cl_abap_structdescr,
lo_table TYPE REF TO cl_abap_tabledescr,
ref_itab TYPE REF TO data,
ref_wa TYPE REF TO data.
FIELD-SYMBOLS: <fs_tab> TYPE STANDARD TABLE,
<fs_wa> TYPE any.
lo_line ?= cl_abap_typedescr=>describe_by_name('SFLIGHT').
lo_table = cl_abap_tabledescr=>create(
p_line_type = lo_line
p_table_kind = cl_abap_tabledescr=>tablekind_sorted
p_unique = cl_abap_typedescr=>true ).
CREATE DATA ref_itab TYPE HANDLE lo_table.
ASSIGN ref_itab->* TO <fs_tab>.
CREATE DATA ref_wa TYPE HANDLE lo_line.
ASSIGN ref_wa->* TO <fs_wa>.
Hope this helps.
Regards,
Shibin