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

Internal table

Former Member
0 Likes
781

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
759

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

8 REPLIES 8
Read only

Former Member
0 Likes
759

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

Read only

Former Member
0 Likes
761

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

Read only

0 Likes
759

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

Read only

0 Likes
759

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

Read only

0 Likes
759

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

Read only

Former Member
0 Likes
759

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

Read only

Former Member
0 Likes
759

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.

Read only

Former Member
0 Likes
759

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