Thursday, August 4, 2011

Pop up window to select month

CALL FUNCTION 'POPUP_TO_SELECT_MONTH'       

EXPORTING
actual_month = ld_spmon

IMPORTING
selected_month = ld_spmon
return_code = ld_returncode
EXCEPTIONS factory_calendar_not_found = 01
holiday_calendar_not_found = 02
month_not_found = 03.

pop up message yes / no in ABAP

REPORT zpopup_menu_yesno. 

DATA : ld_answer TYPE string.

CALL FUNCTION 'POPUP_CONTINUE_YES_NO'

EXPORTING

textline1 = 'POPUP MENU'
textline2 = 'Yes or No?!'
titel = 'Change Confirmation'

IMPORTING

answer = ld_answer.
IF ld_answer = 'J'.
WRITE : / 'Yes !'.
ELSE.
WRITE : / 'Oh, No !'.
ENDIF.

How to catch DUMP in ABAP

REPORT ZCATCHDUMPEXAMPLE.

PARAMETERS: p_file LIKE rlgrap-filename .
DATA: v_file TYPE string.
DATA: BEGIN OF itab OCCURS 0,
      name(23) TYPE  c,
      END OF itab.

DATA: errormessage TYPE char50.
v_file = p_file.
CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename            = v_file
    filetype            = 'ASC'
    has_field_separator = ' '
  TABLES
    data_tab            = itab.

RECEIVE RESULTS FROM FUNCTION 'GUI_UPLOAD'
 EXCEPTIONS
   file_open_error               = 1
   file_read_error               = 2
   no_batch                      = 3
   gui_refuse_filetransfer       = 4
   invalid_type                  = 5
   no_authority                  = 6
   unknown_error                 = 7
   bad_data_format               = 8
   header_not_allowed            = 9
   separator_not_allowed         = 10
   header_too_long               = 11
   unknown_dp_error              = 12
   access_denied                 = 13
   dp_out_of_memory              = 14
   disk_full                     = 15
   dp_timeout                    = 16
   OTHERS                        = 17 .

CASE sy-subrc.
  WHEN 0.
    errormessage     = 'Data Loaded'.
  WHEN 1.
    errormessage     = 'FILE_OPEN_ERROR'.
  WHEN 2.
    errormessage     = 'FILE_READ_ERROR'.
  WHEN 3.
    errormessage     = 'NO_BATCH'.
  WHEN 4.
    errormessage     = 'GUI_REFUSE_FILETRANSFER'.
  WHEN 5.
    errormessage     = 'INVALID_TYPE'.
  WHEN 6.
    errormessage     = 'NO_AUTHORITY'.
  WHEN 7.
    errormessage     = 'UNKNOWN_ERROR'.
  WHEN 8.
    errormessage     = 'BAD_DATA_FORMAT'.
  WHEN 9.
    errormessage     = 'HEADER_NOT_ALLOWED'.
  WHEN 10.
    errormessage     = 'SEPARATOR_NOT_ALLOWED'.
  WHEN 11.
    errormessage     = 'HEADER_TOO_LONG'.
  WHEN 12.
    errormessage     = 'UNKNOWN_DP_ERROR'.
  WHEN 13.
    errormessage     = 'ACCESS_DENIED'.
  WHEN 14.
    errormessage     = 'DP_OUT_OF_MEMORY'.
  WHEN 15.
    errormessage     = 'DISK_FULL'.
  WHEN 16.
    errormessage     = 'DP_TIMEOUT'.
  WHEN 17.
    errormessage     = 'OTHERS'.
ENDCASE.

MESSAGE e001(00) WITH errormessage .

Wednesday, August 3, 2011

An Example of a ListBox Program

REPORT ZLISTBOXPROGRAM.


TYPE-POOLS: VRM.

DATA: NAME  TYPE VRM_ID,
      LIST  TYPE VRM_VALUES,
      VALUE LIKE LINE OF LIST,
      c(20type c.

DATA:BEGIN OF itab OCCURS 0,
      kunnr like kna1-kunnr,
      name1 like kna1-name1,
     END OF itab.

DATA:BEGIN OF jtab OCCURS 0,
      kunnr like kna1-kunnr,
      land1 like kna1-land1,
     END OF jtab.

PARAMETERS: option(20AS LISTBOX VISIBLE LENGTH 20
                          default 'SELECT'.

AT SELECTION-SCREEN OUTPUT.

NAME = 'option'.

VALUE-KEY = '1'.
VALUE-TEXT = 'Company'.
APPEND VALUE TO LIST.

VALUE-KEY = '2'.
VALUE-TEXT = 'Country'.
APPEND VALUE TO LIST.

CALL FUNCTION 'VRM_SET_VALUES' EXPORTING ID = NAME VALUES = LIST.

START-OF-SELECTION.
SELECT kunnr name1 UP TO 20 ROWS FROM kna1 INTO TABLE itab. SELECT kunnr land1 UP TO 20 ROWS FROM kna1 INTO TABLE jtab.

CASE option.
WHEN '1'.
 LOOP AT itab.
  WRITE:/ itab-kunnr,itab-name1.
 ENDLOOP.

WHEN '2'.
 LOOP AT jtab.
  WRITE:/ jtab-kunnr,jtab-land1.
 ENDLOOP.
ENDCASE.