‎2007 Apr 19 11:21 AM
Hi All
I have an internal table with below data:
DATA : BEGIN OF gt_catsdb OCCURS 0,
pernr LIKE catsdb-pernr,
workdate LIKE catsdb-workdate,
rproj LIKE catsdb-rproj,
catshours LIKE catsdb-catshours,
END OF gt_catsdb.
now i want to use collect statement for catshours field.
Can anybody help me this? its very urgent. Pls give the excat data declaration.
Thanks
Babita
‎2007 Apr 19 11:26 AM
Hi,
Select pernr workdate rproj catshours
into ( itab-pernr, itab-workdate,itab-rproj, itab-catshours)
where pernr in S_pernr.
collect Itab.
endselect.
or
Select pernr workdate rproj catshours
into table ITAB where pernr in S_pernr.
sort itab by pernr workdate.
loop at itab.
at end of pernr.
read table itab index sy-tabix.
SUM.
move-corresponding to ITAB1.
append iTAB1.
endat.
clear itab1.
endloop.
reward if useful
regards,
Anji
‎2007 Apr 19 11:25 AM
Hi..,
In general we use APPEND to fill the interanal table .. instead of that just say COLLECT after filling the internal table..
DATA : BEGIN OF gt_catsdb OCCURS 0,
pernr LIKE catsdb-pernr,
workdate LIKE catsdb-workdate,
rproj LIKE catsdb-rproj,
catshours LIKE catsdb-catshours,
END OF gt_catsdb.
fill the values into the header line of the table gt_catsdb.
after filling use <b>COLLECT gt_catsdb.</b>
gt_catsdb-pernr = '0018'.
gt_catsdb-workdate = sy=datum.
gt_catsdb-rproj = 'NAME'.
gt_catsdb-catshours = 12.
COLLECT gt_catsdb.
thats it !!
regards,
sai ramesh
‎2007 Apr 19 11:26 AM
Hi,
Select pernr workdate rproj catshours
into ( itab-pernr, itab-workdate,itab-rproj, itab-catshours)
where pernr in S_pernr.
collect Itab.
endselect.
or
Select pernr workdate rproj catshours
into table ITAB where pernr in S_pernr.
sort itab by pernr workdate.
loop at itab.
at end of pernr.
read table itab index sy-tabix.
SUM.
move-corresponding to ITAB1.
append iTAB1.
endat.
clear itab1.
endloop.
reward if useful
regards,
Anji
‎2007 Apr 19 11:29 AM
hi
DATA : BEGIN OF gt_catsdb OCCURS 0,
pernr LIKE catsdb-pernr,
workdate LIKE catsdb-workdate,
rproj LIKE catsdb-rproj,
catshours LIKE catsdb-catshours,
END OF gt_catsdb.
collect gt-catsdb
loop at gt-catsdb
write: gt-catsdb_catshours
endloop
‎2007 Apr 19 11:30 AM
hi,
The collect statement inserts the contents of a work area wa either as single row into an internal table itab or adds the values of its numeric components to the corresponding values of existing rows with the same key.
If the internal table does not already contain a row with an identical key, the COLLECT statement has the same effect as the following form of the INSERT statement:
for example you can use collect satement
loop at itab into wa.
collect wa into gt_catsdb.
endloop.
remember itab has the same structure as gt_catbd and with some different values which are to be collected into gt_catsdb.
The cathours will get added if with same key and appended if the key is not found,
reward if useful,
regards,
nazeer
‎2007 Apr 19 11:32 AM
Hi,
The COLLECT statement does not append a new line, but adds the contents of the numeric fields in the work area to the contents of the numeric fields in the existing entry.
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb36d5358411d1829f0000e829fbfe/frameset.htm
Regards,
Suresh
‎2007 Apr 19 1:27 PM
thanks to everyone for their prompt replies. points awarded. problem solved...