2012 Nov 20 8:33 AM
How to create a internal table using include?
I am trying to define an internal table and a structure based on P0000.
TYPES: BEGIN OF ty_p0000,
include TYPE p0000,
END OF ty_p0000.
DATA: g_p0000 type ty_p0000,
t_p0000 type TABLE OF ty_p0000.
the above statements creat a flat structure table where all columns are condensed into single column and all values are concatenated.
data BEGIN OF t_p0000 OCCURS 0.
INCLUDE type p0000.
data END OF t_p0000.
data BEGIN OF g_p0000.
INCLUDE type p0000.
data END OF g_p0000.
the above creates a table but this is obsolete.
2012 Nov 20 8:37 AM
DATA : BEGIN OF X_P0000.
Include Structure P0000.
END OF X_P0000,
TB_P0000 Like Standard Table of X_P0000.
Hope this helps..
2012 Nov 20 8:45 AM
Where P0000 is an infotype.
the above code is ok if its a structure but for infotype it will not work.
2012 Nov 20 9:06 AM
2012 Nov 20 8:47 AM
Hi,
You can declare an internal table of type Pnnnn as
DATA : gt_table type table of Pnnnn [with header line initial size 0].
E.g.
DATA : gt_table TYPE TABLE OF p0000.
This will create internal table of type p0000.
To use Include structure , below is an example -
DATA: BEGIN OF gs_table,
INCLUDE STRUCTURE p0000,
END OF gs_table.
DATA : gt_table TYPE STANDARD TABLE OF gs_table.
Thanks and Regards,
Chirag
2012 Nov 20 8:59 AM
data BEGIN OF g_p0000.
INCLUDE type p0000.
data END OF g_p0000.
the above creates a table but this is obsolete.
Instead of the above you can use :-
TYPES : BEGIN OF gs_p0000.
include TYPE p0000.
TYPES: END OF gs_p0000.
DATA : gt_p0000 TYPE STANDARD TABLE OF gs_p0000.
2012 Nov 20 9:31 AM
types: BEGIN OF ty_p0000,
include structure p0000,
END OF ty_p0000.
getting an error message the key word structure has been highlighted with red color.
message text: "," expected after include.
If I replace structure with type then there is no syntax error.
2012 Nov 20 9:42 AM
Use this :-
TYPES : BEGIN OF ty_p0000.
include TYPE p0000.
TYPES: END OF ty_p0000.
DATA : ti_p0000 TYPE STANDARD TABLE OF ty_p0000.
and if you want to use structure then use :-
DATA : BEGIN OF ty_p0000.
include structure p0000.
DATA : END OF ty_p0000.
But this is outdated ( as u told ).
2012 Nov 20 9:55 AM
Hi,
Just try using the following global declarations (just like DATA, TYPES, TABLES statement).
INFOTYPES: Pnnnn.
There are various parameters following this declaration which is mentioned in help (F1).
Regards,
Hardik Mehta
2012 Nov 20 11:53 AM
I got the correct answer
Types: ty_p0000 type p0000.
Data: g_p0000 type ty_p0000,
Gt_p0000 like table of g_p0000.
The other way,
TYPES: BEGIN OF ty_p0000,
include TYPE p0000,
END OF ty_p0000.
DATA: g_p0000 type ty_p0000,
t_p0000 type TABLE OF ty_p0000
The field is p0000 and you address each by p0000
So t_p0000-p0000-pernr.
Read table t_p0000
With key p0000-pernr = prel-pernr.
2012 Nov 20 9:39 PM
Or even more simply...
DATA lt_p0000 TYPE STANDARD TABLE OF p0000.
Cheers,
Amy
2012 Nov 20 9:14 PM
You want to use PA0000, since that's the underlying database table for the infotype P0000. Your open SQL Select would also obtain data from PA0000. On the other hand, you could also use the function modules named like HR_READ...but the most commonly used (HR_READ_INFOTYPE) is for one pernr at a time.