Regarding moving files b/w folders in the Application server
Hi,
I need to move the file from one folder(main folder) of the application server to another (eg, archive, error) with certain conditions. When I try to move file from main folder to archive folder, it is working fine (.txt). The file along with the contents are moving, but when I try to move the file from main folder to error folder (.err), though the file has moved, the contents are not showing (though the file is erased from the main folder). I have used the function module
SXPG_COMMAND_EXECUTE for performing these actions. Can any one suggest as to why the contents are not showing.
LEAR: lv_mv_command_exitcode,
lv_mv_command_arguments,
lv_dummy_string.
CONCATENATE is_dir_list-fullname iv_error_file INTO lv_mv_command_arguments
SEPARATED BY space.
REFRESH lt_mv_command_stdout.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = 'ZMV'
additional_parameters = lv_mv_command_arguments
IMPORTING
exitcode = lv_mv_command_exitcode
TABLES
exec_protocol = lt_mv_command_stdout
EXCEPTIONS
no_permission = 1
command_not_found = 2
parameters_too_long = 3
security_risk = 4
wrong_check_call_interface = 5
program_start_error = 6
program_termination_error = 7
x_error = 8
parameter_expected = 9
too_many_parameters = 10
illegal_command = 11
wrong_asynchronous_parameters = 12
cant_enq_tbtco_entry = 13
jobcount_generation_error = 14
OTHERS = 15.
IF sy-subrc <> 0 OR lv_mv_command_exitcode <> 0.
CONCATENATE 'Error in File'
iv_basefile
'but,not moved to Error folder.'
INTO lv_dummy_string SEPARATED BY space.
WRITE: / lv_dummy_string.
IF sy-batch = c_flag_on.
MESSAGE e054 WITH iv_basefile.
ENDIF.
ELSE.
CONCATENATE 'Error in File,'
iv_basefile
'moved to Error folder.'
INTO lv_dummy_string SEPARATED BY space.
WRITE: / lv_dummy_string.
IF sy-batch = c_flag_on.
MESSAGE s055 WITH iv_basefile.
ENDIF.
Regards,
John
Hi,
Here what I found was, if the file is empty, then the system is not moving the empty file to the destination , but if the file is not empty it is copying the contents and the corresponding folder to the destination folder. My intent is to copy the folder even if the contents of the folder is empty to the destination folder and delete the old file.
regards,
John
Similar Messages
-
How to load data from a flat file which is there in the application server
HI All,
how to load data from a flat file which is there in the application server..Hi,
Firstly you will need to place the file(s) in the AL11 path. Then in your infopackage in "Extraction" tab you need to select "Application Server" option. Then you need to specify the path as well as the exact file you want to load by using the browsing button.
If your file name keeps changing on a daily basis i.e. name_ddmmyyyy.csv, then in the Extraction tab you have the option to write an ABAP routine that generates the file name. Here you will need to append sy-datum to "name" and then append ".csv" to generate complete filename.
Please let me know if this is helpful or if you need any more inputs.
Thanks & Regards,
Nishant Tatkar. -
How can i display a image file which is placed in the applications server
Hi all,
Can any one help me how can I display a image file which is present in the application server.
With regards,
M.Ramana Murthyhi,
*& Form TOP_OF_PAGE
* text
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo = Logo name
* I_END_OF_LIST_GRID =
ENDFORM. "TOP_OF_PAGE
rgds
Anver -
How to run a exe file that is residing in the application server.
Hi,
I have a requirement in which a .exe (Windows executive) file needs to be run through code, which is residing in the application server. That exe file is nothing but a pdf-excel converter that will convert a pdf file to excel. The corresponding pdf file is also in the application server. Is there any function module to make this happen? I have come across the FM GUI_EXEC, but it operates on exe and pdf files that are in the presentation server.hi
1. customise external command in sm69
2. use FM: SXPG_COMMAND_EXECUTE
regards,darek -
Process Chain to do nothing if file does not exist in the application serve
Hi All,
We have a process chain that flows to different data targets daily if files delivered in the application server.
Process chain does works fine. But my question is do we have anyway to stop the process chain or do not run process chain if it does not find the file available any days during this time range instead of failing.*
Is there any settings to enable the check if file available then run or else do not run at all. Please help!!!
Thanks,Follow the function modules listed in :
http://wiki.sdn.sap.com/wiki/display/ABAP/Workingwithfiles
with these function modules - you can get a list of files available in the application server directory.
Pseudo code :
1. Generate the automated fiel name you want
2. Get the list of files in the directory
3. Search the list of files to see if your file exists
4. If the file exists then load the file , else load an empty file .
The code is unfortunately in a different BW system that I do not have access to at this moment... but then the procedre is the same as detailed above. -
Moving files into different folders on the ipod ?
Hi all,
A lot of my movie files are in the wrong place on my ipod - e.g some of my video podcasts are in my songs folder.
Is there anyway I can move the video files on my ipod into the correct place ?
Many thanks in advance,
MartinHi,
They are only showing up in songs.
Also for some reason all my video files are now played as audio files
Can anybody help with this at all ?
Thanks,
Martin -
Need to replace a file in the application server
Hello Experts,
Through ABAP coding, I need to replace a file which is available in the application server from one path to another. I should not use OPEN DATASET, CLOSE DATASET, DELETE DATASET and all as they deal with the data. I need to replace the file with out touching the data of the file.
Could anyone please help.
I heard that i have to use some UNIX script.
Regards,
SudheerSudheer,
Try this...
WITHOUT TOUCHING THE DATA OF A FILE . . .Just Moving the file ( unix commands in abap )
DATA: command(255) TYPE c,
fnam_sour(255),
fnam_target(255).
fnam_sour = '\hme\usr\interface\..... " path of source file
fnam_target = '\hme\usr\interface\..... " target path, where file to placed.
OPEN DATASET fnam_sour FOR INPUT " fnam_sour -> path of source file...
MESSAGE msg IN TEXT MODE
ENCODING DEFAULT.
IF sy-subrc <> 0.
< error msg : no file exits>
else.
OPEN DATASET fnam_target FOR INPUT " fnam_target -> path where file to be placed....
MESSAGE msg IN TEXT MODE
ENCODING DEFAULT.
if sy-surc = 0.
CONCATENATE 'mv' fnam_sour fnam_target INTO command SEPARATED BY
space.
CONDENSE command.
PERFORM uxcmd USING command.
endif.
endif.
*& Form UXCMD
FORM uxcmd USING p_command.
**issue UNIX command by calling system function.
DATA: BEGIN OF itab OCCURS 0,
line(255),
END OF itab.
CALL 'SYSTEM' ID 'COMMAND' FIELD p_command
ID 'TAB' FIELD itab-sys.
ENDFORM. " UXCMD
Regards
Ram -
Cannot find the age in years csv file in the application server
Hi,
I want to upload the age in years hierarchy from the CSV file AGE_E.CSV that should be available in the application server.
When i try to preview file in the info package, a message is thrown which says that the file does not exist, which means that the perticular file is not present in the application server.
Can any one of you please tell me where else can i find this file.
Regards,
Chetana.dear Chetana,
transaction AL11 can be used to check the file location.
check DIR_TEMP or DIR_TRANS. or ask basis where the file is put.
hope this helps. -
Can we compare file contents of two files in the Application server?
Hi,
A file is generated daily to the application server. and i need to compare the generated file to the file generated on the previous day and prepare a report.
Can we compare file contents of two generated files present in the Application server?
If there is any alternative, please suggest.
regards
csyes we can compare if the app server is Unix.
cmp compare two binary files and report if different
cmp is silent if the files are the
same;
if they differ, the byte and line number at which the first
difference occurred is reported.
REPORT ZUNIX line-size 400
no standard page heading.
data: unixcom like rlgrap-filename.
unixcom = 'cmp file1 file2'.
data: begin of tabl occurs 500,
line(400),
end of tabl.
data: lines type i.
start-of-selection.
refresh tabl.
call 'SYSTEM' id 'COMMAND' field unixcom
id 'TAB' field tabl[].
"if the files are different then you will some content in tabl
Regards
Viajy Babu Dudla -
How to delete the record in the file present in the application server?
Hi,
I have two questions.
i) How can I delete a record based on some condition in the recordx in the file that is present in the application server?
ii) How can I lock the users whiel one user is accessing the file on the application server?
Thanks in advance.
SuvanHi,
If u want a frequent deletion this approach to delete a record from a file will havee unnecesary copy of records from one file to another and deletion of one file and renaming activities.
Instead what u can do is Add and field del_flag to ur record structure.
If u want to delete the record from a file just mark this del_flag as 'X'.
While processing u can have a loop like
loop at it_XXX where del_flag <> 'X'.
endloop.
This will logically delete the record.
When u r to finish the application at that time only perform this copying / deleting / and renaing activity
Hope this helps.
Cheers,
Nitin -
Integrating Web server (eg Apache) with the application server
I am thinking a project in which I use more static HTML files than JSPs. One way is to use an Apache server to display those HTML files (it should be faster), and deploy the JSPs into the J2EE server; another way is just simple to change the web container�s port to 80 (of the PE 8), and wrap all the files into a war file and deploy it into the application server.
So can someone advise my which way is better? And if I use the first one, I�d like to know if it is the same way to integrate Apache with Tomcat.
Thank you very much!In the past there has been a belief that the Apache web server serves static content faster than tomcat. Site managers would configure apache to deliver static content and integrate a web container to handle the dynamic content. I believe this argument is losing steam as tomcat gets better. I guess the only way you will know for sure is to deploy your application in PE 8.0 and then in an apache/web container configuration and do some benchmarking. I have no such benchmark data to compare and I base my comments on what I have read in newsgroups over the past months. Personally, I would opt for the app server only setup just to ease configuration. Others may have a different opinion.
-
Moving of flat file from the application server after upload.
Hi All,
I am uploading data from a flat file placed on the application server by a BDC program.
After the BDC has created the session i want to transfer the flat file from that folder to another folder on the application server by changing the name of the flatfile.
Can any one suggest the best way of doing this particular scenario?
Thanks in advance.
Regards
Satish Nair.Here is a sample program.
report zrich_0001.
data: d1 type localfile value '/usr/sap/TST/SYS/Data1.txt',
d2 type localfile value '/usr/sap/TST/SYS/Data2.txt'.
data: begin of itab occurs 0,
rec(20) type c,
end of itab.
data: wa(20) type c.
start-of-selection.
open dataset d1 for input in text mode.
if sy-subrc = 0.
do.
read dataset d1 into wa.
if sy-subrc <> 0.
exit.
endif.
itab-rec = wa.
append itab.
enddo.
endif.
close dataset d1.
open dataset d2 for output in text mode.
loop at itab.
transfer itab to d2.
endloop.
close dataset d2.
delete dataset d1.
Regards,
Rich Heilman -
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 -
Regarding the File Format on the application server
Hi,
I would like to know the file format (ANSI, UTF-8, UTF-16, UTF-32) of the file placed on the application server in my program. Can anyone help me with the Function Module or Class or any other way which will retrieve this information.
Thanks
Sarves S V KHi
You can try the standard class CL_ABAP_FILE_UTILITIES and the method
CALL METHOD cl_abap_file_utilities=>check_utf8
EXPORTING
file_name = filename
IMPORTING
bom = file_bom
encoding = file_encoding.
Check the possible values returned by encoding and BOM:
NO_BOM
BOM_UTF8
BOM_UTF16_BE
BOM_UTF16_LE
ENCODING_UTF8
ENCODING_7BIT_ASCII
ENCODING_OTHER -
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.
Maybe you are looking for
-
Compressor issue, keep getting Failed: QuickTime error.-50. Anyone knows why?
-
We have SD tax invoice from billing document, we also need FI tax invoice, the standard FI invoice is just extracted from FI document, the pogram is RFKORD50. But we need get the same infomation in FI invoice as SD invoice, how can I do it?! Thanks i
-
Hello everyone, my dreamweaver doesn´t start.
hello everyone, i got a problem, dreamweaver doesn´t start on my notebook ( it´s a acer aspire), i tried to start it when all other programms are shut down (espiacelly anti-virus and firewall software) but it doesn´t work... if someone can help me th
-
Syncing photos with correct orientation
I know this has been mentioned in a few threads, but there hasn't been a satisfactory answer so far. Just to summarise - when you sync photos with your iPhone, the EXIF rotation/orientation information is lost and photos are always displayed in the 4
-
My email can,t open, after click blinking .