2010 Oct 27 3:38 PM
Hi All,
I want to select the data of a standard table directly into an internal table but I am not able to get that.
Note : I am working 4.6C version of SAP
Please see the below code :
REPORT zdwnld_tabl_data .
PARAMETERS : p_tabl1 TYPE dd02v-tabname.
DATA : ddobtype TYPE dd02v-tabclass.
DATA : ref TYPE REF TO data.
FIELD-SYMBOLS : <data_tab> TYPE ANY.
CALL FUNCTION 'DDIF_NAMETAB_GET'
EXPORTING
tabname = p_tabl1
all_types = ' '
IMPORTING
ddobjtype = ddobtype
EXCEPTIONS
OTHERS = 2.
IF sy-subrc <> 0 OR ddobtype = 'INTTAB'.
RAISE tabl_not_found.
ENDIF.
CREATE DATA ref type (p_tabl1).
ASSIGN ref->* TO <data_tab>.
SELECT * FROM (p_tabl1) INTO <data_tab>.
ENDSELECT.Here if I dont want SELECT....ENDSELECT but want the data directly into an internal table. When I change the select statement as follows :
SELECT * FROM (p_tabl1) INTO table <data_tab>.it throws error saying <data_tab> is not an internal table. I understand the error.
To resolve this error when I change the FIELD SYMBOL declaration as
FIELD-SYMBOLS : <data_tab> TYPE TABLE. OR FIELD-SYMBOLS : <data_tab> TYPE ANY TABLE. , the program dumps on ASSIGN ref-> statement saying error as Type conflict with ASSIGN in program.
Any idea how this can be resolved.
Regards
Abhii
Hi All,
I want to select the data of a standard table directly into an internal table but I am not able to get that.
Note : I am working 4.6C version of SAP
Please see the below code :
REPORT zdwnld_tabl_data .
PARAMETERS : p_tabl1 TYPE dd02v-tabname.
DATA : ddobtype TYPE dd02v-tabclass.
DATA : ref TYPE REF TO data.
FIELD-SYMBOLS : <data_tab> TYPE ANY.
CALL FUNCTION 'DDIF_NAMETAB_GET'
EXPORTING
tabname = p_tabl1
all_types = ' '
IMPORTING
ddobjtype = ddobtype
EXCEPTIONS
OTHERS = 2.
IF sy-subrc <> 0 OR ddobtype = 'INTTAB'.
RAISE tabl_not_found.
ENDIF.
CREATE DATA ref type (p_tabl1).
ASSIGN ref->* TO <data_tab>.
SELECT * FROM (p_tabl1) INTO <data_tab>.
ENDSELECT.Here if I dont want SELECT....ENDSELECT but want the data directly into an internal table. When I change the select statement as follows :
SELECT * FROM (p_tabl1) INTO table <data_tab>.it throws error saying <data_tab> is not an internal table. I understand the error.
To resolve this error when I change the FIELD SYMBOL declaration as
FIELD-SYMBOLS : <data_tab> TYPE TABLE. OR FIELD-SYMBOLS : <data_tab> TYPE ANY TABLE. , the program dumps on ASSIGN ref-> statement saying error as Type conflict with ASSIGN in program.
Any idea how this can be resolved.
Regards
Abhii
2010 Oct 27 3:45 PM
Hello,
Has been discussed many a times in the forum:
REPORT zdwnld_tabl_data .
PARAMETERS : p_tabl1 TYPE dd02v-tabname.
DATA : ddobtype TYPE dd02v-tabclass.
DATA : ref TYPE REF TO data.
FIELD-SYMBOLS : <data_tab> TYPE STANDARD TABLE.
CALL FUNCTION 'DDIF_NAMETAB_GET'
EXPORTING
tabname = p_tabl1
all_types = ' '
IMPORTING
ddobjtype = ddobtype
EXCEPTIONS
OTHERS = 2.
IF sy-subrc NE 0 OR ddobtype = 'INTTAB'.
RAISE tabl_not_found.
ENDIF.
CREATE DATA ref TYPE STANDARD TABLE OF (p_tabl1).
ASSIGN ref->* TO <data_tab>.
SELECT * FROM (p_tabl1) INTO TABLE <data_tab>.BR,
Suhas
2010 Oct 28 10:15 AM
Hello Dada,
I have even tried using CREATE DATA ref type standard table of (p_tabl1) before posting ths question, it still says Unable to interpret "TABLE". Possible causes of error: Incorrect spelling or comma error
Regards
Abhii
2010 Oct 27 3:47 PM
Can't vouch for the 4.6C compatibility (it's been too long), but try 'TYPE TABLE OF' instead:
CREATE DATA lr_dref TYPE TABLE OF (lv_tabname).
2010 Oct 28 10:18 AM
Hi Brad,
I tried even using TYPE TABLE OF but it still says The type specification of "TABLE" is incomplete before posting the question.
Regards
2010 Oct 28 2:55 PM
Like I said, I could not vouch for 4.6C compatibility; it's been too long since I used that version. You may have to append the entries line by line then to a field symbol that has TYPE ANY TABLE. 4.6C was very limited in its dynamic capabilities.
2010 Oct 27 3:56 PM
REPORT zdwnld_tabl_data .
PARAMETERS : p_tabl1 TYPE dd02v-tabname.
DATA : ddobtype TYPE dd02v-tabclass.
DATA : ref TYPE REF TO data.
FIELD-SYMBOLS : <data_tab> TYPE ANY.
CALL FUNCTION 'DDIF_NAMETAB_GET'
EXPORTING
tabname = p_tabl1
all_types = ' '
IMPORTING
ddobjtype = ddobtype
EXCEPTIONS
OTHERS = 2.
IF sy-subrc ne 0 OR ddobtype = 'INTTAB'.
RAISE tabl_not_found.
ENDIF.
CREATE DATA ref TYPE (p_tabl1).
ASSIGN ref->* TO <data_tab>.
SELECT * FROM (p_tabl1) INTO <data_tab>.
ENDSELECT.
2010 Oct 27 3:57 PM
Hi,
Instead of
CREATE DATA ref type (p_tabl1).
try
CREATE DATA ref TYPE TABLE OF (p_tabl1).
Thanks,
Anmol.
2010 Oct 28 3:08 PM
I once had the same problem in 4.6C, and I used method CREATE_DYNAMIC_TABLE from class CL_ALV_TABLE_CREATE. You just need to create a field catalog using the well known function module LVC_FIELDCATALOG_MERGE, and use that field catalog in the method.
This way you can dynamically create an internal table with having to use CREATE DATA ... TYPE TABLE OF (which does not exist in 4.6C).
Please let me know if this was helpful.
Edited by: Koen De Ruyck on Oct 28, 2010 4:09 PM
2010 Nov 10 9:55 AM
Hi Koen De Ruyck,
Your answer was very very helpful. I have come to a conclusion that, in 4.6 C we can get the data into an internal dynamic table only by using the method create_dynamic_table of class cl_alv_table_create.
All the above methods suggested didnt work.
REPORT zdwnld_tabl_data .
PARAMETERS : p_tabl1 TYPE dd02v-tabname.
DATA: dy_table TYPE REF TO data,
dy_line TYPE REF TO data.
DATA : it_fcat TYPE lvc_t_fcat.
FIELD-SYMBOLS : <data_tab> TYPE STANDARD TABLE,
<dyn_wa>.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = p_tabl1
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
CHANGING
ct_fieldcat = it_fcat
* EXCEPTIONS
* INCONSISTENT_INTERFACE = 1
* PROGRAM_ERROR = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
* I_STYLE_TABLE =
it_fieldcatalog = it_fcat
IMPORTING
ep_table = dy_table
* E_STYLE_FNAME =
* EXCEPTIONS
* GENERATE_SUBPOOL_DIR_FULL = 1
* others = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ASSIGN dy_table->* TO <data_tab>.
SELECT * FROM (p_tabl1) INTO TABLE <data_tab>.However I have tested this with some tables, its working fine but its giving dump for MARA table, the dump says output table is too small , any idea on how we can overcome this error.
Regards
Abhii
2010 Nov 10 10:07 AM
Hi
You should check the catalog table returned by LVC_FIELDCATALOG_MERGE, probably some definition could miss if the dictionary table has certain defination.
And you should consider the method cl_alv_table_create=>create_dynamic_table works in this way:
It creates a pool routine where it write the defination of an internal table based on ALV catalog table, then it defines the dynamic table arranged on that defination, but I remember that certain field definitions were not supported while writing the defination, so certain fields could miss in defination, so in the internal table.
That could explain your problem
Max
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |