08-05-2008 1:15 PM
Hi All,
i have one internal table which has one field MGEIN.If the value of MGEIN is identical for all the rows only then i have to do some calculation.Please help how doi fins whether all values are identical.
Thanks in Advance,
Saket.
08-05-2008 1:17 PM
step 1: sort the table with respect to the field
step 2: check the value in IF....ENDIF. block
Regards,
Anirban
08-05-2008 1:20 PM
Hi,
Use the command DELETE ADJACENT DUPLICATES FROM itab COMPARING <field name> for delete duplicate entries from internal table.
OR
check the below code...
LOOP AT gt_input[] INTO gx_input.
AT NEW <Fname>.
CLEAR lv_count.
ENDAT.
lv_count = lv_count + 1.
At end of each <Fname> check if there are more than one same entry
AT END OF <Fname>.
IF lv_count > 1.
<Do your own process>
ENDIF.
ENDAT.
ENDLOOP.
Rgds,
Bujji
Edited by: Bujji on Aug 5, 2008 2:32 PM
08-05-2008 1:22 PM
I think you need to use the control break statements AT NEW <FIELD_NAME>...AT END OF <FIELD_NAME>.
08-05-2008 1:22 PM
I think you need to use the control break statements AT NEW <FIELD_NAME>...AT END OF <FIELD_NAME>.
08-05-2008 1:23 PM
Hello Saket,
Quite simple SORT the internal table by MGEIN & then DELETE ADJACENT DUPLICATES from the table.
This will delete the duplicate entries. This way you can know if any duplicate entries exist. Can you tell me what operation you want to perform, that way i can suggest a better soln.
BR,
Suhas
08-05-2008 1:29 PM
Hi....
Declare var1, var2, flag, loop variables.... and..
>Loop at itab.
>
>if loop is initial.
>var1 = itab-mgein.
>move var1 to var2.
>loop = 'X'.
>else if itab-mgein ne var2.
> flag = 'X'.
>else.
>flag = space.
>endif.
>
>endloop.
Now in the process of the doing sum...
Check flag = space or not.
If flag = space then only proceed...
Thanks,
Naveen.I
08-05-2008 1:38 PM
Saket,
you can copy your internal table into some other temp internal table.than in temp internal table you can check like this:
sort temp by MGEIN.
delete adjecent duplicates from temp comparing MGEIN.
if sy-subrc = 0.
"means duplicate entry found.
else.
"do calculation here with your orignal internal table.
endif.
08-05-2008 1:38 PM
hiii
you can use following code for comparing field values..for this you need to have same values in another internal tabel
sort it_prd by a.
sort it_chs by a.
LOOP AT it_prd.
READ TABLE it_chs WITH KEY
a = it_prd-a
b = it_prd-b.
w_tmp2 = it_chs-a.
w_tmp3 = it_chs-b.
if w_tmp = w_tmp2 and w_tmp1 = w_tmp3.
if sy-subrc EQ 0.
APPEND it_prd TO it_s.
ENDIF.
w_tmp = it_prd-a.
w_tmp1 = it_prd-b.
ENDLOOP.
i hope it helps you
regards
twinkal
08-05-2008 1:45 PM
First SORT internal table by MGEIN.
Then use AT-NEW command and add up the values you want.
or you can
read the first entry in a variable and the subsequent entry in another variable
Compare them as
IF var1 = var2
add up the values
ENDIF.
Hope this helps
08-05-2008 2:07 PM
Hi,
First declare another internal table with same structure and transfer all the data into newly declared table. Now take this newly declared table perform remove adjacent duplicates.
Then check for sy-dbcnt (total number if records) if the total number of records is greater than one means there exists different MGEIN values. else there exists only one MGEIN then do summation of the required field with your original internal table.
Hope this will help you,
Regards,
Aswini.
11-11-2008 5:29 AM