Friday 13 March 2015

Enabling Selection Mode in Object Oriented ALV ( OO ALV )

Object Oriented ALV using CL_SALV_TABLE also provide the factility to the programmer to determine whether and in which situation the user can select areas of the ALV output .it is possible to programmatically determine which area needs to be selected and which areas are not required to select. The user can select multiple columns and multiple rows in an Object Oriented ALV .

Similar to all other ALV applications , in order to achive this functionality you need to follow only 2 steps :
Step 1 : Get the object reference of class CL_SALV_SELECTIONS by calling the method get_selections( ) of class CL_SALV_TABLE.
DATA : lo_selections TYPE REF TO cl_salv_selections.
lo_selections = lo_alv->get_selections( ).
STEP 2 : Call the set_selection_mode( ) method of class CL_SALV_SELECTIONS
CALL METHOD lo_selections->set_selection_mode
EXPORTING
value = if_salv_c_selection_mode=>multiple.
Please refer to the following source codes :

REPORT ztestr_alv_9.
TYPES : BEGIN OF gy_bseg,
bukrs TYPE bukrs,
belnr TYPE belnr_d,
gjahr TYPE gjahr,
buzei TYPE buzei,
wrbtr TYPE wrbtr,
END OF gy_bseg.
DATA : gt_bseg TYPE STANDARD TABLE OF gy_bseg INITIAL SIZE 1.
REFRESH : gt_bseg[].
SELECT bukrs belnr gjahr buzei wrbtr
FROM bseg
INTO TABLE gt_bseg
UP TO 10 ROWS.
IF sy-subrc IS INITIAL.
SORT gt_bseg BY bukrs belnr gjahr buzei .
ENDIF.
DATA : lo_alv TYPE REF TO cl_salv_table.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = lo_alv
CHANGING
t_table = gt_bseg.
CATCH cx_salv_msg .
ENDTRY.
*-- Enabling Selection Mode logic starts
DATA : lo_selections TYPE REF TO cl_salv_selections.
lo_selections = lo_alv->get_selections( ).
CALL METHOD lo_selections->set_selection_mode
EXPORTING
value = if_salv_c_selection_mode=>multiple.
*-- Enabling Selection Mode logic end
lo_alv->display( ).

HOTSPOT/SINGLE CLICK AREA IN ( OO ALV ) IN SAP ABAP .

In this SAP ABAP tutorial I will show you how to make hospot or single click area in Object Oriented ALV ( OO ALV ) using CL_SALV_TABLE.

To achieve this functionality you need to call the method set_cell_type of class cl_salv_column_table and pass the value as if_salv_c_cell_type=>hotspot . Now clicking on the checkbox will trigger the event LINK_CLICK , so we need to declare and event handler class here lcl_event_handler and declare a method m_link_click to handle the action . The LINK_CLICK event will give us the row and column value of the selected row , so that we can do further process based on the value of that field.
NB : Hotspot coding is similar to the checkbox one of.my previous tutorials except instead of if_salv_c_cell_type=>checkbox_hotspot we need to pass if_salv_c_cell_type=>hotspot .
At the end we need to call the REFRESH( ) method of class CL_SALV_TABLE .
In this SAP ABAP tutorial example we are making the column vbeln values as hotspot so that when the user single click on the value it will lead us to the transaction ‘VL03N’ with the corresponding VBELN value.
Please refer to the following source codes :

REPORT  ztestr_alv_10.
TYPES : BEGIN OF gy_vbap,
          vbeln TYPE vbeln_va,
          posnr TYPE posnr_va,
          matnr TYPE matnr,
END OF   gy_vbap.
DATA : gt_vbap TYPE STANDARD TABLE OF gy_vbap INITIAL SIZE 1.
DATA : lo_alv TYPE REF TO cl_salv_table.
REFRESH : gt_vbap[].
*----------------------------------------------------------------------*
*       CLASS lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
METHODS:
      m_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS.                    "lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
*       CLASS lcl_event_handler IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.
METHOD m_link_click.
FIELD-SYMBOLS : <lfs_vbap> TYPE gy_vbap.
READ TABLE gt_vbap ASSIGNING <lfs_vbap> INDEX row.
IF sy-subrc IS INITIAL.
SET PARAMETER ID 'VL' FIELD <lfs_vbap>-vbeln.
CALL TRANSACTION 'VL03N'.
ENDIF.
    lo_alv->refresh( ).
ENDMETHOD.                    "m_link_click
"m_link_click
ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
START-OF-SELECTION.
SELECT vbeln posnr matnr
FROM vbap
INTO TABLE gt_vbap
UP TO 10 ROWS.
IF sy-subrc IS INITIAL.
SORT gt_vbap BY vbeln posnr matnr  .
ENDIF.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
          r_salv_table = lo_alv
CHANGING
          t_table      = gt_vbap.
CATCH cx_salv_msg .
ENDTRY.
*-- Checkbox logic starts
DATA : lo_columns TYPE REF TO cl_salv_columns_table.
  lo_columns = lo_alv->get_columns( ).
  lo_columns->set_optimize( 'X' ).
DATA : lo_column TYPE REF TO cl_salv_column_table.
TRY.
      lo_column ?= lo_columns->get_column( 'VBELN' ).
      lo_column->set_cell_type( if_salv_c_cell_type=>hotspot ).
      lo_column->set_output_length( 10 ).
CATCH cx_salv_not_found.
ENDTRY.
DATA: lo_events TYPE REF TO cl_salv_events_table.
  lo_events = lo_alv->get_event( ).
DATA: lo_event_handler TYPE REF TO lcl_event_handler.
CREATE OBJECT lo_event_handler.
SET HANDLER lo_event_handler->m_link_click FOR lo_events.
*-- Checkbox logic end
  lo_alv->display( ).









Friday 17 October 2014

Making selection-screen block invisible / visible at runtime in SAP ABAP

REPORT ztestr_screen_change1.

PARAMETERS : p_matnr TYPE matnr.

PARAMETERS: ck_fl AS CHECKBOX USER-COMMAND chk.

SELECTION-SCREEN : BEGIN OF BLOCK b03 WITH FRAME TITLE text-019.

PARAMETERS : rd_up_a RADIOBUTTON GROUP r2 DEFAULT 'X' MODIF ID abc.
PARAMETERS : p_app_up TYPE dxfields-longpath MODIF ID abc.
PARAMETERS : rd_up_p RADIOBUTTON GROUP r2 MODIF ID abc.
PARAMETERS : p_pre_up TYPE dxfields-longpath MODIF ID abc.

SELECTION-SCREEN : END OF BLOCK b03.

SELECTION-SCREEN : BEGIN OF BLOCK b02 WITH FRAME TITLE text-018.

PARAMETERS : rd_dw_a RADIOBUTTON GROUP r1 DEFAULT 'X' MODIF ID abc.
PARAMETERS : p_app_dl TYPE dxfields-longpath MODIF ID abc.
PARAMETERS : rd_dw_p RADIOBUTTON GROUP r1 MODIF ID abc.
PARAMETERS : p_pre_dl TYPE dxfields-longpath MODIF ID abc.

SELECTION-SCREEN : END OF BLOCK b02.

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF ck_fl IS INITIAL.

IF screen-group1 = 'ABC'.
screen-active = 0.
ENDIF.

ENDIF.
MODIFY SCREEN.

ENDLOOP.


Making parameters field uneditable / editable at runtime in SAP ABAP


REPORT ztestr_screen_change.

SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-001.

PARAMETERS: rd_sel1 TYPE c RADIOBUTTON GROUP sel DEFAULT 'X' USER-COMMAND upd.
PARAMETERS: p_gui TYPE rlgrap-filename.
PARAMETERS: rd_sel2 TYPE c RADIOBUTTON GROUP sel,
p_app TYPE rlgrap-filename.

SELECTION-SCREEN END OF BLOCK b01.

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF rd_sel1 IS NOT INITIAL.

IF screen-name = 'P_APP'.
screen-input = 0.
ELSE.
screen-input = 1.
ENDIF.

ELSE.

IF screen-name = 'P_GUI'.
screen-input = 0.
ELSE.
screen-input = 1.
ENDIF.

ENDIF.

MODIFY SCREEN.

ENDLOOP.















Monday 13 October 2014

UPLOADING AND DOWNLOADING FILE FROM APPLICATION SERVER IN SAP

REPORT ztestr_file_handling.

PARAMETERS : p_path TYPE dxfields-longpath,
p_down TYPE dxfields-longpath.

TYPES : BEGIN OF ty_final,
field1(4) TYPE c,
field2(4) TYPE n,
END OF ty_final.

DATA : git_string TYPE STANDARD TABLE OF string INITIAL SIZE 1,
git_final TYPE STANDARD TABLE OF ty_final INITIAL SIZE 1.

*-- F4 help for the presentation layer
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.

CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
i_location_flag = 'A'
* i_server = space
* i_path = lv_i_path
* FILEMASK = '*.*'
* FILEOPERATION = 'R'
IMPORTING
* O_LOCATION_FLAG =
* O_SERVER =
o_path = p_path
* ABEND_FLAG =
EXCEPTIONS
rfc_error = 1
error_with_gui = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

*-- F4 help for the presentation layer
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_down.

CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
i_location_flag = 'A'
* i_server = space
* i_path = lv_i_path
* FILEMASK = '*.*'
* FILEOPERATION = 'R'
IMPORTING
* O_LOCATION_FLAG =
* O_SERVER =
o_path = p_down
* ABEND_FLAG =
EXCEPTIONS
rfc_error = 1
error_with_gui = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

START-OF-SELECTION.

IF p_path IS NOT INITIAL.
*-- Validate whether path exists or not
PERFORM validate_path.
*-- Upload the file
PERFORM upload_file.

IF git_final[] IS NOT INITIAL.
*-- Process the file
PERFORM process_file.

IF p_down IS NOT INITIAL.
*-- Validate whether path exists or not
PERFORM validate_path_d.

*-- Download the file
PERFORM download_file.
ENDIF.

ENDIF.
ENDIF.

*&---------------------------------------------------------------------*
*& Form VALIDATE_PATH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM validate_path .

DATA: lv_file TYPE tpfht-pffile,
lv_true TYPE char1.

CLEAR lv_file.
lv_file = p_path.

CALL FUNCTION 'PFL_CHECK_OS_FILE_EXISTENCE'
EXPORTING
fully_qualified_filename = lv_file
IMPORTING
file_exists = lv_true.
IF lv_true = space.

MESSAGE 'File does not exist' TYPE 'I'.
EXIT.

ENDIF.

ENDFORM. " VALIDATE_PATH
*&---------------------------------------------------------------------*
*& Form UPLOAD_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM upload_file .

DATA : lv_filename TYPE string,
lwa_data TYPE string,
lwa_final TYPE ty_final.

lv_filename = p_path.

*-- Read data from Application Server
OPEN DATASET lv_filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc IS INITIAL.
DO.
READ DATASET lv_filename INTO lwa_data.
IF sy-subrc EQ 0.
SPLIT lwa_data AT '|' INTO lwa_final-field1 lwa_final-field2.
APPEND lwa_final TO git_final.
CLEAR: lwa_final.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET lv_filename.

ELSE.
MESSAGE 'Path does not exist' TYPE 'I'.
EXIT.

ENDIF.

ENDFORM. " UPLOAD_FILE
*&---------------------------------------------------------------------*
*& Form PROCESS_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM process_file .

FIELD-SYMBOLS : <fwa_final> TYPE ty_final.

LOOP AT git_final ASSIGNING <fwa_final>.

<fwa_final>-field2 = <fwa_final>-field2 + 1.
CONDENSE <fwa_final>-field2.

ENDLOOP.

ENDFORM. " PROCESS_FILE
*&---------------------------------------------------------------------*
*& Form DOWNLOAD_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM download_file .

DATA : lv_filename TYPE string,
lwa_string TYPE string,
lit_string TYPE STANDARD TABLE OF string INITIAL SIZE 1.

FIELD-SYMBOLS : <fwa_final> TYPE ty_final.

IF p_down IS NOT INITIAL.

lv_filename = p_down.

IF git_final[] IS NOT INITIAL.

LOOP AT git_final ASSIGNING <fwa_final>.

CONCATENATE <fwa_final>-field1 <fwa_final>-field2 INTO lwa_string
SEPARATED BY '|'.
APPEND lwa_string TO lit_string.
CLEAR lwa_string.

ENDLOOP.

ENDIF.

* // Upload error file to Application Layer
OPEN DATASET lv_filename FOR OUTPUT IN BINARY MODE.
IF sy-subrc IS INITIAL.
LOOP AT lit_string INTO lwa_string.
TRANSFER lwa_string TO lv_filename.
ENDLOOP.

CLOSE DATASET lv_filename.
ENDIF.

ENDIF.

ENDFORM. " DOWNLOAD_FILE
*&---------------------------------------------------------------------*
*& Form VALIDATE_PATH_D
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM validate_path_d .

DATA: lv_file TYPE tpfht-pffile,
lv_true TYPE char1.

CLEAR lv_file.
lv_file = p_down.

CALL FUNCTION 'PFL_CHECK_OS_FILE_EXISTENCE'
EXPORTING
fully_qualified_filename = lv_file
IMPORTING
file_exists = lv_true.
IF lv_true = space.

MESSAGE 'File does not exist' TYPE 'I'.
EXIT.

ENDIF.

ENDFORM. " VALIDATE_PATH_D

INPUT file contents

ABCD|1000
EFGH|2000
IJKL|3000
MNOP|4000
QRST|5000

OUTPUT FILE CONTENT :
ABCD|1001
EFGH|2001
IJKL|3001
MNOP|4001
QRST|5001





UPLOADING AND DOWNLOADING FILE FROM PRESENTATION SERVER IN SAP

REPORT ztestr_file_handling.

PARAMETERS : p_path TYPE dxfields-longpath,
p_down TYPE dxfields-longpath.

TYPES : BEGIN OF ty_final,
field1(4) TYPE c,
field2(4) TYPE n,
END OF ty_final.

DATA : git_string TYPE STANDARD TABLE OF string INITIAL SIZE 1,
git_final TYPE STANDARD TABLE OF ty_final INITIAL SIZE 1.

*-- F4 help for the presentation layer
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.

CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
i_location_flag = 'P'
* i_server = space
* i_path = lv_i_path
* FILEMASK = '*.*'
* FILEOPERATION = 'R'
IMPORTING
* O_LOCATION_FLAG =
* O_SERVER =
o_path = p_path
* ABEND_FLAG =
EXCEPTIONS
rfc_error = 1
error_with_gui = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

*-- F4 help for the presentation layer
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_down.

CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
i_location_flag = 'P'
* i_server = space
* i_path = lv_i_path
* FILEMASK = '*.*'
* FILEOPERATION = 'R'
IMPORTING
* O_LOCATION_FLAG =
* O_SERVER =
o_path = p_down
* ABEND_FLAG =
EXCEPTIONS
rfc_error = 1
error_with_gui = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

START-OF-SELECTION.

IF p_path IS NOT INITIAL.
*-- Validate whether path exists or not
PERFORM validate_path.
*-- Upload the file
PERFORM upload_file.

IF git_string[] IS NOT INITIAL.

*-- Populate the internal table for processing
PERFORM populate_itab .

IF git_final[] IS NOT INITIAL.
*-- Process the file
PERFORM process_file.

IF p_down IS NOT INITIAL.

PERFORM validate_path_d.

*-- Download the file
PERFORM download_file.
ENDIF.


ENDIF.

ENDIF.
ENDIF.

*&---------------------------------------------------------------------*
*& Form VALIDATE_PATH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM validate_path .

DATA: lv_result TYPE char1,
lv_file TYPE string.

lv_file = p_path.

CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = lv_file
RECEIVING
result = lv_result
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF lv_result NE 'X'." if lv_result = 'X' then file exists
MESSAGE 'File does not exist' TYPE 'I'.
EXIT.

ENDIF.

ENDFORM. " VALIDATE_PATH
*&---------------------------------------------------------------------*
*& Form UPLOAD_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM upload_file .

DATA : lv_filename TYPE string.

lv_filename = p_path.

CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = lv_filename
* filetype = 'ASC'
* has_field_separator = SPACE
* header_length = 0
* read_by_line = 'X'
* dat_mode = SPACE
* codepage = SPACE
* ignore_cerr = ABAP_TRUE
* replacement = '#'
* virus_scan_profile =
* IMPORTING
* filelength =
* header =
CHANGING
data_tab = git_string
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
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.




ENDFORM. " UPLOAD_FILE
*&---------------------------------------------------------------------*
*& Form POPULATE_ITAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM populate_itab .

DATA : lwa_final TYPE ty_final.
FIELD-SYMBOLS : <fwa_string> TYPE string.

LOOP AT git_string ASSIGNING <fwa_string>.

SPLIT <fwa_string> AT '|' INTO lwa_final-field1
lwa_final-field2.

APPEND lwa_final TO git_final.
CLEAR lwa_final.

ENDLOOP.

ENDFORM. " POPULATE_ITAB
*&---------------------------------------------------------------------*
*& Form PROCESS_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM process_file .

FIELD-SYMBOLS : <fwa_final> TYPE ty_final.

LOOP AT git_final ASSIGNING <fwa_final>.

<fwa_final>-field2 = <fwa_final>-field2 + 1.
CONDENSE <fwa_final>-field2.

ENDLOOP.

ENDFORM. " PROCESS_FILE
*&---------------------------------------------------------------------*
*& Form DOWNLOAD_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM download_file .

DATA : lv_filename TYPE string,
lwa_string TYPE string,
lit_string TYPE STANDARD TABLE OF string INITIAL SIZE 1.

FIELD-SYMBOLS : <fwa_final> TYPE ty_final.

IF p_down IS NOT INITIAL.

lv_filename = p_down.

IF git_final[] IS NOT INITIAL.

LOOP AT git_final ASSIGNING <fwa_final>.

CONCATENATE <fwa_final>-field1 <fwa_final>-field2 INTO lwa_string
SEPARATED BY '|'.
APPEND lwa_string TO lit_string.
CLEAR lwa_string.

ENDLOOP.

ENDIF.

CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
* bin_filesize =
filename = lv_filename
* filetype = 'ASC'
* append = SPACE
* write_field_separator = SPACE
* header = '00'
* trunc_trailing_blanks = SPACE
* write_lf = 'X'
* col_select = SPACE
* col_select_mask = SPACE
* dat_mode = SPACE
* confirm_overwrite = SPACE
* no_auth_check = SPACE
* codepage = SPACE
* ignore_cerr = ABAP_TRUE
* replacement = '#'
* write_bom = SPACE
* trunc_trailing_blanks_eol = 'X'
* wk1_n_format = SPACE
* wk1_n_size = SPACE
* wk1_t_format = SPACE
* wk1_t_size = SPACE
* show_transfer_status = 'X'
* fieldnames =
* write_lf_after_last_line = 'X'
* virus_scan_profile = '/SCET/GUI_DOWNLOAD'
* IMPORTING
* filelength =
CHANGING
data_tab = lit_string
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

ENDIF.

ENDFORM. " DOWNLOAD_FILE
*&---------------------------------------------------------------------*
*& Form VALIDATE_PATH_D
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM VALIDATE_PATH_D .

DATA: lv_result TYPE char1,
lv_file TYPE string.

lv_file = p_down.

CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = lv_file
RECEIVING
result = lv_result
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF lv_result NE 'X'." if lv_result = 'X' then file exists
MESSAGE 'File does not exist' TYPE 'I'.
EXIT.

ENDIF.
ENDFORM. " VALIDATE_PATH_D


INPUT file contents

ABCD|1000
EFGH|2000
IJKL|3000
MNOP|4000
QRST|5000

OUTPUT FILE CONTENT :
ABCD|1001
EFGH|2001
IJKL|3001
MNOP|4001
QRST|5001
INPUT :