Skip to Content

Validation of Fields

  • How to validate the Fields in an ABAP programs., please explain with examples

Thankyou for your time in giving the answers.

Bhaskar.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    Posted on Jan 04, 2007 at 04:13 AM

    Hi,

    If your screen fileds are of standard type like date etc then there will be an automatic check. And also if you have value help for those fileds through foriegn key then those screen fileds will also have automatic checking. If you have generic fields like String then you have to validate them in PAI modules. If you are using selection screen then you can write your validaton code in AT SELECTION-SCREEN event.

    Regards,

    Sesh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 04, 2007 at 04:15 AM

    sorry i dint get your question clearly....

    usually in PAI we validate the screen fields.

    like for selection-screen

    at selection-screen event.

    if you are using the fields by refering database table fields or data element it will automatically validate your screen fields.

    regards

    shiba dutta

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 04, 2007 at 04:19 AM
    data : v_name(25).
    
    at selection-screen output.
    
    if v_name is initial.
      message e001(ZE) with 'Enter valid name'.
    enif.
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 04, 2007 at 04:24 AM

    hi,

    if u want to do some validation in PBO use.

    <b>At selection scteen output</b> event

    if u want to do some validation in PAI use.

    <b>At selection scteen</b> event

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 09:17 AM

    For field validation

    1. Declaration the data type.

    data:w_vbeln like vbrk-vbeln.

    2. Then write this code for field validation.

    select single vbeln

    from vbrk

    into w_vbeln

    where vbeln = vbeln .

    if sy-subrc ne 0.

    message e000(0) with 'Enter Valid Number'.

    endif.

    If it usefull donot foget to point

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 09:33 AM

    Hi Bhasker,

    1. <b>AT SELECTION-SCREEN</b>

    The AT SELECTION-SCREEN event is triggered in the PAI of the selection screen once the ABAP runtime environment has passed all of the input data from the selection screen to the ABAP program. If an error message occurs in this processing block, the selection screen is redisplayed with all of its fields ready for input. This allows you to check input values for consistency.

    REPORT demo_at_selection_screen .

    NODES spfli.

    AT SELECTION-SCREEN.

    IF carrid-low IS INITIAL

    OR airp_fr-low IS INITIAL

    OR airp_to-low IS INITIAL.

    MESSAGE e888(sabapdocu) WITH text-001.

    ENDIF.

    2. <b>AT SELECTION-SCREEN OUTPUT</b>

    In the PBO of the selection screen, the

    <b>AT SELECTION-SCREEN OUTPUT</b>

    event is triggered. This event block allows you to modify the selection screen and its fields directly before it is displayed.

    Initializations of selections screen fields at this moment always take effect, whereas at the execution of an executable program, initializations at moment INITIALIZATION only take effect at the first program start, and are otherwise overwritten by the previous user inputs at the beginning of AT SELECTION-SCREEN OUTPUT.

    REPORT demo_at_selection_screen_pbo.

    PARAMETERS: test1(10) TYPE c MODIF ID sc1,

    test2(10) TYPE c MODIF ID sc2,

    test3(10) TYPE c MODIF ID sc1,

    test4(10) TYPE c MODIF ID sc2.

    AT SELECTION-SCREEN OUTPUT.

    LOOP AT SCREEN.

    IF screen-group1 = 'SC1'.

    screen-intensified = '1'.

    MODIFY SCREEN.

    CONTINUE.

    ENDIF.

    IF screen-group1 = 'SC2'.

    screen-intensified = '0'.

    MODIFY SCREEN.

    ENDIF.

    ENDLOOP.

    3.<b>AT SELECTION-SCREEN ON field</b>

    AT SELECTION-SCREEN ON field

    event is triggered. The input field field can be checked in the corresponding event block. If an error message occurs within this event block, the corresponding field is made ready for input again on the selection screen.

    REPORT event_demo.

    NODES spfli.

    AT SELECTION-SCREEN ON city_fr.

    IF carrid-low EQ 'AA' AND city_fr NE 'NEW YORK'.

    MESSAGE e010(hb).

    ENDIF.

    4. <b>AT SELECTION-SCREEN ON RADIOBUTTON GROUP group</b>

    In the PAI event of the selection screen, the event

    AT SELECTION-SCREEN ON RADIOBUTTON GROUP group

    event is triggered. To define a radio button group, use the addition RADIOBUTTON GROUP group in the corresponding PARAMETERS statements. This event block allows you to check the whole group. If an error message occurs within this event block, the radio button group is made ready for input again on the selection screen. The individual fields of radio button groups do not trigger the event AT SELECTION-SCREEN ON field.

    REPORT demo_at_selection_on_radio.

    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

    PARAMETERS: r1 RADIOBUTTON GROUP rad1 DEFAULT 'X',

    r2 RADIOBUTTON GROUP rad1,

    r3 RADIOBUTTON GROUP rad1.

    SELECTION-SCREEN END OF BLOCK b1.

    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.

    PARAMETERS: r4 RADIOBUTTON GROUP rad2 DEFAULT 'X',

    r5 RADIOBUTTON GROUP rad2,

    r6 RADIOBUTTON GROUP rad2.

    SELECTION-SCREEN END OF BLOCK b2.

    AT SELECTION-SCREEN ON RADIOBUTTON GROUP rad1.

    IF r1 = 'X'.

    MESSAGE w888(sabapdocu) WITH text-001.

    ENDIF.

    AT SELECTION-SCREEN ON RADIOBUTTON GROUP rad2.

    IF r4 = 'X'.

    MESSAGE w888(sabapdocu) WITH text-001.

    ENDIF.

    5. <b>AT SELECTION-SCREEN ON HELP-REQUEST FOR field</b>

    If the data type of an input field declared in an executable program is defined in the ABAP Dictionary, the documentation of the underlying data element is automatically displayed if the user positions the cursor in that field and presses F1. To create help for input fields that have no Dictionary reference, or to override the help normally linked to the field, you can create an event block for the event

    AT SELECTION-SCREEN ON HELP-REQUEST FOR field

    The event is triggered when the user calls the F1 help for the field field. If no corresponding event block has been defined, the help from the ABAP Dictionary is displayed, or none at all if the field has no Dictionary reference. If a corresponding event block exists, it takes precedence over the default help mechanism. It is then up to the programmer to ensure in the event block that appropriate help is displayed to the user.

    No event block AT SELECTION-SCREEN ON HELP-REQUEST can be created for input fields of the selection screen that are declared within the logical database used. You cannot override the help mechanism of the logical database within the executable program. You can define separate help within the logical database program using the HELP-REQUEST option in the PARAMETERS and SELECT-OPTIONSstatements.

    REPORT demo_selection_screen_f1.

    PARAMETERS: p_carr_1 TYPE s_carr_id,

    p_carr_2 TYPE spfli-carrid.

    AT SELECTION-SCREEN ON HELP-REQUEST FOR p_carr_2.

    CALL SCREEN 100 STARTING AT 10 5

    ENDING AT 60 10.

    This program declares a selection screen with two parameters that both refer to the data element S_CARR_ID in the ABAP Dictionary. The documentation from the Dictionary is used for p_carr_1, and a help screen 100 is called for Pp_carr_2. The help screen is defined in the Screen Painter as a modal dialog box with next screen 0. It contains the help text defined as help texts. The screen does not require any flow logic.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 10:10 AM

    if u need to validate the fields, the first thing u need to do is use at selection-screen event and use the check table for the validation purpose

    eg if ur using ltak table it has field lgnum in validation dont use ltak,but instead click on lgnum and click on help/check tab so that u can able to find out the exact master table for it.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.