UNZIP file from ABAP
Hi,
I have a requirement to retrieve a zip file from the FTP Server, unzip it to the SAP Server and process the unzipped files. Retrieving the data from the FTP server should work via FTP commands which can be executed from within an ABAP program. However, the problem is unzipping these files via ABAP and put them on the server as well. 1. How to do this from within an ABAP Program? (unix commands?)
2. Can I unzip these files with or without using the folder structure? (additional parameter for unix command?)
Kind regards,
Micky.
REPORT ZTESTUNIX line-size 400
no standard page heading.
selection-screen begin of block ucmd with frame title text-001.
parameters: unixcom like rlgrap-filename. " ...SAP Interface file
selection-screen end of block ucmd.
data: begin of tabl occurs 500,
line(400),
end of tabl.
data: lines type i.
start-of-selection.
refresh tabl.
call 'SYSTEM' id 'COMMAND' field unixcom
id 'TAB' field tabl[].
describe table tabl lines lines.
loop at tabl.
write:/01 tabl-line.
endloop.
skip 2.
if lines = 0.
write:/ 'NO Occurances were found'.
else.
write:/ 'Command was successfully executed' color col_total.
write:/ 'Number of entries in Search' color col_total,
lines color 6.
endif.
end-of-selection.
while running give the command as
<b>unzip test.zip -x dir</b>
then it will unzip test.zip file to dir called dir.
you can specify the filepath instead of file...
regards
vijay
Similar Messages
-
Creating an xml file from abap code
Hello All,
Please let me know which FM do I need to execute in order to create an XML file from my ABAP code ?
Thanks in advance,
Paul.This has been discussed before
XML files from ABAP programs -
Create XML file from ABAP with SOAP Details
Hi,
I am new to XML and I am not familiar with JAVA or Web Service. I have searched in SDN and googled for a sample program for creating XML document from ABAP with SOAP details. Unfortunately I couldn't find anything.
I have a requirement for creating an XML file from ABAP with SOAP details. I have the data in the internal table. There is a Schema which the client provided and the file generated from SAP should be validating against that Schema. Schema contains SOAP details like Envelope, Header & Body.
My question is can I generate the XML file using CALL TRANSFORMATION in SAP with the SOAP details?
I have tried to create Transformation (Transaction XSLT_TOOL) in SAP with below code. Also in CALL transformation I am not able to change the encoding to UTF-8. It's always show UTF-16.
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
<xsl:template match="/">
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Header>
<CUNS:HeaderInfo>
<CUNS:InterfaceTypeId>10006</InterfaceTypeId>
<CUNS:BusinessPartnerID>11223344</BusinessPartnerID>
<CUNS:SchemaVersion>1.0</SchemaVersion>
<CUNS:DateTime>sy-datum</DateTime>
</CUNS:HeaderInfo>
</SOAP:Header>
<SOAP:Body>
<xsl:copy-of select="*"/>
</SOAP:Body>
</SOAP:Envelope>
</xsl:template>
</xsl:transform>
In ABAP program, I have written below code for calling above Transformation.
call transformation ('Z_ID')
source tab = im_t_output[]
result xml xml_out.
call function 'SCMS_STRING_TO_FTEXT'
exporting
text = xml_out
tables
ftext_tab = ex_t_xml_data.
Please help me how to generate XML file with SOAP details from ABAP. If anybody have a sample program, please share with me.
Is there any easy way to create the XML file in CALL Transformation. Please help.
ThanksTry ABAP forum, as it seems not to be PI related.
-
How to create .csv file from ABAP report
Hi
We have a requirement to generate .csv file from abap report.
Currently user saves data from abap report to spreadsheet(.xls format) in desktop. Then opens excel file and save as .csv format. Need option to save directly in .csv format instead of .xls format.
Please let me know, if there is any standard function module available to create .csv file.
Regards
UmaI tried with your code it's going to dump
REPORT ZTEMP101 message-id 00.
tables: lfa1.
types: begin of t_lfa1,
lifnr like lfa1-lifnr,
name1 like lfa1-name1,
end of t_lfa1.
data: i_lfa1 type standard table of t_lfa1,
wa_lfa1 type t_lfa1.
types truxs_t_text_data(4096) type c occurs 0.
data: csv_converted_table type table of TRUXS_T_TEXT_DATA.
select-options: s_lifnr for lfa1-lifnr.
select lifnr name1 from lfa1 into table i_lfa1
where lifnr in s_lifnr.
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = ';'
I_LINE_HEADER =
I_FILENAME =
I_APPL_KEEP = ' '
TABLES
I_TAB_SAP_DATA = I_LFA1
CHANGING
I_TAB_CONVERTED_DATA = csv_converted_table
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = ' '
CODEPAGE = ' '
FILENAME =
'C:\Documents and Settings\ps12\Desktop\Test folder\exl.cvs'
FILETYPE = 'DAT'
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = csv_converted_table
FIELDNAMES =
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
my version is 4.6c -
HI,
i am trying to unzipping files from external sdcard..
i am using zipme.jar, but when i am deploying this application it give error.
please nay one hep me to unzipping files using 3rd-party jarBut my question is that if in a source folder we have several files which are in zipped format and the folder is getting updated every min (say) with new zipped files (which are dumped from some outside environment).I need to unzip all the files present in the folder ,if new one comes there then also check for the new zipped file and unzip it.You don't need to keep re-stating that.
I had written a code for unzipping a file from a folder (thinking the folder is not updated everytime).Or that.
Now I am thinking of using threads because if I create suppose 5 threads and every threads poll the source folder and pick up a zip file ,send it for unzipping it and again poll the source folder for any new entries?Or that.
If using the threads here hits performace then what should I use?Err, what you presently have?
Provide me any sample code or link that would be more useful.You've already written it. -
Sending .xlsx file from ABAP
Hi Experts,
How can we send .XLSX file from ABAP.
I have done as suggested in note 1459896 but it's not working.
I have added the header table with such value
concatenate '&SO_FILENAME=' lv_filename into lv_text_line.
append lv_text_line to lt_att_head.
passing header table to
lo_document->add_attachment( exporting i_attachment_type = 'XLS'
i_attachment_subject = 'AttachmentFilename'
i_attachment_size = lv_size
i_attachment_header = lt_att_head
i_att_content_hex = binary_content ).
but when I try to open it in SOST it says," file format or extension is not valid " .
Do you think if I send thsi mail to outlook it will work. ?
Thanks
WilliBut SAP note says 1459896 , it can be done
using
filename = 'attachment.xlsx'
concatenate '&SO_FILENAME=' lv_filename into lv_text_line.
append lv_text_line to lt_att_head.
but still not working. -
Unzip files from FTP using ABAP
Hi All,
I have the a requirement to unzip certain files from ftp and transfer the extracted files to another directory in ftp.
Searched (Re: Unzip file;) in SDN but didnt find the perfect solution
Appreciate the help.
Regards
SivaYou can use IndexOf function
see this example
http://visakhm.blogspot.in/2012/05/package-to-implement-daily-processing.html
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Issue while sending a zipped file from ABAP to JAVA layer
Hi All,
I have a requirement wherein i have to zip a xml file in abap, convert it to base64 encoded string and send it to JAVA layer.
I'm using the class CL_ABAP_ZIP for zipping the xml string and FM "SCMS_BASE64_ENCODE_STR" to convert the zipped data to base64 encoded string.
But on the JAVA layer we get an exception while unzipping this data.
Has anybody come across a similar situtation.
Please help.
Regards,
Ankit AgrawalExample
REPORT Z_PAP_UP_ZIP_DL.
DATA: L_ZIPPER TYPE REF TO cl_abap_zip.
DATA: FILEX type XSTRING.
DATA: FILENAME type string.
DATA: PATH type string.
DATA: zip type xstring.
DATA: FILE_N_TAB type FILETABLE.
DATA: FULL_PATH type string.
DATA: FILE_LENGTH type i.
DATA: FILE_TAB type w3mimetabtype.
DATA: WA_INT type int4.
DATA: PATH_TABLE TYPE TABLE of char1024.
" Load the file
"Which file to upload
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
CHANGING
FILE_TABLE = FILE_N_TAB
RC = WA_INT
"load the (first) file from the frontend the user has selected.
LOOP at FILE_N_TAB into FULL_PATH.
"get the file
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = FULL_PATH
FILETYPE = 'BIN'
IMPORTING
FILELENGTH = FILE_LENGTH
CHANGING
DATA_TAB = file_tab.
exit.
endloop.
"create xstring from table
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
INPUT_LENGTH = FILE_LENGTH
IMPORTING
BUFFER = FILEX
TABLES
BINARY_TAB = file_tab
"get the name of the file. we take entry after the last '\' ...windows.
SPLIT FULL_PATH AT '\' INTO TABLE PATH_TABLE.
DESCRIBE TABLE PATH_TABLE LINES WA_INT.
READ TABLE PATH_TABLE INTO FILENAME INDEX WA_INT. -
Unzip files using ABAP program
Hi All,
Can anybody guide me how to Unzip a .zip file using ABAP program... Appreciate your immediate reply...
actually, my scenario is to check whether zip file is created in appl.server or not.., and if zip file created then i need to check whether its blank file or any content exist inside the file...
Thanks in advance
Bhaskerhi
good
parameters: command(236) lower case.
data: std_lines(255) occurs 0 with header line.
call function 'RFC_REMOTE_PIPE'
destination 'SERVER_EXEC'
exporting
command = command
read = 'X'
tables
pipedata = std_lines
exceptions
communication_failure = 1
system_failure = 2.
You should put your Unix command in the command parameter. "gunzip /yourfilepath/yourfilename" works on my Unix system. Once you determine the proper Unix command, you should be set. This technique is also nice because it provides you with echos back from Unix in table std_lines. For more complex Unix activity, you may want to consider throwing together a Unix script, and calling that via this code.
reward point if helpful.
thanks
mrutyun^ -
Unzipping files from a zipped folder
Hi,
I need unzip files stored in .zip folder using ABAP. Could you please tell me of a utility/Funtion Module or any other method which exists for the same?
Thanks a lot
ShujathHi Mohammed,
you just have to execute an external program from your ABAP.
For example, if the ZIP file is in the client computer you have to use the WS_EXECUTE.
Have fun
Frédéric -
Can we do a Secure FTP for an XML file from ABAP when firewall is enabled?
Hi all,
I have a requirement to send an XML file to an External FTP Server which is out of our corporate network and our firewall is enabled.
I have to send an XML file with Purchase Order details. I completed that with the help of this blog https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/2657. [original link is broken] [original link is broken] [original link is broken]
Now I need to FTP the XML file that is generated. How should I be doing this? Can some of help me with this?
I need to do a Secure FTP to the external non SAP server which is out of our corporate network and our firewall is enabled. Can some one tell me if SFTP is possible in ABAP.
This is not a web service. I am working on dropping an XML file in an external FTP serveru2026 I have searched the forums but still in a confusion if weather Secure FTP is possible in ABAP or not when our company firewall is enabledu2026
If some one encountered this situation earlier please help,,,..any help will be highly appreciated.
Regards,
Jessica SamThanks a lot for your valuable suggestions Richu2026
I agree with you Rich that web services would be a better option. But I need to send this file to an external third party and they dont have web services.
They are telling us that either we can send them an XML file or a CSV file in the format that they want. We decided to go with XML file format.
I am done with formatting the Purchase Order details in the format that they want. Now the challenge is that I need to send this FTP file to them and it should be a Secure FTP when our fire wall is enabled,
When you say
1) Run an ABAP program to generate the XML file and put it on the local PC
2) Log into the FTP site via some FTP client, could simply be windows as well.
3) Manually cut/paste the file from the PC to the FTP site.
For Step 1 running ABAP Program can I schedule a batch job?
For Step 2 and Step 3 can I automate it in any other way..if not in ABAP?
Can I advice my company to follow any alternate method in which they can automate this step 2 and step 3u2026if not in ABAP can it be possible in any other way as the third party does not have web services I now have no other alternative.
Please Helpu2026
Regards,
Jessica Sam -
Hi everyone!
Is there a way in ABAP to output XML files? Pls. send code/ function module if any.
From ABAP programs, we are sure that we can output TEXT files, but how about XML files?
The significance of this question is related
Currently we are using XI to interface SAP and AMS, this question for ABAP to produce XML file arose, if for example, the XI server is down and we have to still send data from one system to another. IDocs can also produce XML files, pls confirm. Earlier however, we have preferred XI rather than IDocs to do this. Anyway, any idea regarding this scenario will be greatly appreciated.
Thanks and God bless!
CelesteHi,
Please check this sample codes from other thread.
1. itab --- > xml
xml ---> itab.
2. This program will do both.
(just copy paste in new program)
3.
REPORT abc.
*-------------- DATA
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
DATA : BEGIN OF itab OCCURS 0,
a(100) TYPE c,
END OF itab.
DATA: xml_out TYPE string .
DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
DATA: xmlupl TYPE string .
******************************* FIRST PHASE
******************************* FIRST PHASE
******************************* FIRST PHASE
*------------------ Fetch Data
SELECT * FROM t001 INTO TABLE t001.
*------------------- XML
CALL TRANSFORMATION ('ID')
SOURCE tab = t001[]
RESULT XML xml_out.
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
TEXT = xml_out
* IMPORTING
* LENGTH =
TABLES
FTEXT_TAB = itab.
*-------------- Download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = 'BIN'
filename = 'd:xx.xml'
TABLES
data_tab = itab.
******************************* SECOND PHASE
******************************* SECOND PHASE
******************************* SECOND PHASE
BREAK-POINT.
REFRESH t001.
CLEAR t001.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.
LOOP AT upl.
CONCATENATE xmlupl upl-f INTO xmlupl.
ENDLOOP.
*------------------- XML
CALL TRANSFORMATION ('ID')
SOURCE XML xmlupl
RESULT tab = t001[]
BREAK-POINT.
Regards,
Ferry Lianto -
Unzip file from froms then load
i have form (basically called loader) which read text file and then load it in data base.
Now,there is a user requirement that if text file is in zip format then he can unzip file using form.
Any idea how to do this can some unzip software used at back end.
I mean any idea any suggestion is required.
Forms 6i i am using.The zip.exe and unzip.exe are shipped with Oracle products, they are found under %ORACLE_HOME%/bin
just type zip or unzip in a command line session and you'll get all the switches and details.
Judging from your first post I understand you are running in C/S mode, if not you need to use CLIENT_HOST from webutil instead of HOST. It's the same concept.
As for HOST built-in example, I told you, there are very nice and detailed examples in the online help of Forms builder.
Open Forms builder and either press Ctrl + H or click on the big blue question mark, or open help menu and click on "Online Help".
Tony
Message was edited by:
Tony Garabedian -
Unzip files from a folder which is updating regularly using multithreading
Hi All,
I have acode which unzip all the files from a folder .This code picks up all the zipped files at a time and then unzip it and write them to another folder but now my requirement is changed ,suppose the source folder where all the zipped files are present is refreshed or updated with new zipped files regularly then how can I implement in my code multithreading to get several files by threads and send it for unzipping.
Please suggest with some example or edit my code.
package com.myprojcet;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public class Main {
* Extracts a zip file
public void extractZipFile() {
try {
String zipFileName = "C:\\soft\\test"; //Source folder for zipped files
//Create input and output streams
File SourceDir = new File(zipFileName);
File[] zipFiles = SourceDir.listFiles();
ZipInputStream inStream = null;
OutputStream outStream = null;
ZipEntry entry;
byte[] buffer = new byte[1024];
int nrBytesRead;
//Get next zip entry and start reading data
for(int i=0; i < zipFiles.length; i++) {
inStream= new ZipInputStream(new FileInputStream(zipFiles));
while((entry = inStream.getNextEntry()) != null) {
outStream=new FileOutputStream("C:\\soft\\test2\\"+entry.toString()); //destination folder for unzipped file
while ((nrBytesRead = inStream.read(buffer)) > 0) {
outStream.write(buffer, 0, nrBytesRead);
//Finish off by closing the streams
outStream.close();
inStream.close();
} catch (IOException ex) {
ex.printStackTrace();
* @param args the command line arguments
public static void main(String[] args) {
new Main().extractZipFile();
Thanks
Sumit
Edited by: user8687839 on Feb 27, 2012 11:00 PMBut my question is that if in a source folder we have several files which are in zipped format and the folder is getting updated every min (say) with new zipped files (which are dumped from some outside environment).I need to unzip all the files present in the folder ,if new one comes there then also check for the new zipped file and unzip it.You don't need to keep re-stating that.
I had written a code for unzipping a file from a folder (thinking the folder is not updated everytime).Or that.
Now I am thinking of using threads because if I create suppose 5 threads and every threads poll the source folder and pick up a zip file ,send it for unzipping it and again poll the source folder for any new entries?Or that.
If using the threads here hits performace then what should I use?Err, what you presently have?
Provide me any sample code or link that would be more useful.You've already written it. -
Hi,
I would like your help in identifying a mechanism in calling a Java Program from an ABAP program. The requirement is that I need to pass enough parameters(possibly in a single object like a <i>table</i>) and fetch that in a Java Program residing in a jar in the J2EE engine. The possibility of this java file interpreting this incoming object and also be able to return something to ABAP which can eventually be printed on the screen needs to be known.
I also would like to validate an assumption of mine which is that, the jar(the receipient java file) file needs to be put under the directory
"\usr\sap\<i>SystemID</i>\<i>instancenumber</i>j2ee\deploying\lib"
Appreciate your time and effort in helping me with this.
Regards,
Sam.i am not sure about
I also would like to validate an assumption of mine which is that, the jar(the receipient java file) file needs to be put under the directory
"\usr\sap\SystemID\instancenumberj2ee\deploying\lib"
but for your case what you could do is, on the java side get developed a jsp page which will receive data and use the jar to proces and return the results as xml. once thats done.
from abap you can use cl_http_client class to call this jsp page to pass parameters and get the processed results from jsp page.
Raja
Maybe you are looking for
-
Cant get double_click to work?
port1a_mc.addEventListener(MouseEvent.DOUBLE_CLICK, pageClick) function pageClick(e:MouseEvent) gotoAndPlay(port1); trying to add this to my 4 _mc but keep recieving an error message: 1120: Access of undefined property port1a_mc. 1120: Access of unde
-
Taking phone video over to a PC/MAC...quality is still poor at best
the playback quality on the iphone 4 is oh so sweet, but its only sweet on the phone...i understand the frame size ect, just looking for the best way to view a iphone 4 video on a PC/MAC sidenote - viewing youtube on this new phone is about 100 times
-
ONLY video files not already in library wont transfer to itunes library
I've found NO help from the apple website dealing with this problem, video only importing problems don't even come up in the help sections. heres an example, i just bought a new cd, i can easily transfer the files from the drive to my library, or fro
-
Mac Pro / Cinema Display slow boot time
Hi there, I have a late 2008 Mac Pro, running OSX 10.6.8 and it is connected to a 23" Apple Cinema Display. A couple of days ago I noticed that when I switched the Mac on, the display would not turn on. I forced it to shut down by holding the power b
-
Adobe Premiere Pro to Quicktime - iPod Video
I have a question about going from a video editing system such as Adobe Premiere Pro - to Quicktime. I have been exporting my Premiere Pro videos to AVI files and then opening them in Quicktime and exporting them to iPod compatible video. Is there a