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: 

Can I use field symbol in AT events? How?

Former Member
0 Kudos

Hi all,

I want to use field symbol in <b>AT END OF</b> event

Can I use field symbol in such event as it takes table fields only.

Kinldy look in to pseudo:

Loop itab.

AT END OF <FS1>.

ENDAT.

Endloop.

I tried in my program but it's giving me a short dump.

If it is possible to use field symbol in AT events, kindly tell me how..??

Thanks in Advance.

Sagar

3 REPLIES 3

Pawan_Kesari
Active Contributor
0 Kudos

try this


REPORT zpwtest .

DATA : it_ekpo TYPE TABLE OF ekpo ,
       wa_ekpo TYPE ekpo          .

DATA fieldname TYPE char10 VALUE  'EBELN' .

SELECT * INTO TABLE it_ekpo from ekpo WHERE ebeln = 'S062788845' .

SORT it_ekpo BY ebeln .

LOOP AT it_ekpo INTO wa_ekpo .

  AT END OF (fieldname) .
    write 'inside' .
  ENDAT .

ENDLOOP.

Former Member
0 Kudos

Hi,

i don't know your reqirement but it is possible:


DATA: t1(4), t2 TYPE i.

FIELD-GROUPS: header.

INSERT t2 t1 INTO header.

t1 ='AABB'. t2 = 1. EXTRACT header.
t1 ='BBCC'. t2 = 2. EXTRACT header.
t1 ='AAAA'. t2 = 2. EXTRACT header.
t1 ='AABB'. t2 = 1. EXTRACT header.
t1 ='BBBB'. t2 = 2. EXTRACT header.
t1 ='BBCC'. t2 = 2. EXTRACT header.
t1 ='AAAA'. t2 = 1. EXTRACT header.
t1 ='BBBB'. t2 = 1. EXTRACT header.
t1 ='AAAA'. t2 = 3. EXTRACT header.
t1 ='AABB'. t2 = 1. EXTRACT header.

SORT BY t1 t2.
*******************************************
*Here begins the definition of the field symbols
*******************************************
FIELD-SYMBOLS:
<t1> TYPE ANY,
<t2> TYPE ANY.
ASSIGN t1 TO <t1>.
ASSIGN t2 TO <t2>.</b>
LOOP.

  AT FIRST.
    WRITE 'Start of LOOP'.
    ULINE.
  ENDAT.

  AT NEW <t1>.
    WRITE / '   New T1:'.
  ENDAT.

  AT NEW <t2>.
    WRITE / '   New T2:'.
  ENDAT.

  WRITE: /14 t1, t2.

  AT END OF <t2>.
    WRITE / 'End of T2'.
  ENDAT.

  AT END OF <t1>.
    WRITE / 'End of T1'.
  ENDAT.

  AT LAST.
    ULINE.
  ENDAT.

ENDLOOP.

Regards,

Gianpietro

Former Member
0 Kudos

<b>It is not possible.</b>

This is because.....every field in internal table will be present in work area of that internal table and if u include a field symbol in internal table...it will be dynamic and will not be included in work area till runtime as the type assigned to it will not be known till runtime. As this field of type field symbols is not completely present in workarea, u cannot use it in 'at end of ' statement.

That is why it goes for short dump.

field-symbols : <fs1>.

data : begin of itab occurs 0,

<fs1>,

num type i,

end of itab.

loop at itab.

at end of <fs>.

*--<b>it will go to dump in above statement</b>

endat.

endloop.

Regards

Vasu