Exporting R3 tables into Flat Files for BPC
Dear BPC experts,
I understand currently the way for BPC to extract data from R3 is via flat files. I have the following queries:
1) What exactly are the T codes and steps required to export R3 tables into flat files (without going through the OpenHub in BI7)? Can this process be automated?
2) Is Data Manager of BPC equivalent to SSIS (Integration Services) of SQL Server?
Please advise. Thanks!!
SJ
Hi Soong Jeng,
I would take a look at the existing BI Extractors for the answer to Q1, I am working on finishing up a HTG regarding this. Look for it very soon.
Here is the code to dump out data from a BI Extractor directly from ERP.
You need dev permissions in your ERP system and access to an app server folder. ...Good Luck
*& Report Z_EXTRACTOR_TO_FILE *
report z_extractor_to_file .
type-pools:
rsaot.
parameters:
p_osrce type roosource-oltpsource,
p_filnm type rlgrap-filename,
p_maxsz type rsiodynp4-maxsize default 100,
p_maxfc type rsiodynp4-calls default 10,
p_updmd type rsiodynp4-updmode default 'F'.
data:
l_lines_read type sy-tabix,
ls_select type rsselect,
lt_select type table of rsselect,
ls_field type rsfieldsel,
lt_field type table of rsfieldsel,
l_quiet type rois-genflag value 'X',
l_readonly type rsiodynp4-readonly value 'X',
l_desc_type type char1 value 'M',
lr_data type ref to data,
lt_oltpsource type rsaot_s_osource,
l_req_no type rsiodynp4-requnr,
l_debugmode type rsiodynp4-debugmode,
l_genmode type rois-genflag,
l_columns type i,
l_temp_char type char40,
l_filename like rlgrap-filename,
wa_x030l like x030l,
tb_dfies type standard table of dfies,
wa_dfies type dfies,
begin of tb_flditab occurs 0,
* field description
fldname(40) type c,
end of tb_flditab,
ls_flditab like line of tb_flditab,
l_file type string.
field-symbols:
<lt_data> type standard table,
<ls_data> type any,
<ls_field> type any.
call function 'RSA1_SINGLE_OLTPSOURCE_GET'
exporting
i_oltpsource = p_osrce
importing
e_s_oltpsource = lt_oltpsource
exceptions
no_authority = 1
not_exist = 2
inconsistent = 3
others = 4.
if sy-subrc <> 0.
* ERROR
endif.
create data lr_data type standard table of (lt_oltpsource-exstruct).
assign lr_data->* to <lt_data>.
call function 'RSFH_GET_DATA_SIMPLE'
exporting
i_requnr = l_req_no
i_osource = p_osrce
i_maxsize = p_maxsz
i_maxfetch = p_maxfc
i_updmode = p_updmd
i_debugmode = l_debugmode
i_abapmemory = l_genmode
i_quiet = l_quiet
i_read_only = l_readonly
importing
e_lines_read = l_lines_read
tables
i_t_select = lt_select
i_t_field = lt_field
e_t_data = <lt_data>
exceptions
generation_error = 1
interface_table_error = 2
metadata_error = 3
error_passed_to_mess_handler = 4
no_authority = 5
others = 6.
* get table/structure field info
call function 'GET_FIELDTAB'
exporting
langu = sy-langu
only = space
tabname = lt_oltpsource-exstruct
withtext = 'X'
importing
header = wa_x030l
tables
fieldtab = tb_dfies
exceptions
internal_error = 01
no_texts_found = 02
table_has_no_fields = 03
table_not_activ = 04.
* check result
case sy-subrc.
when 0.
* copy fieldnames
loop at tb_dfies into wa_dfies.
case l_desc_type.
when 'F'.
tb_flditab-fldname = wa_dfies-fieldname.
when 'S'.
tb_flditab-fldname = wa_dfies-scrtext_s.
when 'M'.
tb_flditab-fldname = wa_dfies-scrtext_m.
when 'L'.
tb_flditab-fldname = wa_dfies-scrtext_l.
when others.
* use fieldname
tb_flditab-fldname = wa_dfies-fieldname.
endcase.
append tb_flditab.
* clear variables
clear: wa_dfies.
endloop.
when others.
message id sy-msgid type sy-msgty number sy-msgno
with sy-subrc raising error_get_dictionary_info.
endcase.
describe table tb_flditab lines l_columns.
" MOVE DATA TO THE APPLICATION SERVER
open dataset p_filnm for output in text mode encoding utf-8
with windows linefeed.
data i type i.
loop at <lt_data> assigning <ls_data>.
loop at tb_flditab into ls_flditab.
i = sy-tabix.
assign component i of structure <ls_data> to <ls_field>.
l_temp_char = <ls_field>.
if i eq 1.
l_file = l_temp_char.
else.
concatenate l_file ',' l_temp_char into l_file.
endif.
endloop.
transfer l_file to p_filnm.
clear l_file.
endloop.
close dataset p_filnm.
Cheers,
Scott
Edited by: Jeffrey Holdeman on May 25, 2010 4:44 PM
Added markup to improve readability
Edited by: Jeffrey Holdeman on May 25, 2010 4:47 PM
Similar Messages
-
Import data from Oracle table into flat file
How to import the data in the oracle table into flat file using UTL File of PL/SQL....
I am new in PL/SQL..
can someone help me in writing query?Note : Not Tested.
DECLARE
V1 VARCHAR2(32767);
F1 UTL_FILE.FILE_TYPE;
cursor c1 is select ename,empno from emp;
r_c1 c1%rowtype;
BEGIN
-- In this example MAX_LINESIZE is less than GET_LINE's length request
-- so the number of bytes returned will be 256 or less if a line terminator is seen.
open c1;
F1 := UTL_FILE.FOPEN('MYDIR','MYFILE','W',256);
loop
fetch c1 into r_c1;
v1:= r_c1.ename||''||To_char(r_c1.empno);
UTL_FILE.PUT_LINE (F1, v1,TRUE);
v1:= null;
Exit when c1%not found;
end loop;
UTL_FILE.FCLOSE(F1);
END;
http://download.oracle.com/docs/cd/B19306_01/appdev.102
------------------------------------------------------------------ -
Store oracle table into flat file
Hello,
How to store oracle table into flat file with comma ( , ) delimiter.
Thanx
Muraliset echo off feedback off termout off heading off pages 0
spool path/filename
select cola||','||colb||';'||colc ...
from tablea;
spool off -
Exporting tables to flat files
Hi,
Can I export tables to flat files(csv) using pl/sql. I mean suppose I have 2 tables 'student' and 'subject' and I want to create two flat files student.csv and subject.csv Please let me know, if I can do it using pl/sql for both the tables in one go.
Even if I can do it for one table, than I can write a script to automate for all the tables. Please let me know with your suggestions. Appreciate your help.
ThanksAs sys user:
CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
/As myuser:
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
,p_dir IN VARCHAR2
,p_header_file IN VARCHAR2
,p_data_file IN VARCHAR2 := NULL) IS
v_finaltxt VARCHAR2(4000);
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_fh UTL_FILE.FILE_TYPE;
v_samefile BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
BEGIN
c := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE(c);
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
END CASE;
END LOOP;
-- This part outputs the HEADER
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
FOR j in 1..col_cnt
LOOP
v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
IF NOT v_samefile THEN
UTL_FILE.FCLOSE(v_fh);
END IF;
-- This part outputs the DATA
IF NOT v_samefile THEN
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
END IF;
LOOP
v_ret := DBMS_SQL.FETCH_ROWS(c);
EXIT WHEN v_ret = 0;
v_finaltxt := NULL;
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
ELSE
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
END CASE;
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
END LOOP;
UTL_FILE.FCLOSE(v_fh);
DBMS_SQL.CLOSE_CURSOR(c);
END;This allows for the header row and the data to be written to seperate files if required.
e.g.
SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
PL/SQL procedure successfully completed.Output.txt file contains:
empno,ename,job,mgr,hiredate,sal,comm,deptno
7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
Adapt to output different datatypes and styles are required. -
How to convert from SQL Server table to Flat file (txt file)
I need To ask question how convert from SQL Server table to Flat file txt file
Hi
1. Import/Export wizened
2. Bcp utility
3. SSIS
1.Import/Export Wizard
First and very manual technique is the import wizard. This is great for ad-hoc and just to slam it in tasks.
In SSMS right click the database you want to import into. Scroll to Tasks and select Import Data…
For the data source we want out zips.txt file. Browse for it and select it. You should notice the wizard tries to fill in the blanks for you. One key thing here with this file I picked is there are “ “ qualifiers. So we need to make
sure we add “ into the text qualifier field. The wizard will not do this for you.
Go through the remaining pages to view everything. No further changes should be needed though
Hit next after checking the pages out and select your destination. This in our case will be DBA.dbo.zips.
Following the destination step, go into the edit mappings section to ensure we look good on the types and counts.
Hit next and then finish. Once completed you will see the count of rows transferred and the success or failure rate
Import wizard completed and you have the data!
bcp utility
Method two is bcp with a format file http://msdn.microsoft.com/en-us/library/ms162802.aspx
This is probably going to win for speed on most occasions but is limited to the formatting of the file being imported. For this file it actually works well with a small format file to show the contents and mappings to SQL Server.
To create a format file all we really need is the type and the count of columns for the most basic files. In our case the qualifier makes it a bit difficult but there is a trick to ignoring them. The trick is to basically throw a field into the
format file that will reference it but basically ignore it in the import process.
Given that our format file in this case would appear like this
9.0
9
1 SQLCHAR 0 0 """ 0 dummy1 ""
2 SQLCHAR 0 50 "","" 1 Field1 ""
3 SQLCHAR 0 50 "","" 2 Field2 ""
4 SQLCHAR 0 50 "","" 3 Field3 ""
5 SQLCHAR 0 50 ""," 4 Field4 ""
6 SQLCHAR 0 50 "," 5 Field5 ""
7 SQLCHAR 0 50 "," 6 Field6 ""
8 SQLCHAR 0 50 "," 7 Field7 ""
9 SQLCHAR 0 50 "n" 8 Field8 ""
The bcp call would be as follows
C:Program FilesMicrosoft SQL Server90ToolsBinn>bcp DBA..zips in “C:zips.txt” -f “c:zip_format_file.txt” -S LKFW0133 -T
Given a successful run you should see this in command prompt after executing the statement
Starting copy...
1000 rows sent to SQL Server. Total sent: 1000
1000 rows sent to SQL Server. Total sent: 2000
1000 rows sent to SQL Server. Total sent: 3000
1000 rows sent to SQL Server. Total sent: 4000
1000 rows sent to SQL Server. Total sent: 5000
1000 rows sent to SQL Server. Total sent: 6000
1000 rows sent to SQL Server. Total sent: 7000
1000 rows sent to SQL Server. Total sent: 8000
1000 rows sent to SQL Server. Total sent: 9000
1000 rows sent to SQL Server. Total sent: 10000
1000 rows sent to SQL Server. Total sent: 11000
1000 rows sent to SQL Server. Total sent: 12000
1000 rows sent to SQL Server. Total sent: 13000
1000 rows sent to SQL Server. Total sent: 14000
1000 rows sent to SQL Server. Total sent: 15000
1000 rows sent to SQL Server. Total sent: 16000
1000 rows sent to SQL Server. Total sent: 17000
1000 rows sent to SQL Server. Total sent: 18000
1000 rows sent to SQL Server. Total sent: 19000
1000 rows sent to SQL Server. Total sent: 20000
1000 rows sent to SQL Server. Total sent: 21000
1000 rows sent to SQL Server. Total sent: 22000
1000 rows sent to SQL Server. Total sent: 23000
1000 rows sent to SQL Server. Total sent: 24000
1000 rows sent to SQL Server. Total sent: 25000
1000 rows sent to SQL Server. Total sent: 26000
1000 rows sent to SQL Server. Total sent: 27000
1000 rows sent to SQL Server. Total sent: 28000
1000 rows sent to SQL Server. Total sent: 29000
bcp import completed!
BULK INSERT
Next, we have BULK INSERT given the same format file from bcp
CREATE TABLE zips (
Col1 nvarchar(50),
Col2 nvarchar(50),
Col3 nvarchar(50),
Col4 nvarchar(50),
Col5 nvarchar(50),
Col6 nvarchar(50),
Col7 nvarchar(50),
Col8 nvarchar(50)
GO
INSERT INTO zips
SELECT *
FROM OPENROWSET(BULK 'C:Documents and SettingstkruegerMy Documentsblogcenzuszipcodeszips.txt',
FORMATFILE='C:Documents and SettingstkruegerMy Documentsblogzip_format_file.txt'
) as t1 ;
GO
That was simple enough given the work on the format file that we already did. Bulk insert isn’t as fast as bcp but gives you some freedom from within TSQL and SSMS to add functionality to the import.
SSIS
Next is my favorite playground in SSIS
We can do many methods in SSIS to get data from point A, to point B. I’ll show you data flow task and the SSIS version of BULK INSERT
First create a new integrated services project.
Create a new flat file connection by right clicking the connection managers area. This will be used in both methods
Bulk insert
You can use format file here as well which is beneficial to moving methods around. This essentially is calling the same processes with format file usage. Drag over a bulk insert task and double click it to go into the editor.
Fill in the information starting with connection. This will populate much as the wizard did.
Example of format file usage
Or specify your own details
Execute this and again, we have some data
Data Flow method
Bring over a data flow task and double click it to go into the data flow tab.
Bring over a flat file source and SQL Server destination. Edit the flat file source to use the connection manager “The file” we already created. Connect the two once they are there
Double click the SQL Server Destination task to open the editor. Enter in the connection manager information and select the table to import into.
Go into the mappings and connect the dots per say
Typical issue of type conversions is Unicode to non-unicode.
We fix this with a Data conversion or explicit conversion in the editor. Data conversion tasks are usually the route I take. Drag over a data conversation task and place it between the connection from the flat file source to the SQL Server destination.
New look in the mappings
And after execution…
SqlBulkCopy Method
Sense we’re in the SSIS package we can use that awesome “script task” to show SlqBulkCopy. Not only fast but also handy for those really “unique” file formats we receive so often
Bring over a script task into the control flow
Double click the task and go to the script page. Click the Design script to open up the code behind
Ref.
Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/ -
Extracting into Flat Files Using OCI or Pro*C Programs
Data Extraction into Flat Files from a database Using OCI or Pro*C Programs - please provide me a sample code. It is urgent. Thank you in advance.
This problem is very simple to solve. Simply use Pro*C, issue an SQL select into a host variable, then use unix "printf" to output the result. An alternative is to use the provided sqlplus utility to grab the data in a script, disabling headers, etc.
Sadly, this area is a huge, basic hole in the Oracle product offering. While they have an import utility, there is no export utility, except for one that makes binary files not usable outside Oracle. Every other RDBMS I've seen has this. In Informix, you can say something like "export to <filename> select * from <table>", but that syntax is not offered by Oracle Corporation. -
Import data from oracle database table into csv file
Hi
I have to import data from a table into a csv file. Could anyone suggest the best method to do it? My application is JSP as frontend and have put business logic in servlet.
Thanks in advance.FastReader from wisdomforce will help you quickly export data into csv file. http://www.wisdomforce.com
fastreader can be called and executed as an external process ( Runtime.exec(..) ) to extract data from Oracle tables into flat file -
Extracting from flat file for testing inplace of ECC(r/3)
Hi Expert,
Please help me out and give me your suggestion.
We are creating a custom table in ECC it is under progress.
I would like to create infoObject, transformation, DTP and Cube and create queries with loading info by flate file. Later on connection whole provider to table.
Give me suggestion is ther any problem for this Or any good opinion.
Thanks in AdvanceLoading from a flat file for testing has worked well for me. We recently wanted to test an ODS object, but I didn't want to create a custom extracter until we knew if the ODS object would work for us. So under my infoSource I created a quick infopackage that pulled some test data from a flat file. We've loaded test data into cubes before. Only problem that I ever had was when I used Excel to create the flat file. Excel wants to truncate leading zeros. 0calmonth for example needs to be loaded as 072007 not 72007.
-
Transfer data from Result Set (Execute SQL Task) into Flat File
Hi to all,
My problem is this:
-) I have a stored procedure which use a temporary table in join with another "real" table in select statement. In particular the stored procedure look like this:
create table #tmp
col1 varchar(20),
col2 varchar(50)
--PUT SOME VALUE IN #TMP
insert into #tmp
values ('abc','xyz')
--SELECT SOME VALUE
select rt.*
from realTable rt, #tmp
where rt.col1 = #tmp.col1
-) I cannot modify the stored procedure because I'm not admin of database.
-) I HAVE THE REQUIREMENT OF TRANSFER DATA OF SELECT STATEMENT OF SOTRED PROCEDURE INTO FLAT FILE
-) THE PROBLEM is that if I use an OLEDB source Task within a Data Flow Task I'm not be able of mapping column from OLEDB source to flat file destination. The reason for this, is that in the "Column page" of OLEDB source task, SSIS do not retrieves
any column when we using a temporary table. The reason for this, is that SSIS is not be able to retrieve metadata related to temporary table.
-) One possible solution to this problem is to use an Execute SQL Task to invoke the stored procedure, store the result returned from stored procedure in a Result Set through a Object type user variable.
-) The problem now is: How to transfer data from result set to flat file?
-) Reading here on this forum the solution look be like to use a Script task to transfer data from result set to flat file.
QUESTIONS: How to transfer data from result set to flat file using a script task?? (I'm not an expert of vb .net) Is it really possible?? P.S.: The number of row returned of stored procedure is very high!
thanks in advance.Hi Visakh16<abbr
class="affil"></abbr>
thanks for the response.
Your is a good Idea, but I do not have permission to use DDL statement on the database in production environment. -
Export batch data into CSV file using SQL SP
Hi,
I have created WCF-Custom receive adapter to poll Sql SP (WITH xmlnamespaces(DEFAULT 'Namespace' and For XML PATH(''), Type) . Get the result properly in batch while polling and but getting error while converting into CSV by using map.
Please can anyone give me some idea to export SQL data into CSV file using SP.How are you doing this.
You would have got XML representation for the XML batch received from SQL
You should have a flat-file schema representing the CSV file which you want to send.
Map the received XML representation of data from SQL to flat-file schema
have custom pipeline with flat-file assembler on the assembler stage of the send pipeline.
In the send port use the map which convert received XML from SQL to flat file schema and use the above custom flat-file disassembler send port
If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply. -
Date o/p probelm when download into flat file inf110 tcode in fi
hi,
when im create payment transaction in f110 tcode in fi , and selct the record and down load into flat file
in flat file first line it shows run date same as we given in transaction,but in second line it shows same date as before
but it shows different date example : firstline it shows 12 .10.2008 and second line 12.10.2008 is right o/p.
but it shows as first line 12.10.2008,and seconde line 6.10.2008. why it show like that.Hi Ganesh,
As per my understanding you have an issue with the date while downloading it into the Flat file.
It is displaying the incorrect date in the second line in Flat file.
Are you downloading the data in Notepad or in the Excel sheet?
Can you please elaborate the issue, if it is in Excel sheet then check if it is displaying multiple records for the same date.
Ex :
Date Records
12 .10.2008 ad
fg
as
6.10.2008 we
af
Check if this is the case...
Regards,
Kittu -
How to design Flat file for loading attribute dimension in a planning application
Dear Gurus,
I have a requirement to extract attribute dimensions from an essbase application and load it to another planning application. I have a dimension called Program and two attribute dimensions Sales Manager, Accounts manager associated with Program dimension in Essbase application. I will Extract these dimensions using Essbase outline extractor. After Extracting the attribute dimensions I have to load these dimensions to planning applications using outline load utility. Kindly guide me how to design the flat file for loading attribute dimensions in planning application.
Thanks and Regards
SCYou could dig through the docs and try to figure out the file format manually, or you could do this the easy way. Simply use the Outline Load Utility to export your attribute dimension from Planning. The export file format is the same as the import file format. You might have to manually add a couple of test members to your attribute dimension so that your export file has some content. Then simply update the file you exported, and import it.
(I am assuming you have already manually created the Attribute dimension in Planning, and that you simply need to add members to it.)
Hope this helps,
- Jake -
Download data from internal table to flat file.
I need to download the data from Internal table to Flat file. can any one suggest how to do it? i suppose WS_Download OR GUI_DOWNLOAD.
but if it is please guide me how to use this.
is thre any other F.M. please provide the information.
Thanks in advanceHi,
Try this,
* File download, uses older techniques but achieves a perfectly
* acceptable solution which also allows the user to append data to
* an existing file.
PARAMETERS: p_file like rlgrap-filename.
* Internal table to store export data
DATA: begin of it_excelfile occurs 0,
row(500) type c,
end of it_excelfile.
DATA: rc TYPE sy-ucomm,
ld_answer TYPE c.
CALL FUNCTION 'WS_QUERY'
EXPORTING
query = 'FE' "File Exist?
filename = p_file
IMPORTING
return = rc.
IF rc NE 0. "If File alread exists
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
* TITLEBAR = ' '
* DIAGNOSE_OBJECT = ' '
text_question = 'File Already exists!!'
text_button_1 = 'Replace'
* ICON_BUTTON_1 = ' '
text_button_2 = 'New name'
* ICON_BUTTON_2 = ' '
* DEFAULT_BUTTON = '1'
* DISPLAY_CANCEL_BUTTON = 'X'
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
IMPORTING
answer = ld_answer
* TABLES
* PARAMETER =
EXCEPTIONS
text_not_found = 1
OTHERS = 2.
* Option 1: Overwrite
IF ld_answer EQ '1'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = p_file "File Name
filetype = 'ASC'
* IMPORTING
* FILELENGTH =
TABLES
data_tab = it_excelfile "Data table
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE i003(zp) WITH
'There was an error during Excel file creation'(200).
exit. "Causes short dump if removed and excel document was open
ENDIF.
* Option 2: New name.
ELSEIF ld_answer EQ '2'.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
filename = p_file "File name
filetype = 'ASC' "File type
* col_select = 'X' "COL_SELECT
* col_selectmask = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
* "COL_SELECTMASK
filetype_no_show = 'X' "Show file type selection?
* IMPORTING
* act_filename = filename_dat
TABLES
data_tab = it_excelfile "Data table
* fieldnames =
EXCEPTIONS
file_open_error = 01
file_write_error = 02
invalid_filesize = 03
invalid_table_width = 04
invalid_type = 05
no_batch = 06
unknown_error = 07.
ENDIF.
ELSE. "File does not alread exist.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = p_file "File name
filetype = 'ASC' "File type
* IMPORTING
* FILELENGTH =
TABLES
data_tab = it_excelfile "Data table
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE i003(zp) WITH
'There was an error during Excel file creation'(200).
exit. "Causes short dump if removed and excel document was open
ENDIF.
ENDIF.
Regards,
Raghav -
Conversion of internal table into excel file format &put it on app server
Hi,
My requirement is to convert the internal table into excel file format and I have to store it on application server so that administrator can send the file thr e-mail attachment.
So, please let me know how to convert the records of internal table and store it on application server in Excel file format.
TIA,
NitinHi,
Use FM GUI_DOWNLOAD to download the data from inernal table to excel sheet.
Then Using tcode CG3Z u can transfer file to application server.
*& Form sub_download
text
--> p1 text
<-- p2 text
FORM sub_download.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = p_path
filetype = 'ASC'
APPEND = ' '
write_field_separator = 'X'
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = it_final
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " sub_download
Otherwise use OPEN DATASET and TRANSFER statement to download data from internal table to direct application server
Regards,
Prashant -
Need Flat file for Message type DELINS
Hi Experts,
It possible to see the flat file for the Message type DELINS ,, If needed means please say how it can view..
Advance thanks..>My need is to convert the EDI format into SAP.
As far as I know EDI can be read by SAP as Idoc directly without conversion. At least I would try this.
I checked in WE20 /partner profiles/ for outbound parameters there is a tab called 'EDI standards' and here you can define the EDI parameters. However there is no such tab for inbound processing.
What I would do /using transaction code SALE/
- define logical systems
- assign the received to the client
- create RFC port for Idoc processing
- create distribution model with the correct message type
- create port as file
- define or generate partner profiles
Try to upload sample files via transaction WE19 or WE16.
You can try to debug the inbound processing and write a program based on that, which could be scheduled as a background job.
I had a program doing similar, but it was another message type and it was XML based, however the FMs I used are the following:
'EDI_PORT_READ' - read port definition
'EPS_GET_DIRECTORY_LISTING' - get the file names in the dir
'EDI_DATA_INCOMING' - process idocs
Hope it helps.
Peter
Maybe you are looking for
-
Product Safety Automatic MSDS shipment
Hi everybody, I am doing a feasiblity study on implementing the product safety module for MSDS shipment. I would like some clarification on the implementation steps. The scenario is: MSDS documents are created and stored outside SAP. I am able to cre
-
There's a email address in my phone how do I can be it
There's a email address in my phone and it's wrong ow do I change it
-
Mac needs to be restarted after Lion upgrade
hi, can anyone help me? I upgraded my Mac to Lion, ever since then I am having problems: every time I turn on the Mac it tells be to hold down the power button and restart it, I do this and it starts to work only then. I have been having problems wit
-
Performance Improvement - Buffering
Hi , To improve the performance of the ABAP Program we can buffer database table. my Question is: which table can be buffered , Master databse table or Transactional database table? Regards, Archana.
-
Hello, Is there a way to see the print of Gantt Chart of our requirement in 2010 version.? Emil