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

Field Validations

sudhir_uppalapati
Participant
0 Likes
867

Hi all,

I have two Mandatory fields VBAK-VKORG & VBAK-AUART. i am using SELECT-OPTIONS to display these fields on the selection screen. .How to do Field Validation for these two filels.provide me the code.

7 REPLIES 7
Read only

JozsefSzikszai
Active Contributor
0 Likes
763

hi Sudhir,

IF s_vkorg IS INITIAL.

... ==> your code here in case of nothing is filled

ENDIF.

similarly for the other

hope this helps

ec

Read only

Former Member
0 Likes
763

Hi,

try this

 

At selection screen.

select * into table lt_TVKO from TVKO where VKORG in s_VKORG.

if sy-subrc ne 0.
* Raise error message
endif.

select * into table lt_TVAK from TVAK where AUART in s_AUART.

if sy-subrc ne 0.
* Raise error message
endif.


Regards,

Niyaz

Read only

Former Member
0 Likes
763

Hi

see this sample code where i am validation my select-options

REPORT ZNNR_REPORT NO STANDARD PAGE HEADING MESSAGE-ID ZNNR LINE-SIZE 100 LINE-COUNT 65(4).

******DATA DECLARATIONS**********

DATA : BEGIN OF IT_PLANT OCCURS 0,

MATNR LIKE MARA-MATNR,

WERKS LIKE MARC-WERKS,

PSTAT LIKE MARC-PSTAT,

EKGRP LIKE MARC-EKGRP,

END OF IT_PLANT.

DATA : BEGIN OF IT_PONO OCCURS 0,

EBELN LIKE EKKO-EBELN,

EBELP LIKE EKPO-EBELP,

MATNR LIKE EKPO-MATNR,

WERKS LIKE EKPO-WERKS,

LGORT LIKE EKPO-LGORT,

END OF IT_PONO.

TABLES EKKO.

********END OF DATA DECLARATIONS*********

********SELECTION SCREEN DESIGN ***********

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETER : P_WERKS LIKE MARC-WERKS MODIF ID S1.

SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN NO INTERVALS MODIF ID S2.

SELECTION-SCREEN END OF BLOCK B1.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-004.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS : R1 RADIOBUTTON GROUP G1 DEFAULT 'X'.

SELECTION-SCREEN COMMENT 5(20) TEXT-002 FOR FIELD R1.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS : R2 RADIOBUTTON GROUP G1.

SELECTION-SCREEN COMMENT 5(20) TEXT-003 FOR FIELD R2.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK B2.

******END OF SELECTION SCREEN DESIGN****************

*********INITIALIZATION OF SELECTION SCREEN ELEMENTS.*****

INITIALIZATION.

P_WERKS = '1000'.

S_EBELN-LOW = '4500016926'.

S_EBELN-OPTION = 'EQ'.

S_EBELN-SIGN = 'I'.

APPEND S_EBELN.

CLEAR S_EBELN.

************END OF INITIALIZATION***********************

***********SCREEN MODIFICATIONS*******************

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF R1 EQ 'X' AND SCREEN-GROUP1 EQ 'S2'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

IF R2 EQ 'X' AND SCREEN-GROUP1 EQ 'S1'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

********END OF SCREEN MODIFICATIONS*****************

*****************SCREEN VALIDATIONS *******************

*at selection-screen.*

SELECT SINGLE

*FROM EKKO*

*INTO EKKO*

*WHERE EBELN IN S_EBELN.*

*IF SY-SUBRC <> 0.*

*SET CURSOR FIELD 'S_EBELN-LOW'.*

*MESSAGE E999 WITH TEXT-005.*

*ENDIF.*

*********end of screen validation******************

Read only

0 Likes
763

see that last code

****************SCREEN VALIDATIONS ******************

at selection-screen.

*SELECT SINGLE **

FROM EKKO

INTO EKKO

WHERE EBELN IN S_EBELN.

IF SY-SUBRC <> 0.

SET CURSOR FIELD 'S_EBELN-LOW'.

MESSAGE E999 WITH TEXT-005.

ENDIF.

********end of screen validation*****************

Read only

Former Member
0 Likes
763

hi,

what type of validation u want?

Read only

Former Member
0 Likes
763

Hi,

Check the following code:

tables: vbak.

select-options: s_vkorg for vbak-vkorg,

s_auart for vbak-auart.

if s_vkorg[] is initial.

message i000(0) WITH 'No records found'.

endif.

if s_auart[] is initial.

message i000(1) with 'Must enter Date'.

endif.

Regards,

Bhaskar

Read only

Former Member
0 Likes
763

at selection-screen.

*&--Validation for vkorg.

if s_vkorg is not initial.

select single vkorg into wa_itab-vkorg

from vbak

where vkorg in s_vkorg.

*&--Checking for errors in the entry

if sy-subrc <> 0.

message e100.

endif.

endif.

Put in the message as 'VKORG does not exist'.

Use the similar code for auart validation in at selection-screen.