on 02-23-2010 12:15 PM
Hi Guys,
Have a situation as follows:
Have an internal table as below.Have filled the itab with a select statement.
DATA: BEGIN OF t2 OCCURS 0,
mdocnr TYPE rkwa-mblnr,
mjahr TYPE rkwa-mjahr,
zeile TYPE rkwa-zeile,
budat TYPE rkwa-budat,
matnr TYPE rkwa-matnr,
belnr TYPE rkwa-belnr,
bwart TYPE mseg-bwart,
sobkz TYPE mseg-sobkz,
lifnr TYPE mseg-lifnr,
kdauf TYPE mseg-kdauf,
posnn TYPE vbfa-posnn,
posnr TYPE ser01-posnr,
obknr TYPE ser01-obknr,
sernr TYPE equi-sernr,
matn2 TYPE objk-matnr,
mtart TYPE mara-mtart,
END OF t2.
When looping through the itab:
When the itab contains for example, 3 rows(It could be more than 3 as well) with the same meaterial document number(mdocnr) and when t2-posnr > t2-posnn for all the 3 rows,I want to delete all the rows(In our example - 2 rows) except 1 and modify this row so that I want to make the posnr and posnn value TO empty strings and update or write it back to the itab.
When the hit is only one.Ie: where only 1 row is found where t2-posnr > t2-posnn ,I want to make the posnr and posnn value of this single row TO empty strings and update or write it back to the itab.
How could it be done....
Would appreciate if someone could post a sample code.
Thanks
P
Hello pazzuzu
you can filter by
sort itab by mblnr (and all other fields).
DELETE ADJACENT DUPLICATES FROM itab comparing mblnr ( all other fields).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
first sort your internal based on the key field and delete adjacent duplicates.
*********
sort t2 by <key>.
delete adjacent duplicates from t2.
*********
as you said that your' mblnr' is same for all rows,
then check for the condition whether that posnn > posnr inside the loop.
**********
if posnn > posnr.
*... then delete that row based upon the index.
before loop starts take a counter and assign default value '1' to it.
then after each loop pass increment the counter by '1'.
in this way you can achieve this.
regards,
sasi kanth.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.