Sample Program On AT SELECTION-SCREEN Event.


Sample program On SET CURSOR FIELD.


Sometimes there is a requirement to place the cursor on the field having a wrong value in the selection screen.


REPORT ztest.

TABLES:bsid.

DATA: temp_hkont TYPE bsid-hkont,
temp_kunnr TYPE bsid-kunnr,
temp_bukrs TYPE bsid-bukrs.

SELECT-OPTIONS: s_bukrs FOR bsid-bukrs.
PARAMETERS: s_hkont LIKE bsid-hkont.
PARAMETERS: s_kunnr LIKE bsid-kunnr.

AT SELECTION-SCREEN.
CLEAR: temp_hkont.
IF s_hkont IS NOT INITIAL.
   SELECT SINGLE hkont FROM bsid INTO temp_hkont
                  WHERE hkont = s_hkont.

      IF sy-subrc <> 0.
          MESSAGE 'Enter a valid G/L Account' TYPE 'E'.
      ENDIF.
ENDIF.

CLEAR: temp_kunnr.
IF s_hkont IS NOT INITIAL.
    SELECT SINGLE kunnr FROM bsid INTO temp_kunnr
                  WHERE kunnr = s_kunnr.

      IF sy-subrc <> 0.
          MESSAGE 'Enter a valid G/L Account' TYPE 'E'.
      ENDIF.
ENDIF.


CLEAR: temp_bukrs.
IF s_bukrs IS NOT INITIAL.
    SELECT SINGLE bukrs FROM bsid INTO temp_bukrs
                  WHERE bukrs = s_bukrs-low.

      IF sy-subrc = 0.
            SELECT SINGLE bukrs FROM bsid INTO temp_bukrs
                          WHERE bukrs = s_bukrs-high.
                  IF sy-subrc <> 0.
                      MESSAGE 'Enter a Valid Company Code' TYPE 'E'.
                  ENDIF.
      ELSE.
            MESSAGE 'Enter a Valid Company Code' TYPE 'E'.
      ENDIF.
ENDIF.

OUTPUT:


In this case, the user enters correct company code and G/L account values, but the user gives a wrong value in customer Number field.

On pressing “ENTER” button or executing (F8) the program, it can be seen that the entry was wrong for customer number field but the cursor gets placed in company code field.



If such are the cases then modify the program as:

MODIFIED PROGRAM:


REPORT ztest.

TABLES:bsid.

DATA: temp_hkont TYPE bsid-hkont,
temp_kunnr TYPE bsid-kunnr,
temp_bukrs TYPE bsid-bukrs.

SELECT-OPTIONS: s_bukrs FOR bsid-bukrs.
PARAMETERS: s_hkont LIKE bsid-hkont.
PARAMETERS: s_kunnr LIKE bsid-kunnr.

AT SELECTION-SCREEN.
CLEAR: temp_hkont.
IF s_hkont IS NOT INITIAL.
SELECT SINGLE hkont FROM bsid INTO temp_hkont
WHERE hkont = s_hkont.

IF sy-subrc <> 0.
SET CURSOR FIELD 'S_HKONT' DISPLAY OFFSET 0.
MESSAGE 'Enter a valid G/L Account' TYPE 'E'.
ENDIF.
ENDIF.

CLEAR: temp_kunnr.
IF s_hkont IS NOT INITIAL.
SELECT SINGLE kunnr FROM bsid INTO temp_kunnr
WHERE kunnr = s_kunnr.

IF sy-subrc <> 0.
SET CURSOR FIELD 'S_KUNNR' DISPLAY OFFSET 0.
MESSAGE 'Enter a valid G/L Account' TYPE 'E'.
ENDIF.
ENDIF.


CLEAR: temp_bukrs.
IF s_bukrs IS NOT INITIAL.
SELECT SINGLE bukrs FROM bsid INTO temp_bukrs
WHERE bukrs = s_bukrs-low.

IF sy-subrc = 0.
   SELECT SINGLE bukrs FROM bsid INTO temp_bukrs
                   WHERE bukrs = s_bukrs-high.

   IF sy-subrc <> 0.
       SET CURSOR FIELD 'S_BUKRS' DISPLAY OFFSET 0.
       MESSAGE 'Enter a Valid Company Code' TYPE 'E'.
   ENDIF.

ELSE.
       SET CURSOR FIELD 'S_BUKRS' DISPLAY OFFSET 0.
       MESSAGE 'Enter a Valid Company Code' TYPE 'E'.

ENDIF.
ENDIF.

OUTPUT:


In this case, the user enters correct company code and G/L account values, but the user gives a wrong value in customer Number field.

On pressing “ENTER” button or executing (F8) the program, it can be seen that the cursor gets placed in G/L account field correctly.




ALSO READ:

- ABAP EVENTS During Runtime Of A Report Program.

- INITIALIZATION Event - Introduction With A Sample Code.

- AT SELECTION-SCREEN Event - Introduction With A Sample Code.

- AT SELECTION-SCREEN OUTPUT Event - Introduction With A Sample Code.

- AT SELECTION-SCREEN ON VALUE REQUEST- Introduction With A Sample Code.

- AT SELECTION-SCREEN ON HELP REQUEST- Introduction With A Sample Code.

- AT SELECTION-SCREEN ON - Introduction With A Sample Code.


- Sample Program On AT SELECTION-SCREEN OUTPUT - 1.

- Sample Program On AT SELECTION-SCREEN OUTPUT - 2.

- Sample Program On AT SELECTION-SCREEN OUTPUT - 3.

- Sample Program On AT SELECTION-SCREEN OUTPUT - 4.

- Sample Program On AT SELECTION-SCREEN ON VALUE REQUEST FOR field - 1.

- Sample Program On AT SELECTION-SCREEN ON VALUE REQUEST FOR field - 2.

- Sample Program On AT SELECTION-SCREEN ON HELP REQUEST FOR field- 1.


Your suggestions and comments are welcome in this section.

Please mail all your contributions to administrator@abapmadeeasy.com We request you to mention your Name, Designation, Experience & Organization you are working for. Your posts will be verified and posted in this site with your name.