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: 

on change event

Former Member
0 Kudos

Hi experts,

I have ITAB something like this.


REVNR	       AUFNR	MENGE	VKBUR	MATNR
<b>21PSK200</b>	4007627	2	9003	02A15B
21PSK200	4007627	2	9003	02A15B
21PSK200	4007629	3	9003	02A34B
21PSK200	4007629	3	9003	02A34B
21PSK200	4007629	3	9003	36F14B
21PSK200	4007629	3	9003	36F14B
<b>21PSK201</b>	4007627	5	9003	02A15B
21PSK201	4007627	2	9003	02A15B
<b>21PSK202</b>	4007629	1	9003	02A34B
21PSK202	4007629	6	9003	02A34B
21PSK202	4007629	6	9003	36F14B
21PSK202	4007629	2	9003	36F14B

On change of REVNR, i want to display <b>new page</b> with details....and total of MENGE & totol records...

For example


REVNR  : 21PSK200


MATNR    VKBUR  MENGE
02A15B   9003    2
02A15B   9003    2
02A34B   9003    2
02A34B   9003    2
36F14B   9003    3
36F14B   9003    3
------        ------
  6             14
-----          -----

Can any one tell me what is the better way to get it?

My code is not working using ON change event...

thanks

kaki

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello Kaki,

I hope if you ITAB is sorted on REVNR and if this is the first field in the ITAB u can use

Loop at ITAB.

at New REVNR

ENDLOOP.

9 REPLIES 9

Former Member
0 Kudos

Hi,

I guess you have SORTED your table by REVNR. In that case your ON CHANGE should work.

Can you publish the code here?

Regards,

Ravi

0 Kudos

HI Ravi

REVNR is the first field in my ITAB(T_DET)


 LOOP AT T_DET.
    G_ORDR = G_ORDR + 1.

    ON CHANGE OF T_DET-REVNR.
      NEW-PAGE.
    ENDON.

      WRITE:/1(10) T_DET-AUFNR,
             14(20) T_DET-TPLNR,
             36(4) T_DET-VKBUR,
             43(12) T_DET-ERNAM,
             54(10) T_DET-BUDAT,
             65(5) T_DET-QTY,
             75(3) T_DET-MEINS.

      G_QTY = G_QTY + T_DET-QTY.

      IF CNT = 1.
        WRITE :/1(7) SY-ULINE,
                66(5) SY-ULINE.
        WRITE:/1(10) G_ORDR,
               65(5) G_QTY.
        WRITE :/1(7) SY-ULINE,
                66(5) SY-ULINE.
      ENDIF.

  
  ENDLOOP.


0 Kudos

Hi Kaki,

what problem you are facing. are you not getting the proper output.

Regards

vijay

Former Member
0 Kudos

Hello Kaki,

I hope if you ITAB is sorted on REVNR and if this is the first field in the ITAB u can use

Loop at ITAB.

at New REVNR

ENDLOOP.

Former Member
0 Kudos

Hi Kaki,

You can use <b>at new revnr</b> and <b>at end of revnr</b> for your requrement (After sorting itab on revnr).

Regards,

Raj

sort itab by revnr.

loop at itab.

at new revnr.

new-page.

clear: v_tot_items, v_tot_qty.

write:/ 'REVNR: ' itab-revnr.

endat.

v_tot_items = v_tot_items + 1.

v_tot_qty = v_tot_qty + itab-qty.

write:/ itab-matnr , itab-vkur, itab-menge.

at end of revnr.

write:/ 'Total: ' , v_tot_items, v_tot_qty.

clear: v_tot_items, v_tot_qty.

endat.

endloop.

sreemsft
Contributor
0 Kudos

Hi Kaki,

Try to use the below logic.

Loop at itab.
  V_MATNR = V_MATNR + 1. " COUNTER FOR MATERIALS
  At NEW REVNR.
    NEW-PAGE.
    WRITE:/ 'REVNR:', REVNR.
    WRITE:/ 'MATNR', 
            'VKBUR',
            'MENGE'.
  ENDAT.
  WRITE:/ ITAB-MATNR,
          ITAB-VKBUR,
          ITAB-MENGE.
  AT END OF REVNR.
    SUM.
    WRITE:/ V_MATNR.
    WRITE: ITAB-MENGE.
    CLEAR V_MATNR.
  ENDAT.
Endloop.

Thanks,

Sreekanth

former_member186741
Active Contributor
0 Kudos

'on change' is really for use within 'select endselect' blocks. Use 'at new' as the others have suggested. This will work as your field is the first column in the table.

0 Kudos

thanks for all the replies...

will allot points once server is on...

cheers

kaki

0 Kudos

hi kaki ur problem ll be solved by this code...

see tricks for handling first and last record.....

data : begin of itab occurs 0,

REVNR like zchange-REVNR,

AUFNR like zchange-AUFNR,

MENGE like zchange-MENGE,

VKBUR like zchange-VKBUR,

MATNR like zchange-MATNR,

end of itab.

data : s type i value 0.

data : c type i value 1.

select * into corresponding fields of table itab from zchange.

read table itab index 1.

write : /10 'Revnr : ', itab-revnr.

write : /10 itab-matnr,itab-vkbur,itab-menge.

loop at itab.

at first.

continue.

endat.

at new revnr.

break-point.

write : /8 '--


', 40 '--


'.

write : /5 C, 40 s.

write : /8 '--


', 40 '--


'.

write : sy-uline.

s = 0.

c = 0.

new-page.

write : /10 'Revnr : ', itab-revnr.

endat.

s = s + itab-menge.

c = c + 1.

write : /10 itab-matnr,itab-vkbur,itab-menge.

at last.

write : /8 '--


', 42 '--


'.

write : /5 C, 40 s.

write : /8 '--


', 42 '--


'.

write : sy-uline.

endat.

endloop.