Application Development and Automation 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: 
Read only

sy-tabix value has changed...

Former Member
0 Likes
3,050

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,373

put the AT END OF before on change.

hope this will work

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

16 REPLIES 16
Read only

Former Member
0 Likes
2,373

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.

Read only

Former Member
0 Likes
2,373

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.

Read only

0 Likes
2,373

Thanks for reply,

But my dear frns these are the basic things which i have already taken care of before posting this problem

Read only

0 Likes
2,373

ok i got it your problem.

just use if else condition.and when sy-tabix = 1 ..else..hope this will help you.

Read only

0 Likes
2,373

Thanks For ur reply

I am unable to understand what exactly ur telling me to do...

Read only

0 Likes
2,373

instead of using endon, use at new, on endon has its inherent problems.

Read only

Former Member
0 Likes
2,373

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

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
2,373

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 ...

Read only

Former Member
0 Likes
2,373

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.

Read only

0 Likes
2,373

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.

Read only

0 Likes
2,373

write :-

on change of kunnr.

instead of

on change of itab-kunnr.

Read only

Former Member
0 Likes
2,373

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."

Read only

0 Likes
2,373

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

Read only

former_member585060
Active Contributor
0 Likes
2,373

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

Read only

Former Member
0 Likes
2,374

put the AT END OF before on change.

hope this will work

Read only

0 Likes
2,373

Hi Soumaya..

You Rock man this is the best answer..

It has solved my problem...

i will definitely give you full points for this