This is an implementation of the ustar and pax tar formats.
Archives can be compressed and decompressed using gzip and gunzip methods as well.
NO WARRANTIES, MIT License
Limitations: Block size is hardcoded to 512 bytes
Here's an example of how to tar a list of files.
DATA your_files TYPE zcl_tar=>ty_files.
DATA(tar) = zcl_tar=>new( ).
LOOP AT files INTO ls_file.
tar->append(
name = file-name
content = file-content
date = file-date
time = file-time
mode = file-mode
typeflag = file-typeflag ).
ENDLOOP.
DATA(tar_data) = tar->save( ).
" Gzip
DATA(packed_data) = tar->gzip( tar_data ).
Here's an example of how to untar a file.
DATA:
your_data TYPE xstring,
unpacked_data TYPE xstring.
DATA(tar) = zcl_tar=>new( ).
" Gunzip
IF filename CP '*.tgz' OR filename CP '*.tar.gz'.
unpacked_data = tar->gunzip( your_data ).
ELSE.
unpacked_data = your_data.
ENDIF.
tar->load( unpacked_data ).
List the files and get file content:
DATA(files) = tar->list( ).
LOOP AT files INTO DATA(file).
DATA(content) = tar->get( file-name ).
" ...
ENDLOOP.
You can use program Z_TAR_TESTER
to test the methods:
- upload a tar file
- untar it
- tar it again
- save it as a clone of the original tar file
SAP Basis 7.50 or higher
Install tar
as a global module in your system using apm.
or
Specify the tar
module as a dependency in your project and import it to your namespace using apm.
All contributions are welcome! Read our Contribution Guidelines, fork this repo, and create a pull request.
You can install the developer version of ABAP Tar using abapGit by creating a new online repository for https://github.com/abapPM/ABAP-Tar
.
Recommended SAP package: $TAR
Made with ❤ in Canada
Copyright 2025 apm.to Inc. https://apm.to