Application Development 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: 

AT END OF Statement

Former Member
0 Kudos

Hi,

I use the AT END OF statement to group the internal table (VBDPL Document Item View for Delivery Note). But, i found that the statement inside the at end of is executed in every loop. What is the possible cause of this??

Regards,

Kit

1 ACCEPTED SOLUTION

Former Member
0 Kudos

make VBDPL left most field and sort the int tab w.r.t. VBDPL

Reward if useful

Regards

ANUPAM

4 REPLIES 4

Former Member
0 Kudos

Hi,

I guess that there are one or more fields left of the structure who changes there values.

Please see the ABAP reference:

... |{END OF} compi/>

Effect

Control levels are defined by the beginning or end of a group of lines with the same content in the component compi (where i = 1, 2, and so on) and in the components to the left of compi. The control breaks take place when the content of the component compi or another component to the left of compi changes.

Many greetings,

Stefan

matt
Active Contributor
0 Kudos

You know, if you posted your actual code, it would be a lot easier to help you.

matt

Former Member
0 Kudos

make VBDPL left most field and sort the int tab w.r.t. VBDPL

Reward if useful

Regards

ANUPAM

former_member387317
Active Contributor
0 Kudos

Hi

You need to sort the internal table first with the key has what you are going to give in AT end <filedname>

1.place the first fields as the field for which u r using AT END OF in internal table

2.SORT ITAB BY <field1> <field2>

3. then use AT END OF <field2>.

See the example code for AT END OF


data : begin of itab occurs 0,
f1(4) type c,
f2(4) type c,
end of itab.
data : begin of Jtab occurs 0,
f1(4) type c,
f2(4) type c,
f3(4) type c,
end of Jtab.
DATA : CNT TYPE I.

DATA: GV_FLAG TYPE C.

itab-f1 = 'A'.
itab-f2 = '10'.
APPEND ITAB.

itab-f1 = 'A'.
itab-f2 = '10'.
APPEND ITAB.

itab-f1 = 'A'.
itab-f2 = '10'.
APPEND ITAB.

itab-f1 = 'B'.
itab-f2 = '8'.
APPEND ITAB.

itab-f1 = 'B'.
itab-f2 = '8'.
APPEND ITAB.

itab-f1 = 'B'.
itab-f2 = '8'.
APPEND ITAB.

SORT ITAB BY F1 F2. "use this
LOOP AT ITAB.
CNT = CNT + 1.

AT END OF F1. "apply here
GV_FLAG = 'X'.
ENDAT.

IF GV_FLAG = 'X'.
JTAB-F1 = ITAB-F1.
JTAB-F2 = ITAB-F2.
JTAB-F3 = CNT.
APPEND JTAB.
CLEAR JTAB.
CLEAR: CNT , GV_FLAG.
ENDIF.

ENDLOOP.

LOOP AT JTAB.
WRITE:/ JTAB-F1 , JTAB-F2, JTAB-F3.
ENDLOOP.

Hope it will solve ur problem.

Reward points if useful...

Thanks & Regards

ilesh 24x7