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

validation for dcoument type

Former Member
0 Likes
435

hi,

how to validate document type (bseg-blart) with select options such that it should accept only document types

kd,kc,kg,ka

2 REPLIES 2
Read only

Former Member
0 Likes
346

Hi ...Bharath,

There is no field BLART in BSEG any how if you have one select option let say so_blart.

AT SELECTION-SCREEN ON so_blart.

SELECT SINGLE * FROM t003

WHERE blart IN so_blart.

IF sy-subrc <> 0.

wirte:\ Enter Valid Document Type.

*MESSAGE e016(01)with so_blart.

ENDIF.

This code will help U out...

Regards,

sg

Read only

Former Member
0 Likes
346

Hi,

You can do this by comparing the select options value

*Loop at the select option

LOOP AT s_blart.

lv_blart_low = s_blart-low.

*-User is allowed to enter the values KD, KC, KG, KA

IF NOT lv_blart_low EQ 'KD'

AND NOT lv_blart_low EQ 'KC'

AND NOT lv_blart_low EQ 'KG'

AND NOT lv_blart_low EQ 'KA'.

*Give Error message

MESSAGE s005 DISPLAY LIKE 'E'.

LEAVE LIST-PROCESSING.

ENDIF.

ENDLOOP.

If you require to further restrict users to choose only KD,KC,KG,KA values when F4 help is pressed on the selection option (s_blart)

Do the following : -

CONSTANTS : lc_eq(2) TYPE c VALUE 'EQ',

lc_i TYPE c VALUE 'I'.

s_blart-low = 'KD'.

s_blart-option = lc_eq.

s_blart-sign = lc_i .

APPEND s_blart.

s_blart-low = 'KC'.

s_blart-option = lc_eq.

s_blart-sign = lc_i.

APPEND s_blart.

s_blart-low = 'KG'.

s_blart-option = lc_eq.

s_blart-sign = lc_i .

APPEND s_blart.

s_blart-low = 'KA'.

s_blart-option = lc_eq.

s_blart-sign = lc_i .

APPEND s_blart.

Then,

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_blart-low .

DATA: lv_repid TYPE sy-repid,

lv_user_reset,

lw_category TYPE t_category.

CONSTANTS: lc_s TYPE c VALUE 'S',

lc_x TYPE help_info-dynprofld VALUE 'X',

lc_vbtyp TYPE dfies-fieldname VALUE 'BLART',

lv_repid = sy-repid.

*-Populate the values KD,KC,KG,KA in an internal table.

lw_category-blart = 'KD'.

APPEND lw_category TO gt_category .

CLEAR lw_category.

lw_category-blart = 'KG'.

APPEND lw_category TO gt_category .

CLEAR lw_category.

lw_category-blart =' KC'.

APPEND lw_category TO gt_category .

CLEAR lw_category.

lw_category-blart = 'KA'.

APPEND lw_category TO gt_category .

CLEAR lw_category.

*-Calling a function to perform the search help functionality.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

  • ddic_structure = lc_space

retfield = 'blart'

  • pvalkey = lc_space1

dynpprog = lv_repid

dynpnr = sy-dynnr

dynprofield = 'X'

  • STEPL = 0

  • WINDOW_TITLE =

  • VALUE = lc_Space

value_org = lc_s

  • MULTIPLE_CHOICE = lc_Space

  • DISPLAY = lc_Space

  • CALLBACK_PROGRAM = lc_Space

  • CALLBACK_FORM = lc_Space

  • MARK_TAB =

IMPORTING

user_reset = lv_user_reset

TABLES

value_tab = gt_category.

  • FIELD_TAB =

  • RETURN_TAB =

  • DYNPFLD_MAPPING =

  • EXCEPTIONS

  • parameter_error = 1

  • no_values_found = 2

  • OTHERS = 3.

*

  • IF sy-subrc NE 0.

    • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  • ENDIF.

*

REFRESH gt_category.

Please reward if useful!

Thanks,

KalpanaR