‎2011 Mar 14 3:43 PM
Hi Abap Gurus,
I have some doubt related to code.
1. Generally when we code, we use "Data: <variable name>(size) type (abap_predefined_type or data elements or database table name).
Ex : Data : a(25) type c, " Abap predefined data type
b type matnr, " material number data element
c type mara, " work area
d type standard table of mara. " internal table
Now i have a "view" and the name of the view is /BIC/VZFE_T02F.
I want to create an internal table like that of view.
But the statements,
Data : xx type /BIC/VZFE_T02F.
or
data : xx type standard table of /BIC/VZFE_T02F.
or
data : begin of xx,
include structure /BIC/VZFE_T02F.
end of xx.
did not work out and are giving errors.
do i have to use as given below,
data : begin of xx,
<manually enter all of the fields in the view>
endof xx.
if i need to use as above, the view contains lot of fields and its really a pain.
is there any other way to achieve the same?
2. I am using a function module, FM RSDRI_INFOPROV_READ in my program. This FM reads data from an infoprovider.
See the code given below,
" Error is received here.
" But in FM source code, e_T_DATA is declared as given below
" EXPORTING
" REFERENCE(E_T_DATA) TYPE STANDARD TABLE
data : e_T_DATA TYPE standard table. " This statement is causing error for me
data : E_END_OF_DATA TYPE RS_BOOL.
data : E_AGGREGATE TYPE RSINFOCUBE.
data : E_SPLIT_OCCURRED TYPE RSDR0_SPLIT_OCCURRED.
data : E_T_MSG TYPE RS_T_MSG.
data : E_STEPUID TYPE SYSUUID_25.
CALL FUNCTION 'RSDRI_INFOPROV_READ'
EXPORTING
i_infoprov = 'ZFE_T02' "Name of an InfoProvider, for example of an InfoCubes or an ODS Object.
i_th_sfc = charc_table "Table containing all characteristics
i_th_sfk = kf_table "Table containing all of the Key figuers
IMPORTING
E_T_DATA = E_T_DATA
E_END_OF_DATA = E_END_OF_DATA
E_AGGREGATE = E_AGGREGATE
E_SPLIT_OCCURRED = E_SPLIT_OCCURRED
E_T_MSG = E_T_MSG
E_STEPUID = E_STEPUID
changing
c_first_call = flag
EXCEPTIONS
ILLEGAL_INPUT = 1
ILLEGAL_INPUT_SFC = 2
ILLEGAL_INPUT_SFK = 3
ILLEGAL_INPUT_RANGE = 4
ILLEGAL_INPUT_TABLESEL = 5
NO_AUTHORIZATION = 6
ILLEGAL_DOWNLOAD = 7
ILLEGAL_TABLENAME = 8
TRANS_NO_WRITE_MODE = 9
INHERITED_ERROR = 10
X_MESSAGE = 11
OTHERS = 12.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
i get error ""ANY TABLE" expected, not "STANDARD TABLE"".
If i change "data : e_T_DATA TYPE any table" then i get the error,
""You cannot use generic types for fields. The table types ANY and INDEX are generic".
How to over come this situation?
Regards,
Lakshminarasimhan.N
‎2011 Mar 14 8:00 PM
Halo ,
You can use only field symbols for generic type definitions like type any, type table, type standard table etc.
The interface definition of the Function Module does not mean that you should pass standard table generic table. You can have a Data type whihc refers to DDIC structure (I mean a predefined structure )
If you want to pass generic parameter to the Function Module then it should be thriugh field symbols
like
field-symbols: <fs_table> type table.
create data dref type table of (l_std_table_name).
assign dref->* to <fs_table>.
Now your field symbol is assigned and you can pass that to the FM..
or
data: lt_table type table of marra.
you can pass lt_table.
So here the problem is with the defnition of the internal tables in data delcaration.
Regards
Arshad
‎2011 Mar 15 6:43 AM
It's a bad idea to ask two questions in one thread. Please don't do it again.
It's impossible to answer your first question unless you specify what the errors you're getting are! But I suggest you have another look at the syntax of DATA and INCLUDE.
Regarding part 2 - ignore the above about field symbols, it's irrelevant. But you know this function module is documented, and SAP supply an example program (mentioned in the documentation) about how to use it.
If a parameter is defined as taking ANY TABLE, that means you can supply it with any fully defined table of any type, not that you must define your table as "any table".
matt
Edited by: Matt on Mar 15, 2011 7:45 AM
‎2011 Mar 15 7:37 AM
Hi,
I tried definitions with 3 kinds of views:
- Maintenance Views
- Database Views
- Projection Views
I declare both:
data: a type table of V_MARABELEG.
data: b type V_MARABELEG.This was the database view sample.
All of them worked fine without errors.
Which kind of view do you have?
What error do you get?
Please post it exactly!
Maybe your view is not active or something like that!
Regards,
Klaus
Edited by: Klaus Babl on Mar 15, 2011 8:39 AM
‎2011 Mar 16 4:00 PM
Hi,
You people are right.
The code works for the view.
Data : xx type /BIC/VZFE_T02F.
data : xx type standard table of /BIC/VZFE_T02F.
But i am unable to use "Include structure".
data : begin of xx,
include structure /BIC/VZFE_T02F.
end of xx.
Is it the case that in ECC 6.0 "include structure" statement not accepted?
I have over come the 2nd problem, by creating a structure with all elements and creating an internal table over that structure.
Please suggest me abt the "include structure"
‎2011 Mar 17 6:25 AM
‎2011 Mar 17 7:16 AM
But i am unable to use "Include structure".
data : begin of xx,
include structure /BIC/VZFE_T02F.
end of xx.
Change these statements to:
data : begin of xx.
include structure /BIC/VZFE_T02F.
end of xx.Just replace comma with dot.
‎2011 Mar 17 12:25 PM
In fact that should be
data : begin of xx.
include structure /BIC/VZFE_T02F.
data end of xx.
But that is not allowed within classes. There you have to use:
data : begin of xx.
include type /BIC/VZFE_T02F.
data end of xx.
matt
‎2011 Mar 18 7:49 AM
Why do you think that topic starter uses classes? There was nothing said about it. However, the code was not valid.
‎2011 Mar 18 11:56 AM
>
> Why do you think that topic starter uses classes? There was nothing said about it. However, the code was not valid.
If a particular construct is not allowed in classes, you can safely draw the conclusion that the construct has been regarded by SAP as "not good", and is only retained for backward compatability. My advice (and practice) is to only use syntax that's valid in OO context, even outside of an OO-context, where possible.
The view name has the prefix /BIC/. This indicates that the program will be running in a BI system. Since BI 7.0, (most) routines have been in an OO context. Without knowing which version the OP is using (3.5 routines are implemented in forms), I suggest the solution that will work in ALL contexts.
matt