2007 May 22 11:21 AM
hi all,
my code is as follows:
LOOP AT gt_bseg INTO gs_bseg.
AT NEW xref1.
gv_count = gv_count + 1.
ENDAT.
ENDLOOP.
Note : the field xref1 is not the first field of the internal table. even for the same value of xref1 the count is getting incremented.
What can be the solution.
Any help will be appriciated with points.
Thanks
2007 May 22 11:24 AM
hi,
If the at NEW field is not the first one, for example if it is second field then it consider the <b>combination</b> <b>of first two fields</b> and checks its is new or not.
sudheer.A
2007 May 22 11:23 AM
i thnk u need to sort it before looping into it.
Hope this will solve ur problem..
<b><u>Dont forget to reward all the useful replies</u></b>
Sudheer
2007 May 22 11:24 AM
Because the left fields of xref1 changes this AT New will execute, so change like this.
SORT gt_bseg by xref1.
LOOP AT gt_bseg INTO gs_bseg.
AT LAST xref1.
gv_count = gv_count + 1.
ENDAT.
ENDLOOP.
2007 May 22 11:24 AM
hi,
If the at NEW field is not the first one, for example if it is second field then it consider the <b>combination</b> <b>of first two fields</b> and checks its is new or not.
sudheer.A
2007 May 22 11:29 AM
hi sudheer,
i have sorted the table based on xref1.
can u elaborate on combination of two fields??
2007 May 22 11:30 AM
Hi,
According to me, he means the all the field including field on which AT NEW is used & previous fields in internal table.
Thanks
Sandeep
2007 May 22 11:33 AM
Hello..
No need of any sorting...Change your Internal Table Structure by making xref1 as the first field..Then use your old code..this will work..i am sure...Read my previous query carefully..
Reward All helpfull answers....
2007 May 22 11:36 AM
internal table structure is just as the same of bseg.
ie. data : gt_bseg type standard table of bseg,
and i cant this structure by declaring my own types also.
Moreover, while selecting i have to select the fields in order as they are in table bseg.
So how shall i make xref1 as first field??
2007 May 22 11:38 AM
2007 May 22 11:40 AM
Hi..
u dont have to sort the table, instead make that field as the first field in ur internal table or try using ON CHANGE OF instead of AT NEW.this works..
Thanks and Regards,
Kamal Kumar.
2007 May 22 11:41 AM
Hi
I got your problem..Just try with On Change Of gt_bseg-xref1 instead of at-new.
Anyway u can't use at-new in this condition...If On change of is working its ok..Ur problem solved..If this is not working write back with your error..
Regards
Biju
2007 May 22 11:43 AM
hi alexander,
i tried ur code.
Its incrementing the gv_count only at last.
that means always it will have 1 ie. always gv_count will be 1.
Moreover, at last xref1, is not correct.
it has to be only at last. and not as at last xref1.
Thanks for ur concern. any other way out??
2007 May 22 11:45 AM
2007 May 22 11:28 AM
Hi,
if the previous field in itab changes, AT NEW event gets triggered. try to use at last.
Thanks
sandeep
Reward if helpful
2007 May 22 11:28 AM
Hi
The problem is At-New will trigger whenever the control level will changes..As per u told xref1 is not the first field in th internal table, gv_count will increment whenever any of the field will change that coming before xref1..
ex..
matnr werks xref1
suppose this is thestructure of ur itab..then whenever matnr or werks or xref1 changes at-new will trigger..
hope u got the problem..
Reward All the Helpfull Answers..........
2007 May 22 11:42 AM
hi,
then give on change of 'field name' instead of at new.
for at new to work properly the fld should be the 1st field oterwise it wont work properly.
change code as
LOOP AT gt_bseg INTO gs_bseg.
on change of xref1.
gv_count = gv_count + 1.
ENDAT.
ENDLOOP.
if helpful reward some points.
with regards,
suresh babu aluri.
2007 May 22 12:50 PM
thanks to all for ur help extended.
The problem got solved using on-change of...
But still this is going to create an issue for Extended Program Check as this is obsolute statement.