Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

abap program in process chain

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

3 REPLIES 3

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

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