04-10-2010 11:36 AM
Hi all,
I have developed a modulepool screen...this screen is used for saving vendor details into databse tables...so,here i m entering the vendor number and its details and then save it by using a pushbuton...My problem here is when i enter a vendor number and its detail values and suddenly if a user changes the vendor number...i need to show a message that u need to save vendor details before changing the vendor number..
How to achieve this..as the user first enters the vendor number and presses ENTER buton..then a event will trigger..but from there how to handle that event and how to know exactly the vendor number has changed....
04-10-2010 12:41 PM
Hi Ravi,
in TOP Include
data tmp_lifnr type lifnr. " This is a Tested Code
in PAI
process after input.
module user_command_0100.
field lfa1-lifnr module chk_vendor on request.
" LFA1-LIFNR is your Screen Field for Vendor Number
in program
MODULE chk_vendor INPUT.
IF NOT lfa1-lifnr IS INITIAL.
IF tmp_lifnr IS NOT INITIAL.
IF lfa1-lifnr NE tmp_lifnr.
MESSAGE 'Before you change the Vendor, Please Save the Data'
TYPE 'E'.
ENDIF.
ENDIF.
tmp_lifnr = lfa1-lifnr.
ENDIF.
ENDMODULE. " CHK_VENDOR INPUT
Cheerz
Ram
Edited by: Rob Burbank on Apr 10, 2010 3:16 PM
04-10-2010 12:15 PM
Just create a global variable that can hold the vendor number and each time the user hits enter and your event is triggered, check if the vendor number has changed or not:
IF NOT gv_vendor_number IS INITIAL AND
gv_vendor_number NE your_input_field.
message w000(oo) with 'Vendor Number has changed'.
gv_vendor_number = your_input_field.
ENDIF.
The check for NOT INITIAL is needed because the first time the user enters a value your global variable will be initial but the vendor number hasn't really changed.
Hope that helps,
Michael
04-10-2010 12:19 PM
HI,
Hold the vendor number in new field after user press enter.Then compare it with screen field, if both are different then pass the message.
04-10-2010 12:23 PM
Oups, logged on under the wrong user. This is the right one
Michael
04-10-2010 12:41 PM
Hi Ravi,
in TOP Include
data tmp_lifnr type lifnr. " This is a Tested Code
in PAI
process after input.
module user_command_0100.
field lfa1-lifnr module chk_vendor on request.
" LFA1-LIFNR is your Screen Field for Vendor Number
in program
MODULE chk_vendor INPUT.
IF NOT lfa1-lifnr IS INITIAL.
IF tmp_lifnr IS NOT INITIAL.
IF lfa1-lifnr NE tmp_lifnr.
MESSAGE 'Before you change the Vendor, Please Save the Data'
TYPE 'E'.
ENDIF.
ENDIF.
tmp_lifnr = lfa1-lifnr.
ENDIF.
ENDMODULE. " CHK_VENDOR INPUT
Cheerz
Ram
Edited by: Rob Burbank on Apr 10, 2010 3:16 PM
04-10-2010 1:31 PM
Hi Micheal,
Thanks for ur reply..
One doubt here is ...gv_vendor_number NE your_input_field
so..gv_vendor_number store the vendor and same as your_input_field...so whenever the vendor number is changed..vendor number will be replicated to both the feilds...how does it will we differinate both these feilds...
04-10-2010 1:38 PM
That is why you check if the field content is different BEFORE you set the current value.
Let's simulate:
Transaction is called and your_input_field is empty (gv_vendor_number is empty as well)
User enters a vendor and hits enter
We check if gv_vendor_number NE your_input_field but because gv_vendor_number is still initial we do not raise the message (because this is the first time the user put something in.
Now we move your_input_field to gv_vendor_number (both have the same value)
User now changes the your_input_field value and hits enter
We again check if gv_vendor_number NE your_input_field and because the gv_vendor_number field still has the OLD value in it we can identify it as being changed and raise the message.
Only then we move your_input_field to gv_vendor_number (both have the same value again) to make sure we capture the next change.
Michael
04-10-2010 1:51 PM
Thanks for ur reply...
so..my code will be like this....
In PAI :
IF NOT gv_vendor_number IS INITIAL AND
gv_vendor_number NE your_input_field.
message w000(oo) with 'Vendor Number has changed'.
gv_vendor_number = your_input_field.
ENDIF.
Move your_input_feild to gv_vendor_number.