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

Collect statement in a class.

Former Member
0 Likes
1,134

Hello,

This is related to BW infospoke enhancement,

in this class i have structure which is filled and i have to aggregate the data in this structure by one of the field level,

i want to declare a internal table with header and take the data from structure into internal table and then do a collect statement on to this internal table..

but i am getting a message that no one more header line is supported in OOPS concept..meaning i am not able to declare a internal table with header line..

any solution to this will be awarded with points.

Hello,

This is related to BW infospoke enhancement,

in this class i have structure which is filled and i have to aggregate the data in this structure by one of the field level,

i want to declare a internal table with header and take the data from structure into internal table and then do a collect statement on to this internal table..

but i am getting a message that no one more header line is supported in OOPS concept..meaning i am not able to declare a internal table with header line..

any solution to this will be awarded with points.

9 REPLIES 9
Read only

Former Member
0 Likes
1,026

Hi,

Try this.

TYPES: BEGIN OF TYPE_STRUCTURE,

MATNR TYPE MATNR,

VBELN TYPE VBELN,

END OF TYPE_STRUCTURE.

DATA: T_ITAB TYPE STANDARD TABLE OF TYPE_STRUCTURE.

DATA: WA TYPE TYPE_STRUCTURE.

LOOP AT T_ITAB INTO WA.

IF WA-MATNR IS INITIAL.

.....

ENDIF.

ENDLOOP.

Thanks

Naren

Read only

0 Likes
1,026

guys thanks for the quick reply,

now can u guys let me know how do move the data from the structure to the internal table ITAB.

also if i want to declare the type structure with a structure in it..like include structure...??

Read only

0 Likes
1,026

Hi,

I don't know whether I understood the qn. correctly.

To get records into itab.

select * from db into table itab.

To move from itab into workarea,use collect statement to fetch the unique entries.

.. here both itab and itab1 are of same type.

data : itab type standard table of ty,

itab1 type standard able of ty.

loop at itab into wa.

....

collect wa into itab1.

endloop.

Read only

0 Likes
1,026

here i want to get the records from a structure(e_t_data_out) into itab please.

loop at e_t_data_out into itab.etc..is not working..

Read only

0 Likes
1,026

Hi,

just try moving the fields and appending afterwards.

move-corresponding e_t_data_out into wa.

append wa to itab.

Read only

0 Likes
1,026

i tried the below,

loop at e_t_data_out.

move-corresponding e_t_data_out into wa.

append wa to itab.

endloop.

AND

loop at e_t_data_out into wa.

move-corresponding e_t_data_out into wa.

append wa to itab.

endloop.

getting the message, e_t_data_out is not a structure OR internal table with headerline.

E_T_DATA_OUT is of type ANY TABLE.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,026

Hi,

As told,declare types statement.

types : begin of ty,

f1 ...

end of ty.

Then declare internal table and work area of that type.

data : itab type standard table of ty,

wa type ty.

loop at itab into wa.

...

collect wa into itab.

endloop.

If you use COLLECT with a work area, the work area must be compatible with the line type of the internal table.

Try this and kindly reward points if it helps.

Read only

Former Member
0 Likes
1,026

Hi,

Post the code of your internal table declaration..

Thanks,

Naren

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,026

Hello Shashi

You should not use itab with header lines since they mess up any coding and are a nightmare when it comes to maintaining code.

Fortunately, SAP has abandoned header lines from ABAP-OO. If you are not using table types then you have to define your own types, e.g.:

TYPES: BEGIN OF ty_s_line.
TYPES:   field_a  TYPE ... .
TYPES:   field_b  TYPE ... .
TYPES: END OF ty_s_line.
TYPES: ty_t_itab  TYPE STANDARD TABLE OF ty_s_line
                  WITH DEFAULT KEY.

DATA:
  ls_line   TYPE ty_s_line,
  lt_itab   TYPE ty_t_itab.


* Now fill your itab, e.g.
  SELECT * FROM ... INTO CORRESPONDING FIELDS 
                    OF TABLE lt_itab.

* Now working with the itab data. 
  LOOP AT lt_itab INTO ls_line.
  ...
  ENDLOOP.

Regards

Uwe