Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to declare internal table using include Pnnnn?

atif_bhatti
Participant
0 Kudos

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.

  

11 REPLIES 11

Venkat_Sesha
Advisor
Advisor
0 Kudos

DATA  :   BEGIN OF X_P0000.
        
Include Structure P0000.
       
END OF X_P0000,

        TB_P0000   Like Standard Table of X_P0000.

Hope this helps..

0 Kudos

Where P0000 is an infotype.

the above code is ok if its a structure but for infotype it will not work.

0 Kudos

Hi

Just use the structure of that Infotype

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

atif_bhatti
Participant
0 Kudos

   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.

0 Kudos

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 ).

Former Member
0 Kudos

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

atif_bhatti
Participant
0 Kudos

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.

0 Kudos

Or even more simply...

DATA lt_p0000 TYPE STANDARD TABLE OF p0000.

Cheers,

Amy

Former Member
0 Kudos

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.