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

Doubt in Internal table

Former Member
0 Likes
718

HI All.

I need to pass local value (L_count1) to filed of internal table (It_report1-Old_total_line_item) as follows.

Loop at it_report1.

Clear L_count1.

At end of Old_ebeln.

L_count1 = L_count1 + 1.

It_report1-Old_total_line_item = L_count1.

Append it_report1.

endloop.

here Append is needed or not?

please advice me.

Thanks.

jay

5 REPLIES 5
Read only

Former Member
0 Likes
696

Hi,

Ya ....... U can. not a prob.

Read only

Former Member
0 Likes
696

Hi

Use Modify instead of Append with index

also sort the Itab first before loop.

sort it_report1 by old_vbeln.

Loop at it_report1.

Clear L_count1.

At end of Old_ebeln.

L_count1 = L_count1 + 1.

It_report1-Old_total_line_item = L_count1.

modify it_report1.

endloop.

Reward points for useful Answers

Regards

Anji

Read only

Former Member
0 Likes
696

Hi,

yes append is needed to put he data in table.

this code is correct.

regards,

Ruchika

reward if useful........

Read only

Former Member
0 Likes
696

Hi,

Do not write the APPEND statment, you need to write the Modify Statment

Loop at it_report1.
Clear L_count1.
At end of Old_ebeln.
L_count1 = L_count1 + 1.
It_report1-Old_total_line_item = L_count1.
Modify it_report1 index sy-tabix.
endloop.

Regards

Sudheer

Read only

Former Member
0 Likes
696

Hi

I think it's wrong

-missing an ENDAT and you

-don't append or modify between at end of/endat

-the table must be sorted with at end of

-Old_ebeln must the first field of the table

I would write like this:

REPORT ztest.

DATA : BEGIN OF it_report1 OCCURS 0,

old_ebeln LIKE ekko-ebeln,

old_total_line_item TYPE i,

END OF it_report1.

DATA l_count1 TYPE i.

SORT it_report1 BY old_ebeln.

it_report1-old_total_line_item = 1.

MODIFY it_report1 TRANSPORTING old_total_line_item.

LOOP AT it_report1.

AT NEW old_ebeln.

SUM.

l_count1 = it_report1-old_total_line_item.

ENDAT.

it_report1-old_total_line_item = l_count1.

MODIFY it_report1.

ENDLOOP.

i hope it's help you,

Regards