cancel
Showing results for 
Search instead for 
Did you mean: 

Hi friends, How to pickup the file from zip folder ?

Former Member
0 Kudos

1)How to pickup the file from zip folder ?pls explain.?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

>

> 1)How to pickup the file from zip folder ?pls explain.?

For Example : if ur folder in application server (IO061.zip) in that ur file name is (IO061_test.csv).

then u need to read that file, for that u can follow the following code:

types: begin of y_splic,

name type string,

offset type i,

length type i,

compressed type i,

end of y_splic .

types: begin of y_data,

data type ref to data,

xmlfile type string,

end of y_data.

data: lt_splice_entries type table of y_splic,

lx_splice_entries type y_splic,

lv_xstring type xstring,

lv_string type string,

lt_data type standard table of y_data,

lt_filedata type table of string,

lt_outtab type ref to data.

data : zip type ref to cl_abap_zip.

create object zip.

open dataset '/interfaces/DF1/inbound/IO061.zip' for input in binary mode message lv_msg.

if sy-subrc = 0.

read dataset '/interfaces/DF1/inbound/IO061.zip' into lv_xstring.

endif.

close dataset '/interfaces/DF1/inbound/IO061.zip'.

call method cl_abap_zip=>splice

exporting

zip = lv_xstring

receiving

entries = lt_splice_entries.

zip->load( lv_xstring ).

get reference of lt_data into lt_outtab.

lx_data-data = lt_outtab.

lx_data-xmlfile = 'IO061_test.csv'.

append lx_data to lt_data.

clear lx_data.

if lines( lt_splice_entries ) gt 0.

clear : lx_splice_entries.

loop at lt_splice_entries into lx_splice_entries.

clear : lx_data.

read table lt_data into lx_data with key xmlfile = lx_splice_entries-name.

if sy-subrc eq 0.

clear : lv_xstring.

call method zip->get

exporting

name = lx_splice_entries-name

importing

content = lv_xstring

exceptions

zip_index_error = 1

zip_decompression_error = 2

others = 3.

if sy-subrc = 0.

call function 'HR_KR_XSTRING_TO_STRING'

exporting

in_xstring = lv_xstring

importing

out_string = lv_string.

if not lv_string is initial.

split lv_string at cl_abap_char_utilities=>newline into table lt_filedata.

endif.

endif.

endif.

clear : lx_splice_entries, lv_xstring, lv_string.

endloop.

Edited by: siva on Jun 17, 2009 3:56 PM

Edited by: siva on Jun 17, 2009 4:07 PM

Former Member
0 Kudos

Hi,

If your file resides in the XI Application Server, You can run a OS Command to Unzip the file and then pick up the required file.

Running OS Commands can be achieved by 'Run Operating System Command Before Processing' Option in File Adapter.

Regards,

Amitabha