2007 May 25 9:26 AM
hi all.
i have an internal table with a counter (aa), coep-belnr and coep-buzei.
so with the same belnr and different buzei in the counter must be added 1 each time.
and each time that i have new belnr then the counter will be equal to 1 and so on.
for example.
belnr buzei aa(counter)
A A 1
A B 2
A C 3
B A 1
B B 2
B C 3
B D 4
i used many codes but the resault was not the one i wanted.
one of them is:
sort it_file by belnr buzei.
loop at it_file.
h_file = it_file.
at new belnr.
h_file-aa = 0.
at new buzei.
add 1 to h_file-aa.
endat.
endat.
modify it_file from h_file index sy-tabix.
endloop.
please if you have smth in mind.........
thank you.
2007 May 25 9:33 AM
DATA : COUNT TYPE I.
sort it_file by belnr buzei.
loop at it_file.
h_file = it_file.
at new buzei.
add 1 to COUNT.
endat.
H_FILE-AA = COUNT.
AT END OF BELNR.
COUNT = 0.
ENDAT.
modify it_file from h_file index sy-tabix.
endloop.
REGARDS
SHIBA DUTTA
hi all.
i have an internal table with a counter (aa), coep-belnr and coep-buzei.
so with the same belnr and different buzei in the counter must be added 1 each time.
and each time that i have new belnr then the counter will be equal to 1 and so on.
for example.
belnr buzei aa(counter)
A A 1
A B 2
A C 3
B A 1
B B 2
B C 3
B D 4
i used many codes but the resault was not the one i wanted.
one of them is:
sort it_file by belnr buzei.
loop at it_file.
h_file = it_file.
at new belnr.
h_file-aa = 0.
at new buzei.
add 1 to h_file-aa.
endat.
endat.
modify it_file from h_file index sy-tabix.
endloop.
please if you have smth in mind.........
thank you.
2007 May 25 9:32 AM
Hi,
data: g_count type sy-index.
loop at itab.
g_count = g_count+1.
aa = gcount.
modify itab transporting aa.
at new belnr.
g_count = 0.
endat.
endloop.This will work
Jogdand M B
2007 May 25 9:33 AM
DATA : COUNT TYPE I.
sort it_file by belnr buzei.
loop at it_file.
h_file = it_file.
at new buzei.
add 1 to COUNT.
endat.
H_FILE-AA = COUNT.
AT END OF BELNR.
COUNT = 0.
ENDAT.
modify it_file from h_file index sy-tabix.
endloop.
REGARDS
SHIBA DUTTA
2007 May 25 9:37 AM
The order of the fields in your table affect the results. If you have your table declared as :
belnr
buzei
counter
then the at new buzei statement will occur every time belnr changes. When you state at new belnr, then fields to the right are populated with *. This too will affect the operation of your code.
2007 May 25 9:40 AM
hi
you can try with this.
Data l_local like itab.
Data l_local1 like itab.
Loop at itab.
Clear l_local.
L_local = itab.
At new itab-belnr.
L_local-aa =0.
Clear l_local1.
Endat.
L_local1 = l_local.
If l_local1- buzei = l_local-buzei.
L_local-aa = L_local-aa + 1.
Endif.
Modify itab from l_local index sy-tabix.
Endloop.
thanks
Mohit
2007 May 25 9:44 AM
hi
Please check with this change.
Data l_local like itab.
Data l_local1 like itab.
Loop at itab.
Clear l_local.
L_local = itab.
At new itab-belnr.
L_local-aa =0.
Clear l_local1.
Endat.
L_local1 = l_local.
If l_local1- buzei <> l_local-buzei. " change
L_local-aa = L_local-aa + 1.
Endif.
Modify itab from l_local index sy-tabix.
Endloop.
thanks
Mohit
2007 May 25 9:50 AM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |