‎2007 Apr 11 8:35 AM
eg. is this way of doing correct for building sorted table?
will this lose the binary properties for quick access?
sort standard_itab by a b c.
sorteditab[] = standard_itab[]
or should it be this way? using insert?
loop at standard_itab into wa.
insert wa into sorteditab.
endloop.
‎2007 Apr 11 8:37 AM
Hi,
Actually with insert statement, compiler will take care of the sorting where else using sort command, you explicitly sort the table....
Regards,
‎2007 Apr 11 8:37 AM
Hi,
Actually with insert statement, compiler will take care of the sorting where else using sort command, you explicitly sort the table....
Regards,
‎2007 Apr 11 8:41 AM
hi,
try this
sort standard_itab by <field1>.
loop at standard_itab into wa.
insert wa into sorteditab.
endloop.
if helpful reward plz
ravi
‎2007 Apr 11 8:51 AM
The first form is an effective way of doing things. I would suggest going with the first way of moving the body of the internal table to other, there will be no loss ofbinary properties moreover it is more efficient in terms of performance
‎2007 Apr 11 3:01 PM
Hi Charles,
sorteditab[] = standard_itab[]is correct but will cause a dump if you have duplicate keys in the standard_itab.
loop at standard_itab into wa.
insert wa into sorteditab.
endloop.is comparably very slow because for all loops the table line is copied to the work area. And it is syntacticalkly not correct because you must use into table ... when inserting into sorted itabs.
Do it using field-symbols, optional remember duplicates:
field-symbols:
<itab> like standard_itab.
data:
lt_itab_dup like sorteditab.
loop at standard_itab assigning <itab>.
insert <itab> into table sorteditab. "Note: must use TABLE otherwise syntax error
check sy-subrc <> 0. "Record akready exists
insert <itab> into table lt_itab_dup.
endloop.Now it won't fail under any circumstances. And you have the duplicate key records in table lt_itab_dup for evaulation purposes.
Regards,
Clemens
‎2007 Apr 12 4:19 AM
I thought according to SAP...using field-symbols would NOT be efficient if the the WA size is small.. it would benefit if size is huge?
‎2007 Apr 12 8:39 AM
Hi Charles,
using Field-symbols will not be <b>slower</b> under any circumstances.
WA size small means: 1 field or less
Regards,
Clemens