File archiving in application server ?
Hi Experts,
How to a archive file in application server to another folder? Is there any function module used for that?.
Thanks
Hi Dan
For archiving, we can use FM: <b>EPS_DELETE_FILE</b> for archiving a file.
Below code can help you understand for moving a file:
[code]FUNCTION y_copy_file_within_appli_serv.
""Local interface:
*" IMPORTING
*" VALUE(RFC_DESTINATION) LIKE RFCDES-RFCDEST
*" VALUE(LOCAL_FILE) LIKE EPSF-EPSFILNAM
*" VALUE(LOCAL_DIRECTORY) LIKE EPSF-EPSDIRNAM DEFAULT SPACE
*" VALUE(REMOTE_FILE) LIKE EPSF-EPSFILNAM DEFAULT SPACE
*" VALUE(REMOTE_DIRECTORY) LIKE EPSF-EPSDIRNAM DEFAULT SPACE
*" VALUE(OVERWRITE_MODE) LIKE EPSF-EPSOVRWRI DEFAULT SPACE
*" VALUE(TEXT_MODE) LIKE EPSF-EPSTXTMOD DEFAULT SPACE
*" VALUE(TRANSMISSION_MONITOR) LIKE EPSF-EPSTRAMON DEFAULT 'X'
*" VALUE(RECORDS_PER_TRANSFER) LIKE EPSF-EPSRECTRA DEFAULT 10
*" VALUE(REQUESTED_FILE_SIZE) LIKE EPSF-EPSFILSIZ DEFAULT 0
*" VALUE(MONITOR_TITLE) LIKE EPSF-EPSTEXT OPTIONAL
*" VALUE(MONITOR_TEXT1) LIKE EPSF-EPSTEXT OPTIONAL
*" VALUE(MONITOR_TEXT2) LIKE EPSF-EPSTEXT OPTIONAL
*" VALUE(PROGRESS_TEXT) LIKE EPSF-EPSTEXT OPTIONAL
*" VALUE(OBJECT_NAME) LIKE EPSF-EPSFILNAM OPTIONAL
*" EXPORTING
*" VALUE(LOCAL_DIRECTORY) LIKE EPSF-EPSDIRNAM
*" VALUE(LOCAL_PATH) LIKE EPSF-EPSPATH
*" VALUE(REMOTE_FILE) LIKE EPSF-EPSFILNAM
*" VALUE(REMOTE_DIRECTORY) LIKE EPSF-EPSDIRNAM
*" VALUE(REMOTE_PATH) LIKE EPSF-EPSPATH
*" VALUE(FILE_SIZE) LIKE EPSF-EPSFILSIZ
*" VALUE(LOCAL_SYSTEM_INFO) LIKE EPSFTPSI STRUCTURE EPSFTPSI
*" VALUE(REMOTE_SYSTEM_INFO) LIKE EPSFTPSI STRUCTURE EPSFTPSI
*" EXCEPTIONS
*" OPEN_INPUT_FILE_FAILED
*" OPEN_OUTPUT_FILE_FAILED
*" READ_BLOCK_FAILED
*" WRITE_BLOCK_FAILED
*" CLOSE_OUTPUT_FILE_FAILED
*" INVALID_FILE_SIZE
*" STOPPED_BY_USER
*" INVALID_INPUT_FILE_SIZE
*" RESTART_FAILED
*" CONNECTION_FAILED
*" INVALID_VERSION
DATA: BEGIN OF eps_buffer OCCURS 10.
INCLUDE STRUCTURE tbl8000.
DATA: END OF eps_buffer.
DATA: BEGIN OF eps_txtbuf OCCURS 0.
INCLUDE STRUCTURE epsteco.
DATA: END OF eps_txtbuf.
DATA: ls_save_moni LIKE g$moni.
DATA: lv_local_file_size LIKE epsf-epsfilsiz,
lv_remote_file_size LIKE epsf-epsfilsiz,
lv_block_size LIKE epsf-epsfilsiz,
lv_number_of_records LIKE epsf-epsrectra,
lv_last_record_length LIKE epsf-epsreclen,
lv_max_record_length LIKE epsf-epsreclen,
lv_end_of_file LIKE epsf-epsflag,
lv_low_rc LIKE sy-subrc,
lv_rfc_message LIKE sy-msgv1,
lv_restart_flag LIKE epsf-epsflag,
lv_pattern LIKE tbl8000-line,
lv_records_to_skip LIKE epsf-epsrectra,
lv_skiped_size LIKE epsf-epsfilsiz.
check parameters (only if not started from EPS_ftp_mput)
IF transmission_monitor <> gc_mon_flag_m.
PERFORM get_ftp_system_info " get ftp system info
USING
rfc_destination
CHANGING
local_system_info
remote_system_info.
PERFORM check_ftp_version " check ftp version
USING
text_mode
remote_system_info.
PERFORM check_overwrite_mode " check OVERWRITE_MODE
USING
text_mode
CHANGING
overwrite_mode.
PERFORM check_records_per_transfer " check RECORDS_PER_TRANSFER
USING
text_mode
CHANGING
records_per_transfer.
ENDIF.
determine block_size [byte] (binary mode only)
IF text_mode <> 'X'.
*>>> Begin of modification for change log reference UnicodeC <<<
DESCRIBE FIELD eps_buffer-line LENGTH lv_max_record_length.
DESCRIBE FIELD eps_buffer-line LENGTH lv_max_record_length IN
BYTE MODE.
*<<< End of modification for change log reference UnicodeC >>>
lv_block_size = lv_max_record_length * records_per_transfer.
ENDIF.
open local file for input
CALL FUNCTION 'EPS_OPEN_INPUT_FILE'
EXPORTING
file_name = local_file
dir_name = local_directory
text_mode = text_mode
IMPORTING
dir_name = local_directory
file_path = local_path
file_size = lv_local_file_size
EXCEPTIONS
invalid_eps_subdir = 11
sapgparam_failed = 12
build_directory_failed = 13
no_authorization = 14
build_path_failed = 15
open_failed = 16
read_directory_failed = 17
read_attributes_failed = 18.
lv_low_rc = sy-subrc.
IF sy-subrc <> 0.
CALL FUNCTION 'EPS_CLOSE_FILE'
EXPORTING
file_name = local_file
dir_name = local_directory
EXCEPTIONS
OTHERS = 99.
MESSAGE e001 WITH lv_low_rc local_file local_directory
space " rfc message
RAISING open_input_file_failed.
ENDIF.
check file size
IF requested_file_size <> 0 AND
requested_file_size <> lv_local_file_size.
CALL FUNCTION 'EPS_CLOSE_FILE'
EXPORTING
file_name = local_file
dir_name = local_directory
EXCEPTIONS
OTHERS = 99.
lv_low_rc = 0.
MESSAGE e008 WITH lv_low_rc local_file
requested_file_size lv_local_file_size
RAISING invalid_input_file_size.
ENDIF.
open remote file for output
IF remote_file = space. " no remote file specified
remote_file = local_file. " -> remote file = local file
ENDIF.
IF text_mode = 'X' AND " no restart in textmode
overwrite_mode = 'R'.
overwrite_mode = 'S'.
ENDIF.
CALL FUNCTION 'EPS_OPEN_OUTPUT_FILE'
DESTINATION rfc_destination
EXPORTING
file_name = remote_file
dir_name = remote_directory
file_size_request = lv_local_file_size
overwrite_mode = overwrite_mode
text_mode = text_mode
IMPORTING
dir_name = remote_directory
file_path = remote_path
restart_flag = lv_restart_flag
EXCEPTIONS
system_failure = 03 MESSAGE lv_rfc_message
communication_failure = 04 MESSAGE lv_rfc_message
invalid_eps_subdir = 11
sapgparam_failed = 12
build_directory_failed = 13
no_authorization = 14
build_path_failed = 15
open_failed = 16
file_already_exists = 19.
lv_low_rc = sy-subrc.
IF sy-subrc <> 0.
CALL FUNCTION 'EPS_CLOSE_FILE'
DESTINATION rfc_destination
EXPORTING
file_name = remote_file
dir_name = remote_directory
EXCEPTIONS
OTHERS = 99.
CALL FUNCTION 'EPS_CLOSE_FILE'
EXPORTING
file_name = local_file
dir_name = local_directory
EXCEPTIONS
OTHERS = 99.
MESSAGE e002 WITH lv_low_rc remote_file remote_directory
lv_rfc_message
RAISING open_output_file_failed.
ENDIF.
restart file transfer
IF lv_restart_flag = 'X'.
ls_save_moni = g$moni. " save monitor data
CALL FUNCTION 'EPS_SEEK_OUTPUT_FILE'
DESTINATION rfc_destination
EXPORTING
file_name = remote_file
dir_name = remote_directory
records_per_transfer = records_per_transfer
object_name = object_name
IMPORTING
pattern = lv_pattern
records_to_skip = lv_records_to_skip
EXCEPTIONS
system_failure = 03 MESSAGE lv_rfc_message
communication_failure = 04 MESSAGE lv_rfc_message
invalid_eps_subdir = 11
sapgparam_failed = 12
build_directory_failed = 13
no_authorization = 14
build_path_failed = 15
open_failed = 16
read_directory_failed = 17
read_attributes_failed = 18
read_failure = 20
write_failure = 21
OTHERS = 99.
lv_low_rc = sy-subrc.
IF sy-subrc <> 0.
CALL FUNCTION 'EPS_CLOSE_FILE'
EXPORTING
file_name = local_file
dir_name = local_directory
EXCEPTIONS
OTHERS = 99.
g$moni = ls_save_moni. " restore monitor data
MESSAGE e009 WITH lv_low_rc remote_file remote_directory
lv_rfc_message
RAISING restart_failed.
ENDIF.
CALL FUNCTION 'EPS_SEEK_INPUT_FILE'
EXPORTING
pattern = lv_pattern
records_to_skip = lv_records_to_skip
file_path = local_path
records_per_transfer = records_per_transfer
EXCEPTIONS
read_failure = 20
write_failure = 21
end_of_file = 22
pattern_not_found = 23
OTHERS = 99.
lv_low_rc = sy-subrc.
IF sy-subrc <> 0.
CALL FUNCTION 'EPS_CLOSE_FILE'
DESTINATION rfc_destination
EXPORTING
file_name = remote_file
dir_name = remote_directory
EXCEPTIONS
OTHERS = 99.
CALL FUNCTION 'EPS_CLOSE_FILE'
EXPORTING
file_name = local_file
dir_name = local_directory
EXCEPTIONS
OTHERS = 99.
CALL FUNCTION 'EPS_DELETE_FILE'
DESTINATION rfc_destination
EXPORTING
file_name = remote_file
dir_name = remote_directory
EXCEPTIONS
OTHERS = 99.
g$moni = ls_save_moni. " restore monitor data
MESSAGE e009 WITH lv_low_rc remote_file remote_directory
space " rfc message
RAISING restart_failed.
ENDIF.
lv_skiped_size = lv_records_to_skip * lv_max_record_length.
g$moni = ls_save_moni. " restore monitor data
ENDIF.
start transmission monitor
IF transmission_monitor <> 'M'.
PERFORM monitor_open
USING transmission_monitor
monitor_title.
PERFORM monitor_set_values
USING gc_ftp_put
progress_text
monitor_text1
monitor_text2
rfc_destination
local_file
0 " total files
0 " current file
0 " maxval gauge 1
lv_local_file_size " maxval gauge 2
0 " skiped size gauge 1
lv_skiped_size. " skiped size gauge 2
ELSE.
PERFORM monitor_update_values
USING 0 " increment
0 " skiped size gauge 1
lv_skiped_size. " skiped size gauge 2
ENDIF.
file transfer ------------------------------------------ begin -------
CLEAR lv_end_of_file.
WHILE lv_end_of_file <> 'X'.
read block from input file
IF text_mode = 'X'.
REFRESH eps_txtbuf.
CALL FUNCTION 'EPS_READ_TEXT_BLOCK'
EXPORTING
file_path = local_path
records_per_transfer = records_per_transfer
IMPORTING
end_of_file = lv_end_of_file
TABLES
eps_buffer = eps_txtbuf
EXCEPTIONS
read_failure = 20.
ELSE.
REFRESH eps_buffer.
CALL FUNCTION 'EPS_READ_BLOCK'
EXPORTING
file_path = local_path
records_per_transfer = records_per_transfer
IMPORTING
number_of_records = lv_number_of_records
last_record_length = lv_last_record_length
end_of_file = lv_end_of_file
TABLES
eps_buffer = eps_buffer
EXCEPTIONS
read_failure = 20.
ENDIF.
lv_low_rc = sy-subrc.
IF sy-subrc <> 0.
IF transmission_monitor = 'X'. " stop monitor
PERFORM monitor_stop.
ENDIF.
MESSAGE e003 WITH lv_low_rc local_path space
RAISING read_block_failed.
ENDIF.
write block into output file
IF text_mode = 'X'.
CALL FUNCTION 'EPS_WRITE_TEXT_BLOCK'
DESTINATION rfc_destination
EXPORTING
file_path = remote_path
IMPORTING
transfered_bytes = lv_block_size
TABLES
eps_buffer = eps_txtbuf
EXCEPTIONS
system_failure = 03 MESSAGE lv_rfc_message
communication_failure = 04 MESSAGE lv_rfc_message
write_failure = 21.
ELSE.
CALL FUNCTION 'EPS_WRITE_BLOCK'
DESTINATION rfc_destination
EXPORTING
file_path = remote_path
number_of_records = lv_number_of_records
last_record_length = lv_last_record_length
TABLES
eps_buffer = eps_buffer
EXCEPTIONS
system_failure = 03 MESSAGE lv_rfc_message
communication_failure = 04 MESSAGE lv_rfc_message
write_failure = 21.
ENDIF.
lv_low_rc = sy-subrc.
IF sy-subrc <> 0.
IF transmission_monitor = 'X'. " stop monitor
PERFORM monitor_stop.
ENDIF.
MESSAGE e004 WITH lv_low_rc remote_path lv_rfc_message
RAISING write_block_failed.
ENDIF.
update transmission monitor
PERFORM monitor_update_values
USING lv_block_size " increment
0 " skiped size gauge 1
0. " skiped size gauge 2
IF g$moni-cancel = 'X'. " stop transmission
MESSAGE e007 RAISING stopped_by_user.
ENDIF.
ENDWHILE.
file transfer ------------------------------------------ end ---------
stop transmission monitor
IF transmission_monitor = 'X'.
PERFORM monitor_stop.
ENDIF.
close output file and get size
CALL FUNCTION 'EPS_CLOSE_FILE'
DESTINATION rfc_destination
EXPORTING
file_name = remote_file
dir_name = remote_directory
IMPORTING
file_size = lv_remote_file_size
EXCEPTIONS
system_failure = 03 MESSAGE lv_rfc_message
communication_failure = 04 MESSAGE lv_rfc_message
build_path_failed = 15
read_directory_failed = 17
read_attributes_failed = 18.
lv_low_rc = sy-subrc.
IF sy-subrc <> 0.
MESSAGE e005 WITH lv_low_rc remote_file remote_directory
lv_rfc_message
RAISING close_output_file_failed.
ENDIF.
compare size of local and remote file (binary mode only)
IF text_mode <> 'X'.
IF lv_local_file_size <> lv_remote_file_size.
lv_low_rc = 0.
MESSAGE e006 WITH lv_low_rc local_file lv_local_file_size
RAISING invalid_file_size.
ENDIF.
ENDIF.
file_size = lv_local_file_size.
ENDFUNCTION.[/code]
Regards
Eswar
Similar Messages
-
How to see the file at the application server
HI TO ALL SDNERS ,
THIS IS MY CODE WHERE TO CHECK THE DOWNLOADED FILE AT THE APPLICATION SERVER.IN TCODE AL11 I HAVE SEEN THERE IS NO FILE GETTING CREATED.WHEN TRANSFERRING THE SY-SUBRC VALUE IS ZERO.
Program Name : ZME11_BDC.
Title : PURCHASE INFORMATION RECORD LOAD PROGRAM
Program Objective : THIS PROGRAM READS IN THE PURCHASE
INFORMATION FILE. IT CREATES A BDC SESSION TO
USE TO LOAD THE PURCHASE INFORMATION RECORDS
INTO SAP using the ME11 Transaction.
REPORT ZME11_BDC no standard page heading MESSAGE-ID ZHNC line-size 55.
constants declaration
constants: c_x value 'X',
c_sess type apqi-groupid value 'zcustomer',
c_xd01 type tstc-tcode value 'ME11'.
DECLARING VARIABLES
DATA: V_MSG(255),
V_ERREC TYPE I,"NO OF FAILED RECORDS
V_LINES."NO OF RECORDS
FLAG DECLARATIONS
DATA: FG_DATA_EXIST VALUE 'X',"CHECK FOR DATA
FG_SESSION_OPEN VALUE ''.
STRUCTURES AND INTERNAL TABLE DECLARATIONS
TYPES :BEGIN OF TY_PIR,
LIFNR TYPE EINA-LIFNR,
MATNR TYPE EINA-MATNR,
EKORG TYPE EINE-EKORG,
WERKS TYPE EINE-WERKS,
VERKF TYPE EINA-VERKF,"sales person
TELF1 TYPE EINA-TELF1,"telephone
URZLA TYPE EINA-URZLA,"country
REGIO TYPE EINA-REGIO,"region
APLFZ(5),"plan deleivery time
EKGRP TYPE EINE-EKGRP,"purchase group
NORBM(13),
NETPR(13),
END OF TY_PIR.
DATA : IT_PIR TYPE TABLE OF TY_PIR,
WA_PIR LIKE LINE OF IT_PIR.
DATA: BEGIN OF IT_BDCDATA.
INCLUDE STRUCTURE BDCDATA.
DATA END OF IT_BDCDATA.
DATA : BEGIN OF IT_BDCMSG.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA END OF IT_BDCMSG.
SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETER : FNAME TYPE RLGRAP-FILENAME.
SELECTION-SCREEN END OF BLOCK B1.
AT SELECTION ON VALUE REQUEST
AT SELECTION-SCREEN ON VALUE-REQUEST FOR FNAME.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = FNAME.
START OF SELECTION
START-OF-SELECTION.
PERFORM F_GET_DATA USING FNAME
CHANGING IT_PIR.
PERFORM F_GENERATE_DATASET USING FNAME
CHANGING IT_PIR WA_PIR.
*& Form F_GET_DATA
text
-->P_V_FNAME text
<--P_IT_PIR text
FORM F_GET_DATA USING P_FNAME LIKE FNAME
CHANGING P_IT_PIR LIKE IT_PIR.
DATA: LV_FILE TYPE STRING.
LV_FILE = FNAME.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = LV_FILE
FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = P_IT_PIR
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
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 P_IT_PIR IS INITIAL.
FG_DATA_EXIST = ''.
ENDIF.
ENDFORM. " F_GET_DATA
*& Form F_GENERATE_DATASET
text
-->P_V_FNAME text
<--P_IT_PIR text
FORM F_GENERATE_DATASET USING P_V_FNAME LIKE FNAME
CHANGING P_IT_PIR LIKE IT_PIR
P_WA_PIR LIKE WA_PIR.
MESSAGE I001(ZHNC).
*OPENING FILE AT THE APPLICATION SERVER FOR WRITING
OPEN DATASET FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC EQ 0.
MESSAGE I002(ZHNC).
LOOP AT P_IT_PIR INTO P_WA_PIR.
SPLIT P_WA_PIR AT '*' INTO P_WA_PIR-LIFNR
P_WA_PIR-MATNR
P_WA_PIR-EKORG
P_WA_PIR-WERKS
P_WA_PIR-VERKF
P_WA_PIR-TELF1
P_WA_PIR-URZLA
P_WA_PIR-REGIO
P_WA_PIR-APLFZ
P_WA_PIR-EKGRP
P_WA_PIR-NORBM.
*TRANSFER THE FILE FROM INTERNAL TABLE TO APPLICATION SERVER
MESSAGE I003(ZHNC).
TRANSFER P_WA_PIR TO FNAME.
ENDLOOP.
*CLOSING THE FILE AT THE APPLICATION SERVER
CLOSE DATASET FNAME.
ENDIF.Hello,
I made a similar program. You can have a look at it.
*& Form write_to_app_server
text
--> p1 text
<-- p2 text
FORM write_to_app_server.
To get filename
PERFORM get_filename.
To write into the application server
OPEN DATASET g_filename_with_path FOR OUTPUT IN TEXT MODE.
IF sy-subrc = 0.
LOOP AT <l_table> INTO <l_line>.
TRANSFER <l_line> TO g_filename_with_path.
ENDLOOP.
CLOSE DATASET g_filename_with_path.
ELSE.
CLOSE DATASET g_filename_with_path.
ENDIF.
To send mail
PERFORM send_mail.
ENDFORM. " write_to_app_server
*& Form get_filename
text
--> p1 text
<-- p2 text
FORM get_filename.
DATA : l_log_path TYPE filepath-pathintern
VALUE 'Y28M_DOWNLOADS_BACKGROUND' .
CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
EXPORTING
client = sy-mandt
logical_path = l_log_path
operating_system = sy-opsys
file_name = p_fname
IMPORTING
file_name_with_path = g_filename_with_path
EXCEPTIONS
path_not_found = 1
missing_parameter = 2
operating_system_not_found = 3
file_system_not_found = 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.
ENDFORM. " get_filename
You may find it useful.
Regards,
Karuna. -
Creation of xml file in r3 application server (AL11)
Hi All
I need to create xml file in r3 application server (AL11) using PI.Can we achieve this using file adapter or we need to proceed with proxy. As I tried with file adapter with FTP transport protocol. Its giving the error as "Unable to create new pooled resource:FTPEx:Login incorrect".
Thanks in advance
Regards,
KartikeyaHi
need to create xml file in r3 application server (AL11) using PI.Can we achieve this using file adapter or we need to proceed with proxy.
To generate file at AL11 file directory use File adapter. Proxy is not required for this
Its giving the error as "Unable to create new pooled resource:FTPEx:Login incorrect".
1. Check with the Login credentials for the FTP service.
2. FTP User you use in communication channel must have 777 access to FTP location.
Thanks
Gaurav -
How to delete string or line from unix file(dataset) of application server
Hi All,
After transfer workarea information or all records into dataset(unix file). When I see the file in application server automatically the last line is shown a blank line. I am not passing any blank line.
I have tried for single record than also the file generates the last line(2nd line) also a blank line.
When I m reading the dataset, it is not reading the last blank line but why it is showing the last blank line?
How to delete string or line from unix file(dataset) of application server?
Please give your comments to resolve this.
Thanks
Tirumula Rao ChinniHi Rio,
I faced similar kind of issue working with files on UNIX platform.
The line is a line feed to remove it use
DATA : lv_carr_linefd TYPE abap_cr_lf VALUE cl_abap_char_utilities=>cr_lf.
DATA : lv_carr_return TYPE char1,
lv_line_feed TYPE char1.
lv_line_feed = lv_carr_linefd(1).
lv_carr_return = lv_carr_linefd+1(1).
Note: IMP: The character in ' ' is not space but is a special
character set by pressing ALT and +255 simultaneosly
REPLACE ALL OCCURRENCES OF lv_line_feed IN l_string WITH ' '.
REPLACE ALL OCCURRENCES OF lv_carr_return IN l_string WITH ' '. -
File from the Application server
Hi gurus,
I am working on a scenario where I need to get a file from the application server and for this I need to ask user to enter the location and that too at the selection screen and then I need to read this location using open data set and read data set in my program , once I am done with this I need to do some other validations. so can you please help me out how to achieve this.
Thanks
Rajeev GuptaHi
Declare the selection screen with file as parameter so that the user enter the application server file..
the use the OPEND DATASET as mentioned in below code and process
Refer this:
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm
ABAP code for uploading a TAB delimited file into an internal table. See code below for structures.
*& Report ZUPLOADTAB * &----
*& Example of Uploading tab delimited file *
REPORT zuploadtab .
PARAMETERS: p_infile LIKE rlgrap-filename
OBLIGATORY DEFAULT '/usr/sap/'..
DATA: ld_file LIKE rlgrap-filename.
*Internal tabe to store upload data
TYPES: BEGIN OF t_record,
name1 like pa0002-VORNA,
name2 like pa0002-name2,
age type i,
END OF t_record.
DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
wa_record TYPE t_record.
*Text version of data table
TYPES: begin of t_uploadtxt,
name1(10) type c,
name2(15) type c,
age(5) type c,
end of t_uploadtxt.
DATA: wa_uploadtxt TYPE t_uploadtxt.
*String value to data in initially.
DATA: wa_string(255) type c.
constants: con_tab TYPE x VALUE '09'.
*If you have Unicode check active in program attributes then you will
*need to declare constants as follows:
*class cl_abap_char_utilities definition load.
*constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
*START-OF-SELECTION
START-OF-SELECTION.
ld_file = p_infile.
OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
ELSE.
DO.
CLEAR: wa_string, wa_uploadtxt.
READ DATASET ld_file INTO wa_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
wa_uploadtxt-name2
wa_uploadtxt-age.
MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
APPEND wa_upload TO it_record.
ENDIF.
ENDDO.
CLOSE DATASET ld_file.
ENDIF.
*END-OF-SELECTION
END-OF-SELECTION.
*!! Text data is now contained within the internal table IT_RECORD
Display report data for illustration purposes
loop at it_record into wa_record.
write:/ sy-vline,
(10) wa_record-name1, sy-vline,
(10) wa_record-name2, sy-vline,
(10) wa_record-age, sy-vline.
endloop.
Regards
Anji -
Upload tab-delimited file from the application server to an internal table
Hello SAPients.
I'm using OPEN DATASET..., READ DATASET..., CLOSE DATASET to upload a file from the application server (SunOS). I'm working with SAP 4.6C. I'm trying to upload a tab-delimited file to an internal table but when I try load it the fields are not correctly separated, in fact, they are all misplaced and the table shows '#' where supposedly there was a tab.
I tried to SPLIT the line using as separator a variable with reference to CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB but for some reason that class doesn't exist in my system.
Do you know what I'm doing wrong? or Do you know a better method to upload a tab-delimited file into an internal table?
Thank you in advance for your help.Try:
REPORT ztest MESSAGE-ID 00.
PARAMETER: p_file LIKE rlgrap-filename OBLIGATORY.
DATA: BEGIN OF data_tab OCCURS 0,
data(4096),
END OF data_tab.
DATA: BEGIN OF vendor_file_x OCCURS 0.
* LFA1 Data
DATA: mandt LIKE bgr00-mandt,
lifnr LIKE blf00-lifnr,
anred LIKE blfa1-anred,
bahns LIKE blfa1-bahns,
bbbnr LIKE blfa1-bbbnr,
bbsnr LIKE blfa1-bbsnr,
begru LIKE blfa1-begru,
brsch LIKE blfa1-brsch,
bubkz LIKE blfa1-bubkz,
datlt LIKE blfa1-datlt,
dtams LIKE blfa1-dtams,
dtaws LIKE blfa1-dtaws,
erdat LIKE lfa1-erdat,
ernam LIKE lfa1-ernam,
esrnr LIKE blfa1-esrnr,
konzs LIKE blfa1-konzs,
ktokk LIKE lfa1-ktokk,
kunnr LIKE blfa1-kunnr,
land1 LIKE blfa1-land1,
lnrza LIKE blfa1-lnrza,
loevm LIKE blfa1-loevm,
name1 LIKE blfa1-name1,
name2 LIKE blfa1-name2,
name3 LIKE blfa1-name3,
name4 LIKE blfa1-name4,
ort01 LIKE blfa1-ort01,
ort02 LIKE blfa1-ort02,
pfach LIKE blfa1-pfach,
pstl2 LIKE blfa1-pstl2,
pstlz LIKE blfa1-pstlz,
regio LIKE blfa1-regio,
sortl LIKE blfa1-sortl,
sperr LIKE blfa1-sperr,
sperm LIKE blfa1-sperm,
spras LIKE blfa1-spras,
stcd1 LIKE blfa1-stcd1,
stcd2 LIKE blfa1-stcd2,
stkza LIKE blfa1-stkza,
stkzu LIKE blfa1-stkzu,
stras LIKE blfa1-stras,
telbx LIKE blfa1-telbx,
telf1 LIKE blfa1-telf1,
telf2 LIKE blfa1-telf2,
telfx LIKE blfa1-telfx,
teltx LIKE blfa1-teltx,
telx1 LIKE blfa1-telx1,
xcpdk LIKE lfa1-xcpdk,
xzemp LIKE blfa1-xzemp,
vbund LIKE blfa1-vbund,
fiskn LIKE blfa1-fiskn,
stceg LIKE blfa1-stceg,
stkzn LIKE blfa1-stkzn,
sperq LIKE blfa1-sperq,
adrnr LIKE lfa1-adrnr,
mcod1 LIKE lfa1-mcod1,
mcod2 LIKE lfa1-mcod2,
mcod3 LIKE lfa1-mcod3,
gbort LIKE blfa1-gbort,
gbdat LIKE blfa1-gbdat,
sexkz LIKE blfa1-sexkz,
kraus LIKE blfa1-kraus,
revdb LIKE blfa1-revdb,
qssys LIKE blfa1-qssys,
ktock LIKE blfa1-ktock,
pfort LIKE blfa1-pfort,
werks LIKE blfa1-werks,
ltsna LIKE blfa1-ltsna,
werkr LIKE blfa1-werkr,
plkal LIKE lfa1-plkal,
duefl LIKE lfa1-duefl,
txjcd LIKE blfa1-txjcd,
sperz LIKE lfa1-sperz,
scacd LIKE blfa1-scacd,
sfrgr LIKE blfa1-sfrgr,
lzone LIKE blfa1-lzone,
xlfza LIKE lfa1-xlfza,
dlgrp LIKE blfa1-dlgrp,
fityp LIKE blfa1-fityp,
stcdt LIKE blfa1-stcdt,
regss LIKE blfa1-regss,
actss LIKE blfa1-actss,
stcd3 LIKE blfa1-stcd3,
stcd4 LIKE blfa1-stcd4,
ipisp LIKE blfa1-ipisp,
taxbs LIKE blfa1-taxbs,
profs LIKE blfa1-profs,
stgdl LIKE blfa1-stgdl,
emnfr LIKE blfa1-emnfr,
lfurl LIKE blfa1-lfurl,
j_1kfrepre LIKE blfa1-j_1kfrepre,
j_1kftbus LIKE blfa1-j_1kftbus,
j_1kftind LIKE blfa1-j_1kftind,
confs LIKE lfa1-confs,
updat LIKE lfa1-updat,
uptim LIKE lfa1-uptim,
nodel LIKE blfa1-nodel.
DATA: END OF vendor_file_x.
FIELD-SYMBOLS: <field>,
<field_1>.
DATA: delim TYPE x VALUE '09'.
DATA: fld_chk(4096),
last_char,
quote_1 TYPE i,
quote_2 TYPE i,
fld_lth TYPE i,
columns TYPE i,
field_end TYPE i,
outp_rec TYPE i,
extras(3) TYPE c VALUE '.,"',
mixed_no(14) TYPE c VALUE '1234567890-.,"'.
OPEN DATASET p_file FOR INPUT.
DO.
READ DATASET p_file INTO data_tab-data.
IF sy-subrc = 0.
APPEND data_tab.
ELSE.
EXIT.
ENDIF.
ENDDO.
* count columns in output structure
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE vendor_file_x TO <field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
columns = sy-index.
ENDDO.
* Assign elements of input file to internal table
CLEAR vendor_file_x.
IF columns > 0.
LOOP AT data_tab.
DO columns TIMES.
ASSIGN space TO <field>.
ASSIGN space TO <field_1>.
ASSIGN COMPONENT sy-index OF STRUCTURE vendor_file_x TO <field>.
SEARCH data_tab-data FOR delim.
IF sy-fdpos > 0.
field_end = sy-fdpos + 1.
ASSIGN data_tab-data(sy-fdpos) TO <field_1>.
* Check that numeric fields don't contain any embedded " or ,
IF <field_1> CO mixed_no AND
<field_1> CA extras.
TRANSLATE <field_1> USING '" , '.
CONDENSE <field_1> NO-GAPS.
ENDIF.
* If first and last characters are '"', remove both.
fld_chk = <field_1>.
IF NOT fld_chk IS INITIAL.
fld_lth = strlen( fld_chk ) - 1.
MOVE fld_chk+fld_lth(1) TO last_char.
IF fld_chk(1) = '"' AND
last_char = '"'.
MOVE space TO fld_chk+fld_lth(1).
SHIFT fld_chk.
MOVE fld_chk TO <field_1>.
ENDIF. " for if fld_chk(1)=" & last_char="
ENDIF. " for if not fld_chk is initial
* Replace "" with "
DO.
IF fld_chk CS '""'.
quote_1 = sy-fdpos.
quote_2 = sy-fdpos + 1.
MOVE fld_chk+quote_2 TO fld_chk+quote_1.
ELSE.
MOVE fld_chk TO <field_1>.
EXIT.
ENDIF.
ENDDO.
<field> = <field_1>.
ELSE.
field_end = 1.
ENDIF.
SHIFT data_tab-data LEFT BY field_end PLACES.
ENDDO.
APPEND vendor_file_x.
CLEAR vendor_file_x.
ENDLOOP.
ENDIF.
CLEAR data_tab.
REFRESH data_tab.
FREE data_tab.
Rob -
Error while extracting XML file from the application server
Hi ,
I am writing a XML file into the application server, after which when i try to extract the file to the local server using the report - RFASLDPC ,
the file is extracted, but with a '#' symbol at the first position.
Because of which the XML File does not open. But after i open the file in notepad and manually delete the '#' symbol and then reopen the file, it works fine.
Is there any way to remove the '#' symbol while extracting itself ??
Thanks in advance,
Vikas.Select the option "No Character Set Conversion" in stead of Code page 1100.
However, I still have troubles -> the downloaded xml file misses a space on several places. This causes errors too. -
Printing files on the application server
Hi,
I am looking for ways to print files residing on the application server. Do you know of any function modules/transaction code that can do this?
Here is my situation:
I am using GRAPH_PRINT_POSTSCRIPT_FILE to print postscript file to the printer. I have no problem using this FM. The issue is that this function only prints files residing on the PC/local computer. It doesn't print any files on the application server.
Thanks in advance for any help you can provide.Hi,
use
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_FNAME'
dyname = 'ZFILE_HELP'
dynumb = sy-dynnr
filetype = 'P'
location = 'A'.
Thanks,
NN. -
Issue: XML File Downloading to Application Server
Hi All,
I am experiencing an issue downloading an XML File to the Application Server.
I'm using FM SAP_CONVERT_TO_XML_FORMAT to convert SAP data to XML Format.
After getting the XML data into XMLTAB, I'm using:
OPEN DATASET pfile_fs FOR OUTPUT IN BINARY MODE .
LOOP AT xmltab INTO xmltab_w.
TRANSFER xmltab_w TO pfile_fs.
CLEAR xmltab_w.
ENDLOOP.
CLOSE DATASET pfile_fs.
The xml file is downloaded show an Error in 'XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
Invalid at the top level of the document. Error processing resource 'file:/shared/TEST/2009'
But when i download xml file using the FM WS_Download , the XML page has no errors .
I am unable to figure out what could be the issue, If this issue is due to some characters like Chinese or Japanese then .. is there any solution for this .
Please, give me your valuable suggestions.
Thank you,
PraseadDear Prasead,
Hope things are good at your end, i have got the same issue as well, could you please care to share the solution...Wud be of a gr8 help if you could do that, hope to have your response back.
Regards,
Abdul. -
Urgent :- Unable to deploy EAR file in Oracle application server
Hello folks,
I am trying to deploy an application containing jsps and servlets
packaged into EAR using ant. However when am trying to do so by using
the Deploy EAR option in the Enterprise manager, it throws the
following error -
"Invalid J2EE application file specified - Jar file:
/var/tmp/jar47241.tmp is missing its standard xml descriptor located at
META-INF/ejb-jar.xml"
I suspect that something could be wrong with regards to the way the ear
file has been created.
Please if someone could pin point the problem and help me understand
the the above error message , it will be of great help to me and I d
really appreciate this.
Many Thanks,
Ramn.Hello,
I try to deploy an ear file (contains jar and war files) in Oracle Application server in linux, but the time is so long. The same file I deploy in a OAS in windows and the deploy time was 2 minutes, but in linux I leave the hole night and the session close and the deploy in unable.
I don't know if I need configure an especial option in the OAS in Linux, how I can load my ear file.
The OAS in windows was installed with oc4j options only, but the OAS in linux was full installation
Please help me....
Thanks. -
Various ways to place a File in the Application Server.
Hi all,
What are the various ways to place a file in the application Server.
Please classify them as shown below.
1. Use of ABAP Code.
2. Without the use of ABAP code.
RegardsHi
<b>1. Use of ABAP Code.</b>
by writing code like this
REPORT ZSD_EXCEL_INT_APP.
parameter: file_nm type localfile.
types : begin of it_tab1,
f1(20),
f2(40),
f3(20),
end of it_tab1.
data : it_tab type table of ALSMEX_TABLINE with header line,
file type rlgrap-filename.
data : it_tab2 type it_tab1 occurs 1,
wa_tab2 type it_tab1,
w_message(100) TYPE c.
at selection-screen on value-request for file_nm.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
* PROGRAM_NAME = SYST-REPID
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
STATIC = 'X'
* MASK = ' '
CHANGING
file_name = file_nm
EXCEPTIONS
MASK_TOO_LONG = 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.
start-of-selection.
refresh it_tab2[].clear wa_tab2.
file = file_nm.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '10'
i_end_row = '35'
tables
intern = it_tab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at it_tab.
case it_tab-col.
when '002'.
wa_tab2-f1 = it_tab-value.
when '004'.
wa_tab2-f2 = it_tab-value.
when '008'.
wa_tab2-f3 = it_tab-value.
endcase.
at end of row.
append wa_tab2 to it_tab2.
clear wa_tab2.
endat.
endloop.
data : p_file TYPE rlgrap-filename value 'TEST3.txt'.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
*--- Display error messages if any.
IF sy-subrc NE 0.
MESSAGE e001(zsd_mes).
EXIT.
ELSE.
*---Data is downloaded to the application server file path
LOOP AT it_tab2 INTO wa_tab2.
TRANSFER wa_tab2 TO p_file.
ENDLOOP.
ENDIF.
*--Close the Application server file (Mandatory).
CLOSE DATASET p_file.
loop at it_tab2 into wa_tab2.
write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
endloop.
Here is a pseudo code for what you are looking for-
OPEN DATASET P_FLPTH FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC eq 0.
LOOP AT LT_TAB INTO LS_TAB.
TRANSFER LS_TAB TO P_FLPTH.
ENDLOOP.
CLOSE DATASET P_FLPTH.
if sy-batch = 'X'.
write:/ 'File uploaded successfully'.
else.
message sXXX with 'File uploaded successfully'.
endif.
Else.
if sy-batch = 'X'.
write:/ 'Error in File upload'.
else.
message sxxx with 'Error in File upload'.
endif.
LEAVE PROGRAM.
ENDIF.
<b>2. Without the use of ABAP code.</b>
CG3Y -
Appl to Presentation server
<b>Reward if useful</b> -
Regarding reading data from a file in the application server.
Hello Everyone,
My question is:
The file in the application server consists of data with header, detail and trail out of which the detail contains the main information. The detail again contains the data in the form of a continuous string and again some spaces corresponding to a single record. I need to split the data in the internal table in such a way so that the first few characters get into field-1 of the target internal table. Again I need to consider the spaces for accessing the data for filling up in field-2. How do I decide on the 'Split' statement and specially when the whole string has to be taken care of as contatining data in a single string format without space and again some data after some spaces corresponding to a single record.
Your help is very much needed. Thanks to all the experts in advance.Hi
This is the sample code I was used for the similar requirement.
DATA: single_line TYPE string .
v_file_listings = pa_filn1.
IF v_file_listings IS INITIAL .
MESSAGE e039 WITH v_file_listings.
ENDIF.
*-- read file, split lines into fields and put data into table
OPEN DATASET v_file_listings FOR INPUT IN TEXT MODE ENCODING NON-UNICODE. "Opening the files
IF sy-subrc EQ 0.
DO.
READ DATASET v_file_listings INTO single_line. "Reading the content of file into line
IF sy-subrc = 0.
IF sy-index > 1. "skip header-line
SPLIT "Split the content of line into work area
single_line
AT k_split
INTO
wa_listings-kschl " Condition type
wa_listings-tabname16 " Condition table name
wa_listings-vkorg " Sales organisation
wa_listings-kunnr " sold-to party numberor ship-to party number
wa_listings-matnr " Material Number
wa_listings-kodatab " Valid-from date
wa_listings-kodatb1. " Valid-to date
APPEND wa_listings TO itab_listings. "Appending Work Area to internal table
ENDIF.
ELSE.
EXIT.
ENDIF.
v_count1 = sy-tabix.
ENDDO.
Regards,
Sreeram -
How to run ear file in java application server
i want how to run .ear file in java application server
1. i m created ear file
2. i m created jar file (bean,home,remote)
3.i m created war file(in the form of jsp)
but till now i couldnt run ear file
how to run
please hel meYou must create :
1.Jar file
2.War file
And then put them into an ear file
Exemple : myapp.ear contains
myappEJB.jar
myappWEB.war
META-INF/application.xml
and application.xml looks like this :
<application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>myapp</display-name>
<description>Demo application</description>
<module>
<ejb>myappEJB.jar</ejb>
</module>
<module>
<web>
<web-uri>myappWAR.war</web-uri>
<context-root>/myapp</context-root>
</web>
</module>
</application>Good luck -
ABEND while creating file in the application server
Dear All,
Please provide the solution for the following.
REPORT ZMAIN.
SELECT BKORM UP TO 1000
EXTRACT ext.
ENDSELECT
Imagine, now the extract file having 1000 Entries
Reading the above EXTRACT file
LOOP .
submit ZSUB.
ENDLOOP.
End OF Main Program----
REPORT ZSUB.
SELECT BKORM UPTO 500
EXTRACT ext.
ENDSELECT
Here for each submit of the ZSUB, it is creating one EXTRACT file in the application server. When it reaching to create 999, it is going for ABEND.
Can anybody provide the solution to avoid going for ABEND .
Is there any restriction to create extract files in the applciation server?
Thanks in advance.Instead of select/endselect, try to use a loop with internal tables..
There's no limit in the extracts you can do..
<removed by moderator>
Edited by: Thomas Zloch on Nov 2, 2010 5:20 PM - please do not ask for... -> Ok
Edited by: Roberto Vacca on Nov 2, 2010 5:29 PM -
Looking for file in the application server.
Hello expert,
I want to download a file from SAP application server, but when I get into file system for application server by AL11 , I can't find out the folder for my file, why? is that authority issue or I did the wrong way to get into the system? appreciate very much for your help.
Many Thanks,Hi,
At AL11, if you have the proper authorizations, you should see a Configure button. After that, enter:
- Directory Name:
server-name\directory
- Param. Name: Z_<directory>
- ServerName: all
Then, click on Save.
Take into account that SAPServiceSID user should have read access to the share.
Regards,
Maximiliano
Maybe you are looking for
-
Using nested query to avoid repeated object traversal
Hi everyone, My SQL is still very basic, hopefully this is not a dumb question ;-) I have a table with a single spatial column of type SDO_GEOMETRY: SQL> desc WITHIN_POINT_DISTANCE_TAB Name Null? Type POI
-
Hi , Is it best practise to do all filed validation using java...or could field validation be done using java beans in JSP ? Thanks Vivek
-
Working with version management and promotion management best practices BO 4.1
Hi Experts I wondered if anybody knows if there is a document or something about best practices to work with the version management and promotion management in BO 4.1? Our Environment includes two servers. The first one is our development and test se
-
CR.XI.R2: report assistant: bug found
Post Author: felix CA Forum: Crystal Reports Hi @all, there is a small bug in the report assistant. start the assistant select your datasourceselect your tablesclick next(found out, that you forgot a table)click backselect your tablesclick next(found
-
I purchased this subscription on August 7 for converting a pdf file (scientific paper produced by Latex) and I was very disappointing that the translation provided was a serie of graphic symols, but not at all the text I would lioke to get. I ask a q