SAPが提供している拡張子がSARとなっているファイルについて。
SARファイルはSAPが提供するSAPCARを用いてアーカイブされたファイルとなっており、ファイルを抽出するにはSAPCARコマンドを利用します。
本記事ではWindows端末にSAPCARをインストールしてSARファイルを作成したり、SARファイルからファイルを取り出してみます。
なおSAPCAR
のダウンロードにはS-User
が必要となります。
ドキュメント
- 212876 - The new archiving tool SAPCAR
- 2452588 - SAPCAR release and patch information
- 2632047 - How to download SAPCAR for extracting .SAR files - SAP for Me
SAPCARとは?
SAPCAR
はSAPがCAR
コマンドに変わって提供するアーカイブコマンドになります。
ノートに記載がありますが、R/3 4.6c
より前、SAPからは提供されるアーカイブファイルはCAR
形式で提供されていたようです。
それがR/3 4.6c
以降はSAPが提供するSAPCARを用いたSAR
形式に切り替わりました。
今回の環境
- Windows 10 21H2
WindowsにSAPCARをインストール
SAPCAR
コマンドはsap for me
のソフトウェアダウンロードセンター
から入手できます。
sap fo me
のソフトウェアダウンロードについてURLでアクセスする場合、https://me.sap.com/softwarecenter にアクセス。
画面から遷移する場合はサービスおよびサポート
の画面 または システムおよびプロビジョニング
から遷移できます。
ソフトウェアのダウンロードまできたら、サポートおよびパッチ
=> カテゴリ別 => SAP Technology Components => SAPCAR => バージョン を選択
2023年7月現在は7.22が最新となっていました、今回はこちらのWindows版をダウンロードするため、プルダウンからWindowsを選択
リンクをクリックすればブラウザでダウンロードできます。
EXEファイルがそのままダウンロードできました。
ダウンロードしたexeファイルを適当なディレクトリに配置する
ダウンロードしたコマンドを(SAPCAR_1115-70006231.EXE)適用なディレクトリに配置して利用可能なオプションを確認してみます。
今回はc:\qiita\sapcar\sapcar.exe
に配置してみました。
必要な場合はPATHに適宜、追加して利用して下さい。
利用方法とオプションを確認してみる
ダウンロードした実行ファイルに引数をなにもつけずに実行すると、利用方法とオプションの確認ができます。
SARファイルを作成してみる
create a new archive:
SAPCAR -c[vir][f archive] [-P] [-C directory]
[-A filename] [-T filename] [-X filename]
[-p value] [-V] file1 file2 ...
今回は、PowerShellでhelloworld.txtとfoobar.txtを作成して、これをアーカイブしてsample.SARファイルを作成してみます。
# 今回、sapcarを配置したディレクトへカレントディレクトリを移動
cd c:\qiita\sapcar
# helloworld.txt と foobar.txtを作成
New-Item .\helloworld.txt -value helloworld | Out-Null
New-Item .\foobar.txt -value foobar | Out-Null
.\sapcar.exe -cvf sample.SAR helloworld.txt foobar.txt
sample.SAR
が作成されました。
SARファイルの中身をリストしてみる
list the contents of an archive:
SAPCAR -t[vs][f archive] [file1 file2....]
オプション-t
を利用するとアーカイブに含まれているファイルをリストできるようなので、ここでは先程作成したsample.SARファイルに含まれているファイルを確認してみます。
オプションの意味は下記参照
-t : list the contents of an archive
-v : verbosely list files processed
-s : do free space check
-f FILE : use archive file FILE (default DEFAULT.SAR)
# 今回、sapcarを配置したディレクトへカレントディレクトリを移動
cd c:\qiita\sapcar
.\sapcar.exe -tvsf sample.SAR
画像のようにsample.SARにfoobar.txtとhellworold.txtが含まれている事が確認できます
また今回はオプションs
をつけているので、下記のメッセージも表示されています。
The extraction does not require free disk space (maybe
the extraction will only overwrite existing files of
greater or equal size or the uncompressed size of each
file in the archive is zero).
c:\qiita\sapcar\のディレクトリにはhelloworld.txt
とfooar.txt
をおいたままだったので上書きするだけだよって感じのメッセージになっていました。
結構賢いですよね。
ためしにhelloworld.txt
とfoobar.txt
を削除してから実行したメッセージは下記
テキストファイルでサイズが小さすぎてちょっと面白みがなかったですね。
SARファイルを展開してみる
extract files from an archive:
SAPCAR -x[v][f archive] [-R directory] [-A filename]
[-V] [file1 file2....]
オプションの意味は下記参照
-x : extract files from an archive
-v : verbosely list files processed
-f FILE : use archive file FILE (default DEFAULT.SAR)
-R dir : use dir instead of current directory
-A FILE : get names to include from file FILE
-V : activate signature verification in existing commands -a, -c, -d, -t and -x.
# 今回、sapcarを配置したディレクトへカレントディレクトリを移動
cd c:\qiita\sapcar
# saple.SARを展開
.\sapcar.exe -xvf sample.SAR
# helloworld.txtだけをsample.SARから展開
.\sapcar.exe -xvf sample.SAR helloworld.txt
# helloworld.txtとfoobar.txtをsample.SARから展開
.\sapcar.exe -xvf sample.SAR helloworld.txt foobar.txt
# sample.SARを ディレクトリ sampleDir に展開
.\sapcar -xvf sample.SAR -R sampleDir
総評
初見ではSAPから提供されるファイルは、独自の形式でアーカイブされてるって驚きがあった気がします。