Sunday, 8 April 2012

ABAP Events Program- Excellent Output

REPORT ztest MESSAGE-ID zebg1.

TABLES: bsid, vbrk.

DATA: temp_vkorg TYPE vbrk-vkorg,
           temp_bukrs TYPE bsid-bukrs.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE title.

   PARAMETER: s_bukrs LIKE bsid-bukrs. " Company Code
   PARAMETER: s_hkont LIKE bsid-hkont OBLIGATORY. " G/L Account
   PARAMETER: s_vkorg LIKE vbrk-vkorg. " Sales Organization
   PARAMETER: p_budat LIKE bsid-budat OBLIGATORY DEFAULT sy-datum. " As On Date

 SELECTION-SCREEN END OF BLOCK b1.


SELECTION-SCREEN SKIP.

INITIALIZATION.

 s_hkont = '0015515001'.
 title = 'Please enter the following details'.

AT SELECTION-SCREEN.

IF s_bukrs IS NOT INITIAL.

  SELECT SINGLE bukrs FROM bsid INTO temp_bukrs
  WHERE bukrs EQ s_bukrs.

  IF sy-subrc NE 0 .
    MESSAGE 'Please enter correct Company Code' TYPE 'E'.
  ENDIF.

ENDIF.

IF s_vkorg IS NOT INITIAL.

   SELECT SINGLE vkorg FROM vbrk INTO temp_vkorg
   WHERE vkorg EQ s_vkorg.

  IF sy-subrc NE 0 .
    MESSAGE 'Please enter correct Sales Organisation' TYPE 'E'.
  ENDIF.

ENDIF.

IF p_budat CP '2011*'.
  MESSAGE 'The report will be generated For year 2011' TYPE 'I'.
ENDIF.


START-OF-SELECTION.


  WRITE: 'This is a test program.'


OUTPUT:












Enter Company Code: 2522. Execute the report or press enter.
















Enter Sales Organization: 5436. Execute the report or press enter.












When the user enters valid company code and sales organization and executes the report or press enter button on the screen. 













On executing the report: