2019 Jan 08 5:30 AM
Dear Experts,
I need to move'.txt' files from Local folder to AL11 in background mode without using FTP. Currently using FM ARCHIVFILE_CLIENT_TO_SERVER.
When i searched in SCN, someone has posted like below.
Use FM "C13Z_FILE_UPLOAD_ASCII" to upload file to application server in batch mode then use open data set read dataset and close data set.
I tired this but no luck.
Any suggestions pls.
Regards,
Ishwarya
2019 Jan 08 7:02 AM
NB: C13Z_FILE_UPLOAD_ASCII (C13Z_UPLOAD) use GUI classes to upload file from presentation server, so either it was a wrong answer or you use it out of context. Don't forget that presentation server isn't defined in background. ARCHIVFILE_CLIENT_TO_SERVER (SCMS_DOWNLOAD) use FTP.
If you don't want to use FTP (why?) then ask basis to define the directory as a shared folder and to map it on application server, so AL11 will display it an you can use DATASET statements.
2019 Jan 08 5:50 AM
Hi Ishwarya,
Background means how the .txt file will be passed to your program?
Can you please explain bit more in-detail about your requirement?
Regards
Raju C D
2019 Jan 08 6:19 AM
I have a share folder . currently i'm passing share folder path and file name and placing it in AL11. Then reading files using Dataset. But while doing this action in Background, it is not working. Is there any other way to get my file in local share folder to AL11 in background mode?
2019 Jan 08 6:08 AM
Why do we need FTP ?
You can get this done with Open / Read / Close Dataset.
K.Kiran.
2019 Jan 08 6:16 AM
2019 Jan 08 7:02 AM
NB: C13Z_FILE_UPLOAD_ASCII (C13Z_UPLOAD) use GUI classes to upload file from presentation server, so either it was a wrong answer or you use it out of context. Don't forget that presentation server isn't defined in background. ARCHIVFILE_CLIENT_TO_SERVER (SCMS_DOWNLOAD) use FTP.
If you don't want to use FTP (why?) then ask basis to define the directory as a shared folder and to map it on application server, so AL11 will display it an you can use DATASET statements.
2019 Jan 08 7:35 AM
2019 Jan 08 7:13 AM
Thanks Raymond for your response! I wish to know all other possibilities besides FTP.
Sorry,I'm not clear on this point - ask basis to define the directory as a shared folder and to map it on application server.
if that is done, will my files in local folder be available in AL11? Will above point happen only in Windows Server ?
2019 Jan 08 7:27 AM
2019 Jun 05 3:56 PM
Thanks for the various insights..
SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S32 {
color: #3399FF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}
*&---------------------------------------------------------------------*
*& Report ZZ_ALL11_UP_DOWN
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zz_al11_down_up.
TABLES: rovertable.
CONSTANTS: c_execute_command TYPE sy-ucomm VALUE 'ONLI'.
SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE lv_t1.
PARAMETERS gv_rb1 TYPE c RADIOBUTTON GROUP butt DEFAULT 'X'.
PARAMETERS gv_rb2 TYPE c RADIOBUTTON GROUP butt.
PARAMETERS gv_rb3 TYPE c RADIOBUTTON GROUP butt.
SELECTION-SCREEN END OF BLOCK 1.
SELECT-OPTIONS: so_asfil FOR rovertable-filename NO INTERVALS. "RLGRAP-FILENAME.
PARAMETERS: p_out TYPE string DEFAULT 'C:\temp' LOWER CASE.
PARAMETERS: p_addext type c AS CHECKBOX DEFAULT ''.
DATA: ls_asfil LIKE LINE OF so_asfil,
ls_subrc type sy-subrc.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_out.
DATA:lv_selected_folder TYPE string.
CALL METHOD cl_gui_frontend_services=>directory_browse
CHANGING
selected_folder = lv_selected_folder
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
p_out = lv_selected_folder.
AT SELECTION-SCREEN.
IF sy-ucomm = c_execute_command.
PERFORM check_directory.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR so_asfil-low.
*******************
PERFORM z30_get_filename CHANGING so_asfil-low.
START-OF-SELECTION.
*If Download to Desktop is selected
IF gv_rb1 = 'X'.
LOOP AT so_asfil INTO ls_asfil.
PERFORM download USING ls_asfil-low p_out.
PERFORM show_msg.
ENDLOOP.
ELSEIF gv_rb2 = 'X'. "Upload To Application Server is selected
LOOP AT so_asfil INTO ls_asfil.
BREAK-POINT.
PERFORM upload USING ls_asfil-low p_out ls_subrc.
PERFORM show_upd_msg using ls_subrc.
ENDLOOP.
ELSEIF gv_rb3 = 'X'. "Delete Files From Application Server is selected
LOOP AT so_asfil INTO ls_asfil.
PERFORM delete_from_as USING ls_asfil-low ls_subrc.
PERFORM show_del_msg using ls_subrc.
ENDLOOP.
ENDIF.
FORM delete_from_as USING
pv_dimfile TYPE localfile
changing lv_subrc type sy-subrc.
* trim the path out of filename
* .//BU_LINE -> BU_LINE
DATA:
filesize TYPE epsf-epsfilsiz,
filenm TYPE epsfilnam,
filepath TYPE epsdirnam,
lv_string TYPE string, " VALUE './/BU_LINE',
lv_len TYPE i,
lv_pos TYPE i,
lv_last_occ TYPE i.
MOVE pv_dimfile TO lv_string.
lv_len = strlen( lv_string ).
DO.
SEARCH lv_string FOR '/'.
IF sy-subrc = '0'.
lv_pos = sy-fdpos + 1.
lv_len = lv_len - sy-fdpos - 1.
lv_string = lv_string+lv_pos(lv_len).
lv_last_occ = lv_last_occ + sy-fdpos + 1. "last occurence number
ELSE.
EXIT.
ENDIF.
ENDDO.
* file name is
filenm = lv_string.
* path is
filepath = pv_dimfile(lv_last_occ).
* check file existence
CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
EXPORTING
file_name = filenm
* IV_LONG_FILE_NAME =
dir_name = filepath
* IV_LONG_DIR_NAME =
IMPORTING
file_size = filesize
* FILE_OWNER =
* FILE_MODE =
* file_type = filetyp
* FILE_MTIME =
* FILE_SIZE_LONG =
EXCEPTIONS
read_directory_failed = 1
read_attributes_failed = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* Implement suitable error handling here
lv_subrc = sy-subrc.
ELSE.
CALL FUNCTION 'EPS_DELETE_FILE'
EXPORTING
file_name = filenm "VERSION
* IV_LONG_FILE_NAME =
dir_name = filepath ".//
* IV_LONG_DIR_NAME =
* IMPORTING
* FILE_PATH =
* EV_LONG_FILE_PATH =
* EXCEPTIONS
* INVALID_EPS_SUBDIR = 1
* SAPGPARAM_FAILED = 2
* BUILD_DIRECTORY_FAILED = 3
* NO_AUTHORIZATION = 4
* BUILD_PATH_FAILED = 5
* DELETE_FAILED = 6
* OTHERS = 7
.
IF sy-subrc <> 0.
* Implement suitable error handling here
lv_subrc = sy-subrc.
ENDIF.
ENDIF.
ENDFORM.
FORM show_msg.
MESSAGE s398(00) WITH TEXT-004."Files downloaded successfully!
ENDFORM. "show_msg
FORM show_upd_msg using p_subrc type sy-subrc.
if p_subrc = 0.
MESSAGE s398(00) WITH TEXT-003."Files Uploaded successfully!
else.
MESSAGE s398(00) WITH TEXT-002."Error at Uploading Files!
endif.
ENDFORM. "show_msg
FORM show_del_msg using p_subrc type sy-subrc.
if p_subrc = 0.
MESSAGE s398(00) WITH TEXT-005."Files deleted successfully!
else.
MESSAGE s398(00) WITH TEXT-006."Error in Files Deletion!
endif.
ENDFORM. "show_del_msg
FORM upload USING pv_dimfile TYPE localfile
out_path TYPE string
changing lv_subrc type sy-subrc.
DATA: lv_dimfile TYPE SAPB-SAPPFAD,
ls_out_path TYPE SAPB-SAPPFAD,
lv_out_path TYPE SAPB-SAPPFAD.
DATA:
filesize TYPE epsf-epsfilsiz,
filenm TYPE epsfilnam,
filepath TYPE epsdirnam,
lv_string TYPE string, " VALUE './/BU_LINE',
lv_len TYPE i,
lv_pos TYPE i,
lv_last_occ TYPE i.
MOVE: pv_dimfile TO lv_string,
out_path to ls_out_path.
lv_len = strlen( lv_string ).
DO.
SEARCH lv_string FOR '/'.
IF sy-subrc = '0'.
lv_pos = sy-fdpos + 1.
lv_len = lv_len - sy-fdpos - 1.
lv_string = lv_string+lv_pos(lv_len).
lv_last_occ = lv_last_occ + sy-fdpos + 1. "last occurence number
ELSE.
EXIT.
ENDIF.
ENDDO.
* file name is
filenm = lv_string.
* path is
filepath = pv_dimfile(lv_last_occ).
CONCATENATE out_path filenm INTO ls_out_path SEPARATED BY '\'.
MOVE: pv_dimfile to lv_out_path,
ls_out_path to lv_dimfile.
if p_addext = 'X'.
CONCATENATE lv_dimfile '.txt' INTO lv_dimfile.
CONCATENATE lv_out_path '.txt' INTO lv_out_path.
endif.
CALL FUNCTION 'ARCHIVFILE_CLIENT_TO_SERVER'
EXPORTING
path = lv_dimfile
targetpath = lv_out_path
EXCEPTIONS
error_file = 1
no_authorization = 2
OTHERS = 3.
lv_subrc = sy-subrc.
clear: lv_last_occ, lv_string, lv_len, lv_pos, filenm, filepath, lv_dimfile, lv_out_path, ls_out_path.
ENDFORM. "form upload
*&---------------------------------------------------------------------*
*& Form download
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM download USING
pv_dimfile TYPE localfile
out_path TYPE string.
DATA:lv_path LIKE sapb-sappfad VALUE '',
lv_targetpath LIKE sapb-sappfad,
lv_ot_filename TYPE string.
CONCATENATE lv_path pv_dimfile INTO lv_path.
if p_addext = 'X'.
CONCATENATE pv_dimfile '.txt' INTO pv_dimfile.
endif.
CONCATENATE out_path pv_dimfile INTO lv_targetpath SEPARATED BY '\'.
* BREAK-POINT.
CALL FUNCTION 'ARCHIVFILE_SERVER_TO_CLIENT'
EXPORTING
path = lv_path
targetpath = lv_targetpath
EXCEPTIONS
error_file = 1
OTHERS = 2.
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. "download
*&---------------------------------------------------------------------*
*& Form check_directory
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM check_directory.
DATA: lv_result TYPE c,
lv_directory TYPE string.
lv_directory = p_out.
CALL METHOD cl_gui_frontend_services=>directory_exist
EXPORTING
directory = lv_directory
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 IS INITIAL.
MESSAGE e398(00) WITH TEXT-001."The output directory does not exist!
ENDIF.
ENDFORM. "check_directory
*&---------------------------------------------------------------------*
*& Form Z30_GET_FILENAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM z30_get_filename CHANGING p_file.
*-------------------*
DATA: lt_files TYPE filetable,
ls_file TYPE file_table,
lv_lfile TYPE string,
lv_rc TYPE i,
lv_applserv TYPE as4flag,
lv_al11 TYPE as4flag,
lv_initial_dir TYPE string,
lv_guiext TYPE string,
lv_guiflt TYPE string,
lv_title TYPE string.
* CASE 'X'.
* WHEN p_pc. " Files from PC or Network
* lv_initial_dir = 'My Documents'.
* WHEN p_unix. " Files from Sap Server
* lv_applserv = 'X'.
* lv_al11 = 'X'.
* WHEN OTHERS.
* ENDCASE.
lv_lfile = p_file.
CALL METHOD cl_rsan_ut_files=>f4
EXPORTING
i_applserv = 'X' "lv_applserv'
i_title = lv_title
i_gui_extension = lv_guiext
i_gui_ext_filter = lv_guiflt
i_applserv_logical = space
i_applserv_al11 = 'X' "lv_al11'
CHANGING
c_file_name = lv_lfile
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
p_file = lv_lfile.
ENDFORM. " Z30_GET_FILENAME
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |