Application Development and Automation 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: 
Read only

data declaration

Former Member
0 Likes
1,074

Hello All,

I have the following code:

DATA: Begin of structure,

fld1,

fld2,

fld3,

end of structure.

DATA: tab1 like structure occurs 0 with header line,

tab2 like structure occurs 0 with header line.

DATA: struc1 like structure,

struc2 like structure.

Class cls DEFINITION.

PUBLIC section.

METHODS.

---

---

---

ENDCLASS.

class implementation.

method.

loop at tab1 into struc1

.......

endloop.

endmethod.

The code is syntactically correct and has been activated. IN the above, when I double click on tab1 it is not going to its definition, but instead throws an error message saying that the object struc1 is not found.

This is the case when I double click the tab1 inside method-endmethod.

Outside the method-endmethod, it goes directly to its definition in DATA declaration.

Any suggestions to avoid this?

Thanks

M A

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,043

Please try this.



*---------------------------------------------------------------------*
*       CLASS cls DEFINITION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
class cls definition.

  public section.

    types: begin of structure.
         include type  zstruc.   "<----
    types: upd_ind(1) type c,  "<----
    cellio_tab type lvc_t_styl,
    linecolor(4) type c,
    end of structure.

endclass.

*---------------------------------------------------------------------*
*       CLASS implementation DEFINITION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
class cls implementation.

endclass.

Regards,

Rich Heilman

8 REPLIES 8
Read only

Former Member
0 Likes
1,043

Hi,

Declare the tab1 in the class definition..

Probably you cannot use global internal tables inside the class...

Thanks,

Naren

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,043

Try putting the DATA statements inside you class definition under the PUBLIC SECTION. You will need to define like so.



Types: Begin of structure,
fld1,
fld2,
fld3,
end of structure.

DATA: tab1 type table of structure,
tab2 type table of structure,

DATA: struc1 like line of tab1,
          struc2 like line of tab2.


Regards,.

Rich Heilman

Read only

0 Likes
1,043

Thanks for your solution.

The structure definition which iam using is as follows:

DATA: BEGIN OF structure.

INCLUDE STRUCTURE zstruc.

DATA: upd_ind TYPE c,

cellio_tab TYPE lvc_t_styl,

linecolor(4) TYPE c,

END OF structure.

Now, when this is placed inside PUBLIC SECTION, we need to use TYPES.

I have taken like this:

TYPES: BEGIN OF structure.

INCLUDE STRUCTURE zstruc.

TYPES: upd_ind TYPE c,

cellio_tab TYPE lvc_t_styl,

linecolor(4) TYPE c,

END OF structure.

But still I am getting errors. Hope the second TYPES declared above is wrong.

Please suggest.

Thanks

M A

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,044

Please try this.



*---------------------------------------------------------------------*
*       CLASS cls DEFINITION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
class cls definition.

  public section.

    types: begin of structure.
         include type  zstruc.   "<----
    types: upd_ind(1) type c,  "<----
    cellio_tab type lvc_t_styl,
    linecolor(4) type c,
    end of structure.

endclass.

*---------------------------------------------------------------------*
*       CLASS implementation DEFINITION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
class cls implementation.

endclass.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,043

Hi,

Try this..

TYPES: BEGIN OF structure,

ztable type <b>zstruc</b>,

upd_ind type char1,

cellio_tab TYPE lvc_t_styl,

linecolor(4) TYPE c,

END OF structure.

Thanks,

Naren

Read only

Former Member
0 Likes
1,043

Thanks Narendran and Rich.

I have already put the code which u both have sent. But still I am getting errors like:

"Explicit length specifications are necessary with types C, P, X, N undW in the OO context".

What modifications are to be done here. PLease suggest.

Thanks

M A

Read only

Former Member
0 Likes
1,043

Yeah

I have got it.

I have specified the length of upd_id. And now its taking.

Anyways, Thanks a lot to all of you.

MA

Read only

0 Likes
1,043

HI,

i suggest used in this way

TYPES BEGIN OF structure.

include structure zstruc.

types: upd_ind type char1.

tcellio_tab TYPE lvc_t_styl,

linecolor(4) TYPE c,

END OF structure.

now structure is a flat one.