**********************************************************************
* FORM : sub_download
* Created : 11.12.2008 13:23:47
**********************************************************************
FORM sub_download .
IF NOT i_likp_text IS INITIAL.
PERFORM sub_write_local TABLES i_likp_text
i_errors
USING 'D:/likp.txt'.
ENDIF.
IF NOT i_lips_text IS INITIAL.
PERFORM sub_write_local TABLES i_lips_text
i_errors
USING 'D:/lips.txt'.
ENDIF.
ENDFORM. "sub_download
*&---------------------------------------------------------------------*
*& Form sub_write_local
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->FILE_OUTTAB text
* -->RETURN text
* -->FILENAME text
*----------------------------------------------------------------------*
FORM sub_write_local TABLES file_outtab
return TYPE tt_bapiret2
USING filename TYPE any.
DATA l_error_msg(40) TYPE c. "Error Message
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = filename
TABLES
data_tab = file_outtab
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
OTHERS = 22.
IF sy-subrc NE 0.
* Get the exact error parameter for the failure
SELECT parameter FROM fupararef UP TO 1 ROWS
INTO l_error_msg
WHERE funcname EQ 'GUI_DOWNLOAD'
AND r3state EQ 'A' "Active
AND paramtype EQ 'X' "Exception
AND pposition EQ sy-subrc.
ENDSELECT.
PERFORM message_build TABLES return
USING '00'
'E'
'398'
'Unable to download file'(i04)
filename
'Error:'(i05)
l_error_msg.
EXIT.
ENDIF.
ENDFORM. "sub_write_Local
*&---------------------------------------------------------------------*
*& Form message_build
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RETURN text
* -->VALUE(CLASS) text
* -->VALUE(TYPE) text
* -->VALUE(NUMBER) text
* -->VALUE(VAR1) text
* -->VALUE(VAR2) text
* -->VALUE(VAR3) text
* -->VALUE(VAR4) text
*----------------------------------------------------------------------*
FORM message_build TABLES return TYPE tt_bapiret2
USING value(class) TYPE symsgid
value(type) TYPE symsgty
value(number) TYPE symsgno
value(var1) TYPE any
value(var2) TYPE any
value(var3) TYPE any
value(var4) TYPE any.
DATA: ld_par1 TYPE symsgv, "Variable for Msg
ld_par2 TYPE symsgv, "Variable for Msg
ld_par3 TYPE symsgv, "Variable for Msg
ld_par4 TYPE symsgv, "Variable for Msg
ls_return TYPE bapiret2. "Return structure
* Assign Message to variables
ld_par1 = var1.
ld_par2 = var2.
ld_par3 = var3.
ld_par4 = var4.
* Fills the return parameter
CALL FUNCTION 'BALW_BAPIRETURN_GET2'
EXPORTING
type = type
cl = class
number = number
par1 = ld_par1
par2 = ld_par2
par3 = ld_par3
par4 = ld_par4
IMPORTING
return = ls_return.
APPEND ls_return TO return.
ENDFORM. "MESSAGE_BUILD