2013 Nov 21 2:43 PM
Hi All.
Below is my selection screen
p_bukrs like bkpf-bukrs.
p_gjahr like bkpf-gjahr.
p_monat like bkpf-monat,
s_blart for bkpf-blart.
s_mwskz for t007a-mwskz.
How to validate if the Tax Code entered on the selection screen for company code 2500 is INPUT tax code(where T007A-MWART = 'V').
Also Tax code should be populated only for company code 2500 where country is France ( T001-BUKRS = “FR” ) . Show error message if Tax codes are populated for a Company code where country is NOT FR- France.
How to do this and in which event I have to write these conditions. Please help me.
Thanks,
Haritha
2013 Nov 22 5:46 AM
Hii Haritha,
To validate the selection screen elememts , use EVENT AT SELECTION-SCREEN [ON BLOCK, ON SCREEN, ON FIELD].
Here is sample validation code .
REPORT zr05_validation.
DATA v_mwart TYPE mwart.
PARAMETERS p_bukrs TYPE bukrs. "Company code
SELECT-OPTIONS s_mwart FOR v_mwart. "Tax type
AT SELECTION-SCREEN.
IF p_bukrs IS INITIAL .
SET CURSOR FIELD 'P_BUKRS'.
MESSAGE 'Enter the Company Code ' TYPE 'E'.
ENDIF.
IF s_mwart IS INITIAL.
SET CURSOR FIELD 'S_MWART'.
MESSAGE 'Enter the Tax type' TYPE 'E'.
ENDIF.
IF NOT p_bukrs IS INITIAL AND
NOT s_mwart IS INITIAL.
IF p_bukrs EQ 2500 AND
s_mwart-low NE 'V'.
SET CURSOR FIELD 'S_MWART'.
MESSAGE 'Enter the tax type as V ' TYPE 'E'.
ELSEIF p_bukrs EQ 2500 AND
s_mwart-low EQ 'V'.
SELECT SINGLE COUNT(*) "Validating the company code for country as FRANCE
FROM t001
WHERE bukrs EQ p_bukrs
AND land1 EQ 'FR'. "FR as FRANCE
IF sy-subrc NE 0.
MESSAGE 'Country is not FRANCE for entered conmpany code' TYPE 'E'.
ENDIF.
ENDIF.
MESSAGE 'Success' TYPE 'S'.
ENDIF.
regards
Syed
2013 Nov 21 2:48 PM
Use AT SELECTION SCREEN EVENTS...
Write the statement in ur editor and click on F1 help...U will get detailed documentation with examples..
Regards,
Maju
2013 Nov 22 4:59 AM
Hi Maju Alexander,
Try like this
TABLES : t007a.
DATA : wa_t007a TYPE t007a.
PARAMETERS : p_mwskz TYPE t007a-mwskz,
p_bukrs TYPE bkpf-bukrs.
AT SELECTION-SCREEN.
if p_bukrs ne 'FR'.
MESSAGE : 'Enter Correct Code' TYPE 'E'.
endif.
IF p_mwskz NE '2500'.
MESSAGE : 'Enter Correct Code' TYPE 'E'.
ELSE.
SELECT SINGLE * FROM t007a
INTO wa_t007a
WHERE mwskz = p_mwskz
AND mwart = 'V'.
IF wa_t007a IS INITIAL.
MESSAGE : ' No data found' TYPE 'E'.
ENDIF.
endif.
START-OF-SELECTION.
2013 Nov 22 3:45 AM
2013 Nov 22 3:50 AM
Hi,
Use the event AT SELECTION SCREEN to validate the fields.
In the table T001 check for the field LAND1 is FR or not using BURKS, if not show error message.
2013 Nov 22 4:04 AM
HI haritha,
you can write the code as,
AT SELECTION SCREEN.
if s_mwskz EQ 'V' AND taxcode EQ 2500.
if BUKRS NE 'FR'.
message 'Write your error message here' type E.
endif.
endif.
Regards,
Sivaganesh
2013 Nov 22 5:46 AM
Hii Haritha,
To validate the selection screen elememts , use EVENT AT SELECTION-SCREEN [ON BLOCK, ON SCREEN, ON FIELD].
Here is sample validation code .
REPORT zr05_validation.
DATA v_mwart TYPE mwart.
PARAMETERS p_bukrs TYPE bukrs. "Company code
SELECT-OPTIONS s_mwart FOR v_mwart. "Tax type
AT SELECTION-SCREEN.
IF p_bukrs IS INITIAL .
SET CURSOR FIELD 'P_BUKRS'.
MESSAGE 'Enter the Company Code ' TYPE 'E'.
ENDIF.
IF s_mwart IS INITIAL.
SET CURSOR FIELD 'S_MWART'.
MESSAGE 'Enter the Tax type' TYPE 'E'.
ENDIF.
IF NOT p_bukrs IS INITIAL AND
NOT s_mwart IS INITIAL.
IF p_bukrs EQ 2500 AND
s_mwart-low NE 'V'.
SET CURSOR FIELD 'S_MWART'.
MESSAGE 'Enter the tax type as V ' TYPE 'E'.
ELSEIF p_bukrs EQ 2500 AND
s_mwart-low EQ 'V'.
SELECT SINGLE COUNT(*) "Validating the company code for country as FRANCE
FROM t001
WHERE bukrs EQ p_bukrs
AND land1 EQ 'FR'. "FR as FRANCE
IF sy-subrc NE 0.
MESSAGE 'Country is not FRANCE for entered conmpany code' TYPE 'E'.
ENDIF.
ENDIF.
MESSAGE 'Success' TYPE 'S'.
ENDIF.
regards
Syed
2013 Nov 22 7:31 AM
Hi
Write all the validation under the event AT SELECTION SCREEN so that if any error is there it will stay in the same page and display error.
AT SELECTION SCREEN.
SELECT SINGLE COUNT(*) "Validating the company code for country as FRANCE
FROM t001
WHERE bukrs EQ p_bukrs
AND land1 EQ 'FR'. "FR as FRANCE
if sy-subrc <> 0
message e000 with text-001. (double click on text-001 and print appropritate text)
2013 Nov 22 7:33 AM
Hi Haritha,
The following are the proessing blocks in ABAP:
NITIALIZATION
Before the standard selection screen is displayed
AT SELECTION SCREEN OUTPUT
This is called just before the selection screen is displayed and can be used to manipulate the actual selection screen attributes using teh loop at screen functionality. This allows you to do things like hide fields, grey them out so they are output only or make them intensified etc.
AT SELECTION-SCREEN
After user input on a selection screen has been processed, but while the selection screen is still active
START-OF-SELECTION
After the standard selection screen has been processed, before data is read from the logical database
END-OF-SELECTION
After all data has been read by the logical database
List processor events:
TOP-OF-PAGE
In list processing when a new page starts
END-OF-PAGE
In list processing when a page ends
AT LINE-SELECTION
When the user triggers the predefined function code PICK
AT PFnn
When the user triggers the predefined function code PFnn
AT USER-COMMAND
When the user triggers a function code defined in the program.
So in order to validate you should use at selection screen.