Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Compare two fields in table control

Former Member
0 Likes
1,030

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 ....?

10 REPLIES 10
Read only

deepak_dhamat
Active Contributor
0 Likes
990

Hi ,

you requirment is not clear .

regards

Deepak.

Read only

0 Likes
990

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.

Read only

0 Likes
990

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.

Read only

0 Likes
990

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.

Read only

0 Likes
990

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

Read only

0 Likes
990

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.

Read only

0 Likes
990

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..

Read only

Former Member
0 Likes
990

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..

Read only

Former Member
0 Likes
990

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

Read only

0 Likes
990

Hi,

I my previous query itab contains selected rows from screen.

BR

Dep