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: 

Problem with 'AT END OF' statement

Former Member
0 Kudos

Hi All,

I have a problem with 'AT END OF' statement and I have no idea what is the problem.

My code goes like:

DATA : BEGIN OF tb_pre_selection OCCURS 0,

matnr LIKE ekbe-matnr,

lifnr LIKE ekko-lifnr,

budat LIKE ekbe-budat,

werks LIKE ekbe-werks,

menge LIKE ekbe-menge,

meins LIKE ekpo-meins,

dmbtr LIKE ekbe-dmbtr,

belnr LIKE ekbe-belnr,

gjahr LIKE ekbe-gjahr,

zekkn LIKE ekbe-zekkn,

vgabe LIKE ekbe-vgabe,

buzei LIKE ekbe-buzei,

bwart LIKE ekbe-bwart,

shkzg LIKE ekbe-shkzg,

umrez LIKE ekpo-umrez,

umren LIKE ekpo-umren,

lmein LIKE ekpo-lmein,

END OF tb_pre_selection.

.

.

.

LOOP AT tb_pre_selection.

.

.

.

AT END OF MATNR

.

.

.

ENDAT.

ENDLOOP.

My problem is that when AT END OF MATNR starts it generates stars (********) in some of the fields in header line but after ENDAT the header line is normal again.

Does anyone know why this occures ???

Thanks.

John.

7 REPLIES 7

Former Member
0 Kudos

Hi,

Use read statement in between AT END OF -


ENDAT.

READ tb_pre_selection index sy-tabix

OR

READ tb_pre_selection WITH KEY matnr = tb_pre_selection-matnr.

use that header line fileds

Regards

Krishna

Former Member
0 Kudos

Hi,

You need to do something like this:

DATA : BEGIN OF tb_pre_selection OCCURS 0,
matnr LIKE ekbe-matnr,
lifnr LIKE ekko-lifnr,
budat LIKE ekbe-budat,
werks LIKE ekbe-werks,
menge LIKE ekbe-menge,
meins LIKE ekpo-meins,
dmbtr LIKE ekbe-dmbtr,
belnr LIKE ekbe-belnr,
gjahr LIKE ekbe-gjahr,
zekkn LIKE ekbe-zekkn,
vgabe LIKE ekbe-vgabe,
buzei LIKE ekbe-buzei,
bwart LIKE ekbe-bwart,
shkzg LIKE ekbe-shkzg,
umrez LIKE ekpo-umrez,
umren LIKE ekpo-umren,
lmein LIKE ekpo-lmein,
END OF tb_pre_selection.

DATA: g_matnr like mara-matnr.
.
.
.
LOOP AT tb_pre_selection.
.
.
.
g_matnr = tb_pre_selection-matnr.
AT END OF MATNR

* Use g_matnr here
.
.
.
ENDAT.
ENDLOOP.

This is a normal behavior of AT ENDAT statement.

Regards,

Gilberto Li

Former Member
0 Kudos

hi John

This is the normal behaviour of this statement.

After the field which you specify in the AT statement (like MATNR in your case), it will put ***** in

all the CHARACTER type fields.

Thanks

Nitin

Former Member
0 Kudos

Hi,

I am sure you'll be able to solve the problem by the genuine answers given above. But I wud like to educate more about control break statements (i.e AT END of MATNR ..... ENDAT.)

1. The Field on which you putting AT condition should be the first field of the Interbal table

2. You should always sort the Internal table with the field that you want to use with AT statement.

3. To avoid the **** conditions that you are facing, always use a work area and access that work area within the (AT END of MATNR.....(work area)..... ENDAT.).

Hope this would help you.

Regards,

Ashish Arora

Former Member
0 Kudos

HI ,

Few records matnr will come blank that it mat come ******* check the bellow cod it will work.

material values are printing.

DATA : BEGIN OF tb_pre_selection OCCURS 0,

matnr LIKE ekbe-matnr,

budat LIKE ekbe-budat,

werks LIKE ekbe-werks,

menge LIKE ekbe-menge,

dmbtr LIKE ekbe-dmbtr,

belnr LIKE ekbe-belnr,

gjahr LIKE ekbe-gjahr,

zekkn LIKE ekbe-zekkn,

vgabe LIKE ekbe-vgabe,

buzei LIKE ekbe-buzei,

bwart LIKE ekbe-bwart,

shkzg LIKE ekbe-shkzg,

  • lifnr LIKE ekko-lifnr,

meins LIKE ekpo-meins,

umrez LIKE ekpo-umrez,

umren LIKE ekpo-umren,

lmein LIKE ekpo-lmein,

END OF tb_pre_selection.

select Amatnr Abudat Awerks Amenge Admbtr Abelnr Agjahr Azekkn Avgabe Abuzei Abwart Ashkzg

Bmeins Bumrez Bumren Blmein into corresponding fields of table tb_pre_selection

from ekbe as A inner join ekpo as B

on Aebeln = Bebeln and

Aebelp = Bebelp and

b~ebeln = '3000000115'.

LOOP AT tb_pre_selection.

AT END OF MATNR.

write : tb_pre_selection-matnr.

ENDAT.

ENDLOOP.

Former Member
0 Kudos

Hi John,

If u use At end,At new statements,the fields after the field u have used will be changed to **********

So waht u have to do is u have to copy the data into another structure before these kind of statements and use the new structure.I have already faced the problem ,I used the above technique and the problem was solved.Hope this will be helpful to u.

Thanks,

Pallavi.

Former Member
0 Kudos

Hi,

I have modified the code....Please check

DATA : BEGIN OF tb_pre_selection OCCURS 0,

matnr LIKE ekbe-matnr,

lifnr LIKE ekko-lifnr,

budat LIKE ekbe-budat,

werks LIKE ekbe-werks,

menge LIKE ekbe-menge,

meins LIKE ekpo-meins,

dmbtr LIKE ekbe-dmbtr,

belnr LIKE ekbe-belnr,

gjahr LIKE ekbe-gjahr,

zekkn LIKE ekbe-zekkn,

vgabe LIKE ekbe-vgabe,

buzei LIKE ekbe-buzei,

bwart LIKE ekbe-bwart,

shkzg LIKE ekbe-shkzg,

umrez LIKE ekpo-umrez,

umren LIKE ekpo-umren,

lmein LIKE ekpo-lmein,

END OF tb_pre_selection.

.

.

.

LOOP AT tb_pre_selection.

.

.

.

AT END OF MATNR

flag = 'X'

.

ENDAT.

If Flag = 'X'.

  Write the logic.....

endif.

ENDLOOP.

Regards,

Sandhya