2009 Jul 23 8:15 AM
Hi Gurus,
I am using a code like dis...this is not the actual code m using instad m sendin u a sample program so that u can understand the problem
There is a selecvtion for Customer.
sort itab by kunnr.
loop at itab.
on change of itab-kunnr.
wkunnr = itab-kunnr.
read table zitab with key kunnr = itab-kunnr.
endon.
if itab-kunnr = wkunnr.
wdmbtr = wdmbtr + itab-dmbtr.
endif.
at end of kunnr.
ftab-kunnr = wkunnr.
ftab-dmbtr = wdmbtr.
append ftab.
endat.
endloop.
Now my problem is that AT END OF Kunnr is working fine for the first customer or say for single customer but when there are multiple customers AT END OF kunnr is triggring for each entry.......
In debug MOdei can see that as soon as read table syntax is used the tabix value is changed....
So Can anyone suggest what is the solution....
Regards,
Raman
2009 Jul 23 8:41 AM
2009 Jul 23 8:18 AM
Hi,
First you must search in such kind of issue in forum. There many more same forums.
The Kunnr filed must be the first filed in your internal table defination.
Thanks.
2009 Jul 23 8:19 AM
Are there any fields declared in itab before kunnr. As the On change will be triggereed if any of the fields before KUNNR or Kunnr is changed. If u only have to consider Kunnr then it should be the first field in itab.
2009 Jul 23 8:20 AM
Thanks for reply,
But my dear frns these are the basic things which i have already taken care of before posting this problem
2009 Jul 23 8:24 AM
ok i got it your problem.
just use if else condition.and when sy-tabix = 1 ..else..hope this will help you.
2009 Jul 23 8:29 AM
Thanks For ur reply
I am unable to understand what exactly ur telling me to do...
2009 Jul 23 8:32 AM
instead of using endon, use at new, on endon has its inherent problems.
2009 Jul 23 8:19 AM
Hi,
What is your requirment?
AT END of KUNNR will trigger on every change of KUNNR value.
If you want it to be triggered only for the firts customer, then use AT FIRST.
Regards,
Ankur Parab
2009 Jul 23 8:19 AM
here tabix and at end of has no relation
it will trigger before a new value is found ...
check whether u hace sorted your itab
the field must be the first field of itab. "it also get triggerd based on left dependant fields when a value changes
check all these ...
2009 Jul 23 8:22 AM
please can send the declaration of fields in your internal table for which you are using at end of. because i want to see the sequence of the fields.
2009 Jul 23 8:24 AM
This is the Declaration
DATA: BEGIN OF ITAB OCCURS 0,
KUNNR LIKE BSID-KUNNR,
BELNR LIKE BSID-BELNR,
BUKRS LIKE BSID-BUKRS,
GJAHR LIKE BSID-GJAHR,
BUZEI LIKE BSID-BUZEI,
SHKZG LIKE BSID-SHKZG,
VALUT LIKE BSID-ZFBDT,
SGTXT(70) TYPE C,
ZFBDT LIKE BSID-ZFBDT,
ZBD1T TYPE BSID-ZBD1T,
ZBD2T TYPE BSID-ZBD2T,
ZBD3T TYPE BSID-ZBD3T,
REBZG TYPE BSID-REBZG,
NETDT TYPE BSID-BUDAT,
ZUONR LIKE BSID-ZUONR,
BLART LIKE BSID-BLART,
DMBTR LIKE BSID-DMBTR,
SPART TYPE VBRK-SPART,
DAY TYPE RFPOSX-VERZN,
FLAG TYPE C,
CITY TYPE KNA1-ORT01,
NAME1 TYPE LFA1-NAME1,
CR_DR1(4) TYPE C,
PSWSL LIKE BSID-PSWSL,
ZTERM LIKE BSID-ZTERM,
VBELN LIKE BSID-VBELN,
UMSKZ LIKE BSID-UMSKZ,
KLIMK LIKE KNKK-KLIMK,
VTEXT LIKE TVZBT-VTEXT,
ADV LIKE BSID-DMBTR,
REBZT TYPE BSID-REBZT,
XBLNR LIKE BSID-XBLNR,
VTEXT1(70) TYPE C,
FKLIMK LIKE KNKK-KLIMK,
ABC(4) TYPE C,
AGRO(4) TYPE C,
BIO(4) TYPE C,
SKFOR LIKE KNKK-SKFOR,
SSOBL LIKE KNKK-SSOBL,
CTLPC LIKE KNKK-CTLPC,
OEIKW LIKE S066-OEIKW,
OLIKW LIKE S067-OLIKW,
OFAKW LIKE S067-OFAKW,
NAME1 LIKE LFA1-NAME1,
BUDAT LIKE BKPF-BUDAT,
D_DMBTR LIKE BSID-DMBTR,
S_DMBTR LIKE BSID-DMBTR,
VORGN LIKE BSEG-VORGN,
WERKS LIKE BSEG-WERKS,
NAMESO LIKE KNA1-NAME1,
NAMEAM LIKE KNA1-NAME1,
NAMERM LIKE KNA1-NAME1,
NAMEDR LIKE KNA1-NAME1,
END OF ITAB.
2009 Jul 23 8:30 AM
write :-
on change of kunnr.
instead of
on change of itab-kunnr.
2009 Jul 23 8:29 AM
Hi Raman,
Why are you reading ztab? You are not using it any where.IO thing so.
"read table zitab with key kunnr = itab-kunnr."
2009 Jul 23 8:30 AM
Hi Murli...
This is just the sample code however in actual program that read table is being used to pass some value..
So it cannot be ignored
2009 Jul 23 8:32 AM
Hi,
Try this way
To get the sy-tabix value, declare a field and store the sy-tabix value, but AT events don't require sy-tabix value.
DATA : it_itab TYPE TABLE OF <table>,
wa_itab TYPE <table>.
DATA : w_tabix TYPE sy-tabix.
SORT it_itab BY kunnr.
LOOP AT it_itab INTO wa_itab.
w_tabix = sy-tabix. " U can use that w_tabix value after read statement
w_kunnr = wa_itab-kunnr. " Move to a variable
AT NEW kunnr.
w_kunnr1 = w_kunnr. " This contains only new KUNNR
READ TABLE zitab WITH KEY kunnr = w_kunnr1.
ENDAT.
IF wa_itab-kunnr = w_kunnr1.
wdmbtr = wdmbtr + itab-dmbtr.
ENDIF.
AT END OF kunnr.
ftab-kunnr = w_kunnr1.
ftab-dmbtr = wdmbtr.
APPEND ftab.
CLEAR : w_kunnr1.
ENDAT.
CLEAR w_kunnr.
ENDLOOP.Regards
Bala Krishna
Edited by: Bala Krishna on Jul 23, 2009 1:04 PM
2009 Jul 23 8:41 AM
2009 Jul 23 8:46 AM
Hi Soumaya..
You Rock man this is the best answer..
It has solved my problem...
i will definitely give you full points for this
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |