‎2007 Oct 11 7:23 AM
Hi gurus,
I have created a screen with 5 fields, and two buttons , one is SAVE and Cancel buttons.
1. My question is after giving the input to the 5 fields, the SAVE button should be enable,if any one of the field blank means ,save button should be disable.
2. how to do validations for given dates(i.e fromdate and todate), plz provide code for it.
‎2007 Oct 11 7:29 AM
Use
LOOP AT SCREEN to enable and disable save button.
To validate from and to date.
Do your validation is PAI event...
IF TO_DATE < FROM_DATE
***MESSAGE.
ENDIF.
Close the thread once your question is answered.
Regards,
SaiRam
‎2007 Oct 11 7:45 AM
Hi,
1)assign a group to the SAVE button suppose G1, then follow in pai module:
loop at screen where group1 = 'G1'.
screen-active = 0.
screen-input = 0.
modify screen.
endloop.
put this loop and endloop inside the check that any of the field is initial .
2) u can simply comapre to date fields as we do for numeric or character. but both should be of type DATUM or DATE.
Reward points if info useful....
‎2007 Oct 11 8:23 AM
‎2007 Oct 11 11:19 PM
Groups as assigned in the screen painter per field... but you could also just use something like:
loop at screen.
if screen-name = 'MY_BUTTON'. "change to your PB name
screen-active = 0.
screen-input = 0.
modify screen.
endif.
endloop.Jonathan
‎2007 Oct 12 6:49 AM
Check if any of the field is initial.
If Yes disable the save button.
or
You can use a variable which is set to 1 if any of the field is initial.
e.g. if field1 is initial
var1 = 1.
end if.
if field2 is initial
var1 = 1.
end if.
loop at screen.
if var1 = 1.
make screen inactive.
end loop.
‎2007 Oct 12 9:13 AM
hi,
there are many logics that can be used to explain ur prob. Here is one of the solutions...
1) we use a variable to represent whether the Save button has to be disabled or not.
2) before processing the OKCODE (sy-ucomm) we check whether the button is needed to be disabled or not. (here im doing that in the module VALIDATE_TEXTBOXES).
3) we enable/disable the save button in the PBO using LOOP AT SCREEN.
-
X--
firstly im pasting the FLOW logic of my Screen...
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
PROCESS AFTER INPUT.
MODULE VALIDATE_TEXTBOXES.
MODULE USER_COMMAND_0100.
-
X-----X-----
Next im pasting the code of my prog. my prog is a executable type of program.
PROGRAM ZSCREEN_PROG1.
DATA: TEXTBOX1(20) TYPE C,
TEXTBOX2(20) TYPE C,
TEXTBOX3(20) TYPE C,
OKCODE TYPE SY-UCOMM,
DISABLE_SAVE_BUTTON TYPE BOOLEAN VALUE 'X'.
call screen 100.
&----
*& Module VALIDATE_TEXTBOXES INPUT
*& Module for checking whether to enable or disable the save button
&----
MODULE VALIDATE_TEXTBOXES INPUT.
IF TEXTBOX1 IS INITIAL or
TEXTBOX2 IS INITIAL or
TEXTBOX3 IS INITIAL.
DISABLE_SAVE_BUTTON = 'X'.
ELSE.
DISABLE_SAVE_BUTTON = ''.
ENDIF.
ENDMODULE. " VALIDATE_TEXTBOXES INPUT
&----
*& Module USER_COMMAND_0100 INPUT
*& The Main PAI Module
----
MODULE USER_COMMAND_0100 INPUT.
CASE OKCODE.
WHEN 'SAVE'.
IF DISABLE_SAVE_BUTTON NE 'X'. "if save button is not disabled
"enter ur code for Save Button
ENDIF.
WHEN 'CANC'.
"Code for action on clicking Cancel button
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Module STATUS_0100 OUTPUT
*& Main PBO Module
----
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
*---If we have to disable the SAVE button
IF DISABLE_SAVE_BUTTON = 'X'.
LOOP AT SCREEN.
IF SCREEN-NAME = 'SAVE'.
SCREEN-INPUT = 0. "to Disable
MODIFY SCREEN.
ENDIF.
ENDLOOP.
*---If we have to enable the SAVE button
ELSE.
LOOP AT SCREEN.
IF SCREEN-NAME = 'SAVE'.
SCREEN-INPUT = 1. "to Enable
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
-
Regards,
Sagar.
PS: Rewards points are appriciated..