Beruflich Dokumente
Kultur Dokumente
My Home > Code Gallery > Community Code Gallery > ABAP - Reading-Writing to-from application-presentation server with F4 help for filename Search the w iki
ABAP - Reading-Writing to-from application-presentation server with F4 help for filename Welcome Guest
Added by Pratik Vora , last edited by Pratik Vora on Jan 15, 2009
Labels: (None)
*&----------------DATA DECLARATION----------------------------------&
INCLUDE z_appl_presentation_server_data_declaration.
INCLUDE z_appl_presentation_server_forms.
AT SELECTION-SCREEN OUTPUT.
PERFORM screen_attributes.
PERFORM source_destination
PERFORM application_server_path.
*&----------------START OF SELECTION--------------------------------&*
START-OF-SELECTION.
*& Reading data from application server and copy it to presentation server
IF p_read = 'X'.
PERFORM read_from_server.
*& Copy the data from presentation server and write to application server
ELSE.
PERFORM write_to_server.
ENDIF.
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
end of ty_bseg
…sap.com/…/ABAP+-+Reading-Writing… 1/5
3/24/2010 SAP Community Network Wiki - Code G…
rdata: d_filename(128),
PARAMETERS : p_read RADIOBUTTON GROUP rad1 default 'X' "Copy the file from Application server to PC
USER-COMMAND CHEK,
p_write RADIOBUTTON GROUP rad1, "Copy the file from PC to Application server
modif id G01
.*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
FORM read_from_server.
CLEAR d_filename.
d_filename = p_file1.
DO.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ENDDO.
file = p_file.
EXPORTING
filename = file
filetype = 'ASC'
TABLES
data_tab = it_bseg
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
…sap.com/…/ABAP+-+Reading-Writing… 2/5
3/24/2010 SAP Community Network Wiki - Code G…
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.
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
FORM write_to_server.
file = p_file.
EXPORTING
filename = file
filetype = 'ASC'
TABLES
data_tab = it_bseg
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.
CLEAR d_filename.
d_filename = p_file1.
ENDLOOP.
…sap.com/…/ABAP+-+Reading-Writing… 3/5
3/24/2010 SAP Community Network Wiki - Code G…
OPEN DATASET d_filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ENDDO.
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
FORM source_destination.
file = p_file.
EXPORTING
program_name = syst-repid
dynpro_number = syst-dynnr
field_name = p_file
CHANGING
file_name = p_file
EXCEPTIONS
mask_too_long = 1
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
FORM application_server_path.
IF p_read = 'X'.
EXPORTING
directory = '.\'
IMPORTING
serverfile = p_file1
EXCEPTIONS
canceled_by_user = 1.
ELSE.
MESSAGE 'F4 is only valid for transfering data from Server to PC' TYPE 'S'.
ENDIF.
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
…sap.com/…/ABAP+-+Reading-Writing… 4/5
3/24/2010 SAP Community Network Wiki - Code G…
FORM screen_attributes .
IF p_write = 'X'.
LOOP AT SCREEN.
IF screen-group1 = 'G01'.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSE.
LOOP AT SCREEN.
IF screen-group1 = 'G02'.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
…sap.com/…/ABAP+-+Reading-Writing… 5/5