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: 

Want to Unzip a file using CL_ABAP_ZIP

former_member378040
Participant
0 Kudos

I want to unzip a file from one folder and save the unzipped files into another folder using the methods of the class CL_ABAP_ZIP. I searhed the SDN for definite steps to use the methods of this class but could not find any info.

Has someone used this class and can post the code on the SDN (step by step).

It will be a great help.

Thanks

Amit.

7 REPLIES 7

former_member583013
Active Contributor
0 Kudos

I tried to do some examples...but i couldn't make it work...no errors....and no output -:(

Any help would be appreciated.

Greetings,

Blag.

former_member378040
Participant
0 Kudos

I used FM SXPG_CALL_SYSTEM to issue commands at the server.

AMit.

0 Kudos

Have a look at this thread -

Former Member
0 Kudos

Hi Amit

Have you got the solution to Unzip the file using CL_ABAP_ZIP.

Could you plese share it with SDN.

That will be the great help.

Thanks in Advance

Amit

Former Member

Here's a program to decompress a zip file, i have one to compress too.

REPORT  YFPZ0008.

TYPES:
t_xline(2048) TYPE x, "BINARY FILES

BEGIN OF t_line,
line(1024) TYPE c,
END OF t_line. "CONTENT

DATA:
size type i.

DATA:
data_tab TYPE STANDARD TABLE OF t_xline,
text_tab TYPE STANDARD TABLE OF t_line.

DATA:
input_x type xstring, "BINARY CONTENT INPUT
output_x type xstring. "BINARY OUTPUT OUTPUT


data : CL_ZIP type ref to CL_ABAP_ZIP .

DATA files LIKE LINE OF  cl_abap_zip=>files.

DATA:
name type string.

  PARAMETER:
    p_file TYPE string.

  PARAMETER:
    p_output TYPE string.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = p_file
FILETYPE = 'BIN'
IMPORTING
FILELENGTH = size
CHANGING
DATA_TAB = data_tab.


CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
INPUT_LENGTH = size
IMPORTING
BUFFER = input_x
TABLES
BINARY_TAB = data_tab.

CREATE OBJECT cl_zip.

CALL METHOD cl_zip->load(
EXPORTING
zip = input_x
).


LOOP AT cl_zip->files INTO files.

CLEAR output_x.
MOVE files-name TO name.
cl_zip->GET(
EXPORTING
NAME = name " Example.txt (file in the zip file)
IMPORTING
CONTENT = output_x
)
.

REFRESH data_tab.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = output_x
IMPORTING
OUTPUT_LENGTH = size
TABLES
BINARY_TAB = data_tab
.
CALL FUNCTION 'SCMS_BINARY_TO_TEXT'
EXPORTING
INPUT_LENGTH = size
TABLES
BINARY_TAB = data_tab
TEXT_TAB = text_tab
.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
BIN_FILESIZE = size
FILENAME = p_output
FILETYPE = 'BIN'
CHANGING
DATA_TAB = data_tab.

0 Kudos

I think Amit Gupta should close this thread, because Felipe your example works. I'd tried it out in my system. It works.

William Wilstroth

0 Kudos

Hi ,

Can we upload .rar files from URL and upload the content into Application Server?

Kindly suggest me to solve my issue.

Regards,

Ramana.