‎2011 Aug 10 9:37 AM
how to compare two fields in a table control with emp ids repeating and before saving it.....have to check the selection is done with the same emp ids...
say only emp id 1001 alone is selected for saving ....?
‎2011 Aug 10 10:03 AM
‎2011 Aug 10 10:09 AM
i am tryng to validate a single field in a table control
while selecting a couple of records,i have selected say 3 with same emp id 1001 and 1 with emp id 1002
before saving the same, i need to pop up a error message telln tat i have selected one wrong empid 1002.
hope it was elaborative.
thank you.
‎2011 Aug 10 10:21 AM
Why cant u validate that in the qurey ??
select * from table_1 where table_1-field1 = fk_field1
and table_1-field2 = fk_field2
And moreover after retriving the emp id , Where do u check to confirm that u have selected the wrong emp id ?
you dont want to display a message that u have selected the wrong fields , thy can be omitted y using a Query,,,
Rep me if i am right.
‎2011 Aug 10 11:29 AM
With Query u can delete but all the records shud be selected with tat query,not emiting those with dupolicate entries.
i have selected internal table into a local temp work area
but selectn that will cause error everytime now
LOOP AT it_tab INTO wa_tab1
WHERE sel = 'X'.
if wa_tab-empid NE wa_tab1-empid.
MESSAGE e000 with text-052.
endif.
please help
Thank you.
‎2011 Aug 10 11:40 AM
hey your displaying error message in loop. after the message type exit. it will exit the loop like below my code. and make sure wa_tab-empid contains old empid number..
if wa_tab-empid NE wa_tab1-empid.
MESSAGE e000 with text-052.
EXIT.
endif.
try this way
data : lv_empid type empid,
flag(1).
flag = 'X'."pass the value
LOOP AT it_tab INTO wa_tab1
WHERE sel = 'X'.
if flag = 'X'.
lv_empid = wa_tab1-empid."get the 1st empid
clear flag. "clear the flag
endif.
.
.
if lv_empid NE wa_tab1-empid.
MESSAGE e000 with text-052.
EXIT. "write EXIT here
endif.
endloop.
Regards,
Dhina..
Edited by: Dhina DMD on Aug 10, 2011 12:57 PM
‎2011 Aug 10 12:35 PM
can we have smethng related to the code that i have posted without using flags?
because for wrong values the message pop-ups up but for same ids still that error message coming.
‎2011 Aug 10 12:50 PM
hi,
try at first event inside the loop. why i am using flag means i want to get first empid.
LOOP AT it_tab INTO wa_tab1
WHERE sel = 'X'.
at first.
lv_empid = wa_tab1-empid."get the 1st empid
endat.
.
.
if lv_empid NE wa_tab1-empid.
MESSAGE e000 with text-052.
EXIT. "write EXIT here
endif.
endloop.
regards,
Dhina..
‎2011 Aug 10 10:26 AM
Hi,
best-way is in PAI write the code in save ucomm
1) append all selected records in one internal table.
2) read the internal table 1st record using read table index 1.
3) pass the emp id with one variable.
4) delete the selected record internal table with condition empid NE variable.
5) if sy-subrc = 0. throw the message because different empid is there in your internal table
Hope you can understand.
Regards,
Dhina..
‎2011 Aug 10 11:18 AM
Hi,
In Your PAI event.
SORT itab BY empid.
DELETE ADJACENT DUPLICATES FROM itab COMPARING empid.
DESCRIBE TABLE itab LINES *nols* . " nols meaning no. of lines.
IF nols GT 1.
error message.
ENDIF.BR
Dep
Edited by: DeepakNandikanti on Aug 10, 2011 12:18 PM
‎2011 Aug 10 11:24 AM
Hi,
I my previous query itab contains selected rows from screen.
BR
Dep