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: 

conversion of report output into a ZIP file and then transfer of the ZIP fi

Former Member
0 Kudos

Hi Team

Functionality :-->

There are 2 behaviours that are required; it should be possible to invoke each of the behaviours independently from custom report programs or dialog transactions.

Given an input file name parameter this file should be converted into a ZIP file.

Given an input file name, FTP server, optional directory, user name and password the input file should be sent to the appropriate directory on the FTP server.

Requirement 1 :

The ZIP file functionality can be implemented by calling the FTP command line program 7z.exe. This program is stored in share


zn-viper-db03\sapmnt\IVI\SYS\exe\7zip

Requirement 2:

The send File to FTP server functionality should use the functionality provided by the SAP package SFTP.

Thanks in Advance.

Puneet.

9 REPLIES 9

Former Member
0 Kudos

hi Puneet,

Take a look at the class CL_ABAP_GZIP to zip a file which stored on application server. then give this zip file name to the follwing subroutine to send file to another system using FTP.

----


  • -->P_FNAME text

----


FORM F_DATA_FTP_TO_DESTINATION USING P_FNAME.

DATA L_V_FILENAME TYPE CHAR100.

*File name in the destiantion system

CONCATENATE SY-DATUM P_WERK P_DFNAME

INTO L_V_FILENAME.

V_ERROR = 0.

  • DESCRIBE FIELD P_SPWD LENGTH V_SLEN.

DESCRIBE FIELD P_SPWD LENGTH V_SLEN IN CHARACTER MODE.

*Encript password

CALL 'AB_RFC_X_SCRAMBLE_STRING'

ID 'SOURCE' FIELD P_SPWD ID 'KEY' FIELD V_KEY

ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD P_SPWD

ID 'DSTLEN' FIELD V_SLEN.

*Display the status on status bar

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

TEXT = 'Connecting to FTP Server - Source...'.

  • connect to ftp server - Source

PERFORM F_FTP_CONNECT USING P_SUSER P_SPWD P_SHOST P_DEST

CHANGING V_SHDL.

  • DESCRIBE FIELD P_DPWD LENGTH V_SLEN.

DESCRIBE FIELD P_DPWD LENGTH V_SLEN IN CHARACTER MODE.

*Encript password

CALL 'AB_RFC_X_SCRAMBLE_STRING'

ID 'SOURCE' FIELD P_DPWD ID 'KEY' FIELD V_KEY

ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD P_DPWD

ID 'DSTLEN' FIELD V_SLEN.

*Display the status on status bar

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

TEXT = 'Connecting to FTP Server - Destination...'.

  • connect to ftp server - destination

PERFORM F_FTP_CONNECT USING P_DUSER P_DPWD P_DHOST P_DEST

CHANGING V_DHDL.

*Display the status on status bar

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

TEXT = 'Copying File to Destination...'.

REFRESH I_RESULT.

  • Copy Files

CALL FUNCTION 'FTP_COPY'

EXPORTING

HANDLE_SOURCE = V_SHDL

HANDLE_DESTINATION = V_DHDL

FILE_SOURCE = P_FNAME

FILE_DESTINATION = L_V_FILENAME

TABLES

DATA = I_RESULT

EXCEPTIONS

TCPIP_ERROR = 1

COMMAND_ERROR = 2

DATA_ERROR = 3

OTHERS = 4.

IF SY-SUBRC NE 0.

V_ERROR = 1.

ENDIF.

LOOP AT I_RESULT.

WRITE / I_RESULT-LINE.

ENDLOOP.

  • Disconnect

CALL FUNCTION 'FTP_DISCONNECT'

EXPORTING

HANDLE = V_SHDL.

CALL FUNCTION 'FTP_DISCONNECT'

EXPORTING

HANDLE = V_DHDL.

*Close the RFC Connection

CALL FUNCTION 'RFC_CONNECTION_CLOSE'

EXPORTING

DESTINATION = P_DEST

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC NE 0.

WRITE: / 'RFC Connection not open'.

ENDIF.

IF V_ERROR NE 0.

FORMAT COLOR COL_NEGATIVE.

WRITE: / 'FTP Failed - File NOT sent to the Destination.'.

ELSE.

FORMAT COLOR COL_POSITIVE.

WRITE: / ' FTP Successful - File sent to the Destination.'.

ENDIF.

ENDFORM. " f_data_ftp_to_destination

Thanks,

Venkat

Sandra_Rossi
Active Contributor
0 Kudos

About compressing using 7ZIP : if you have a SAP server on windows, install 7ZIP on it and execute it by External Operating System Command. Check the forum with SM49, SM69, SXPG keywords. If the program is outside SAP, I'm afraid you need to call it via RFC. And I am not aware it is possible to execute a program via FTP.

about FTP, you have tens of threads in the forum

Former Member
0 Kudos

Hi Team

i have input file from application server which is any type of file like excel, wordpad,text etc...) i have requirement like

create a function module which has input parameter is "input file path" and exporting parameter "ZIP file path".

Any sample coding will be very much appreciated.

Appreciate in advance for your help!!!!

Regards

Puneet.

Former Member
0 Kudos

Hi Team

i have input file from application server which is any type of file like excel, wordpad,text etc...) i have requirement like

create a function module which has input parameter is "input file path" and exporting parameter "ZIP file path".

Any sample coding will be very much appreciated.

Appreciate in advance for your help!!!!

Regards

Puneet.

0 Kudos

Couldn't you tell that at the beginning, why are you asking first a precise question, and later a general one !? (hopefully for you, I'm not in the mood of reporting abuse)

To zip using "standard" zip algorithm, SEARCH for CL_ABAP_ZIP snippets in the forum. Note: do not use CL_ABAP_GZIP which is only for internal compression in memory, and it cannot be used to generate files.

0 Kudos

Hi Sandra

Thank you very much for quick response.

I have checked in my system class CL_ABAP_ZIP is not available in 4.70. can you pls tell the example of program against system 4.70.

Regards

Puneet

0 Kudos

R/3 4.7 corresponds to 6.20. GZIP is supplied in 6.20 kernel patch 641. Check your patch level. If it's installed, then you might try to downport CL_ABAP_ZIP from 6.40 to 6.20 (you must ask someone to give you the code). Hmm, does the license authorize that?

Otherwise, you should use external OS command to compress with ZLIB algorithm (zip) (or 7ZIP as discussed above, or other tools)

Check sap [Note 616958 GZIP in ABAP|http://service.sap.com/sap/support/notes/616958].

0 Kudos

Hi Sandra

Thankyou for prompt action!!!!

I have tried convert input file into the zip file in system 6.40 using class CL_ABAP_ZIP. it's working fine . But in our original system 6.20 there is no class CL_ABAP_ZIP available.i want to do in 6.20 system, can i create zclass in our system same as 6.40 system.

is it possible to create ZCL_ABAP_ZIP without any problems.

Thanks

Puneet

0 Kudos

As CL_ABAP_ZIP is based on GZIP, I think it can be backported without problem! (I also looked at the code to see how it works, it seems to be rather simple, so risks are rather limited). But, as usually, it's at your own risk