11-29-2005 10:22 AM
Hi,
Can any one tell me wether we can use the collect statement in an internal table which has no header line
if it can be used can anyone please send me a sample snippet
Thanks In ADVANCE
Guhapriyan Subrahmanyam
11-29-2005 10:26 AM
Hi,
COLLECT is used to create unique or compressed datasets. The key fields are the default key fields of the internal table itab.
If you use only COLLECT to fill an internal table, COLLECT makes sure that the internal table does not contain two entries with the same default key fields.
If, besides its default key fields, the internal table contains number fields (see also ABAP/4 number types), the contents of these number fields are added together if the internal table already contains an entry with the same key fields.
If the default key of an internal table processed with COLLECT is blank, all the values are added up in the first table line.
******************
If you specify wa INTO , the entry to be processed is taken from the explicitly specified work area wa . If not, it comes from the header line of the internal table itab .
*****************
After COLLECT , the system field SY-TABIX contains the index of the - existing or new - table entry with default key fields which match those of the entry to be processed.
Thanks.
If it helps you award points and close the thread.
11-29-2005 10:26 AM
Hi,
COLLECT is used to create unique or compressed datasets. The key fields are the default key fields of the internal table itab.
If you use only COLLECT to fill an internal table, COLLECT makes sure that the internal table does not contain two entries with the same default key fields.
If, besides its default key fields, the internal table contains number fields (see also ABAP/4 number types), the contents of these number fields are added together if the internal table already contains an entry with the same key fields.
If the default key of an internal table processed with COLLECT is blank, all the values are added up in the first table line.
******************
If you specify wa INTO , the entry to be processed is taken from the explicitly specified work area wa . If not, it comes from the header line of the internal table itab .
*****************
After COLLECT , the system field SY-TABIX contains the index of the - existing or new - table entry with default key fields which match those of the entry to be processed.
Thanks.
If it helps you award points and close the thread.
11-29-2005 10:26 AM
Yeap, there is no problem.
But you need a structure, like this:
data: w_1 type ty_1 ,
it_1 type table of ty_1 .
collect w_1 into it_1 .
Alexandre Nogueira
11-29-2005 10:28 AM
Hi Guhapriyan,
I have used the collect statement in the way as shown..
DATA : BEGIN of I_ALLOCATIONS OCCURS 0,
PSPNR LIKE PRPS-PSPNR,
PSPID LIKE PROJ-PSPID,
PSPHI LIKE PRPS-PSPHI,
POST1 LIKE PROJ-POST1,
ZZLOB LIKE PROJ-ZZLOB,
WERKS LIKE PROJ-WERKS,
SOBID LIKE HRP1001-SOBID,
OBJID LIKE HRP1001-OBJID,
BEGDA LIKE HRP1001-BEGDA,
ENDDA LIKE HRP1001-ENDDA,
PROZT LIKE HRP1001-PROZT,
LOB LIKE HRP1000-STEXT,
TEMP TYPE P decimals 2,
TYPE(3),
ZROLE LIKE PA0001-ZROLE,
HOLID TYPE P decimals 2,
LEAVE TYPE P decimals 2,
DAYS TYPE P decimals 2,
END of I_ALLOCATIONS.
DATA: I_ALLOCATION LIKE I_ALLOCATIONS OCCURS 0 WITH HEADER LINE.
************Populate I_ALLOCATIONS **************
LOOP AT I_ALLOCATIONS.
COLLECT I_ALLOCATIONS INTO I_ALLOCATION.
ENDLOOP.
Actually i had requirement like u, but this one is rather simple...
Get the required data in an I_Table which dont require Header line..
Later on collect this particular I_Table in other I_Table1 with the Header Line...
Regards,
Abhishek
11-29-2005 10:33 AM
Yes u can add line into itab which has no header line.
Check the below link.
http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb36a1358411d1829f0000e829fbfe/frameset.htm
Regards,
Abdul
11-29-2005 10:37 AM
If you use only COLLECT to fill an internal table, COLLECT makes sure that the internal table does not contain two entries with the same default key fields.
If, besides its default key fields, the internal table contains number fields (see also ABAP/4 number types ), the contents of these number fields are added together if the internal table already contains an entry with the same key fields.
If the default key of an internal table processed with COLLECT is blank, all the values are added up in the first table line.
If you specify wa INTO , the entry to be processed is taken from the explicitly specified work area wa . If not, it comes from the header line of the internal table itab .
After COLLECT , the system field SY-TABIX contains the index of the - existing or new - table entry with default key fields which match those of the entry to be processed.