09-22-2005 8:29 AM
Hi,
i´ve got the following internal table:
DATA: BEGIN OF ITAB OCCURS 0.
RSNUM TYPE MSEG-RSNUM,
RSPOS TYPE MSEG-RSPOS,
CHARG TYPE MSEG-CHARG.
DATA: END OF ITAB.
i can have several CHARG within the same RSNUM RSPOS.
How can i know the number of RSNUM RSPOS?
e.g.
RSNUM RSPOS CHARG
7000000182 0001 C000000548
7000000182 0001 C000000549
7000000182 0002 C000000550
in a LOOP with AT NEW RSNUM i would get the number of RSNUM but i need the combination of RSNUM RSPOS.
How can i do like AT NEW but for both RSNUM and RSPOS?
Best regards.
09-22-2005 9:23 AM
Sorry, the former example was a wrog one.
the correct example would be:
RSNUM RSPOS CHARG
7000000182 0001 C000000548
7000000182 0001 C000000549
7000000182 0002 C000000550
7000000183 0001 C000000551
here i would need: number of registers = 3
1 for 7000000182 0001
1 for 7000000182 0002
1 for 7000000183 0001
Sorry and my excuses for the former post.
Best regards.
09-22-2005 8:32 AM
You could say at new RSPOS, all the changes on teh left hand side of the filed are treated as new.
Rgds,
Manohar
make sure to sort the table rsnum rspos
09-22-2005 8:32 AM
09-22-2005 8:40 AM
With your internal table
DATA COUNT TYPE I.
LOOP AT ITAB.
.....
.....
count = count + 1.
At end of RSPOS.
< Here in field count you will have the no of lines
corresponding to one RSNUM & RSPOS >
ENDAT.
ENDLOOP.
09-22-2005 8:41 AM
Hi
Do You want to know the number of combination or all combination?
Max
09-22-2005 8:55 AM
Hi,
with this example:
RSNUM RSPOS CHARG
7000000182 0001 C000000548
7000000182 0001 C000000549
7000000182 0002 C000000550
the number of registers i need is 2
1 for 7000000182 0001 and
1 for 7000000182 0002
Best regards.
09-22-2005 9:00 AM
Sir ,
Please say at
Loop at table.
at new rspos.
count = count + 1.
at end.
endloop.
09-22-2005 9:23 AM
Sorry, the former example was a wrog one.
the correct example would be:
RSNUM RSPOS CHARG
7000000182 0001 C000000548
7000000182 0001 C000000549
7000000182 0002 C000000550
7000000183 0001 C000000551
here i would need: number of registers = 3
1 for 7000000182 0001
1 for 7000000182 0002
1 for 7000000183 0001
Sorry and my excuses for the former post.
Best regards.
09-22-2005 9:29 AM
Hi
Use AT END or AT NEW event for field RSPOS
LOOP AT itab
AT NEW RSPOS.
ENDAT.
ENDLOOP
Remember:
LOOP AT itab
AT NEW FIELD.
ENDAT.
ENDLOOP
these events runs if a value of a field at left of FIELD is changing or if the value of FIELD is changing.
Max
Message was edited by: max bianchi
Message was edited by: max bianchi
09-22-2005 9:33 AM
then do like this -
data v_cnt type i.
sort itab by RSNUM RSPOS CHARG.
loop at itab.
at new RSPOS.
v_cnt = v_cnt + 1.
endat.
endloop.
it will give you v_cnt = 3 for the example you mentioned here, i.e. -
RSNUM RSPOS CHARG
7000000182 0001 C000000548
7000000182 0001 C000000549
7000000182 0002 C000000550
7000000183 0001 C000000551
09-22-2005 1:24 PM
If you are not really interested in keeping the duplicate RSNUM RSPOS in your internal table, then simply do this;
SORT itab BY rsnum rspos.
DELETE ADJACENT DUPLICATES FROM itab COMPARING rsnum rspos.
DESCRIBE TABLE itab LINES v_cnt.
This will give you what you want. Now if you want to keep your original itab intact, then make a copy of it and do this on the copy.
Regards,
Srinivas
09-22-2005 1:56 PM
hi
7000000182 0001 C000000548
7000000182 0002 C000000548
7000000182 0003 C000000548
7000000182 0001 C000000549
7000000182 0001 C000000549
7000000182 0001 C000000549
7000000182 0002 C000000550
7000000183 0001 C000000551
7000000183 0003 C000000551
what is your expected result.
7000000182 0001 C000000548
7000000182 0001 C000000549
7000000182 0002 C000000550
7000000183 0001 C000000551
as per your example if you delete the adjacent duplicates
all the records has 1 value.
please clarify bit more.
cheers,
sasi
09-22-2005 4:41 PM
> Sorry, the former example was a wrog one.
> the correct example would be:
> RSNUM RSPOS CHARG
> 7000000182 0001 C000000548
> 7000000182 0001 C000000549
> 7000000182 0002 C000000550
> 7000000183 0001 C000000551
>
> here i would need: number of registers = 3
> 1 for 7000000182 0001
> 1 for 7000000182 0002
> 1 for 7000000183 0001
>
> Sorry and my excuses for the former post.
> Best regards.
Hi Sasi,
If you look at his post pasted above, you will see that he wanted the count of unique RSNUM RSPOS combination which is what my response will achieve.
Calsadillo, can you please let me know if I am on the wrong track? If not, please close the post once answered.
Regards,
Srinivas