Google Search - Blog...........

Showing posts with label uploading zip files to appl. server.. Show all posts
Showing posts with label uploading zip files to appl. server.. Show all posts

ABAP - ZIP Files In Application Server Using FM SCMS_XSTRING_TO_BINARY.

report Z_ZIP_FILES_IN_APPSVR .

DATA: lt_data TYPE TABLE OF x255,
ls_data LIKE LINE OF lt_data.

DATA: lv_zip_content TYPE xstring ,
lv_dsn1(100) VALUE '/sap/NSP/sys/test.as',
lv_dsn2(100) VALUE '/sap/NSP/sys/test2.mxml',
lv_dsn3(100) VALUE '/sap/NSP/sys/testarchive.zip',
lv_file_length TYPE i ,
lv_content TYPE xstring,
lo_zip TYPE REF TO cl_abap_zip.

CREATE OBJECT lo_zip.

* Read the data as a string
clear lv_content .
OPEN DATASET lv_dsn1 FOR INPUT IN BINARY MODE.
READ DATASET lv_dsn1 INTO lv_content .
CLOSE DATASET lv_dsn1.

lo_zip->add( name = 'test.as' content = lv_content ).

clear lv_content .

OPEN DATASET lv_dsn2 FOR INPUT IN BINARY MODE.
READ DATASET lv_dsn2 INTO lv_content .
CLOSE DATASET lv_dsn2.

lo_zip->add( name = 'test2.mxml' content = lv_content ).

lv_zip_content = lo_zip->save( ).

* Conver the xstring content to binary
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_zip_content
IMPORTING
output_length = lv_file_length
TABLES
binary_tab = lt_data.


OPEN DATASET lv_dsn3 FOR OUTPUT IN BINARY MODE.
LOOP AT lt_data INTO ls_data.
TRANSFER ls_data TO lv_dsn3.
ENDLOOP.
CLOSE DATASET lv_dsn3.



RETURN TO MAIN INDEX:

- Sample Programs On Uploading & Downloading Files.

- Sample Programs On HR ABAP.

- Sample Report Programs On ALV List/ Grid Display.

- Sample Programs On Selection Screen.

- Sample Programs On BDC.

.....Back To MAIN INDEX.