Creation of a excel file
I am using my own context and for that I configure my server.xml file.
by writing
<Context path="/rcm" docBase="e:\rcm" reloadable="true" debug="0"/>
Now I am using JXL API to create excel file dynamically.
In my rcm folder there is a another folder named as excel file.
Now i want to create a excel file in that directory.
String file_name="/rcm/excel/"+"date_wise"+"-"+today+".xls";
workbook=Workbook.createWorkbook(new File(file_name));
But it can not create an excel file in that directory
So how can i create an excel file in that directory?
your missing the drive letter in the file path
change this:
String file_name="/rcm/excel/"+"date_wise"+"-"+today+".xls";to this:
String file_name="e:/rcm/excel/"+"date_wise"+"-"+today+".xls";
Similar Messages
-
Creating an Excel File in Background
Hi Guys,
Is there a function or Bapi that allows the creation of an Excel file in a background process?, because the WS_EXCEL function doesn't allow it.
Regards,
EricHi,
If you want to create a file in Background then you have to use OPEN DATASET statement only. WS_EXCEL function module will work only in foreground.
use below statement to open a file in background and use Transfer statement to move a record into this opened file and at last close the dataset using Close statement.
OPEN DATASET p_outfile FOR APPENDING IN TEXT MODE ENCODING DEFAULT.
thanks,
sksingh -
Excel file creation on application server
Gurus,
I have seen a lot of threads on excel file creation in application server, but failed to see if anyone had a solution.
Problem: In background execution I need to create an excel sheet on application server, the data would be contained in internal table, The FM like WS_DOWNLOAD etc..cannot support these as they have GUI component.
All the documentation that I have been through states to use dataset which saves the file in.csv or txt format seperated by delimiter, is it possible to save as a true excel file.
same as this thread:
Re: Excel download in Application Server
let me know,
Thanks in advance .* Write column headers, if required
IF column_headers = 'X'.
* ... override field names with LABELS_IN, if specified
IF NOT labels_in[] IS INITIAL.
DESCRIBE TABLE labels_in LINES num_lines.
IF num_lines > num_fields.
RAISE too_many_labels.
ELSEIF num_lines < num_fields.
RAISE too_few_labels.
ENDIF.
ASSIGN COMPONENT 1 OF STRUCTURE labels_in TO <f>.
LOOP AT fields_in.
READ TABLE labels_in INDEX sy-tabix.
fields_in-name = labels_in-name.
MODIFY fields_in.
ENDLOOP.
ENDIF.
* ...write column headers to file...
position = 0.
LOOP AT fields_in.
IF fixed_length NE space.
*** INSERT: DAR was here for Issue 17817 --------------- dar012009 ---v
field_len = STRLEN( fields_in-name ).
*** INSERT: DAR was here for Issue 17817 --------------- dar012009 ---^
DO fields_in-len TIMES.
offset = sy-index - 1.
* IF sy-index > 15. dar012009
IF sy-index > field_len. "dar012009
line_out+position(1) = space.
ELSEIF fields_in-name+offset(1) NE space.
line_out+position(1) = fields_in-name+offset(1).
ELSE.
line_out+position(1) = space.
ENDIF.
position = position + 1.
ENDDO.
ELSE.
CONCATENATE line_out fields_in-name INTO line_out
SEPARATED BY delimiter.
ENDIF.
ENDLOOP.
IF fixed_length EQ space.
SHIFT line_out LEFT DELETING LEADING delimiter.
ENDIF.
IF no_write IS INITIAL. "dar041505
TRANSFER line_out TO file_out.
ENDIF. "dar041505
data_out = line_out. APPEND data_out. "dar041505
ENDIF.
* Write lines to file...
LOOP AT data_in.
CLEAR line_out.
position = 0.
DO num_fields TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE data_in TO <f>. -
Creation of Excel files using XSLT
Hi frnds,
From the blog provided by the Michal
/people/michal.krawczyk2/blog/2005/12/10/xi-generating-excel-files-without-the-java-nor-the-conversion-agent-not-possible
I came to know that we can create excel files using XSLT mapping but here inthis blog the example provides creation of only one column but I have a scenario where in I want 3 columns ex:Name,Age,***
Shiva 26 Male
Ravi 25 Male
Rani 24 Female
but using the code provided in Michal blog Im getting the output as
Shiva
26
Male
Ravi
25
Male
Rani
24
Female
Can anyone help me in modifying the code given in Michal blog to get the output as required.
Please share your ideas or suggestion onthis...
Thanks in advance,
Shiva.Please change the code as
<xsl:template match="file_SDN/recordset/data/*">
<Row>
<Cell>
<Name ss:Type="String">
<xsl:apply-templates/>
</Name>
<Age ss:Type="Integer">
<xsl:apply-templates/>
</Age>
<*** ss:Type="String">
<xsl:apply-templates/>
</***>
</Cell>
</Row>
</xsl:template> -
Hi,
is it possible to create a PO up-loading an Excel file (in the file I have material code, description, quantity, price, etc...).
Thanks
FabioHi,
It is possible to upload PO data directly from excel. In my case, I am using PO BAPI to upload open POs and uploading data from excel file.
At the selection of screen, just call the function;
CALL FUNCTION 'WS_FILENAME_GET' " To get the flat file to SAP
EXPORTING
def_filename = '*'
mask = '.xls'
Take help of ABAPer to do this. -
Regarding Excel file creation.
Hi experts,
I retrieved the ALV output into an internal Table which is containing Text(1024) as member.
After getting Data I need to pass this data to Excel file.
Excel file should contain exact format of ALV.
Please suggest me..............
Regards,
Subashhi,
after getting data into EXCEL File and i need to pass this one as attachment to mail. If i use GUI_DOWNLOAD is saved into presentation server and i need to pick that file from presentation server and i will send. But this one won't work in BACK Ground. That is the reason after getting data from ALV report into Text Variable and i need to pass this data to excel file, and that excel file as to go an attachemnt to mail,.Everything in Background only. -
How to create a New Excel File programmatically
Hi !
I am documenting acquired data continuously in an excel file, what I need to do is to create a new excel file automatically when the size of the previous file exceeds a certain limit lets say 1MB.
I have tried using the simple 'Create/Open File' function and the 'Write to Spreadsheet File' function to create the new excel file. I does create a file but when I open the file it says the format of the file is not what you have opened it with.
Also when the new file is created, three new worksheet are to be added programmatically with pre-defined worksheet name and also Column headers for each of the worksheet are to be added.
I am also using 'Labview Report Generation Toolkit for Office'.
Regards,
Reeves
Solved!
Go to Solution.@ Aldo A
Thanks for the reference to tutorial, I didn't know about them. They are useful in general but unfortunately they don't answer the problem of creating an altogether new excel file programmatically.
@ ben64
The template thing simplifies the issue of formatting the new file. But I am still working on the new excel file creation challenge.
Let me put my problem in a different way.
Certain data is being acquired continually and is being written to a certain excel file, when the size of the file exceeds lets say 1MB the program should start saving the data in a NEW FILE instead of the previous file.
I have attached the VI to explain what I am trying to achieve here.
Reeves
Attachments:
New Microsoft Office Excel Worksheet.zip 30 KB -
Generating Excel file using PL/SQL
Hi,
I wanted to generate the excel file using the below pasted PL/SQL which I have downloaded from one of the tech sites. And as I have very limited knowledge about PL/SQL I really dont know how & where I should compile this below mentioned code and get the desired O/P?
Please reply me ASAP if anybody can help me with this?
Please see the below code and please help me to interpret the same.
CREATE OR REPLACE PACKAGE gen_xl_xml IS
-- Version 0.5
-- Objective : The main objective OF this PACKAGE IS TO CREATE excel files from PL/SQL code
-- Requirement : Excel version 2003 onwards support XML format.
-- The procedures does have TO be called IN specific order at this moment.
-- expected SEQUENCE AS OF now IS
-- At first call create_file -> It creates a FILE WITH NAME that you pass AS parameter. This PROCEDURE writes the
-- excel file header AND some basic requirments like default style.
-- procedures 1. create_style , create_worksheet AND write_cell can be used IN ANY SEQUENCE AS many
-- times AS you need.
-- When done WITH writing TO FILE call the PROCEDURE close_file
-- CLOSE FILE --> This will actually flush the data INTO the worksheet(s) one BY one and then close the file.
-- What colors I can use ?
-- red , blue , green, gray , YELLOW, BROWN , PINK . lightgray ,
debug_flag BOOLEAN := TRUE ;
PROCEDURE create_excel( p_directory IN VARCHAR2 DEFAULT NULL , p_file_name IN VARCHAR2 DEFAULT NULL ) ;
PROCEDURE create_excel_apps ;
PROCEDURE create_style( p_style_name IN VARCHAR2
, p_fontname IN VARCHAR2 DEFAULT NULL
, p_fontcolor IN VARCHAR2 DEFAULT 'Black'
, p_fontsize IN NUMBER DEFAULT null
, p_bold IN BOOLEAN DEFAULT FALSE
, p_italic IN BOOLEAN DEFAULT FALSE
, p_underline IN VARCHAR2 DEFAULT NULL
, p_backcolor IN VARCHAR2 DEFAULT NULL );
PROCEDURE close_file ;
PROCEDURE create_worksheet( p_worksheet_name IN VARCHAR2 ) ;
PROCEDURE write_cell_num(p_row NUMBER , p_column NUMBER, p_worksheet_name IN VARCHAR2, p_value IN NUMBER , p_style IN VARCHAR2 DEFAULT NULL );
PROCEDURE write_cell_char(p_row NUMBER, p_column NUMBER, p_worksheet_name IN VARCHAR2, p_value IN VARCHAR2, p_style IN VARCHAR2 DEFAULT NULL );
PROCEDURE write_cell_null(p_row NUMBER , p_column NUMBER , p_worksheet_name IN VARCHAR2, p_style IN VARCHAR2 );
PROCEDURE set_row_height( p_row IN NUMBER , p_height IN NUMBER, p_worksheet IN VARCHAR2 ) ;
PROCEDURE set_column_width( p_column IN NUMBER , p_width IN NUMBER , p_worksheet IN VARCHAR2 ) ;
END ;
-- Package : gen_xl_sml
-- Version : 0.62
CREATE OR REPLACE PACKAGE Body gen_xl_xml IS
-- worksheets must be created before it could be passed AS parameter TO the write cell procedures
l_file utl_FILE.file_type ;
g_apps_env VARCHAR2(1) := 'U' ; -- unset at the start
TYPE tbl_excel_data IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER ;
g_excel_data tbl_excel_data ;
g_null_data tbl_excel_data ;
g_data_count NUMBER ;
TYPE rec_styles IS record ( s VARCHAR2(30) , def VARCHAR2(2000) );
TYPE tbl_style IS TABLE OF rec_styles INDEX BY BINARY_INTEGER ;
g_styles tbl_style ;
g_null_styles tbl_style ;
g_style_count NUMBER := 0;
TYPE rec_worksheets IS record ( w VARCHAR2(30) , whdr VARCHAR2(300), wftr VARCHAR2(2000) );
TYPE tbl_worksheets IS TABLE OF rec_worksheets INDEX BY BINARY_INTEGER ;
g_worksheets tbl_worksheets ;
g_null_worksheets tbl_worksheets ;
g_worksheets_count NUMBER := 0;
TYPE rec_cell_data IS record ( r NUMBER , c NUMBER , v VARCHAR2(2000) ,s VARCHAR2(30) , w VARCHAR2(100), dt VARCHAR2(8) );
TYPE tbl_cell_data IS TABLE OF rec_cell_data INDEX BY binary_INTEGER ;
g_cells tbl_cell_data ;
g_null_cells tbl_cell_data ;
g_cell_count NUMBER := 0 ;
TYPE rec_columns_data IS record( c NUMBER, wd NUMBER, w VARCHAR2(30) ) ;
TYPE tbl_columns_data IS TABLE OF rec_columns_data Index BY BINARY_INTEGER ;
g_columns tbl_columns_data ;
g_null_columns tbl_columns_data ;
g_column_count NUMBER ;
TYPE rec_rows_data IS record( r NUMBER, ht NUMBER , w VARCHAR2(30) ) ;
TYPE tbl_rows_data IS TABLE OF rec_rows_data Index BY BINARY_INTEGER ;
g_rows tbl_ROWS_data ;
g_null_rows tbl_rows_data ;
g_ROW_count NUMBER ;
PROCEDURE p ( p_string IN VARCHAR2) is
begin
IF debug_flag = TRUE THEN
DBMS_OUTPUT.put_line( p_string) ;
END IF;
END ;
FUNCTION style_defined ( p_style IN VARCHAR2 ) RETURN BOOLEAN IS
BEGIN
FOR i IN 1..g_style_count LOOP
IF g_styles(i).s = p_style THEN
RETURN TRUE ;
END IF;
END LOOP ;
RETURN FALSE ;
END ;
-- Function : cell_used returns : BOOLEAN
-- Description : Cell_used FUNCTION returns TRUE IF that cell IS already used
-- Called BY : write_Cell_char, write_cell_num
-- ??? right now it IS NOT called BY write_Cell_null , this needs TO be evaluated
FUNCTION cell_used ( p_r IN NUMBER , p_c IN number , p_w IN VARCHAR2 ) RETURN BOOLEAN IS
BEGIN
FOR i IN 1..g_cell_count LOOP
IF ( g_cells(i).r = p_r AND g_cells(i).c = p_c AND g_cells(i).w = p_w ) THEN
RETURN TRUE ;
END IF;
END LOOP ;
RETURN FALSE ;
END ;
PROCEDURE initialize_collections IS
--- following lines resets the cell data and the cell count as it was
-- observed that the data is retained across the two runs within same seseion.
BEGIN
g_cells := g_null_cells ;
g_Cell_count := 0 ;
g_styles := g_null_styles ;
g_style_count := 0 ;
g_rows := g_null_rows ;
g_ROW_count := 0 ;
g_columns := g_null_columns ;
g_column_count := 0 ;
g_excel_data := g_null_data ;
g_data_count := 0 ;
g_apps_env := 'U';
g_worksheets := g_null_worksheets ;
g_worksheets_count := 0;
END ;
PROCEDURE create_excel_apps is
BEGIN
-- CHECK the env value
IF g_apps_env = 'N' THEN
raise_application_error( -20001 , 'You have already called create_excel ( Non Apps ) procedure, Can not set env to create_excel_apps.');
END IF ;
initialize_collections ;
g_apps_env := 'Y' ;
END ;
PROCEDURE create_excel( p_directory IN VARCHAR2 DEFAULT NULL , p_file_name IN VARCHAR2 DEFAULT NULL )
IS
BEGIN
-- CHECK the env value
IF g_apps_env = 'Y' THEN
raise_application_error( -20001 , 'You have already called procedure create_excel_apps , Can not set env to Non-Apps create_excel.');
END IF ;
initialize_collections ;
g_apps_env := 'N' ;
IF ( p_directory IS NULL OR p_file_name IS NULL ) THEN
raise_application_error( -20001 , 'p_directory and p_file_name must be not null');
END IF ;
BEGIN
-- Open the FILE IN the specified directory
l_file := utl_file.fopen( p_directory, p_file_name , 'w') ;
EXCEPTION
WHEN utl_file.write_error THEN
raise_application_error( -20101 , 'UTL_FILE raised write error, check if file is already open or directory access');
WHEN utl_file.INVALID_OPERATION THEN
raise_application_error( -20101 , 'UTL_FILE could not open file or operate on it, check if file is already open.');
WHEN utl_file.invalid_path THEN
raise_application_error( -20101 , 'UTL_FILE raised invalid path, check the directory passed is correct and you have access to it.');
WHEN others THEN
raise_application_error( -20101 , 'UTL_FILE raised others exception ');
END ;
p( 'File '||p_file_name ||' created successfully');
END ;
PROCEDURE create_style( p_style_name IN VARCHAR2
, p_fontname IN VARCHAR2 DEFAULT NULL
, p_fontcolor IN VARCHAR2 DEFAULT 'Black'
, p_fontsize IN NUMBER DEFAULT null
, p_bold IN BOOLEAN DEFAULT FALSE
, p_italic IN BOOLEAN DEFAULT FALSE
, p_underline IN VARCHAR2 DEFAULT NULL
, p_backcolor IN VARCHAR2 DEFAULT NULL ) is
l_style VARCHAR2(2000) ;
l_font VARCHAR2(1200);
BEGIN
--- CHECK IF this style IS already defined AND RAISE ERROR IF yes
IF style_defined( p_style_name ) THEN
RAISE_application_error( -20001 , 'Style "'||p_style_name ||'" is already defined.');
END IF;
g_style_count := g_style_count + 1;
---- ??? pass ANY value OF underline AND it will only use single underlines
-- ??? pattern IS NOT handleed
IF upper(p_style_name) = 'DEFAULT' THEN
RAISE_application_error( -20001 , 'Style name DEFAULT is not allowed ');
END IF ;
IF upper(p_style_name) IS NULL THEN
RAISE_application_error( -20001 , 'Style name can not be null ');
END IF ;
g_styles(g_style_count).s := p_style_name ;
g_styles(g_style_count).def := ' <Style ss:ID="'|| p_style_name ||'"> ' ;
l_font := ' <Font ' ;
IF p_fontname IS NOT NULL THEN
l_font :=l_font || 'ss:FontName="'|| p_fontname ||'" ';
end if ;
IF p_fontsize is not null then
l_font := l_font ||' ss:Size="'|| p_fontsize ||'" ';
end if ;
IF p_fontcolor is not null then
l_font := l_font ||' ss:Color="'|| p_fontcolor ||'" ';
ELSE
l_font := l_font ||' ss:Color="Black" ';
end if ;
IF p_bold = TRUE THEN
l_font := l_font ||' ss:Bold="1" ' ;
END IF;
IF p_italic = TRUE THEN
l_font := l_font ||' ss:Italic="1" ' ;
END IF;
IF p_underline IS NOT NULL THEN
l_font := l_font ||' ss:Underline="Single" ' ;
END IF ;
-- p( l_font );
g_styles(g_style_count).def := g_styles(g_style_count).def || l_font || '/>' ;
IF p_backcolor IS NOT NULL THEN
g_styles(g_style_count).def := g_styles(g_style_count).def || ' <Interior ss:Color="'||p_backcolor ||'" ss:Pattern="Solid"/>' ;
ELSE
g_styles(g_style_count).def := g_styles(g_style_count).def || ' <Interior/>';
END IF ;
g_styles(g_style_count).def := g_styles(g_style_count).def || ' </Style>' ;
--- ??? IN font there IS SOME family which IS NOT considered
END ;
PROCEDURE close_file IS
l_last_row NUMBER := 0 ;
l_dt CHAR ; -- ??? Variable TO store the datatype ; this IS NOT used at this time but may be needed IF the memory
-- issue IS there FOR example IF there IS big array
l_style VARCHAR2(140) ;
l_row_change VARCHAR2(100) ;
l_file_header VARCHAR2(2000) := '<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<LastAuthor>a</LastAuthor>
<Created>1996-10-14T23:33:28Z</Created>
<LastSaved>2007-05-10T04:00:57Z</LastSaved>
<Version>11.5606</Version>
</DocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>9300</WindowHeight>
<WindowWidth>15135</WindowWidth>
<WindowTopX>120</WindowTopX>
<WindowTopY>120</WindowTopY>
<AcceptLabelsInFormulas/>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>'
BEGIN
IF gen_xl_xml.g_Cell_count = 0 THEN
raise_application_error( -20007 , 'No cells have been written, this version of gen_xl_xml needs at least one cell to be written');
END IF;
IF gen_xl_xml.g_worksheets_count = 0 THEN
raise_application_error( -20008 , 'No worksheets have been created, this version does not support automatic worksheet creation');
END IF;
p( gen_xl_xml.g_Cell_count) ;
-- Write the header xml part IN the FILE.
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := l_file_header ;
p( 'Headers written');
FOR i IN 1..g_style_count LOOP
p( ' writing style number : '||i);
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := g_styles(i).def ;
END LOOP ;
-- CLOSE the styles tag
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' </Styles>' ;
p( 'worksheet count '|| g_worksheets_count );
FOR j IN 1..g_worksheets_count LOOP
l_last_row := 0 ; --- FOR every worksheet we need TO CREATE START OF the row
p( '()()------------------------------------------------------------ last row '||l_last_row );
--- write the header first
-- write the COLUMN widhts first
-- write the cells
-- write the worksheet footer
l_row_change := NULL ;
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' <Worksheet ss:Name="'|| g_worksheets( j).w ||'"> ' ;
p( '-------------------------------------------------------------');
p( '****************.Generated sheet '|| g_worksheets( j).w);
p( '-------------------------------------------------------------');
-- write the TABLE structure ??? change the LINE here TO include tha maxrow AND cell
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := '<Table ss:ExpandedColumnCount="16" ss:ExpandedRowCount="44315" x:FullColumns="1" x:FullRows="1">' ;
FOR i IN 1..g_column_count LOOP
IF g_columns(i).w = g_worksheets( j).w THEN
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' <Column ss:Index="'||g_columns(i).c||'" ss:AutoFitWidth="0" ss:Width="'||g_columns(i).wd ||'"/> ' ;
END IF;
END LOOP ;
-- write the cells data
FOR i IN 1..g_cell_count LOOP ------ LOOP OF g_cell_count
p( '()()()()()()()()()()()() '|| i);
--- we will write only IF the cells belongs TO the worksheet that we are writing.
IF g_cells(i).w <> g_worksheets(j).w THEN
p( '........................Cell : W :'|| g_worksheets( j).w ||'=> r='|| g_cells(i).r ||',c ='|| g_cells(i).c||',w='|| g_cells(i).w );
p( '...Not in this worksheet ');
-- l_last_row := l_last_row -1 ;
ELSE
p( '........................Cell : W :'|| g_worksheets( j).w ||'=> r='|| g_cells(i).r ||',c ='|| g_cells(i).c||',w='|| g_cells(i).w );
IF g_cells(i).s IS NOT NULL AND NOT style_defined( g_cells(i).s ) THEN
-- p(g_cells(i).s) ;
raise_application_error( -20001 , 'Style "'||g_cells(i).s ||'" is not defined, Note : Styles are case sensative and check spaces used while passing style');
END IF;
p( '()()------------------------------------------------------------ last row '||l_last_row );
IF l_last_row = 0 THEN
FOR t IN 1..g_row_count LOOP
p( '...Height check => Row =' ||g_rows(t).r ||', w='||g_rows(t).w);
IF g_rows(t).r = g_cells(i).r AND g_rows(t).w = g_worksheets(j).w THEN
p( '...Changing height') ;
l_row_change := ' ss:AutoFitHeight="0" ss:Height="'|| g_rows(t).ht||'" ' ;
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' <Row ss:Index="'||g_cells(i).r||'"'|| l_row_change ||'>' ;
l_last_row := g_cells(i).r ;
EXIT ;
ELSE
p( '...NO change height') ;
l_row_change := NULL ;
END IF ;
END loop ;
IF l_ROW_CHANGE IS NULL THEN
g_data_count := g_data_count + 1 ;
p( '...Creating new row ');
g_excel_data( g_data_count ) := ' <Row ss:Index="'||g_cells(i).r||'"'|| l_row_change ||'>' ;
l_last_row := g_cells(i).r ;
END IF;
END IF;
IF g_cells(i).s IS NOT NULL THEN
p( '...Adding style ');
l_style := ' ss:StyleID="'||g_cells(i).s||'"' ;
ELSE
p( '...No style for this cell ');
l_style := NULL ;
END IF;
p( '()()------------------------------------------------------------ last row '||l_last_row );
IF g_cells(i).r <> l_last_row THEN
p('...closing the row.'||g_cells(i).r);
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' </Row>' ;
p( 'ROWCOUNT : '||g_row_count );
FOR t IN 1..g_ROW_count LOOP
p( '.....Height check => Row =' ||g_rows(t).r ||', w='||g_rows(t).w);
IF g_rows(t).r = g_cells(i).r AND g_rows(t).w = g_worksheets(j).w THEN
p( '.....Changing height') ;
l_row_change := ' ss:AutoFitHeight="0" ss:Height="'|| g_rows(t).ht||'" ' ;
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' <Row ss:Index="'||g_cells(i).r||'"'|| l_row_change ||'>' ;
EXIT ;
ELSE
p( '.....NO change height') ;
l_row_change := NULL ;
END IF ;
END loop ;
-- P( 'Row :'||g_cells(i).r ||'->'|| l_ROW_CHANGE);
IF l_row_change IS NULL THEN
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' <Row ss:Index="'||g_cells(i).r||'"'|| l_row_change ||'>' ;
END IF;
IF g_cells(i).v IS NULL THEN
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := '<Cell ss:Index="'||g_cells(i).c||'"' || l_style ||' ></Cell>';
ELSE
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := '<Cell ss:Index="'||g_cells(i).c||'"' || l_style ||' ><Data ss:Type="'||g_cells(i).dt ||'">'||g_cells(i).v||'</Data></Cell>';
END IF ;
l_last_row :=g_cells(i).r ;
ELSE
IF g_cells(i).v IS NULL THEN
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := '<Cell ss:Index="'||g_cells(i).c||'"' || l_style ||' > </Cell>';
ELSE
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := '<Cell ss:Index="'||g_cells(i).c||'"' || l_style ||' ><Data ss:Type="'||g_cells(i).dt ||'">'||g_cells(i).v||'</Data></Cell>';
END IF ;
END IF ;
END IF ;
NULL ;
END LOOP ; -- LOOP OF g_cells_count
p('...closing the row.');
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' </Row>' ;
-- ??? does following COMMENT will have sheet NAME FOR debugging
p( '-------------------------------------------------------------');
p( '....End of writing cell data, closing table tag');
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' </Table>' ;
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := g_worksheets(j).wftr ;
p( '..Closed the worksheet '|| g_worksheets( j).w );
END LOOP ;
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := '</Workbook>' ;
p( 'Closed the workbook tag');
IF g_apps_env = 'N' THEN
FOR i IN 1..g_data_count LOOP
utl_FILE.put_line( l_file, g_excel_data(i ));
END LOOP ;
utl_file.fclose( l_file );
p( 'File closed ');
ELSIF g_apps_env = 'Y' THEN
FOR i IN 1..g_data_count LOOP
fnd_file.put_line( fnd_file.output , g_excel_data(i));
fnd_file.put_line( fnd_file.log , g_excel_data(i));
END LOOP ;
ELSE
raise_application_error( -20001 , 'Env not set, ( Apps or not Apps ) Contact Support.' );
END IF;
END ;
PROCEDURE create_worksheet ( p_worksheet_name IN VARCHAR2 ) IS
BEGIN
g_worksheets_count := g_worksheets_count + 1 ;
g_worksheets(g_worksheets_count).w := p_worksheet_name ;
g_worksheets(g_worksheets_count).whdr := '<Worksheet ss:Name=" ' || p_worksheet_name ||' ">' ;
g_worksheets(g_worksheets_count).wftr := '<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>' ;
END ;
PROCEDURE write_cell_char(p_row NUMBER, p_column NUMBER, p_worksheet_name IN VARCHAR2, p_value IN VARCHAR2, p_style IN VARCHAR2 DEFAULT NULL ) IS
l_ws_exist BOOLEAN ;
l_worksheet VARCHAR2(2000) ;
BEGIN
-- CHECK IF this cell has been used previously.
IF cell_used( p_row , p_column , p_worksheet_name ) THEN
RAISE_application_error( -20001 , 'The cell ( Row: '||p_row ||' Column:'||p_column ||' Worksheet:'||p_worksheet_name ||') is already used.Check if you have missed to increment row number in your code. ');
END IF;
-- IF worksheet NAME IS NOT passed THEN use first USER created sheet ELSE use DEFAULT sheet
-- this PROCEDURE just adds the data INTO the g_cells TABLE
g_cell_count := g_cell_count + 1 ;
g_cells( g_cell_count ).r := p_row ;
g_cells( g_cell_count ).c := p_column ;
g_cells( g_cell_count ).v := p_value ;
g_cells( g_cell_count ).w := p_worksheet_name ;
g_cells( g_cell_count ).s := p_style ;
g_cells( g_cell_count ).dt := 'String' ;
END ;
PROCEDURE write_cell_num(p_row NUMBER , p_column NUMBER, p_worksheet_name IN VARCHAR2, p_value IN NUMBER , p_style IN VARCHAR2 DEFAULT NULL ) IS
l_ws_exist BOOLEAN ;
l_worksheet VARCHAR2(2000) ;
BEGIN
-- ??? IF worksheet NAME IS NOT passed THEN use first USER created sheet ELSE use DEFAULT sheet
-- this PROCEDURE just adds the data INTO the g_cells TABLE
-- CHECK IF this cell has been used previously.
IF cell_used( p_row , p_column , p_worksheet_name ) THEN
RAISE_application_error( -20001 , 'The cell ( Row: '||p_row ||' Column:'||p_column ||' Worksheet:'||p_worksheet_name ||') is already used. Check if you have missed to increment row number in your code.');
END IF;
g_cell_count := g_cell_count + 1 ;
g_cells( g_cell_count ).r := p_row ;
g_cells( g_cell_count ).c := p_column ;
g_cells( g_cell_count ).v := p_value ;
g_cells( g_cell_count ).w := p_worksheet_name ;
g_cells( g_cell_count ).s := p_style ;
g_cells( g_cell_count ).dt := 'Number' ;
END ;
PROCEDURE write_cell_null(p_row NUMBER , p_column NUMBER , p_worksheet_name IN VARCHAR2, p_style IN VARCHAR2 ) IS
BEGIN
-- ???? NULL IS allowed here FOR time being. one OPTION IS TO warn USER that NULL IS passed but otherwise
-- the excel generates without error
g_cell_count := g_cell_count + 1 ;
g_cells( g_cell_count ).r := p_row ;
g_cells( g_cell_count ).c := p_column ;
g_cells( g_cell_count ).v := null ;
g_cells( g_cell_count ).w := p_worksheet_name ;
g_cells( g_cell_count ).s := p_style ;
g_cells( g_cell_count ).dt := NULL ;
END ;
PROCEDURE set_row_height( p_row IN NUMBER , p_height IN NUMBER, p_worksheet IN VARCHAR2 ) IS
BEGIN
g_ROW_count := g_ROW_count + 1 ;
g_rows( g_row_count ).r := p_row ;
g_rows( g_row_count ).ht := p_height ;
g_rows( g_row_count ).w := p_worksheet ;
END ;
PROCEDURE set_column_width( p_column IN NUMBER , p_width IN NUMBER, p_worksheet IN VARCHAR2 ) IS
BEGIN
g_column_count := g_column_count + 1 ;
g_columns( g_column_count ).c := p_column ;
g_columns( g_column_count ).wd := p_width ;
g_columns( g_column_count ).w := p_worksheet ;
END ;
END ;
SHOW errors ;
Thanks,
Maddy BHi,
Peter Gjelstrup wrote:
Next thing is how to use it:
declare
k_file constant varchar2(30) := 'YourFile.xls'
begin
create_file(k_file);
-- Call other procedures
close_file;
end;
Don't forget: these procedures are all part of the gen_xl_xml package.
To call them from outside the package, you have to prefix each procedure name with the package name, like this:
declare
k_file constant varchar2(30) := 'YourFile.xls'
begin
gen_xl_xml.create_file(k_file);
-- Call other procedures
gen_xl_xml.close_file;
end; -
Report to display PO details and download details in an excel fil
Hi,
I have been asked to develop a report for "Develop report to display PO details and download details in an excel file".
Could any one guide me technically what are the different tables i need to take to generate the report. Treat this is very urgent. Pls provide sample code too....
Thanks in advance....Purchase Order PO
Tcode for creation ME21,ME22,ME23. tables EKKO,EKPO.
refer this program
REPORT ZPOCHANGE.
This is a subroutine perform in the Purchase order Layout sets.
Description : To retreive the details of changed remarks in PO output and to capture the retrival date
Additional features with the previous changed appearing. e.g. from .... to
Note : If the latest modification details required
Please Uncomment the lines mentioned under 'Last Modified Remarks only'
Information
/: PERFORM CHDATE IN PROGRAM ZPOCHANGE
/: USING &EKKO-EBELN&
/: CHANGING &RVDATE2&
/: ENDPERFORM.
/: IF &RVDATE2& EQ ' '.
/ Revision Date: NIL
/: ELSE.
/ Revision Date: &RVDATE2&
/: ENDIF.
Main Window
/E CHANGE_REMARKS
/: PERFORM CHDET IN PROGRAM ZPOCHANGE
/: USING &EKPO-EBELP&
/: USING &EKKO-EBELN&
/: USING &T166T-CHTXT&
/: USING &T166T-CTXNR&
/: CHANGING &ITAB1-F_NEW&
/: CHANGING &ITAB1-F_OLD&
/:ENDPERFORM.
/:IF &ITAB1-F_NEW& NE ' '
= &ITAB1-F_OLD(C)& CHANGED TO &ITAB1-F_NEW(C)&
/:ENDIF
You might need to apply Note 373524 - Message determination and printing
TABLES : CDSHW , "Change documents, formatting table
CDHDR , "Change document header
EKPO , "Purchasing Document Item
EKKO , "Purchasing Document Header
T166C . "Print-Relevant Purchasing Document Changes
DATA : ITAB1 LIKE CDSHW OCCURS 100 WITH HEADER LINE.
DATA : ITAB2 LIKE EKPO OCCURS 100 WITH HEADER LINE.
DATA : DOCUM LIKE EKKO OCCURS 100 WITH HEADER LINE.
DATA : TABKEY LIKE CDSHW-TABKEY.
data : begin of ctab occurs 10,
tname like t166c-tname,
fname like t166c-fname,
TABKEY LIKE CDSHW-TABKEY,
FLAG(3),
end of ctab.
DATA : VAL1(15), VAL2(15).
DATA : M1(20), M2(10), M3(10),M4(5).
DATA : RVDATE(10),RVDATE2(10) , EBELN LIKE EKKO-EBELN, COUNT TYPE I.
Text number for change text(CTXNR), CHANGE TEXT(CHTXT), Purchase order
Number and item number are passed from Layoutset
FORM CHDET *
--> ITAB *
--> OTAB *
FORM CHDET TABLES ITAB STRUCTURE ITCSY
OTAB STRUCTURE ITCSY.
LOOP AT ITAB.
CASE ITAB-NAME.
WHEN 'T166T-CHTXT'.
MOVE ITAB-VALUE TO M1.
WHEN 'T166T-CTXNR'.
MOVE ITAB-VALUE TO M2.
WHEN 'EKKO-EBELN'.
MOVE ITAB-VALUE TO M3.
WHEN 'EKPO-EBELP'.
MOVE ITAB-VALUE TO M4.
ENDCASE.
ENDLOOP.
Throught this function change details are retrived into itab1.
CALL FUNCTION 'ME_CHANGES_READ'
EXPORTING
DOCUMENT_CATEGORY = 'F'
DOCUMENT_NUMBER = M3
TABLES
XCDSHW = itab1.
SELECT SINGLE * FROM T166C WHERE CTXNR = M2.
IF SY-SUBRC = 0.
CONCATENATE M3 M4 INTO TABKEY.
********Last Modified Remarks only**********************
read table ctab with key tname = T166C-TNAME
tabkey = tabkey
fname = T166C-FNAME.
if sy-subrc ne 0.
LOOP AT ITAB1 WHERE TABNAME = T166C-TNAME
AND TABKEY+3(15) = TABKEY
AND FNAME = T166C-FNAME.
*********Last Modified Remarks only**********************
ctab-tname = t166c-tname.
ctab-fname = t166c-fname.
ctab-tabkey = tabkey.
append ctab.
delete itab1.
exit.
endloop.
Captured details are exported to Layoutset
LOOP AT OTAB.
CASE OTAB-NAME.
WHEN 'ITAB1-F_OLD'.
OTAB-VALUE = ITAB1-F_OLD.
MODIFY OTAB.
CLEAR : ITAB1-F_OLD.
WHEN 'ITAB1-F_NEW'.
OTAB-VALUE = ITAB1-F_NEW.
MODIFY OTAB.
CLEAR : ITAB1-F_NEW.
ENDCASE.
endloop.
endif.
******Last Modified Remarks only****************
ENDIF.
clear ctab.
ENDFORM.
FORM CHDATE *
--> ITAB *
--> OTAB *
Form for revision date retrival. PO no. is passed from layoutset
and in the change document header latest modified date is captured
and passed to revision date field in Layoutset.
FORM CHDATE TABLES ITAB STRUCTURE ITCSY
OTAB STRUCTURE ITCSY.
CLEAR : RVDATE, EBELN.
LOOP AT ITAB.
CASE ITAB-NAME.
WHEN 'EKKO-EBELN'.
MOVE ITAB-VALUE TO EBELN.
ENDCASE.
ENDLOOP.
SELECT UDATE INTO CDHDR-UDATE FROM CDHDR WHERE OBJECTCLAS = 'EINKBELEG'
AND OBJECTID = EBELN.
IF RVDATE < CDHDR-UDATE.
RVDATE = CDHDR-UDATE.
ENDIF.
COUNT = COUNT + 1.
ENDSELECT.
LOOP AT OTAB.
CASE OTAB-NAME.
WHEN 'RVDATE2'.
CONCATENATE RVDATE6(2) '.' RVDATE4(2) '.' RVDATE(4) INTO RVDATE2.
IF COUNT = 1.
RVDATE2 = ''.
ENDIF.
MOVE RVDATE2 TO OTAB-VALUE.
MODIFY OTAB.
ENDCASE.
ENDLOOP.
CLEAR : COUNT.
ENDFORM.
Message was edited by:
Karthikeyan Pandurangan -
How to read the data from excel file and store into the table?
Hi All,
I have table with BLOB datatype contains a excel file. I have to read that data from excel and store into one table with all the fields in excel.
All the excel fields and my table columns are same.
Can you share with me how can acheive this using LOB's?
ThanksHi OraSuirya,
you can try with external tables .
syntax as follows
create table ext_table_csv (
i Number,
n Varchar2(20),
m Varchar2(20)
organization external (
type oracle_loader
default directory ext_dir
access parameters (
records delimited by newline
fields terminated by ','
missing field values are null
location ('file.csv')
reject limit unlimited;
For this you need to create directory
Directory Creation syntax:
create or replace directory ext_dir as 'D:\oracle\user_dir\ext_dir';
grant read, write on directory ext_dir to <User>;
please paste the excel file in the particular directory .
I hope this will help you.
Please correct me if I am wrong anywhere .
Thanks,
Tippu. -
Create key mapping using import manager for lookup table FROM EXCEL file
hello,
i would like create key mapping while importing the values via excel file.
the source file containing the key, but how do i map it to the lookup table?
the properties of the table has enable the creation of mapping key. but during the mapping in import manager, i cant find any way to map the key mapping..
eg
lookup table contains:
Material Group
Code
excel file contain
MatGroup1 Code System
Thanks!
ShantiHi Shanti,
Assuming you have already defined below listed points
1) Key Mapping "Yes" to your lookup table in MDM Console
2) Created a New Remote System in MDM console
3) proper rights for your account for updating the remote key values in to data manager through import manager.
Your sample file can have Material Group and Code alone which can be exported from Data Manager by File-> Export To -> Excel, if you have data already in Data Manager.
Open your sample file through Import Manager by selecting the remote system for which you want to import the Key mapping.
(Do Not select MDM as Remote System, which do not allows you to maintain key mapping values) and also the file type as Excel
Now select your Soruce and Destination tables, under the destination fields you will be seeing a new field called [Remote Key]
Map you source and destination fields correspondingly and Clone your source field code by right clicking on code in the source hierarchy and map it to Remote Key if you want the code to be in the remote key values.
And in the matching criteria select destination field code as a Matching field and change the default import action to Update NULL fields or UPDATED MAPPED FIELDS as required,
After sucessfull import you can check the Remote Key values in Data Manager.
Hope this helps
Thanks
Sowseel -
Jar files required to read excel file in SAP PI 7.3.1 sp09 dualstack
Hi experts,
I need to read excel file (.xls) using SAP PI and process it to target system. I have read blogs
and found that there are 2 ways to read an excel file in PI using file adapter.
1) Developing a custom adapter module
2) Using XSLT code.
So in order to develop a custom adapter module, i have followed the following blogs
**************** - XI - Step-by-step guide to develop Adapter Module to read Excel file
and
Excel Files - How to handle them in SAP XI/PI (The Alternatives)
and
http://wiki.scn.sap.com/wiki/display/ABAP/Adapter+Module+To+Read+Excel+File+with+Multiple+Rows+and+Multiple+Columns
I am unable to find the jar files in SAP PI at OS level as per the first blog(think they were obsolete).
Please let me know
1) What are the required jar files needed to read excel file and their location
2) Even if i use the old jar files as mentioned in the first blog can i achieve my requirement
3) Following this blog Convert incoming XML to Excel or Excel XML – Part 1 - XSLT Way if i apply the same logic at sender side, will it work? Because through case studies i came to know that we cannot read a .xls file using XSLT code. Correct me if i am wrong.
Looking for your valuable suggestions.
Regards
ShilpaHi Shilpa
Welcome to SCN!
The blog you refered to might be for previous versions of PI. You can refer to the following two wikis to find out what are the relevant JAR files for PI 7.3 and also how to get them.
XI libraries for development - Process Integration - SCN Wiki
Where to get the libraries for XI development - Process Integration - SCN Wiki
It also looks like for newer versions, you might not need to manually get and add those JAR files into your NWDS project - please refer to the first comment on the blog below. I have not tried it personally as I'm not using the latest NWDS, but you can try that first, and if it does not work, then go get them manually.
PI 7.4 - Adapter Module Creation using EJB 3.0
Do note that you should be using the JAR files that is corresponding to your PI server version.
As for your third question, that does not apply to you. XLS is the older non-XML format, and therefore cannot be read by XLST since it is in binary format.
Rgds
Eng Swee -
Working with excel files in C#, in a web farm
I am creating a excel file uploader that after the upload, searches for specific columns, saves data to SQL Server, then gets rid of the excel file.
I will be accepting .xls & xlsx file types. The internal file structure should be all fairly standard because this is an internal company app. So for example, the sheet with the data I am searching for may not always be the first in the book,
but it will always have the same name.
From the research I have done, it seems I can use the Interop library or OpenXML. I am leaning towards interop. Because we are on a web farm, I think it would be best to not save the file, just work with it in memory. Would this be a concern
if the files are only only around 50kb? I am only expecting 100 uploads a month.
If it is preferred or required I save the file before pulling the data out, should I save it to the application directory on the web server and expect it to be ok because I am saving/processing/deleting in one request? Or is there a better solution? I
thought of saving to our file share but that opens a whole new bucket of worms because of having to send credentials with the file when saving.
Simon.Hi Simon,
Open XML SDK can only manipulate Office 2007 and above versions. Since your web form accepts Excel 2003 file, it's not a good choice. But if you want to use the PIA(Primary Interop Assembly) to automate the excel files, it's also not recommened. Neither
of these two options are suitable in your case, you need to use some 3rd-party library to help you, as recommened in this Microsoft KB article.
http://support.microsoft.com/kb/257757/en-au
If your business requires the server-side creation of the Office 97, Office 2000, Office XP, and Office
2003 binary file formats, third-party vendors offer components that can help you. Microsoft does not provide any such components, so you will need to either build a solution yourself or purchase one from a third-party vendor. Many different
third-party products are available. You should investigate each solution to best match the vendor to your business needs.If you want to build your own solution that edits the Office 97, Office 2000, Office XP, and Office 2003 binary file
formats directly, you can obtain the file format specifications for free under the terms of the Microsoft Open Specification Promise (OSP). No technical support is available for the documentation or for the products that you create, but
documentation is available. For more information, visit the following Web site:
http://www.microsoft.com/interop/docs/officebinaryformats.mspx
As far as I know, NPOI is a good choice for you. You can search and try it. But as it's a 3rd-party library, we don't provide support for it. It also provide ability to process the worksheet in the memory.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Upload of excel file in to purchase order
hi guys,
i want to upload a excel file to the internal table and then to create the purchase order.
i know the name of function module and bapi.
but how to make use of them in implementation!!!
fun module : ALSM_EXCEL_TO_INTERNAL_TABLE
bapi : BAPI_PO_CREATE1.
arun and vishnu from
infotech solutions*CREATION OF A TEMPORARY STRUCTURE FOR INSERTING FIELDS OF EXCEL TO INTERNAL TABLE.
TYPES : BEGIN OF STR_FINAL,
COMP_CODE TYPE BAPIMEPOHEADER-COMP_CODE, " STRUCTURE : BAPIMEPOHEADER
ITEM_INTVL TYPE BAPIMEPOHEADER-ITEM_INTVL,
VENDOR TYPE BAPIMEPOHEADER-VENDOR,
PMNTTRMS TYPE BAPIMEPOHEADER-PMNTTRMS,
PURCH_ORG TYPE BAPIMEPOHEADER-PURCH_ORG,
PUR_GROUP TYPE BAPIMEPOHEADER-PUR_GROUP,
CURRENCY TYPE BAPIMEPOHEADER-CURRENCY,
PO_ITEM TYPE BAPIMEPOITEM-PO_ITEM, " STRUCTURE : BAPIMEPOITEM
MATERIAL TYPE BAPIMEPOITEM-MATERIAL,
PLANT TYPE BAPIMEPOITEM-PLANT,
STGE_LOC TYPE BAPIMEPOITEM-STGE_LOC,
QUANTITY TYPE BAPIMEPOITEM-QUANTITY,
TAX_CODE TYPE BAPIMEPOITEM-TAX_CODE,
ITEM_CAT TYPE BAPIMEPOITEM-ITEM_CAT,
ACCTASSCAT TYPE BAPIMEPOITEM-ACCTASSCAT,
SCHED_LINE TYPE BAPIMEPOSCHEDULE-SCHED_LINE, " STRUCTURE : BAPIMEPOSCHEDULE
DELIVERY_DATE TYPE BAPIMEPOSCHEDULE-DELIVERY_DATE,
SERIAL_NO TYPE BAPIMEPOACCOUNT-SERIAL_NO, " STRUCTURE : BAPIMEPOACCOUNT
GL_ACCOUNT TYPE BAPIMEPOACCOUNT-GL_ACCOUNT,
COSTCENTER TYPE BAPIMEPOACCOUNT-COSTCENTER,
CO_AREA TYPE BAPIMEPOACCOUNT-CO_AREA,
END OF STR_FINAL.
DATA : IT_FINAL TYPE TABLE OF STR_FINAL,
WA_FINAL TYPE STR_FINAL.
DATA: ST_BAPIMEPOHEADER TYPE BAPIMEPOHEADER,
ST_BAPIMEPOHEADERX TYPE BAPIMEPOHEADERX.
*it is for item data
DATA: WA_POITEM TYPE BAPIMEPOITEM,
IT_POITEM TYPE TABLE OF BAPIMEPOITEM,
WA_POITEMX TYPE BAPIMEPOITEMX,
IT_POITEMX TYPE TABLE OF BAPIMEPOITEMX,
WA_POSCHEDULE TYPE BAPIMEPOSCHEDULE,
IT_POSCHEDULE TYPE TABLE OF BAPIMEPOSCHEDULE,
WA_POSCHEDULEX TYPE BAPIMEPOSCHEDULX,
IT_POSCHEDULEX TYPE TABLE OF BAPIMEPOSCHEDULX,
WA_POACCOUNT TYPE BAPIMEPOACCOUNT,
IT_POACCOUNT TYPE TABLE OF BAPIMEPOACCOUNT,
WA_POACCOUNTX TYPE BAPIMEPOACCOUNTX,
IT_POACCOUNTX TYPE TABLE OF BAPIMEPOACCOUNTX,
WA_RETURN TYPE BAPIRET2,
IT_RETURN TYPE TABLE OF BAPIRET2.
selection-screen skip 1.
parameters: p_file type localfile default 'D:\VISHNU\DEMO.XLS'.
*selection-screen skip 1.
at selection-screen on value-request for p_file.
call function 'KD_GET_FILENAME_ON_F4'
exporting
static = 'X'
changing
file_name = p_file.
start-of-selection.
clear IT_FINAL.
refresh IT_FINAL.
perform upload_data.
loop at IT_FINAL INTO WA_FINAL.
write:/ WA_FINAL-COMP_CODE,
/ WA_FINAL-ITEM_INTVL,
/ WA_FINAL-VENDOR,
/ WA_FINAL-PMNTTRMS,
/ WA_FINAL-PURCH_ORG,
/ WA_FINAL-PUR_GROUP,
/ WA_FINAL-CURRENCY,
/ WA_FINAL-PO_ITEM,
/ WA_FINAL-MATERIAL,
/ WA_FINAL-PLANT,
/ WA_FINAL-STGE_LOC,
/ WA_FINAL-QUANTITY,
/ WA_FINAL-TAX_CODE,
/ WA_FINAL-ITEM_CAT,
/ WA_FINAL-ACCTASSCAT,
/ WA_FINAL-SCHED_LINE,
/ WA_FINAL-DELIVERY_DATE,
/ WA_FINAL-SERIAL_NO,
/ WA_FINAL-GL_ACCOUNT,
/ WA_FINAL-COSTCENTER,
/ WA_FINAL-CO_AREA.
endloop.
LOOP AT IT_FINAL INTO WA_FINAL.
ST_BAPIMEPOHEADER-COMP_CODE = WA_FINAL-COMP_CODE.
ST_BAPIMEPOHEADER-DOC_TYPE = 'NB'.
ST_BAPIMEPOHEADER-ITEM_INTVL = WA_FINAL-ITEM_INTVL.
ST_BAPIMEPOHEADER-VENDOR = WA_FINAL-VENDOR.
ST_BAPIMEPOHEADER-LANGU = SY-LANGU.
ST_BAPIMEPOHEADER-PMNTTRMS = WA_FINAL-PMNTTRMS.
ST_BAPIMEPOHEADER-PURCH_ORG = WA_FINAL-PURCH_ORG.
ST_BAPIMEPOHEADER-PUR_GROUP = WA_FINAL-PUR_GROUP.
ST_BAPIMEPOHEADER-CURRENCY = WA_FINAL-CURRENCY.
*insert ST_BAPIMEPOHEADERX values
ST_BAPIMEPOHEADERX-COMP_CODE = 'X'.
ST_BAPIMEPOHEADERX-DOC_TYPE = 'X'.
ST_BAPIMEPOHEADERX-ITEM_INTVL = 'X'.
ST_BAPIMEPOHEADERX-VENDOR = 'X'.
ST_BAPIMEPOHEADERX-LANGU = 'X'.
ST_BAPIMEPOHEADERX-PMNTTRMS = 'X'.
ST_BAPIMEPOHEADERX-PURCH_ORG = 'X'.
ST_BAPIMEPOHEADERX-PUR_GROUP = 'X'.
ST_BAPIMEPOHEADERX-CURRENCY = 'X'.
*insert IT_POITEM values
WA_POITEM-PO_ITEM = WA_FINAL-PO_ITEM.
WA_POITEM-MATERIAL = WA_FINAL-MATERIAL.
WA_POITEM-PLANT = WA_FINAL-PLANT.
WA_POITEM-STGE_LOC = WA_FINAL-STGE_LOC.
WA_POITEM-QUANTITY = WA_FINAL-QUANTITY.
WA_POITEM-TAX_CODE = WA_FINAL-TAX_CODE.
WA_POITEM-ITEM_CAT = WA_FINAL-ITEM_CAT.
WA_POITEM-ACCTASSCAT = WA_FINAL-ACCTASSCAT.
APPEND WA_POITEM TO IT_POITEM.
CLEAR WA_POITEM.
*insert IT_POITEMX values
WA_POITEMX-PO_ITEM = WA_FINAL-PO_ITEM.
WA_POITEMX-PO_ITEMX = 'X'.
WA_POITEMX-MATERIAL = 'X'.
WA_POITEMX-PLANT = 'X'.
WA_POITEMX-STGE_LOC = 'X'.
WA_POITEMX-QUANTITY = 'X'.
WA_POITEMX-TAX_CODE = 'X'.
WA_POITEMX-ITEM_CAT = 'X'.
WA_POITEMX-ACCTASSCAT = 'X'.
APPEND WA_POITEMX TO IT_POITEMX.
CLEAR WA_POITEMX.
*insert IT_POSCHEDULE values
WA_POSCHEDULE-PO_ITEM = WA_FINAL-PO_ITEM.
WA_POSCHEDULE-SCHED_LINE = WA_FINAL-SCHED_LINE.
WA_POSCHEDULE-DELIVERY_DATE = WA_FINAL-DELIVERY_DATE .
WA_POSCHEDULE-QUANTITY = WA_FINAL-QUANTITY.
APPEND WA_POSCHEDULE TO IT_POSCHEDULE.
CLEAR WA_POSCHEDULE.
*insert IT_POSCHEDULEX values
WA_POSCHEDULEX-PO_ITEM = WA_FINAL-PO_ITEM.
WA_POSCHEDULEX-SCHED_LINE = WA_FINAL-SCHED_LINE.
WA_POSCHEDULEX-PO_ITEMX = 'X' .
WA_POSCHEDULEX-SCHED_LINEX = 'X' .
WA_POSCHEDULEX-DELIVERY_DATE = 'X' .
WA_POSCHEDULEX-QUANTITY = 'X' .
WA_POSCHEDULEX-PO_ITEM = WA_FINAL-PO_ITEM .
WA_POSCHEDULEX-SCHED_LINE = WA_FINAL-SCHED_LINE.
WA_POSCHEDULEX-PO_ITEMX = 'X'.
WA_POSCHEDULEX-SCHED_LINEX = 'X' .
WA_POSCHEDULEX-DELIVERY_DATE = 'X' .
WA_POSCHEDULEX-QUANTITY = 'X'.
WA_POSCHEDULEX-PO_ITEM = WA_FINAL-PO_ITEM.
WA_POSCHEDULEX-SCHED_LINE = WA_FINAL-SCHED_LINE.
WA_POSCHEDULEX-PO_ITEMX = 'X'.
WA_POSCHEDULEX-SCHED_LINEX = 'X'.
WA_POSCHEDULEX-DELIVERY_DATE = 'X' .
WA_POSCHEDULEX-QUANTITY = 'X'.
APPEND WA_POSCHEDULEX TO IT_POSCHEDULEX.
CLEAR WA_POSCHEDULEX.
*insert IT_POACCOUNT values
WA_POACCOUNT-PO_ITEM = WA_FINAL-PO_ITEM.
WA_POACCOUNT-SERIAL_NO = WA_FINAL-SERIAL_NO.
WA_POACCOUNT-QUANTITY = WA_FINAL-QUANTITY .
WA_POACCOUNT-GL_ACCOUNT = WA_FINAL-GL_ACCOUNT.
WA_POACCOUNT-COSTCENTER = WA_FINAL-COSTCENTER.
WA_POACCOUNT-CO_AREA = WA_FINAL-CO_AREA.
APPEND WA_POACCOUNT TO IT_POACCOUNT.
CLEAR WA_POACCOUNT.
*insert IT_POACCOUNTX values
WA_POACCOUNTX-PO_ITEM = 00001.
WA_POACCOUNTX-SERIAL_NO = 01.
WA_POACCOUNTX-QUANTITY = 'X'.
WA_POACCOUNTX-GL_ACCOUNT = 'X'.
WA_POACCOUNTX-COSTCENTER = 'X' .
WA_POACCOUNTX-CO_AREA = 'X'.
APPEND WA_POACCOUNTX TO IT_POACCOUNTX.
CLEAR WA_POACCOUNTX.
ENDLOOP.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = ST_BAPIMEPOHEADER
POHEADERX = ST_BAPIMEPOHEADERX
POADDRVENDOR =
TESTRUN =
MEMORY_UNCOMPLETE =
MEMORY_COMPLETE =
POEXPIMPHEADER =
POEXPIMPHEADERX =
VERSIONS =
IMPORTING
EXPPURCHASEORDER =
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
RETURN = IT_RETURN
POITEM = IT_POITEM
POITEMX = IT_POITEMX
POADDRDELIVERY =
POSCHEDULE = IT_POSCHEDULE
POSCHEDULEX = IT_POSCHEDULEX
POACCOUNT = IT_POACCOUNT
POACCOUNTPROFITSEGMENT =
POACCOUNTX = IT_POACCOUNTX
POCONDHEADER =
POCONDHEADERX =
POCOND =
POCONDX =
POLIMITS =
POCONTRACTLIMITS =
POSERVICES =
POSRVACCESSVALUES =
POSERVICESTEXT =
EXTENSIONIN =
EXTENSIONOUT =
POEXPIMPITEM =
POEXPIMPITEMX =
POTEXTHEADER =
POTEXTITEM =
ALLVERSIONS =
POPARTNER =
*this is for save the porder number
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
*dispaly the results
LOOP AT IT_RETURN INTO WA_RETURN.
WRITE:/ WA_RETURN-MESSAGE,
ST_BAPIMEPOHEADER-PO_NUMBER.
ENDLOOP.
form upload_data.
data: file type rlgrap-filename.
data: IT_XCEL type table of alsmex_tabline,
WA_XCEL TYPE ALSMEX_TABLINE.
file = p_file.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '21'
i_end_row = '1'
tables
intern = IT_xcel
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
loop at IT_xcel INTO WA_XCEL.
case
WA_XCEL-COL.
when '0001'.
WA_FINAL-COMP_CODE = WA_xcel-value.
WHEN '0002'.
WA_FINAL-ITEM_INTVL = WA_XCEL-VALUE.
WHEN '0003'.
WA_FINAL-VENDOR = WA_XCEL-VALUE.
WHEN '0004'.
WA_FINAL-PMNTTRMS = WA_XCEL-VALUE.
WHEN '0005'.
WA_FINAL-PURCH_ORG = WA_XCEL-VALUE.
WHEN '0006'.
WA_FINAL-PUR_GROUP = WA_XCEL-VALUE.
WHEN '0007'.
WA_FINAL-CURRENCY = WA_XCEL-VALUE.
WHEN '0008'.
WA_FINAL-PO_ITEM = WA_XCEL-VALUE.
WHEN '0009'.
WA_FINAL-MATERIAL = WA_XCEL-VALUE.
WHEN '00010'.
WA_FINAL-PLANT = WA_XCEL-VALUE.
WHEN '00011'.
WA_FINAL-STGE_LOC = WA_XCEL-VALUE.
WHEN '00012'.
WA_FINAL-QUANTITY = WA_XCEL-VALUE.
WHEN '00013'.
WA_FINAL-TAX_CODE = WA_XCEL-VALUE.
WHEN '00014'.
WA_FINAL-ITEM_CAT = WA_XCEL-VALUE.
WHEN '00015'.
WA_FINAL-ACCTASSCAT = WA_XCEL-VALUE.
WHEN '00016'.
WA_FINAL-SCHED_LINE = WA_XCEL-VALUE.
WHEN '00017'.
WA_FINAL-DELIVERY_DATE = WA_XCEL-VALUE.
WHEN '00018'.
WA_FINAL-SERIAL_NO = WA_XCEL-VALUE.
WHEN '00019'.
WA_FINAL-GL_ACCOUNT = WA_XCEL-VALUE.
WHEN '00020'.
WA_FINAL-COSTCENTER = WA_XCEL-VALUE.
WHEN '00021'.
WA_FINAL-CO_AREA = WA_XCEL-VALUE.
ENDCASE.
at end of row.
append WA_FINAL TO IT_FINAL.
clear WA_FINAL.
endat.
ENDLOOP.
ENDFORM. -
Creating automatically "OracleBI Spreadsheet Add-In" files (Excel files)
I have the necessity of create automatically an excel file with a query to a multidimensional model (ROLAP Cube). It exists any API for a programation language that makes easy this process of creation?
How "OracleBI Spreadsheet Add-In" saves the metadata in the excel file, for example, the information about the database (host name, database name), dimensions and measures selected by the user when a query is made with the "Query Builder"?
It is possible to share any information about this subject?
Thanks!!!
Rui TorresI exported to xml an excel file with a query, that was produced by the âQuery Builderâ, and it is true that the metadata that contains the information about the database, dimensions and measures selected, is specified in xml and is stored in hidden sheets.
My problem is not to create an excel file (create sheets, write in the cells,...) because it exists some apis that do this kind of operations.
My difficulty, is to produce the xml metadata, that is defined by Oracle, and contains the information that is used by "OracleBI Spreadsheet Add-In" to put the data in the cells of an excel sheet.
What I want to know is, for example, if exists any kind of function that receives the name of the host, the name of the database, the owner of the cube, the cube name and all the options that we can choose in the âQuery Builderâ (measures and dimensions that we want, the disposition of the dimensions - layout), and return a String with the Oracleâs xml metadata.
With this xml metadata that is returned, I am prepared to create an excel file, that have the functionality of to connect to a database, and get the data that is stored in it.
Thanks!!!
Rui Torres
Maybe you are looking for
-
Need some clarification in the following programs
Hi ABAPers I am learning ABAP programming. I am having some doubts in some programs which are there in the book TEACH YOURSELF ABAP/4 in 21 Days. I hope you will clear all my doubts 1) when I execute this program it is giving me error message and
-
Can see the wifi network but can't connect to the internet
Hi all! I've begun using a new ISP a few days ago, and while my desktop pc works just fine (ethernet), I seemed not to be able to connect to internet with my mac (either ethernet or wifi) even if I could see the wireless network. I thought it was an
-
Help Problems after 10.4.5 Update
I applied the OS 10.4.5 Combo update and everything seems fine, except the help system seems broken. In the finder, I click on help and often a blank box appears. Sometimes the initial menu appears but I can't go further. I've repaired permissions an
-
The best way to implement graphics for a monopoly game
Hello, I am implementing the graphics for a simple Monopoly game. I am currently creating a subclass of Canvas for drawing the board but when I repaint the canvas multiple times, you can clearly see the canvas repaint (a white area quickly flashs up
-
Hi all, I have a question about the performance of the UCCX 7.0(1) SR05_Buil504. (Package: Cisco Unified CCX Premium) How many calls can this version handle? (calls per hour or day) How many agents can work with the agent desktop? (at the same time)