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 validation

Former Member
0 Likes
831

In module pool i have a table control and one field of table control is mandatory with search help attached to it. I want that user should be able to enter value only from the available list, how to validate that? i dont want to make that field as listbox. Kindly help

Thanks

5 REPLIES 5
Read only

Former Member
0 Likes
663

Hello Lucky,

Check this Code............

*"Selection screen elements............................................

SELECT-OPTIONS:

S_EBELN FOR EKKO-EBELN, " Purchasing Document Number

S_LIFNR FOR EKKO-LIFNR, " Vendor's account number

S_EKGRP FOR EKKO-EKGRP, " Purchasing group

S_BEDAT FOR EKKO-BEDAT, " Purchasing Document Date

S_UDATE FOR CDHDR-UDATE. " Creation date of the change

" document

"----


  • AT SELECTION-SCREEN EVENT *

"----


AT SELECTION-SCREEN ON S_EBELN.

  • Subroutine to validate Purchase Document Number.

PERFORM VALIDATE_PD_NUM.

AT SELECTION-SCREEN ON S_LIFNR.

  • Subroutine to validate Vendor Number.

PERFORM VALIDATE_VEN_NUM.

AT SELECTION-SCREEN ON S_EKGRP.

  • Subroutine to validate Purchase Group.

PERFORM VALIDATE_PUR_GRP.

&----


*& Form VALIDATE_PD_NUM

&----


  • Subroutine to validate Purchase Document Number

----


  • There are no interface parameters to be passed to this subroutine.

----


FORM VALIDATE_PD_NUM .

IF NOT S_EBELN[] IS INITIAL.

SELECT EBELN " Purchase Document Number

FROM EKKO

INTO W_EBELN

UP TO 1 ROWS

WHERE EBELN IN S_EBELN.

ENDSELECT.

IF SY-SUBRC NE 0.

CLEAR SSCRFIELDS-UCOMM.

MESSAGE E717(M8).

ENDIF. " IF SY-SUBRC NE 0

ENDIF. " IF NOT S_EBELN[]...

ENDFORM. " VALIDATE_PD_NUM

&----


*& Form VALIDATE_VEN_NUM

&----


  • Subroutine to validate Vendor Number

----


  • There are no interface parameters to be passed to this subroutine.

----


FORM VALIDATE_VEN_NUM .

IF NOT S_LIFNR[] IS INITIAL.

SELECT LIFNR " Vendor Number

FROM LFA1

INTO W_LIFNR

UP TO 1 ROWS

WHERE LIFNR IN S_LIFNR.

ENDSELECT.

IF SY-SUBRC NE 0.

CLEAR SSCRFIELDS-UCOMM.

MESSAGE E002(M8) WITH W_SPACE.

ENDIF. " IF SY-SUBRC NE 0

ENDIF. " IF NOT S_LIFNR[]...

ENDFORM. " VALIDATE_VEN_NUM

&----


*& Form VALIDATE_PUR_GRP

&----


  • Subroutine to validate the Purchase Group

----


  • There are no interface parameters to be passed to this subroutine.

----


FORM VALIDATE_PUR_GRP .

IF NOT S_EKGRP[] IS INITIAL.

SELECT EKGRP " Purchase Group

FROM T024

INTO W_EKGRP

UP TO 1 ROWS

WHERE EKGRP IN S_EKGRP.

ENDSELECT.

IF SY-SUBRC NE 0.

CLEAR SSCRFIELDS-UCOMM.

MESSAGE E622(M8) WITH W_SPACE.

ENDIF. " IF SY-SUBRC NE 0

ENDIF. " IF NOT S_EKFRP[]...

ENDFORM. " VALIDATE_PUR_GRP

with Regards,

Vidya

Read only

Former Member
0 Likes
663

Hi, Lucky

Use this.

IN PAI

loop at itab. "itab is of table control table

field <your table field> module check_field on-request

endloop.

write check_field module by double clicking the same.

Read only

Former Member
0 Likes
663

Hello ,

Validating Fields

Now we will write the code for validating each field of the screen 200.

Module check_name.

Perform validate_name.

endmodule.

Form validate_name.

If not ztryemp-name co c_alphabet.

Message e999(z1) with text-005.

Endif.

Endform.

Module check_phone.

Perform validate_phone.

endmodule.

Form validate_phone.

If not ztryemp-phone co c_digits.

Message e999(z1) with text-006.

Endform.

Module check_basic.

Perform validate_basic.

endmodule.

Form validate_basic.

If ztrytxn-basic le c_0.

Message e999(z1) with text-007.

Endif.

Endform.

Read only

Former Member
0 Likes
663

Hello ,

This will solve your Problem.....

If that screen field is generated in a SELECTION-SCREEN and using the PARAMTERS then you can add the option VALUE CHECK to force the check of input value aginst the possible values.

Like this

PARAMETERS p_carrid TYPE s_carr_id VALUE CHECK.

If this is a screen field in a dialog program, then for the screen field in the screen painter goto the field's attributes and there select the check box "Foriegn key check". Not sure if this checks aginst the domain values

(or)

make use of this FM and see its documentations.

F4IF_FIELD_VALUE_REQUEST'

With Regards,

Vidya

**********Reward with Points,If found useful.

Read only

mahaboob_pathan
Contributor
0 Likes
663

hi

for validating u can check this function module.

may be it will be use full to u.

POPUP_WITH_TABLE_DISPLAY.