‎2009 Nov 06 10:37 AM
Hi All,
I am trying to use READ table instead of SELECT single in a class ZCL_IM_MRSS_EX_MESSAGES
Below is the select statement I am trying to format as READ TABLE
SELECT SINGLE external_id from cgpl_project into wa_zcp_int_fa-project_id where guid = ls_role_det-project_guid.
My read statement is READ TABLE t_cgpl_project into wa_cgpl_project
with key guid = ls_role_det-project_guid.
For the above read statement I am getting below error --
READ dbatb is not supported in the OO context. Use SELECT SINGLE.
What does this error mean? Pls provide inputs ASAP
Regards,
S.Sumana
‎2009 Nov 06 10:49 AM
Hi
But what's t_cgpl_project?
If you want compare READ TABLE statament with SELECT SINGLE, it means t_cgpl_project should be a dictionary table, if it's so READ TABLE DBTAB...is an obsolete statament not supported by OOA, so u have to use SELECT SINGLE...
Anyway I can't see the table T_CGPL_PROJECT, but CGPL_PROJECT....so I suppose T_CGPL_PROJECT is an internal table...if it's so something is wrong in your definition, because READ TABLE itab is allowed in OOA:
CLASS LCL_MY_CLASS DEFINITION.
PUBLIC SECTION.
DATA: WA_CGPL_PROJECT TYPE CGPL_PROJECT.
METHODS: SEL_DATA,
READ_DATA
EXPORTING GUID TYPE CGPL_PROJECT-GUID.
PRIVATE SECTION.
DATA: T_CGPL_PROJECT TYPE TABLE OF CGPL_PROJECT.
ENDCLASS. "LCL_MY_CLASS DEFINITION
CLASS LCL_MY_CLASS IMPLEMENTATION.
METHOD SEL_DATA.
SELECT * FROM CGPL_PROJECT
INTO TABLE T_CGPL_PROJECT.
ENDMETHOD. "sel_data
METHOD READ_DATA.
READ TABLE T_CGPL_PROJECT INTO WA_CGPL_PROJECT
WITH KEY GUID = GUID.
ENDMETHOD. "read_data
ENDCLASS. "LCL_MY_CLASS IMPLEMENTATIONMax
‎2009 Nov 11 9:51 PM
Hi Sumana,
There seems to be a problem with the definition of your t_cgpl_project bcs read table is actually well recommended
your t_cgpl_project shud be an internal table to do the read statement and not a database table
‎2009 Nov 12 6:14 AM
Hi Sumana,
If you want to fetch a single record from DB table, and that is enough in your entire report - then u should fetch it through select single only.
because read DBTable is obsolete.
At a particular instance you want a single record, and as in total report u need many records from that DB table, then first get all the records into an internal table.
Then wherever u need just use read table to that internal table.
Hope this helps you.
Please revert back if u need any further info.