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: 

Alternative for AT NEW --- ENDAT

former_member463678
Participant
0 Kudos
3,830

Hello experts,

I am using field-symbol as internal table. I cant use AT NEW statement inside this loop.

Can u pls provide alternative for above control break statement.

Thanks in advance.

Zak.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
576

Hi,

to use control break statement, first you should sort the internal table and then you use it.

Take one example:

data: begin of it9 occurs 4,
           f1,
           f2,
         end of it9.

  it9 = '1A'. append it9. "Fill it9 with data
  it9 = '3A'. append it9.
  it9 = '1B'. append it9.
  it9 = '2B'. append it9.

 sort it9 by f1.
 loop at it9.
     at new f1.
         write: / 'start of:', it9-f1.
         endat.

     at end of f1.
         write: / 'end   of:', it9-f1.
         endat.
     endloop.
 free it9.

Hope it is helpful.

Regards,

Chris Gu

6 REPLIES 6

Former Member
0 Kudos
576

can you pls post your code???

Former Member
0 Kudos
576

Hi

Use can use the IF condition for the checking the change of field value in the work area when looping on ITAB.

loop at itab assigning <fs>. " f1 is the field for comparision, f1_temp is the temporary variable

if sy-tabix ne 1 and ( <fs>-f1 ne f1_temp ). " for first loop pass as sy-tabix = 1 the code will not be executed.

execute your piece of code when field f1 value changes

endif.

f1_temp = <fs>-f1.

endloop.

With Regards,

Dwaraka.s

Former Member
0 Kudos
576

See this example:-

sort it_clubdocs descending.

loop at it_clubdocs.

at new refnumber.

format hotspot on.

write / it_clubdocs-refnumber.

format hotspot off.

write sy-vline.

flag = 'X' .

endat.

if flag = 'X' .

write it_clubdocs-comminvno .

write sy-vline .

clear flag .

endif .

assign it_clubdocs-vbeln to <docno>.

write <docno> .

endloop.

Former Member
0 Kudos
576

LOOP AT ITAB.

ON CHANGE OF ITAB-FIELD1.

ENDON.

ENDLOOP.

Former Member
0 Kudos
576

Hi,

Check this out.

Say i am checking for every new entry for VBELN.

code_new will be the code which you want to be executed for every new entry.



loop at itab.

if itab-vbeln <> variable_vbeln.
" Put your code_new here.
endif.
"Put your other code here.

variable_vbeln = itab-vbeln.

endloop.

Thanks..

Former Member
0 Kudos
577

Hi,

to use control break statement, first you should sort the internal table and then you use it.

Take one example:

data: begin of it9 occurs 4,
           f1,
           f2,
         end of it9.

  it9 = '1A'. append it9. "Fill it9 with data
  it9 = '3A'. append it9.
  it9 = '1B'. append it9.
  it9 = '2B'. append it9.

 sort it9 by f1.
 loop at it9.
     at new f1.
         write: / 'start of:', it9-f1.
         endat.

     at end of f1.
         write: / 'end   of:', it9-f1.
         endat.
     endloop.
 free it9.

Hope it is helpful.

Regards,

Chris Gu