2005 Nov 30 11:16 PM
hi,
i want to use a abap program in the process chain which reads the necessary files from the app server on the selection criteria(\obdshare\jde\cognos*). once all the files are selected i would like to select the first file,cut and paste it to another directory on the app server (\obdshare\jde\data\cognos_despatch_24112005). can anybody give me the code for this process. i have no idea about the abap programming.
thanx,
Ravi.
P.S: points will be fully rewarded for the working code.
2005 Dec 01 2:10 AM
Hi Ravi,
Try this simple example.
data: begin of it_data occurs 0,
len(350) type c,
end of it_data.
parameters: p_file1 like rlgrap-filename default \obdshare\jde\data\cognos_despatch_24112005.
parameters: p_file2 like rlgrap-filename default \newfolder\jde\data\cognos_despatch_24112005.
refresh it_data.
clear it_data.
open dataset p_file1 for input in text mode.
if sy-subrc ne 0.
message sy(e002) with 'File not found'.
else.
do.
read dataset p_file1 into it_data-len.
if sy-subrc ne 0.
exit.
else.
append it_data.
endif.
enddo.
close dataset p_file1.
endif.
OPEN DATASET p_file2 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT it_data.
TRANSFER it_data TO p_file2.
ENDLOOP.
CLOSE DATASET p_file2.
Thanks
Bhaskar
You will want to use the ABAP statements...
OPEN DATASET
READ DATASET
TRANSFER DATASET
CLOSE DATASET
Do f1 help on these statements.
Regards,
Rich Heilman
2005 Dec 01 12:04 AM
2005 Dec 01 7:30 AM
Hi,
here's a sample:
PARAMETERS: dir LIKE epsf-epsdirnam DEFAULT 'obdsharejdedata'.
PARAMETERS: new LIKE epsf-epsdirnam DEFAULT 'obdsharejdedatanew'.
PARAMETERS : sample LIKE epsf-epsfilnam DEFAULT 'cognos*'.
DATA dir_list LIKE epsfili OCCURS 0 WITH HEADER LINE.
DATA cnt_file TYPE epsf-epsfilsiz.
DATA: command TYPE string.
DATA: BEGIN OF tabl OCCURS 0,
line(255),
END OF tabl.
*get all files
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
EXPORTING
dir_name = dir
file_mask = sample
IMPORTING
file_counter = cnt_file
TABLES
dir_list = dir_list
EXCEPTIONS
invalid_eps_subdir = 1
sapgparam_failed = 2
build_directory_failed = 3
no_authorization = 4
read_directory_failed = 5
too_many_read_errors = 6
empty_directory_list = 7
OTHERS = 8.
IF sy-subrc <> 0 OR cnt_file = 0.
MESSAGE e001(00) WITH 'directy read failed!'.
ENDIF.
READ TABLE dir_list INDEX 1.
*build new filename
CONCATENATE new dir_list-name INTO new.
*build os-command mv
CONCATENATE 'mv' dir_list-name new INTO command SEPARATED BY space.
CALL 'SYSTEM' ID 'COMMAND' FIELD command ID 'TAB' FIELD tabl-*sys*.Andreas
2005 Dec 01 2:10 AM
Hi Ravi,
Try this simple example.
data: begin of it_data occurs 0,
len(350) type c,
end of it_data.
parameters: p_file1 like rlgrap-filename default \obdshare\jde\data\cognos_despatch_24112005.
parameters: p_file2 like rlgrap-filename default \newfolder\jde\data\cognos_despatch_24112005.
refresh it_data.
clear it_data.
open dataset p_file1 for input in text mode.
if sy-subrc ne 0.
message sy(e002) with 'File not found'.
else.
do.
read dataset p_file1 into it_data-len.
if sy-subrc ne 0.
exit.
else.
append it_data.
endif.
enddo.
close dataset p_file1.
endif.
OPEN DATASET p_file2 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT it_data.
TRANSFER it_data TO p_file2.
ENDLOOP.
CLOSE DATASET p_file2.
Thanks
Bhaskar
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |