Posts

Showing posts from September, 2011

ABAP Events - AT SELECTION-SCREEN ON field - Introduction With Sample Program.

Image
AT SELECTION-SCREEN ON <field> Event With A Sample Program This event can be used if the user wants checks or validations to be carried out for a particular field on the selection screen. At Selection-Screen On <field> and At Selection-Screen events , both do the same job i.e. validating the input fields present on the selection screen. The only difference is At Selection-screen event is used to validate all the fields on the selection screen where as At Selection-Screen On <field> event is used to validate a particular field in the selection screen. Suppose there are 4 input fields in the selection screen, we want validation for input field FIELD1 only. Using AT-SELECTION-SCREEN ON <field>: REPORT ztest. PARAMETERS: p_field1 TYPE char10, p_field2 TYPE char10, p_field3 TYPE char10, p_field4 TYPE char10. AT SELECTION-SCREEN ON p_field1. IF p_field1 IS INITIAL. MESSAGE 'Please enter a value in Field1.' TYPE 'E'. ENDIF.

ABAP Events - AT SELECTION-SCREEN ON HELP REQUEST FOR field.

Image
AT SELECTION-SCREEN ON HELP REQUEST FOR <FIELD>. This event is triggered when the user hits F1 on the field in a selection screen . This event gets triggered at the POH of the selection screen. This event is used when we want to display some kind of documentation related to a specific field in the selection screen. In short using this event, a self-programmed help for the input/output field in the selection screen, can be implemented. If the program contains such an event and the user presses F1 , the system processes this rather than displaying the documentation of the Dictionary field - even if the report parameter or the selection option with LIKE or FOR points to a Dictionary field. The event is triggered when the user calls the F1 help for the field <field>. If this event has not been defined, the help from the ABAP Dictionary is displayed, or none, if the field has no Dictionary reference. Also remember that if there is a select-option field, then thi

ABAP Events - AT SELECTION-SCREEN ON VALUE REQUEST FOR field.

Image
AT SELECTION-SCREEN ON VALUE REQUEST FOR <FIELD>. This event is triggered when the user hits F4 on the field in a selection screen. This event gets triggered at the POV of the selection screen. If an input field declared in an executable program refers to a field in the ABAP Dictionary for which possible entries help is defined, the list of values from the Dictionary is automatically displayed when the user calls the F4 help for that field. In case, if a user wants to create possible values help for report input fields that have no Dictionary reference, or to override the Dictionary input help linked to the field, he/she can create one by using AT SELECTION-SCREEN ON VALUE-REQUEST FOR <field> event . Also remember that if there is a select-option field, then this event has to be written twice i.e. one for field-low and another for field-high. SAMPLE PROGRAM: REPORT ztest . TABLES: t001. TYPES: BEGIN OF x_t001, bukrs TYPE t001-bukrs, butxt TYPE t0

ABAP Events - AT SELECTION-SCREEN OUTPUT Keyword, Example With Output.

Image
All About AT SELECTION-SCREEN OUTPUT Event With A Sample Code. This event gets triggered at the PBO of the selection screen every time the user presses “ENTER” button on the selection screen. In simple words, this event is triggered after loading the selection screen into memory but before it is displayed to the user. This event can be used to change the properties of the selection screen fields dynamically. Hence this event allows us to modify the selection screen and its fields directly before it is displayed. Attributes related to any selection screen fields are saved in a workarea called SCREEN during this event. In case you try to use two or more AT SELECTION-SCREEN OUTPUT events, you will get an error message “The event AT SELECTION-SCREEN OUTPUT was already specified in the program.” For example, if you select some radiobutton in the selection screen then you want some of the fields should become invisible or grayed out. Such scenarios can be achieved by using thi

Sample Program On AT SELECTION-SCREEN Event.

Image
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

SAP ABAP-AT SELECTION-SCREEN Event, Example With Output.

Image
At Selection-Screen Event gets triggered right after the Initialization event. This event is basically used to validate fields present in selection screen. Through this event, checks can be incorporated on selection screen fields and appropriate message can be sent back to the screen/user. In simple words, when the user enters the value in the fields of the selection screen and executes it , AT SELECTION-SCREEN event gets triggered. It is used to check or validate the values entered by the user for the fields on selection screen. Authority checks can also be performed in this event. This event gets triggered in two ways: When the user enters the value in the fields of selection screen and executes it (F8). When the user enters the “ENTER” BUTTON on the selection screen. DIFFERENT TYPES OF AT SELECTION-SCREEN EVENTS (In order of execution): At Selection-Screen Output. At Selection-Screen On Value Request For <Field>. At Selection-Screen On Help Request For &l

SAP ABAP - INITIALIZATION Events, Examples With Output.

Image
Initialization event gets triggered when the program is loaded in memory but before the selection screen processing. This event gives an opportunity to initialize the input fields of the selection screen. Initialization is an event that can be used for setting default values on selection fields , setting a title bar, assigning text to pushbuttons, etc. at runtime. Initialization event block can also be used to perform authority checks. SAMPLE PROGRAM - 1: REPORT ztest. SELECTION-SCREEN BEGIN OF BLOCK rad1 WITH FRAME TITLE title. PARAMETER: p_budat LIKE bsid-budat OBLIGATORY. SELECTION-SCREEN END OF BLOCK rad1. INITIALIZATION. title = 'Selection'. p_budat = '20110825'. AUTHORITY-CHECK OBJECT 'Z_BUDAT' ID 'ZCHECK' FIELD 'BUDAT'. IF sy-subrc EQ 0. ..... ENDIF. START-OF-SELECTION. WRITE: 'START-OF-SELECTION Event Initialized'. OUTPUT: On executing / F8: The output is as expected: Also remember