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

Data transfer between 2 it_tables

Former Member
0 Likes
1,794

Hi all,

i have got some data related to sales into an it_table pertaining to G/L account for a date range.

however i want to shift this data to another internal table by putting further restriction by using where condition.

But, i want to do this without looping on my previous internal table.

please help me out with a solution.

Regards,

Kaustubh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,764

my second internal table is of the same type as of the first.

Hi all,

i have got some data related to sales into an it_table pertaining to G/L account for a date range.

however i want to shift this data to another internal table by putting further restriction by using where condition.

But, i want to do this without looping on my previous internal table.

please help me out with a solution.

Regards,

Kaustubh

14 REPLIES 14
Read only

Former Member
0 Likes
1,765

my second internal table is of the same type as of the first.

Read only

0 Likes
1,764

Hi,

If structure of both the internal tables are same then simple

internaltable2[] = intrenaltable1[] should work that actually copies the data from first to sec adn then

either loop at intrenaltable2 and delete the records or simply delete intrenaltable2 where condition should work.

Pooja

Read only

0 Likes
1,764

hi,

thank you for your suggestion but this would the same as looping on the first table as the data in the second table now is the same as it was in the first. looping on this would mean the same thing.

please correct me if im wrong.

Read only

0 Likes
1,764

The best way to avoid the loop would be to first append all the lines of the source itab to target itab, then delete the unwanted entries from the target tab.


append lines of itab to itab_1.
delete itab_1 where ( logical_expresion ) . " delete the entries you dont want.

regards,

Advait

Read only

0 Likes
1,764

@ advait

thanks a lot. it worked. exactly what i was looking out for.

thanks everyone else for your valuable feedbacks.

regards,

kaustubh

Read only

Former Member
0 Likes
1,764

if the structure of both the internal tables are same , use Append line of statement . you can sue where condition in the same.

Read only

0 Likes
1,764

Hi Santosh,

i tried your suggestion. the following is the syntax i have written:

append lines of it_revenue to it_rev where budat = p_bukrs.

following is the error i got when i executed:

".", "ASSIGNING <fs>" or "REFERENCE INTO data-reference" expected after "IT_REV". -

please help.

Read only

Former Member
0 Likes
1,764

Hi,

If the table structures are same and the where conditions are not dependent of the first table.

You can write.

ITAB2[] = ITAB1[].

DELETE ITAB WHERE <condition>.

With Best Regards,

Navneet Chaubey

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
1,764

Hi

ITAB2[] = ITAB1[].

That's it for your case.

Regards,

Sreeram Kumar.Madisetty

Read only

Former Member
0 Likes
1,764

Can you tell me why you dont want to use LOOP...ENDLOOP.

Read only

0 Likes
1,764

the reason being to avoid looping on a large amount of data in a practical scenario

Regards,

kaustubh

Read only

Former Member
0 Likes
1,764

If both internal tables are having the same structure you can use this statement,

it_tab1 = it_tab2.

Regards,

Joan

Read only

Former Member
0 Likes
1,764

Hi Kaustubh,

You can try it this way:

Data:
  w_lines  type i,
  w_index type i value 1.
Describe table itab_1 lines w_lines.

While w_index le w_lines.
  Read table itab_1 into wa index w_index.
  If wa_field eq 'XYZ'. " check youe condition here
    Append wa to itab_2.
  Endif.
  w_index = w_index + 1.
Endwhile.

With luck,

Pritam.

Read only

Former Member
0 Likes
1,764

Hi,

can you please check

To read the contents of internal tables for further processing, you can use either the LOOP or the READ statement.

Reading Internal Tables Line by Line

You use the the LOOP statement to read internal tables line by line.

LOOP AT <itab> [INTO <wa>] [WHERE <condition>].

ENDLOOP.

Reading Single Lines Using the Index

You can select a single line by the READ statement:

READ TABLE <itab> [INTO <wa>] INDEX <idx>.

Thanks and regrds

Durga.K