Application Development and Automation 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: 
Read only

Extract file from http://...zip into ABAP

Former Member
0 Likes
1,742

Hello!

I know how to import a text file from HTTP server into ABAP (string variable) by using the CL_HTTP_CLIENT functionalities (thanks to <a href="https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/u/55615">Craig Cmehil's</a> weblog <a href="/people/sap.user72/blog/2005/05/03/sdn-meets-labs-integrated-web-content Meets Labs: Integrated Web Content</a>).

But now I have a <i>*.txt</i> file packed with other files into a <i>http://...zip</i> file. How do I extract and import the text file into ABAP string (or other) variable?

I'd prefer something direct, without using shell commands and filesystem.

Any ideas?

Thanks in advance!

Regards,

Igor

1 ACCEPTED SOLUTION
Read only

former_member182371
Active Contributor
0 Likes
1,419

Hi Igor,

long ago i found this example in forum "SAP Abap en Castellano".

First find out the winzip parameters accepted from ms-dos.

e.g. to compress two files 1.txt and 2.txt in destination.zip use:

CALL FUNCTION 'WS_EXECUTE'

EXPORTING

  • DOCUMENT = ' '

  • CD = ' '

COMMANDLINE = ' -min -a c:destino.zip c:1.txt c:2.txt'

  • INFORM = ' '

PROGRAM = 'winzip32.exe'

  • STAT = ' '

  • WINID = ' '

  • OSMAC_SCRIPT = ' '

  • OSMAC_CREATOR = ' '

  • WIN16_EXT = ' '

  • EXEC_RC = ' '

  • IMPORTING

  • RBUFF =

  • EXCEPTIONS

  • FRONTEND_ERROR = 1

  • NO_BATCH = 2

  • PROG_NOT_FOUND = 3

  • ILLEGAL_OPTION = 4

  • GUI_REFUSE_EXECUTE = 5

  • OTHERS = 6

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

Hello!

I know how to import a text file from HTTP server into ABAP (string variable) by using the CL_HTTP_CLIENT functionalities (thanks to <a href="https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/u/55615">Craig Cmehil's</a> weblog <a href="/people/sap.user72/blog/2005/05/03/sdn-meets-labs-integrated-web-content Meets Labs: Integrated Web Content</a>).

But now I have a <i>*.txt</i> file packed with other files into a <i>http://...zip</i> file. How do I extract and import the text file into ABAP string (or other) variable?

I'd prefer something direct, without using shell commands and filesystem.

Any ideas?

Thanks in advance!

Regards,

Igor

6 REPLIES 6
Read only

Former Member
0 Likes
1,419

Hi,

I do not have access to an SAP system right now but have you checked the class CL_ABAP_GZIP method DECOMPRESS. There has been some discussion on this forum on using it. See if it helps.

Regards

Read only

former_member182371
Active Contributor
0 Likes
1,420

Hi Igor,

long ago i found this example in forum "SAP Abap en Castellano".

First find out the winzip parameters accepted from ms-dos.

e.g. to compress two files 1.txt and 2.txt in destination.zip use:

CALL FUNCTION 'WS_EXECUTE'

EXPORTING

  • DOCUMENT = ' '

  • CD = ' '

COMMANDLINE = ' -min -a c:destino.zip c:1.txt c:2.txt'

  • INFORM = ' '

PROGRAM = 'winzip32.exe'

  • STAT = ' '

  • WINID = ' '

  • OSMAC_SCRIPT = ' '

  • OSMAC_CREATOR = ' '

  • WIN16_EXT = ' '

  • EXEC_RC = ' '

  • IMPORTING

  • RBUFF =

  • EXCEPTIONS

  • FRONTEND_ERROR = 1

  • NO_BATCH = 2

  • PROG_NOT_FOUND = 3

  • ILLEGAL_OPTION = 4

  • GUI_REFUSE_EXECUTE = 5

  • OTHERS = 6

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

Read only

0 Likes
1,419

Thanks, guys!

Running WINZIP32.EXE as an external command is also an option. I'd have to first import the *.zip file from HTTP site, then download it to server (or PC) just to run WinZip, and then import again the extracted text file. I see this more as a workaround.

I'd loooove to see it work directly from HTTP site, without using the filesystem.

Before I try to do it with external command, I'd like to explore direct possibilities. From the posts about GUI_ABAP_GZIP I can see that it's an internal ABAP compress/decompress tool, not capable of decompressing files zipped with WinZip. And to make it more complicated: It's not just decompressing. I have to extract just one file of many which are zipped in a single *.zip file.

Not to mention that my second step is verifying the digital signature for the text file (it's currency exchange rates) contained in the same *.zip.

It's a tough one, isn't it?

Thanks!

Kind regards,

Igor

Read only

former_member182371
Active Contributor
0 Likes
1,419

Hi Igor,

i don´t know if i´ve understood it right but as a suggestion what if you used a script for decompressing?.

Have a look at: http://java.sun.com/developer/technicalArticles/Programming/compression/

Best regards.

Read only

0 Likes
1,419

Hi, Calsadillo!

Thanks for an interesting suggestion! I could get a zip file with CL_HTTP_CLIENT, pass it to a script which extracts and returns unzipped file.

However, I don't know how to use a script in my ABAP program, whithout using the filesystem commands or JCo server. And especially not filesystem of a workstation, since my program should be able to run in background too.

How do I integrate a script with ABAP?

Thanks!

Igor

P.S. I was on vacation - that's why it took me so long to answer your post.

Read only

former_member182371
Active Contributor
0 Likes
1,419

Hi Igor,

have a look at his link (just in case):

http://www.4soi.de/SAPCAR.php?Area=SAPGenie&;

Best regards.