‎2007 Nov 16 3:38 AM
Hello Friends,
I have a internal table (t_vbak) and filled with some records. Now I want to move those records to one more internal table based on some conditions. What is the best way to move those to other internal table when u consider performance wise.
Please give me some examples.
Thanks,
Shreekant
‎2007 Nov 16 3:47 AM
Hi Shreekant,
If you can give the complete reuiqrement and the table types then I can tell you the best way as it depends on that.
Regards,
Atish
‎2007 Nov 16 3:42 AM
If both the itab are of same structure then
inew[] = it_vbak[].
or you can use
append lines of it_vbak to inew.
if it is not of same structutre
then
loop at it_vbak.
move-corresponding it_vbak to inew.
append inew.
endloop.
regards
shiba dutta
‎2007 Nov 16 3:47 AM
Hi Shreekant,
If you can give the complete reuiqrement and the table types then I can tell you the best way as it depends on that.
Regards,
Atish
‎2007 Nov 16 3:52 AM
Hi Atish,
types: begin of ty_non_hbpv.
include structure vbak.
types: end of ty_non_hbpv.
types: begin of ty_vbak.
include structure vbak.
types: end of ty_vbak.
data: t_non_hbpv type standard table of ty_non_hbpv,
w_non_hbpv type ty_non_hbpv.
data: t_vbak type standard table of ty_vbak,
w_vbak type ty_vbak.
I retrived some records into t_vbak using select statement, now I want to move those records to t_non_hbpv internal table.
Thanks,
Shreekant
‎2007 Nov 16 3:57 AM
Hi Shreekant,
Just some correction in your code.
types: begin of ty_non_hbpv.
include structure vbak.
types: end of ty_non_hbpv.
types: begin of ty_vbak.
include structure vbak.
types: end of ty_vbak.
You don't require these types.
Just use below code.
data: t_non_hbpv type standard table of vbak,
w_non_hbpv type vbak.
data: t_vbak type standard table of vbak,
w_vbak type vbak.
t_non_hbpv[] = t_vbak[].
DELETE t_non_hbpv WHERE <condition>.
This will be fastest way.
Regards,
Atish
‎2007 Nov 16 3:58 AM
Since they have the same structure, you can:
LOOP AT t_vbak into w_vbak
WHERE (your condition).
APPEND w_vbal to t_non_hbpv.
ENDLOOP.Rob
‎2007 Nov 16 3:53 AM
Hi Shreekanth,
If u want to move records based on some conditions, then u have to loop at the internal table t_vbak, if condition satisfies move the contents field by field if the internal tables have different structure else move the entire content.
Eg :
Case 1: If both the tables are having same structure.
loop at t_vbak .
if condition.
t_new = t_vbak.
append t_new.
endif.
Case 2: Both the tables are having differnt structure.
loop at t_vbak .
if condition.
t_new-filed1 = t_vbak-field1.
t_new-filed2 = t_vbak-field2.
t_new-filed3 = t_vbak-field3.
append t_new.
endif.
endloop.
Thanks,
Vidyashree
‎2007 Nov 16 3:54 AM
HI,
types: begin of ty_non_hbpv.
include structure vbak.
types: end of ty_non_hbpv.
types: begin of ty_vbak.
include structure vbak.
types: end of ty_vbak.
data: t_non_hbpv type standard table of ty_non_hbpv,
w_non_hbpv type ty_non_hbpv.
data: t_vbak type standard table of ty_vbak,
w_vbak type ty_vbak.
loop at t_vbak into w_vbak where <Condition>.
w_non_hbpv = w_vbak.
append w_non_hbpv to t_non_hbpv.
clear : w_non_hbpv,
w_vbak.
endloop.
‎2007 Nov 16 3:59 AM
Hi,
Try this code for ur requirement.
loop at t_vbak into wa_vbak where conditions.
wa_vbak_new = wa_vbak.
append wa_vabak_new into t_vbak_new.
endloop.
Reward if useful.
Regards
Shibin