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: 

Unzipping a file on App server through ABAP program

Former Member
0 Kudos
871

Hi Experts,

I have a requirement like a zip file will be placed on app server. We need to unzip it and put all the files on the same server and process them. How can we do this through ABAP?

I read similar post on the same topic but none of the approches worked in it.

4 REPLIES 4

mvoros
Active Contributor
0 Kudos
149

Have you tried class CL_ABAP_ZIP? It worked for me and it has a simple API.

Cheers

Former Member
0 Kudos
149

Hi Martin,

Thanks for you reply.

I tried using CL_ABAP_ZIP, I think we need to use upload modules to get the data from app server. But this has to be run in background. Can you please share your views?

Thanks,

Shanthi Juluru

mvoros
Active Contributor
0 Kudos
149

Hi,

that API is simple. For example to add file to a zip archive you just need to call method ADD which has two input parameters: name and content. You need to get your file into local variable with type XSEQUNCE. It really does not matter where you file is. If you search for CL_ABAP_ZIP here on SDN you will find some examples.

Cheers

former_member182040
Active Contributor
0 Kudos
149

CONSTANTS: c_extcom    TYPE sxpgcolist-name VALUE 'ZTEST',
           c_oper      TYPE syopsys VALUE 'Windows NT'.

DATA: v_dir_input      TYPE sxpgcolist-parameters.  " Input Directory
DATA: t_result         TYPE STANDARD TABLE OF btcxpm.

v_dir_input = 'cmd /c unzip test.zip '.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
  EXPORTING
    commandname                   = c_extcom
    additional_parameters         = v_dir_input
    operatingsystem               = c_oper
  TABLES
    exec_protocol                 = t_result
  EXCEPTIONS
    no_permission                 = 1
    command_not_found             = 2
    parameters_too_long           = 3
    security_risk                 = 4
    wrong_check_call_interface    = 5
    program_start_error           = 6
    program_termination_error     = 7
    x_error                       = 8
    parameter_expected            = 9
    too_many_parameters           = 10
    illegal_command               = 11
    wrong_asynchronous_parameters = 12
    cant_enq_tbtco_entry          = 13
    jobcount_generation_error     = 14
    OTHERS                        = 15.

T.code SM69 create external command name 'ZTEST'