OLE2 error.
hi all
i want to import data from excel to form but it is showing me error frm-40735.please anyone can check my code?
i have 18 rows
and 14 cols
its in tabular form.
here is the code please check it where is the error?
PROCEDURE XLS IS
BEGIN
DECLARE
application OLE2.OBJ_TYPE;
workbooks OLE2.OBJ_TYPE;
workbook OLE2.OBJ_TYPE;
worksheets OLE2.OBJ_TYPE;
worksheet OLE2.OBJ_TYPE;
cell OLE2.OBJ_TYPE;
args OLE2.OBJ_TYPE;
ctr NUMBER(12);
cols NUMBER(2);
name_var1 VARCHAR2(2000);
name_var2 VARCHAR2(2000);
name_var3 VARCHAR2(2000);
name_var4 VARCHAR2(2000);
name_var5 varchar2(2000);
name_var6 varchar2(2000);
name_var7 varchar2(2000);
name_var8 varchar2(2000);
name_var9 varchar2(2000);
name_var10 varchar2(2000);
name_var11 varchar2(2000);
name_var12 varchar2(2000);
name_var13 varchar2(2000);
name_var14 varchar2(2000);
name_var15 varchar2(2000);
name_var16 varchar2(2000);
name_var17 varchar2(2000);
name_var18 varchar2(2000);
filename varchar2(100);
PROCEDURE OLEARG IS
args OLE2.OBJ_TYPE;
BEGIN
args := OLE2.CREATE_ARGLIST;
ole2.add_arg(args,ctr); -- row value
ole2.add_arg(args,cols); -- column value
cell := ole2.GET_OBJ_PROPERTY(worksheet,'Cells',args); -- initializing cell
ole2.destroy_arglist(args);
END;
BEGIN
CLEAR_BLOCK(NO_VALIDATE);
filename :='C:\TRAVEL EXECL FORMAT NEEDED.XLS';--GET_FILE_NAME('c:\', File_Filter=>'Excel Files (*.xls)|*.xls|'); -- to pick the file
application := OLE2.CREATE_OBJ('Excel.Application');
ole2.set_property(application,'Visible','FALSE');
workbooks := OLE2.GET_OBJ_PROPERTY(application, 'Workbooks');
args := OLE2.CREATE_ARGLIST;
ole2.add_arg(args,filename); --'c:\13s002.xls'); -- file path and name
workbook := ole2.GET_OBJ_PROPERTY(workbooks,'Open',args);
ole2.destroy_arglist(args);
args := OLE2.CREATE_ARGLIST;
ole2.add_arg(args,'Sheet1');
worksheet := ole2.GET_OBJ_PROPERTY(workbook,'Worksheets',args);
ole2.destroy_arglist(args);
ctr := 2; --row number
cols := 1; -- column number
FIRST_RECORD;
LOOP
OLEARG;
--get_char_property FOR VARCHAR
--get_num_property FOR NUMBER
name_var1 := ole2.get_char_property(cell,'Value'); --cell value of the argument
cols := cols+1;
OLEARG;
name_var2 := ole2.get_char_property(cell,'Value'); --cell value of the argument
cols := cols+1;
OLEARG;
name_var3 := ole2.get_char_property(cell,'Value'); --cell value of the argument
cols := cols+1;
OLEARG;
name_var4 := ole2.get_char_property(cell,'Value'); --cell value of the argument
cols := cols+1;
OLEARG;
name_var6 := ole2.get_char_property(cell,'Value'); --cell value of the argument
cols := cols+1;
OLEARG;
name_var7 := ole2.get_char_property(cell,'Value'); --cell value of the argument
cols := cols+1;
OLEARG;
name_var8 := ole2.get_char_property(cell,'Value'); --cell value of the argument
cols := cols+1;
OLEARG;
name_var9 := ole2.get_char_property(cell,'Value'); --cell value of the argument
cols := cols+1;
OLEARG;
name_var10 := ole2.get_char_property(cell,'Value'); --cell value of the argument
cols := cols+1;
OLEARG;
name_var12 := ole2.get_char_property(cell,'Value'); --cell value of the argument
cols := cols+1;
OLEARG;
name_var13 := ole2.get_char_property(cell,'Value'); --cell value of the argument
cols := cols+1;
OLEARG;
name_var14 := ole2.get_char_property(cell,'Value'); --cell value of the argument
cols := cols+1;
OLEARG;
name_var16 := ole2.get_char_property(cell,'Value'); --cell value of the argument
cols := cols+1;
OLEARG;
name_var17 := ole2.get_char_property(cell,'Value'); --cell value of the argument
cols := cols+1;
OLEARG;
name_var18 := ole2.get_char_property(cell,'Value'); --cell number value of the argument
EXIT WHEN name_var1 is null;--length(name_var1) = 0 or length(name_var1) is null;
IF ctr = 1 then
:policy_year:=name_var1;
:policy_no:=name_var2;
:Customer_name:=name_var3;
:passport_no:=name_var4;
:date_of_birth:=name_var5;
:age:=name_var6;
:address:=name_var7;
:mobile_no:=name_var8;
:issue_date:=name_var9;
:branch:=name_var10;
:agent_code:=name_var11;
:gross_premium :=name_var12;
:valid_from_date :=name_var13;
:valid_to_date :=name_var14;
:period :=name_var15;
:travel_origin:=name_var16;
:pay_status :=name_var17;
:area :=name_var18;
NULL;
ELSE
:policy_year:=name_var1;
:policy_no:=name_var2;
:Customer_name:=name_var3;
:passport_no:=name_var4;
:date_of_birth:=name_var5;
:age:=name_var6;
:address:=name_var7;
:mobile_no:=name_var8;
:issue_date:=name_var9;
:branch:=name_var10;
:agent_code:=name_var11;
:gross_premium :=name_var12;
:valid_from_date :=name_var13;
:valid_to_date :=name_var14;
:period :=name_var15;
:travel_origin:=name_var16;
:pay_status :=name_var17;
:area :=name_var18;
NEXT_RECORD;
END IF;
SYNCHRONIZE;
ctr := ctr + 1;
cols := 1;
END LOOP;
DELETE_RECORD;
FIRST_RECORD;
OLE2.INVOKE(application,'Quit');
OLE2.RELEASE_OBJ(cell);
OLE2.RELEASE_OBJ(worksheet);
--OLE2.RELEASE_OBJ(worksheets);
OLE2.RELEASE_OBJ(workbook);
--OLE2.RELEASE_OBJ(workbooks);
OLE2.RELEASE_OBJ(application);
END;
END;prompt answer will be greatly appreciated
thanks in advance.
sarah
HI
JOHN.
where should i make changes in excel or in form code?
can u guide me more?
i tried the code something like this but did not give me correct result.
here is the code.
PROCEDURE sarah IS
application OLE2.OBJ_TYPE;
workbooks OLE2.OBJ_TYPE;
workbook OLE2.OBJ_TYPE;
worksheets OLE2.OBJ_TYPE;
worksheet OLE2.OBJ_TYPE;
cell OLE2.OBJ_TYPE;
cellType OLE2.OBJ_TYPE;
args OLE2.OBJ_TYPE;
ctr number := 1;
cols number := 1;
maxColumns number := 18;
MyString VARCHAR2(2000) := 'null';
MyNumber NUMBER;
cell_value_date DATE;
filename varchar2(2000);
BEGIN
go_block('hus');
CLEAR_BLOCK(NO_VALIDATE);
first_record;
go_item('policy_year');
filename :='C:\CHECK11.XLS';--GET_FILE_NAME('c:\', File_Filter=>'Excel Files (*.xls)|*.xls|'); -- to pick the file
application := OLE2.CREATE_OBJ('Excel.Application');
ole2.set_property(application,'Visible','FALSE');
workbooks := OLE2.GET_OBJ_PROPERTY(application, 'Workbooks');
args := OLE2.CREATE_ARGLIST;
ole2.add_arg(args,filename); --'c:\13s002.xls'); -- file path and name
workbook := ole2.GET_OBJ_PROPERTY(workbooks,'Open',args);
ole2.destroy_arglist(args);
args := OLE2.CREATE_ARGLIST;
ole2.add_arg(args,'Sheet1');
worksheet := ole2.GET_OBJ_PROPERTY(workbook,'Worksheets',args);
ole2.destroy_arglist(args);
While (MyString is not null)
loop
args := OLE2.CREATE_ARGLIST;
ole2.add_arg(args,ctr); -- row value
ole2.add_arg(args,cols); -- column value
cell := ole2.GET_OBJ_PROPERTY(worksheet,'Cells',args); -- initializing cell
ole2.destroy_arglist(args);
if cols in(1,4,6,8,10,11,12,15,17,18, /*for dates*/ 5, 9, 13, 14) then
MyString := ole2.get_num_property(cell,'Value'); --cell value of the argument
else
--MyString := ole2.get_char_property(cell,'Value'); --cell value of the argument
cell_value_date := to_date('01/01/1900', 'DD/MM/YYYY') + ole2.get_num_property(cell, 'Value') - 2;
end if;
--check the value of date format
/*if cols in(5, 9, 13, 14) then
copy(to_char(to_date(Mystring,'DDMMRRRR'),'DD-MON-RRRR'), :system.cursor_item);
else */
copy(MyString, :system.cursor_item);
-- end if;
cols := cols + 1;
next_item;
if cols >= maxColumns then
ctr := ctr + 1;
cols := 1;
next_record;
go_item('policy_year');
end if;
end loop;
-- DELETE_RECORD;
FIRST_RECORD;
OLE2.INVOKE(application,'Quit');
OLE2.RELEASE_OBJ(cell);
OLE2.RELEASE_OBJ(worksheet);
OLE2.RELEASE_OBJ(workbook);
OLE2.RELEASE_OBJ(application);
exception when others then
message(sqlerrm);
END;sarah
sarah
Similar Messages
-
OLE2 error in Forms 6i.
Hello All,
I am using forms 6i and database 9i and Office 2007.
When I am trying to import data from a excel file to the database using forms 6i OLE2 I am not getting the proper data. For example,
I have excel data as below.
EMPID ACC_NO PP_ID -- All are fields are declared as varahcr2 in the database. But in the excel other then empid all the fields are as number like below.
EM001 1000121 10000101
EM002 0213322 20100212
When I am uploading the data, it is taking the EMPID as correct data but the other two fields are taking as first charector like
EM001 1 1
EM002 0 2
Any suggestion on it.
Thanks,
SUNHi,
After converting to the text I am getting the error ORA-01403, No data found.
And if I am not converting to the text I am not getting any error.
My code is like below.
<code>
FUNCTION LF_EMP_ACC_UPDATE(P_PATH_FILE VARCHAR2) RETURN BOOLEAN IS
/* EXCEL -> FORMS */
APPLICATION OLE2.OBJ_TYPE;
WORKBOOKS OLE2.OBJ_TYPE;
WORKBOOK OLE2.OBJ_TYPE;
WORKSHEETS OLE2.OBJ_TYPE;
WORKSHEET OLE2.OBJ_TYPE;
CELL OLE2.OBJ_TYPE;
ARGS OLE2.LIST_TYPE;
LN_CNT NUMBER(10) := 0;
LN_ROW NUMBER(5) := 0;
LN_COL NUMBER(5) := 0;
LN_QTY NUMBER(20,3) := 0;
LV_STATUS VARCHAR2(500);
err_code BINARY_INTEGER;
err_text VARCHAR2(255);
LV_EMPID VARCHAR2(20);
LV_PAYROLL_ID VARCHAR2(20);
LV_VHM_EMP_CODE VHM_EMPLOYEE.VHM_EMP_CODE%TYPE;
LV_VHM_EMP_NOK_PHONE VHM_EMPLOYEE.VHM_EMP_NOK_PHONE%TYPE;
LV_VHM_EMP_PAY_MODE VHM_EMPLOYEE.VHM_EMP_PAY_MODE%TYPE;
LV_VHM_EMP_BANK_CODE VHM_EMPLOYEE.VHM_EMP_BANK_CODE%TYPE;
LV_VHM_EMP_BANK_AC_NO VHM_EMPLOYEE.VHM_EMP_BANK_AC_NO%TYPE;
PROD_CODE_CHK VARCHAR2(40);
NUM NUMBER:=0;
BEGIN
APPLICATION := OLE2.CREATE_OBJ('EXCEL.APPLICATION');
WORKBOOKS := OLE2.GET_OBJ_PROPERTY(APPLICATION,'WORKBOOKS');
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,P_PATH_FILE);
WORKBOOK := OLE2.INVOKE_OBJ(WORKBOOKS,'OPEN',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,'SHEET1');
WORKSHEET := OLE2.GET_OBJ_PROPERTY(WORKBOOK,'WORKSHEETS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
-- This procedure is run last 16-aug-2007 fro updation ROL And ROQ
DISPLAY_ME('DO YOU WANT TO UPDATE EMPLOYEE MASTER OLD');
LN_ROW := 1;
LOOP
-- To reset Variable
LV_EMPID :=NULL;
LV_PAYROLL_ID :=NULL;
LV_VHM_EMP_CODE :=NULL;
LV_VHM_EMP_NOK_PHONE :=NULL;
LV_VHM_EMP_PAY_MODE :=NULL;
LV_VHM_EMP_BANK_CODE :=NULL;
LV_VHM_EMP_BANK_AC_NO :=NULL;
LN_ROW := LN_ROW+1;
LN_COL := 1;
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,LN_ROW);
OLE2.ADD_ARG(ARGS,LN_COL);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
LV_VHM_EMP_CODE := OLE2.GET_CHAR_PROPERTY(CELL,'VALUE');
OLE2.RELEASE_OBJ(CELL);
--EXIT WHEN LV_VHM_EMP_CODE IS NULL;
EXIT WHEN LN_ROW >= 555;
LN_COL := 2;
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,LN_ROW);
OLE2.ADD_ARG(ARGS,LN_COL);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
LV_VHM_EMP_NOK_PHONE := OLE2.GET_CHAR_PROPERTY(CELL,'VALUE');
OLE2.RELEASE_OBJ(CELL);
LN_COL := 3;
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,LN_ROW);
OLE2.ADD_ARG(ARGS,LN_COL);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
LV_VHM_EMP_PAY_MODE := OLE2.GET_CHAR_PROPERTY(CELL,'VALUE');
OLE2.RELEASE_OBJ(CELL);
LN_COL := 4;
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,LN_ROW);
OLE2.ADD_ARG(ARGS,LN_COL);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
LV_VHM_EMP_BANK_CODE := OLE2.GET_CHAR_PROPERTY(CELL,'VALUE');
OLE2.RELEASE_OBJ(CELL);
LN_COL := 5;
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,LN_ROW);
OLE2.ADD_ARG(ARGS,LN_COL);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
LV_VHM_EMP_BANK_AC_NO := OLE2.GET_CHAR_PROPERTY(CELL,'VALUE');
OLE2.RELEASE_OBJ(CELL);
:F_DISP := 'EMPLOYEE ID - '||LV_VHM_EMP_CODE;
SYNCHRONIZE;
IF LV_VHM_EMP_CODE IS NOT NULL THEN
IF LN_ROW >= 1 AND LN_ROW <= 5 THEN
MESSAGE('EMP CODE :- '||LV_VHM_EMP_CODE);
MESSAGE('EMP EMPLOYEE ID :- '||LV_VHM_EMP_NOK_PHONE);
MESSAGE('EMP PAY MODE :- '||LV_VHM_EMP_PAY_MODE);
MESSAGE('EMP BANK CODE :- '||LV_VHM_EMP_BANK_CODE);
MESSAGE('EMP ACCOUNT NO :- '||LV_VHM_EMP_BANK_AC_NO);
END IF;
UPDATE VHM_EMPLOYEE_OLD SET
VHM_EMP_NOK_PHONE = LV_VHM_EMP_NOK_PHONE,
VHM_EMP_PAY_MODE = LV_VHM_EMP_PAY_MODE,
VHM_EMP_BANK_CODE = LV_VHM_EMP_BANK_CODE,
VHM_EMP_BANK_AC_NO = LV_VHM_EMP_BANK_AC_NO,
VHM_EMP_EMAIL_ID = 'UPD'
WHERE VHM_EMP_CODE = LV_VHM_EMP_CODE ;
insert into vhm_emp_test (VHM_EMP_CODE,
VHM_EMP_NOK_PHONE,
VHM_EMP_PAY_MODE ,
VHM_EMP_BANK_CODE ,
VHM_EMP_BANK_AC_NO ,
VHM_EMP_EMAIL_ID ) values ( LV_VHM_EMP_CODE, LV_VHM_EMP_NOK_PHONE,
LV_VHM_EMP_PAY_MODE, LV_VHM_EMP_BANK_CODE,
LV_VHM_EMP_BANK_AC_NO, null);
END IF;
COMMIT;
END LOOP;
OLE2.INVOKE(APPLICATION,'QUIT');
OLE2.RELEASE_OBJ(WORKSHEET);
OLE2.RELEASE_OBJ(WORKBOOK);
OLE2.RELEASE_OBJ(WORKBOOKS);
OLE2.RELEASE_OBJ(APPLICATION);
IF FORM_SUCCESS THEN
LV_STATUS := 'Update Completed';
END IF;
RETURN TRUE;
EXCEPTION
WHEN OLE2.OLE_ERROR THEN
ROLLBACK;
err_code := olepack.get_err(err_text);
DISPLAY_ME('Invalid File Eror Code:' || err_code || ': ' || err_text||', Program Aborted');
-- P_STATUS := 'Invalid File Eror Code:' || err_code || ': ' || err_text||', Program Aborted';
OLE2.INVOKE(APPLICATION,'QUIT');
OLE2.RELEASE_OBJ(WORKSHEET);
OLE2.RELEASE_OBJ(WORKBOOK);
OLE2.RELEASE_OBJ(WORKBOOKS);
OLE2.RELEASE_OBJ(APPLICATION);
RETURN FALSE;
WHEN OTHERS THEN
ROLLBACK;
DISPLAY_ME('When other errors- '||DBMS_ERROR_CODE || ': ' || DBMS_ERROR_TEXT);
OLE2.INVOKE(APPLICATION,'QUIT');
OLE2.RELEASE_OBJ(WORKSHEET);
OLE2.RELEASE_OBJ(WORKBOOK);
OLE2.RELEASE_OBJ(WORKBOOKS);
OLE2.RELEASE_OBJ(APPLICATION);
-- P_STATUS := 'Program Aborted,Exception : '||SQLERRM;
RETURN FALSE;
END LF_EMP_ACC_UPDATE;
</code>
Any suggestion on it.
Thanks,
SUN -
Ole2 error when reading excel from form 6i
APPLICATION OLE2.OBJ_TYPE;
WORKBOOKS OLE2.OBJ_TYPE;
WORKBOOK OLE2.OBJ_TYPE;
WORKSHEETS OLE2.OBJ_TYPE;
WORKSHEET OLE2.OBJ_TYPE;
CELL OLE2.OBJ_TYPE;
SROW NUMBER:=0;
COL NUMBER:=0;
CELLVALUE VARCHAR2(89);
V_RC_1 VARCHAR2(1000); -- TRANSACTION DATE
V_RC_2 VARCHAR2(1000); -- STORE #
V_RC_3 VARCHAR2(1000); -- INVOICE #
V_RC_4 VARCHAR2(1000); -- CASES SOLD
V_RC_5 VARCHAR2(1000);
V_RC_6 VARCHAR2(1000);
ARGS OLE2.OBJ_TYPE;
BEGIN
:STIME := TO_CHAR(SYSDATE, 'HH:MI:SS');
SYNCHRONIZE;
--------------INITIATE EXCEL APPLICATION---------------------------
APPLICATION := OLE2.CREATE_OBJ('EXCEL.APPLICATION');
OLE2.SET_PROPERTY(APPLICATION,'VISIBLE','TRUE');
----------------GET WORKBOOKS FROM EXCEL APPLICATION---------------
WORKBOOKS := OLE2.GET_OBJ_PROPERTY(APPLICATION, 'WORKBOOKS');
----------------OPEN REQUIRED WORKBOOK-----------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,:VFILE);
WORKBOOK := OLE2.GET_OBJ_PROPERTY(WORKBOOKS,'OPEN',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
----------------OPEN REQUIRED WORKSHEET---------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,1);
WORKSHEET := OLE2.GET_OBJ_PROPERTY(WORKBOOK,'WORKSHEETS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
----------------GET CELL VALUE-------------------------------------
LOOP
SROW := SROW+1;
-----------------------COLUMN1-------------------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,SROW);
OLE2.ADD_ARG(ARGS,1);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
ARGS := OLE2.CREATE_ARGLIST;
V_RC_1 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
-----------------------COLUMN2-------------------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,SROW);
OLE2.ADD_ARG(ARGS,2);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
ARGS := OLE2.CREATE_ARGLIST;
V_RC_2 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
-----------------------COLUMN3-------------------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,SROW);
OLE2.ADD_ARG(ARGS,3);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
ARGS := OLE2.CREATE_ARGLIST;
V_RC_3 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
-----------------------COLUMN4-------------------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,SROW);
OLE2.ADD_ARG(ARGS,4);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
ARGS := OLE2.CREATE_ARGLIST;
V_RC_4 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
-----------------------COLUMN5-------------------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,SROW);
OLE2.ADD_ARG(ARGS,5);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
ARGS := OLE2.CREATE_ARGLIST;
V_RC_5 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
-----------------------COLUMN6-------------------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,SROW);
OLE2.ADD_ARG(ARGS,6);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
ARGS := OLE2.CREATE_ARGLIST;
V_RC_6 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
IF SROW >8 THEN
EXIT;
END IF;
---------------INSERT THE VALUE IN THE TABLE ---------------------
INSERT INTO EMP VALUES(V_RC_1,V_RC_2,V_RC_3,V_RC_4,V_RC_5,V_RC_6);
END LOOP;
--END LOOP;
COMMIT;
----------------CLOSE THE EXCEL SHEET AFTER READING--------------
OLE2.INVOKE(APPLICATION,'QUIT');
-----------------RELEASE ALL OBJECTS -----------------------------
OLE2.RELEASE_OBJ(CELL);
OLE2.RELEASE_OBJ(WORKSHEET);
OLE2.RELEASE_OBJ(WORKBOOK);
OLE2.RELEASE_OBJ(WORKBOOKS);
OLE2.RELEASE_OBJ(APPLICATION);
:MESSAGE := 'DATA INSERTED INTO THE TABLE '; SYNCHRONIZE;
:ETIME := TO_CHAR(SYSDATE, 'HH:MI:SS');
SYNCHRONIZE;
END;Hi Kundi,
by this time you might have solve your problem.
If not, in your case,
This could be you or user is closing the "Excel" application just appearing in front of there screen.
To solve this replace the following line with the new line of code in your application:
OLE2.SET_PROPERTY(APPLICATION,'VISIBLE','TRUE');
with
OLE2.SET_PROPERTY(APPLICATION,'VISIBLE','FALSE');
Hope this will solve the problem.
Regards,
Tarun
Edited by: Tarun.Oracle on Nov 9, 2012 12:44 PM
Edited by: Tarun.Oracle on Nov 9, 2012 12:45 PM -
No jacob in java.library.path.doc
I am running Developer Suite 10g on Windows XP. I have the OC4J instance running. I am using WebUtil and trying to use the OLE2 stuff. When I execute the code, nothing happens (see errors below) except all my buttons go dead. I checked, and it does not seem that I am getting the Jacob, JNIsharedstubs, and the d2kwut60 DLLs to download to my Jinitiator directory. I removed and reinstalled Jinitiator, but still nothing. If I manually copy the DLLs to the directory, I at least begin to get OLE2 errors. I read the message board (and modified Word.Basic to Word.Application) and read the WebUtil manual and reviewed my set-up. Any suggestions are much appreciated.
Java console:
Oracle JInitiator: Version 1.3.1.17
Using JRE version 1.3.1.17-internal Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\don4
Proxy Configuration: Automatic Proxy Configuration
JAR cache enabled
Location: C:\Documents and Settings\don4\Oracle Jar Cache
Maximum size: 50 MB
Compression level: 0
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
q: hide console
s: dump system properties
t: dump thread list
x: clear classloader cache
0-5: set trace level to <n>
Downloading http://d26.corp.don.com:8889/forms90/java/f90all_jinit.jar to JAR cache
Downloading http://d26.corp.don.com:8889/forms90/webutil/webutil.jar to JAR cache
RegisterWebUtil - Loading Webutil Version 1.0.2 Beta
Downloading http://d26.corp.don.com:8889/forms90/webutil/jacob.jar to JAR cache
proxyHost=null
proxyPort=0
connectMode=HTTP, native.
Forms Applet version is : 9.0.4.0
2004-Jun-18 14:33:28.903 WUI[VBeanCommon.findLocalHost()] obtaining LocalHost info from InetAddress
2004-Jun-18 14:33:28.953 WUF[VBeanCommon.findLocalHost()] obtaining LocalHost info from InetAddress
2004-Jun-18 14:33:28.983 WUH[VBeanCommon.findLocalHost()] obtaining LocalHost info from InetAddress
2004-Jun-18 14:33:29.13 WUS[VBeanCommon.findLocalHost()] obtaining LocalHost info from InetAddress
2004-Jun-18 14:33:29.53 WUT[VBeanCommon.findLocalHost()] obtaining LocalHost info from InetAddress
2004-Jun-18 14:33:29.214 WUO[VBeanCommon.findLocalHost()] obtaining LocalHost info from InetAddress
2004-Jun-18 14:33:29.254 WUL[VBeanCommon.findLocalHost()] obtaining LocalHost info from InetAddress
2004-Jun-18 14:33:29.284 WUB[VBeanCommon.findLocalHost()] obtaining LocalHost info from InetAddress
2004-Jun-18 14:33:34.745 WUT[setProperty()] Setting property WUC_GET_LOCAL_PROPERTY to syslib.jacob.dll
2004-Jun-18 14:33:34.785 WUT[getProperty()] Getting property WUC_GET_LOCAL_PROPERTY
2004-Jun-18 14:33:34.815 WUT[loadSettings()] Local properties file loaded
2004-Jun-18 14:33:34.855 WUT[setProperty()] Setting property WUC_GET_LOCAL_PROPERTY to syslib.JNIsharedstubs.dll
2004-Jun-18 14:33:34.895 WUT[getProperty()] Getting property WUC_GET_LOCAL_PROPERTY
2004-Jun-18 14:33:34.926 WUT[setProperty()] Setting property WUC_GET_LOCAL_PROPERTY to syslib.d2kwut60.dll
2004-Jun-18 14:33:34.976 WUT[getProperty()] Getting property WUC_GET_LOCAL_PROPERTY
2004-Jun-18 14:33:49.722 WUF[setProperty()] Setting property WUF_FILENAME to C:\temp
2004-Jun-18 14:33:49.722 WUF[setProperty()] Setting property WUF_FILE_ATTRIBUTE to 1
2004-Jun-18 14:33:49.722 WUF[getProperty()] Getting property WUF_FILE_ATTRIBUTE
2004-Jun-18 14:33:49.742 WUF[setProperty()] Setting property WUF_FILENAME to C:\temp
2004-Jun-18 14:33:49.742 WUF[setProperty()] Setting property WUF_FILE_ATTRIBUTE to 4
2004-Jun-18 14:33:49.742 WUF[getProperty()] Getting property WUF_FILE_ATTRIBUTE
2004-Jun-18 14:33:49.752 WUF[setProperty()] Setting property WUF_GFN_DIRNAME to C:\temp
2004-Jun-18 14:33:49.772 WUF[setProperty()] Setting property WUF_FILENAME to *.csv
2004-Jun-18 14:33:49.772 WUF[setProperty()] Setting property WUF_FILTER to All CSV Files (*.csv)|*.csv|
2004-Jun-18 14:33:49.792 WUF[setProperty()] Setting property WUF_GFN_MESSAGE to Open Interface Import File
2004-Jun-18 14:33:49.822 WUF[setProperty()] Setting property WUF_GFN_MULTISELECT to FALSE
2004-Jun-18 14:33:49.822 WUF[getProperty()] Getting property WUF_GFN_OPENFILE
2004-Jun-18 14:33:52.904 WUF[setProperty()] Setting property WUF_FILENAME to false
2004-Jun-18 14:33:52.904 WUF[setProperty()] Setting property WUF_FILE_ATTRIBUTE to 4
2004-Jun-18 14:33:52.904 WUF[getProperty()] Getting property WUF_FILE_ATTRIBUTE
2004-Jun-18 14:33:52.914 WUF[setProperty()] Setting property WUF_FILENAME to false
2004-Jun-18 14:33:52.914 WUF[setProperty()] Setting property WUF_FILE_ATTRIBUTE to 1
2004-Jun-18 14:33:52.914 WUF[getProperty()] Getting property WUF_FILE_ATTRIBUTE
2004-Jun-18 14:33:52.924 WUF[setProperty()] Setting property WUF_FILENAME to false
2004-Jun-18 14:33:52.924 WUF[setProperty()] Setting property WUF_FILE_ATTRIBUTE to 2
2004-Jun-18 14:33:52.934 WUF[getProperty()] Getting property WUF_FILE_ATTRIBUTE
2004-Jun-18 14:34:00.212 WUO[setProperty()] Setting property WUO_OLE2_OBJNAME to WORD.Basic
2004-Jun-18 14:34:00.222 WUO[getProperty()] Getting property WUO_OLE2_CREATE_OBJ
Exception occurred during event dispatching:
java.lang.UnsatisfiedLinkError: no jacob in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.jacob.com.Dispatch.<clinit>(Dispatch.java)
at oracle.forms.webutil.ole.OleFunctions.create_obj(OleFunctions.java:513)
at oracle.forms.webutil.ole.OleFunctions.getProperty(OleFunctions.java:218)
at oracle.forms.handler.UICommon.onGet(Unknown Source)
at oracle.forms.engine.Runform.onGetHandler(Unknown Source)
at oracle.forms.engine.Runform.processMessage(Unknown Source)
at oracle.forms.engine.Runform.processSet(Unknown Source)
at oracle.forms.engine.Runform.onMessageReal(Unknown Source)
at oracle.forms.engine.Runform.onMessage(Unknown Source)
at oracle.forms.engine.Runform.processEventEnd(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.redispatchEvent(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
J:\WebUtil\server\WebUtil.cfg file contains:
install.syslib.location=http://d26.corp.don.com:8889/forms90/webutil
install.syslib.0.7.1=jacob.dll|94208|1.0|true
install.syslib.0.9.1=JNIsharedstubs.dll|65582|1.0|true
install.syslib.0.9.2=d2kwut60.dll|192512|1.0|true
C:\Oracle\10iDS2\forms90\server\default.env contains:
ORACLE_HOME=c:\oracle\10iDS2
FORMS90_PATH=c:\oracle\10iDS2\cgenf61\admin;c:\oracle\10iDS2\forms90;c:\ipms\forms10g;j:\WebUtil\forms;j:\WebUtil\lib;j:\bin10g
PATH=c:\oracle\10iDS2\bin;c:\oracle\10iDS2\jdk\jre\bin\client
FORMS90=c:\oracle\10iDS2\forms90
WEBUTIL_CONFIG=j:\webutil\server\webutil.cfg
CLASSPATH=j:\webutil\lib\webutil.jar;j:\webutil\lib\jacob.jar;c:\oracle\10iDS2\jdk\jre\lib\rt.jar;c:\oracle\10iDS2\j2ee\forms90app\forms90web\WEB-INF\lib\f90srv.jar;c:\oracle\10iDS2\jlib\repository.jar;c:\oracle\10iDS2\jlib\ldapjclnt9.jar;c:\oracle\10iDS2\jlib\debugger.jar;c:\oracle\10iDS2\jlib\ewt3.jar;c:\oracle\10iDS2\jlib\share.jar;c:\oracle\10iDS2\jlib\utj90.jar;c:\oracle\10iDS2\jlib\zrclient.jar;c:\oracle\10iDS2\reports\jlib\rwrun.jar;C:\Oracle\10iDS2\jdk\jre\bin\client\jvm.dll
Orion-web.xml contains:
<virtual-directory virtual-path="/webutil" real-path="j:\webutil\lib" />
Forms90.conf contains:
# Virtual path for webutil
AliasMatch ^/forms90/webutil/(..*) "j:\webutil\lib/$1"
Formsweb.cfg has all changes in one named section:
[webutil]
pageTitle=Oracle9iAS Forms Services - WebUtil
webUtilArchive=/forms90/webutil/webutil.jar,/forms90/webutil/jacob.jar
WebUtilLogging=all
WebUtilLoggingDetail=detail
WebUtilErrorMode=Alert
baseHTMLjinitiator=j:\webutil\server\webutiljini.htm>
Orion-web.xml contains:
<virtual-directory virtual-path="/webutil"
real-path="j:\webutil\lib" />
Forms90.conf contains:
# Virtual path for webutil
AliasMatch ^/forms90/webutil/(..*)
"j:\webutil\lib/$1"
I'm not sure about 10G, but for 9ids this is definitely wrong (see famous page 6 of 49 WebUtil Manual). On 9ids you have to add the virtual directory in orion-web.xml only, not in forms90.conf. On 9ias it is vice verca.
Hope this helps
Gerald -
Hi
I've created a report using Oracle Reports 6 and it was working fine and all of a sudden I couldn't run or edit it
and the following message is shown
REP-4004: Error occurred while restoring OLE object.
It has an OLE object but what does that mean?
I've searched in google and in this forum but couldn't find a solution
I've looked in the help menu for that rep-4004 and that was it:
Cause: You were attempting to restore an OLE2 object when an OLE error occurred.
Action: Refer to the accompanying OLE2 error message for more information.
but didn't know how to fix it, please could any one help me our work in my office is depending on this application with its reports, so we are stuck now because of that strange error
ThanksI found another thread in this forum regarding this error:
Attention!!-don't use OLE object in Reports
some suggestions after little bit googling:
- use rdf format for reports
- rebuild report from older version (hope you have archives or using version control)
- if the OLE object is an image, try remove it first and run the report again. Maybe try jpeg instead. -
Outlook 2010 is not opened via OLE2 ABAP program, error is raised
I would like to start Outlook 2010 from an ABAP report, create an email and attach .pdf and .csv files to it. When I try to execute the following code I get a subrc = 2:
CREATE OBJECT outlookapp 'Outlook.Application'.
I have found 'SAP Knowledge Base Article 1570573 - Rich Client throws email error on Windows 7 with Outlook 2007 and Outlook 2010' but this didn't help me solve my problem.
In previous versions of Outlook this piece of code did work.
I'm using Windows7 64 bit with Outlook 2010 32 bit.
ECC Backend:
SAP_BASIS 700 0018 SAPKB70018
SAP_ABA 700 0018 SAPKA70018
best regards,
Roelof JanHi Roelof Jan,
I'm facing the same problem. Did you find any solution for this?
Regards
Manuel -
Error on bapi_acc_document_post
Hi experts,
when i executing this bapi_acc_document_post, am getting error " FI/CO interface: Line item entered several times" i mention code below so please give me suggestion.
*& Report ZSAMPLE
REPORT ZSAMPLE.
data: BEGIN OF WA_HEADER,
ID TYPE I,
KUNNR TYPE n LENGTH 10,
INV_DATE TYPE c LENGTH 10,
PST_DATE TYPE c LENGTH 10,
REF TYPE invfo-xblnr,
AMT_DOCCUR TYPE PA2010-BETRG,
TXT(40),
END OF WA_HEADER.
DATA : IT_HEADER like WA_HEADER OCCURS 0 WITH HEADER LINE.
data: BEGIN OF WA_ITEM,
ID TYPE I,
GL_ACCOUNT TYPE n LENGTH 10,
ITEM_TEXT TYPE BAPIACGL09-ITEM_TEXT,
BUS_AREA TYPE BAPIACGL09-BUS_AREA,
AMT_DOCCUR TYPE BAPIACCR09-AMT_DOCCUR,
KOSTL TYPE CSKT-KOSTL,
* VAT(2),
END OF WA_ITEM.
DATA : IT_ITEM like WA_ITEM OCCURS 0 WITH HEADER LINE.
* value of excel-cell
TYPES: ty_d_itabvalue TYPE alsmex_tabline-value,
* internal table containing the excel data
ty_t_itab TYPE alsmex_tabline OCCURS 0,
* line type of sender table
BEGIN OF ty_s_senderline,
line(4096) TYPE c,
END OF ty_s_senderline,
* sender table
ty_t_sender TYPE ty_s_senderline OCCURS 0.
CONSTANTS: gc_esc VALUE '"'.
DATA temp_row TYPE I.
DATA TEMP(4).
INCLUDE lalsmexf01.
DATA: it_data1 TYPE ty_t_itab.
DATA: it_data2 TYPE ty_t_itab.
DATA: it_data_wa LIKE LINE OF it_data1.
DATA: it_data_wa2 LIKE LINE OF it_data1.
* DATA DECLARATION
data: st_rw_s1 TYPE i VALUE '2'.
data: st_cl_s1 TYPE i VALUE '1'.
data: st_rw_s2 TYPE i VALUE '2'.
data: st_cl_s2 TYPE i VALUE '1'.
data: ed_rw_s1 TYPE i VALUE '3'.
data: ed_cl_s1 TYPE i VALUE '7'.
data: ed_rw_s2 TYPE i VALUE '5'.
data: ed_cl_s2 TYPE i VALUE '8'.
DATA: excel_tab TYPE ty_t_sender,
excel_tab1 TYPE ty_t_sender.
DATA: ld_separator TYPE c.
DATA: application TYPE ole2_object,
workbook TYPE ole2_object,
sheet TYPE ole2_object,
range TYPE ole2_object,
worksheet TYPE ole2_object.
DATA: h_cell TYPE ole2_object,
h_cell1 TYPE ole2_object.
DATA: ld_rc TYPE i.
TYPE-POOLS ole2.
*AT SELECTION-SCREEN.
PARAMETERS: filename LIKE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
PERFORM value_help.
sTART-OF-SELECTION.
* CASE sy-ucomm .
* WHEN 'ONLI'.
PERFORM execute.
PERFORM bapi.
* ENDCASE.
* MESSAGE DEFINATION
DEFINE m_message.
case sy-subrc.
when 0.
when 1.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
when others. raise upload_ole.
endcase.
END-OF-DEFINITION.
*& Form VALUE_HELP
* text
* --> p1 text
* <-- p2 text
FORM VALUE_HELP .
CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
EXPORTING
def_filename = ' '
def_path = ' '
mask = ',*.*,*.*.'
mode = 'O'
title = ' '
IMPORTING
filename = filename
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
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. " VALUE_HELP
*& Form EXECUTE
* text
* --> p1 text
* <-- p2 text
FORM EXECUTE .
* PARAMETER CHECK
IF st_rw_s1 > ed_rw_s1.
RAISE inconsistent_parameters.
ENDIF.
IF st_cl_s1 > ed_cl_s1.
RAISE inconsistent_parameters.
ENDIF.
IF st_rw_s2 > ed_rw_s2.
RAISE inconsistent_parameters.
ENDIF.
IF st_cl_s2 > ed_cl_s2.
RAISE inconsistent_parameters.
ENDIF.
CLASS cl_abap_char_utilities DEFINITION LOAD.
ld_separator = cl_abap_char_utilities=>horizontal_tab.
* OPENING EXCEL FILE
IF application-header = space OR application-handle = -1.
CREATE OBJECT application 'Excel.Application'.
m_message.
ENDIF.
CALL METHOD OF
application
'Workbooks' = workbook.
m_message.
CALL METHOD OF
application
'Workbooks' = workbook.
m_message.
CALL METHOD OF
workbook
'Open'
EXPORTING
#1 = filename.
m_message.
CALL METHOD OF
application
'Worksheets' = sheet
EXPORTING
#1 = 1.
m_message.
CALL METHOD OF
application
'Worksheets' = sheet
EXPORTING
#1 = 1.
m_message.
CALL METHOD OF
sheet
'Activate'.
m_message.
GET PROPERTY OF application 'ACTIVESHEET' = sheet.
m_message.
* MARKING OF WHOLE SPREADSHEET
CALL METHOD OF
sheet
'Cells' = h_cell
EXPORTING
#1 = st_rw_s1
#2 = st_cl_s1.
m_message.
CALL METHOD OF
sheet
'Cells' = h_cell1
EXPORTING
#1 = ed_rw_s1
#2 = ed_cl_s1.
m_message.
CALL METHOD OF
sheet
'RANGE' = range
EXPORTING
#1 = h_cell
#2 = h_cell1.
m_message.
CALL METHOD OF
range
'SELECT'.
m_message.
* Copy marked area (SHEET1) into Clippboard
CALL METHOD OF
range
'COPY'.
m_message.
* Read clipboard into ABAP
CALL METHOD cl_gui_frontend_services=>clipboard_import
IMPORTING
data = excel_tab
EXCEPTIONS
cntl_error = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE a037(alsmex).
ENDIF.
PERFORM separated_to_intern_convert TABLES excel_tab it_data1
USING ld_separator.
* Clear the clipboard
REFRESH excel_tab.
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
data = excel_tab
CHANGING
rc = ld_rc
EXCEPTIONS
cntl_error = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4.
* Working in Second Excel Work Sheet
CALL METHOD OF
application
'Worksheets' = sheet
EXPORTING
#1 = 2.
m_message.
CALL METHOD OF
sheet
'Activate'.
m_message.
GET PROPERTY OF application 'ACTIVESHEET' = sheet.
m_message.
* Mark Sheet2
CALL METHOD OF
sheet
'Cells' = h_cell
EXPORTING
#1 = st_rw_s2
#2 = st_cl_s2.
m_message.
CALL METHOD OF
sheet
'Cells' = h_cell1
EXPORTING
#1 = ed_rw_s2
#2 = ed_cl_s2.
m_message.
CALL METHOD OF
sheet
'RANGE' = range
EXPORTING
#1 = h_cell
#2 = h_cell1.
m_message.
CALL METHOD OF
range
'SELECT'.
m_message.
* Copy Marked Area (Sheet2) into Clippboard
CALL METHOD OF
range
'COPY'.
m_message.
* Read Clipboard into ABAP
CALL METHOD cl_gui_frontend_services=>clipboard_import
IMPORTING
data = excel_tab1
EXCEPTIONS
cntl_error = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE a037(alsmex).
ENDIF.
PERFORM separated_to_intern_convert TABLES excel_tab1 it_data2
USING ld_separator.
* Clear Clipboard
REFRESH excel_tab.
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
data = excel_tab1
CHANGING
rc = ld_rc
EXCEPTIONS
cntl_error = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4
* Leaving Application
CALL METHOD OF
application
'QUIT'.
m_message.
FREE OBJECT application.
m_message.
LOOP AT it_data1 INTO it_data_wa2.
IF temp_row ne it_data_wa2-ROW AND temp_row IS NOT INITIAL.
temp_row = it_data_wa2-ROW.
APPEND IT_HEADER.
ELSE.
temp_row = it_data_wa2-ROW.
ENDIF.
CASE it_data_wa2-COL.
WHEN '0001'.
IT_HEADER-ID = it_data_wa2-VALUE.
WHEN '0002'.
IT_HEADER-KUNNR = it_data_wa2-VALUE.
WHEN '0003'.
IT_HEADER-INV_DATE = it_data_wa2-value.
WHEN '0004'.
IT_HEADER-PST_DATE = it_data_wa2-VALUE.
WHEN '0005'.
IT_HEADER-REF = it_data_wa2-VALUE.
WHEN '0006'.
IT_HEADER-AMT_DOCCUR = it_data_wa2-VALUE.
WHEN '0007'.
IT_HEADER-TXT = it_data_wa2-VALUE.
ENDCASE.
ENDLOOP.
APPEND IT_HEADER.
CLEAR:temp_row.
LOOP AT it_data2 INTO it_data_wa ."WHERE ROW = it_data_wa2-ROW.
IF temp_row ne it_data_wa-ROW AND temp_row IS NOT INITIAL.
temp_row = it_data_wa-ROW.
APPEND IT_ITEM.
ELSEIF ( temp_row NE it_data_wa-ROW AND temp_row IS INITIAL ).
temp_row = it_data_wa-ROW.
* ELSE
ENDIF.
CASE it_data_wa-COL.
WHEN '0001'.
IT_ITEM-ID = it_data_wa-VALUE.
WHEN '0002'.
IT_ITEM-GL_ACCOUNT = it_data_wa-VALUE.
WHEN '0003'.
IT_ITEM-AMT_DOCCUR = it_data_wa-value.
WHEN '0004'.
IT_ITEM-ITEM_TEXT = it_data_wa-VALUE.
WHEN '0005'.
IT_ITEM-BUS_AREA = it_data_wa-VALUE.
WHEN '0006'.
IT_ITEM-KOSTL = it_data_wa-VALUE.
* WHEN '0007'.
* IT_ITEM-VAT = it_data_wa-VALUE.
ENDCASE.
ENDLOOP.
APPEND IT_ITEM.
ENDFORM. " EXECUTE
*ENDLOOP.
*& Form BAPI
* text
* --> p1 text
* <-- p2 text
FORM BAPI .
DATA: it_acc_gl LIKE bapiacgl09 OCCURS 0 WITH HEADER LINE,
it_acc_ap LIKE bapiacap09 OCCURS 0 WITH HEADER LINE,
it_acc_aR LIKE bapiacaR09 OCCURS 0 WITH HEADER LINE,
it_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
it_curr_amt LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE,
it_doc_header LIKE bapiache09 OCCURS 0 WITH HEADER LINE,
it_acc_tax LIKE bapiactx09 OCCURS 0 WITH HEADER LINE,
obj_type LIKE bapiache09-obj_type,
obj_key LIKE bapiache09-obj_key,
obj_sys LIKE bapiache09-obj_sys,
pstng_date LIKE it_doc_header-pstng_date,
doc_date LIKE it_doc_header-doc_date,
loop_cnt TYPE i VALUE 0,
gv_vendor(10) TYPE c,
gv_gl_acc(10) TYPE c.
DATA conv_s_amt TYPE BETRG.
DATA cur_line TYPE P.
data item_no type POSNR_ACC.
data item_no1 type POSNR_ACC.
CLEAR: obj_type, obj_sys, obj_key, pstng_date, doc_date, gv_vendor, gv_gl_acc.
* CLEAR: it_doc_header,it_acc_gl,it_curr_amt,IT_ACC_AR,IT_RETURN.
LOOP AT it_HEADER INTO WA_HEADER .
REFRESH it_doc_header.
it_doc_header-bus_act = 'RFBU'.
it_doc_header-username = sy-uname.
* it_doc_header = WA_HEADER-KUNNR." Customer Number
it_doc_header-header_txt = WA_HEADER-TXT." bdc_source-col_h. " Invoice Text
it_doc_header-comp_code = 'JPOL'."bdc_source-col_a. " Company Code
CONCATENATE WA_HEADER-INV_DATE+6(4) WA_HEADER-INV_DATE+3(2) WA_HEADER-INV_DATE(2)
into it_doc_header-doc_date.
CONCATENATE WA_HEADER-pst_date+6(4) WA_HEADER-pst_date+3(2) WA_HEADER-pst_date(2)
into it_doc_header-pstng_date.
it_doc_header-doc_type = 'DR'. " Return Order...?
it_doc_header-fisc_year = '2013'. " Return Order...?
it_doc_header-fis_period = '02'. " Return Order...?
it_doc_header-ref_doc_no = '123'."bdc_source-col_d. " Invoice Number
APPEND it_doc_header.
REFRESH it_acc_aR.
it_acc_aR-itemno_acc = '1'. " Invoice Number
it_acc_aR-customer = WA_HEADER-KUNNR. " Customer Number
it_acc_aR-comp_code = 'JPOL'. " Company Code
it_acc_aR-item_text = WA_HEADER-txt. " Line Item Text
APPEND it_acc_aR.
* it_acc_aR-itemno_acc = '4'. " Invoice Number
* it_acc_aR-customer = WA_HEADER-KUNNR. " Customer Number
* it_acc_aR-comp_code = 'JPOL'. " Company Code
* it_acc_aR-item_text = WA_HEADER-txt. " Line Item Text
* APPEND it_acc_aR.
REFRESH it_acc_gl.
REFRESH IT_CURR_AMT.
* ITEM_NO = 1.
"GL Information details collected
CLEAR : ITEM_NO,item_no1.
LOOP AT it_ITEM INTO WA_ITEM where id = wa_header-ID.
ITEM_NO = ITEM_NO + 1.
it_acc_gl-itemno_acc = ITEM_NO.
it_acc_gl-gl_account = WA_ITEM-GL_ACCOUNT."gv_gl_acc. " GL Account
it_acc_gl-item_text = WA_ITEM-ITEM_TEXT. "bdc_source-col_o. " Line Item Text
it_acc_gl-doc_type = 'DR'. " Return Order...?
it_acc_gl-comp_code = 'JPOL'."bdc_source-col_a. " Company Code
it_acc_gl-bus_area = WA_ITEM-BUS_AREA."bdc_source-col_a. " Company Code
it_acc_gl-CUSTOMER = WA_HEADER-KUNNR.
conv_s_amt = WA_ITEM-AMT_DOCCUR."bdc_source-col_f. " Invoice Amount
IF conv_s_amt < 0.
it_acc_gl-de_cre_ind = 'H'. " H-Credit
conv_s_amt = - conv_s_amt.
ELSE.
it_acc_gl-de_cre_ind = 'S'. " S-Debit
ENDIF.
APPEND it_acc_gl.
ITEM_NO1 = ITEM_NO1 + 1.
it_curr_amt-itemno_acc = ITEM_NO1 . " Invoice Number
it_curr_amt-curr_type = '00'.
it_curr_amt-currency = 'INR'. " Currancy
it_curr_amt-amt_doccur = conv_s_amt . " Line Item Amount
APPEND it_curr_amt.
ITEM_NO1 = ITEM_NO1 + 1.
it_curr_amt-itemno_acc = ITEM_NO1 . " Invoice Number
it_curr_amt-curr_type = '00'.
it_curr_amt-currency = 'INR'. " Currancy
it_curr_amt-amt_doccur = conv_s_amt * -1. " Line Item Amount
APPEND it_curr_amt.
ENDLOOP.
REFRESH it_return.
"Customer Invoice
* Do the post to GL Account and AP
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = it_doc_header
IMPORTING
obj_type = obj_type
obj_key = obj_key
obj_sys = obj_sys
TABLES
accountgl = it_acc_gl
currencyamount = it_curr_amt
accountreceivable = it_acc_aR
return = it_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
* Check for any errors
WRITE : obj_key.
LOOP at IT_RETURN WHERE TYPE = 'E'.
WRITE : / 'Error :', IT_RETURN-MESSAGE .
endloop.
ENDLOOP.
ENDFORM. " BAPI
Result:Hi
Thank you for your help i did small modification i mention code below
REPORT ZCUS_INVOICE.
data: BEGIN OF WA_HEADER,
ID TYPE I,
KUNNR TYPE n LENGTH 10,
INV_DATE TYPE c LENGTH 10,
PST_DATE TYPE c LENGTH 10,
REF TYPE invfo-xblnr,
PRD_TEXT TYPE BAPIACGL09-ITEM_TEXT,
CMP_CODE TYPE BAPIACGL09-COMP_CODE,
AMT_DOCCUR TYPE PA2010-BETRG,
TXT(40),
END OF WA_HEADER.
DATA : IT_HEADER like WA_HEADER OCCURS 0 WITH HEADER LINE.
data: BEGIN OF WA_ITEM,
ID TYPE I,
GL_ACCOUNT TYPE n LENGTH 10,
ITEM_TEXT TYPE BAPIACGL09-ITEM_TEXT,
BUS_AREA TYPE BAPIACGL09-BUS_AREA,
AMT_DOCCUR TYPE BAPIACCR09-AMT_DOCCUR,
KOSTL TYPE CSKT-KOSTL,
* VAT(2),
END OF WA_ITEM.
DATA : IT_ITEM like WA_ITEM OCCURS 0 WITH HEADER LINE.
* value of excel-cell
TYPES: ty_d_itabvalue TYPE alsmex_tabline-value,
* internal table containing the excel data
ty_t_itab TYPE alsmex_tabline OCCURS 0,
* line type of sender table
BEGIN OF ty_s_senderline,
line(4096) TYPE c,
END OF ty_s_senderline,
* sender table
ty_t_sender TYPE ty_s_senderline OCCURS 0.
CONSTANTS: gc_esc VALUE '"'.
DATA temp_row TYPE I.
DATA TEMP(4).
INCLUDE lalsmexf01.
DATA: it_data1 TYPE ty_t_itab.
DATA: it_data2 TYPE ty_t_itab.
DATA: it_data_wa LIKE LINE OF it_data1.
DATA: it_data_wa2 LIKE LINE OF it_data1.
* DATA DECLARATION
data: st_rw_s1 TYPE i value '2'.
data: st_cl_s1 TYPE i value '1'.
data: st_rw_s2 TYPE i value '2'.
data: st_cl_s2 TYPE i value '1'.
data: ed_rw_s1 TYPE i value '50'.
data: ed_cl_s1 TYPE i value '9'.
data: ed_rw_s2 TYPE i value '50'.
data: ed_cl_s2 TYPE i value '6'.
DATA: excel_tab TYPE ty_t_sender,
excel_tab1 TYPE ty_t_sender.
DATA: ld_separator TYPE c.
DATA: application TYPE ole2_object,
workbook TYPE ole2_object,
sheet TYPE ole2_object,
range TYPE ole2_object,
worksheet TYPE ole2_object.
DATA: h_cell TYPE ole2_object,
h_cell1 TYPE ole2_object.
DATA: ld_rc TYPE i.
TYPE-POOLS ole2.
*AT SELECTION-SCREEN.
PARAMETERS: filename LIKE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
PERFORM value_help.
sTART-OF-SELECTION.
* CASE sy-ucomm .
* WHEN 'ONLI'.
PERFORM execute.
PERFORM bapi.
* ENDCASE.
* MESSAGE DEFINATION
DEFINE m_message.
case sy-subrc.
when 0.
when 1.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
when others. raise upload_ole.
endcase.
END-OF-DEFINITION.
*& Form VALUE_HELP
* text
* --> p1 text
* <-- p2 text
FORM VALUE_HELP .
CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
EXPORTING
def_filename = ' '
def_path = ' '
mask = ',*.*,*.*.'
mode = 'O'
title = ' '
IMPORTING
filename = filename
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
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. " VALUE_HELP
*& Form EXECUTE
* text
* --> p1 text
* <-- p2 text
FORM EXECUTE .
* PARAMETER CHECK
IF st_rw_s1 > ed_rw_s1.
RAISE inconsistent_parameters.
ENDIF.
IF st_cl_s1 > ed_cl_s1.
RAISE inconsistent_parameters.
ENDIF.
IF st_rw_s2 > ed_rw_s2.
RAISE inconsistent_parameters.
ENDIF.
IF st_cl_s2 > ed_cl_s2.
RAISE inconsistent_parameters.
ENDIF.
CLASS cl_abap_char_utilities DEFINITION LOAD.
ld_separator = cl_abap_char_utilities=>horizontal_tab.
* OPENING EXCEL FILE
IF application-header = space OR application-handle = -1.
CREATE OBJECT application 'Excel.Application'.
m_message.
ENDIF.
CALL METHOD OF
application
'Workbooks' = workbook.
m_message.
CALL METHOD OF
application
'Workbooks' = workbook.
m_message.
CALL METHOD OF
workbook
'Open'
EXPORTING
#1 = filename.
m_message.
CALL METHOD OF
application
'Worksheets' = sheet
EXPORTING
#1 = 1.
m_message.
CALL METHOD OF
application
'Worksheets' = sheet
EXPORTING
#1 = 1.
m_message.
CALL METHOD OF
sheet
'Activate'.
m_message.
GET PROPERTY OF application 'ACTIVESHEET' = sheet.
m_message.
* MARKING OF WHOLE SPREADSHEET
CALL METHOD OF
sheet
'Cells' = h_cell
EXPORTING
#1 = st_rw_s1
#2 = st_cl_s1.
m_message.
CALL METHOD OF
sheet
'Cells' = h_cell1
EXPORTING
#1 = ed_rw_s1
#2 = ed_cl_s1.
m_message.
CALL METHOD OF
sheet
'RANGE' = range
EXPORTING
#1 = h_cell
#2 = h_cell1.
m_message.
CALL METHOD OF
range
'SELECT'.
m_message.
* Copy marked area (SHEET1) into Clippboard
CALL METHOD OF
range
'COPY'.
m_message.
* Read clipboard into ABAP
CALL METHOD cl_gui_frontend_services=>clipboard_import
IMPORTING
data = excel_tab
EXCEPTIONS
cntl_error = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE a037(alsmex).
ENDIF.
PERFORM separated_to_intern_convert TABLES excel_tab it_data1
USING ld_separator.
* Clear the clipboard
REFRESH excel_tab.
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
data = excel_tab
CHANGING
rc = ld_rc
EXCEPTIONS
cntl_error = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4.
* Working in Second Excel Work Sheet
CALL METHOD OF
application
'Worksheets' = sheet
EXPORTING
#1 = 2.
m_message.
CALL METHOD OF
sheet
'Activate'.
m_message.
GET PROPERTY OF application 'ACTIVESHEET' = sheet.
m_message.
* Mark Sheet2
CALL METHOD OF
sheet
'Cells' = h_cell
EXPORTING
#1 = st_rw_s2
#2 -
Client.ole2 is not working
Hi i'm migrating to from fomrs 4.5 to 10g as DDE package are not supported in the
10g. i'm using client.ole2
I have written following code to open a stored excel sheet(which is a template for entering the data). this is not working not giving any error.
please tell me where is the error
declare
application client_ole2.obj_type;
workbooks client_OLE2.OBJ_TYPE;
workbook client_OLE2.OBJ_TYPE;
worksheets client_OLE2.OBJ_TYPE;
worksheet client_OLE2.OBJ_TYPE;
worksheet2 client_OLE2.OBJ_TYPE;
worksheet3 client_OLE2.OBJ_TYPE;
args1 client_ole2.list_type;
L_PATH VARCHAR2(100);
COMMAND1 VARCHAR2(5000);
BEGIN
l_PATH := SFN_GET_DIRECTORY_PATH('DIR0003');
COMMAND1 := L_PATH||'\Formats\EMP_NEW_UPLOAD.xls';
application := Client_OLE2.create_obj('Excel.Application');
workbooks := Client_OLE2.Get_Obj_Property(application, 'Workbooks');
args1 := Client_Ole2.create_arglist;
Client_Ole2.add_arg(args1, 'c:\emp.xls');
workbook := Client_Ole2.invoke_obj(workbooks, 'Open', args1);
worksheets := Client_Ole2.get_obj_property(workbook, 'worksheets');
CLIENT_OLE2.destroy_arglist(args1);
CLIENT_OLE2.SET_PROPERTY(application,'Visible',1);
CLIENT_OLE2.SET_PROPERTY(application,'DisplayAlerts',0);
end;As Gerald Krieger suggests, it sounds as if you have not installed the Jacob library correctly. Most WebUtil functions, like CLIENT_GET_FILE_NAME, are included in the base 10g install -- OLE functionality, however, is not. This is because the Jacob library, which is required for OLE support, is not an Oracle product and, as such, could not legally be distributed by Oracle.
Jacob can be downloaded from http://sourceforge.net/projects/jacob-project
Configuring the OC4J for developing/testing OLE-enabled forms involves these steps:
1. Download the Jacob library and extract two files -- jacob.jar & jacob.dll
2. Place a signed copy of jacob.jar in ...\forms\java
3. Place a copy of jacob.dll in ...\forms\webutil
4. If you are not using Jacob 1.8, but are instead using a different version, you must edit ...\forms\server\webutil.cfg by locating the line which contains install.syslib.0.7.1=jacob.dll|94208|1.0|true and replacing 94208 with the size (in bytes) of your particular version of jacob.dll
If these instructions are unclear, please accept my apologies and refer to the WebUtil documentation for details.
Finally, be aware that your forms will not deploy correctly unless ...\forms\webutil.pll has been compiled. You must be connected to a WebUtil-ready database in order for webutil.pll to compile successfully.
Hope this helps,
Eric Adamson
Lansing, Michigan -
Error while using ALSM_EXCEL_TO_INTERNAL_TABLE
I am getting the exception "Upload OLE" while using this FM to upload data from excel sheet into SAP system. It errors out at the following statement inside the FM -
CREATE OBJECT obj_application 'Excel.Application'.
Any pointers?
Regards,
Shivalihi, take a look at this code
*& Report ZKRIS_OLE3_PALETTE
*& Displays the full OLE color range in excel
REPORT ZKRIS_OLE3_PALETTE.
TYPE-POOLS ole2 .
DATA: count TYPE i,
count_real TYPE i,
application TYPE ole2_object,
workbook TYPE ole2_object,
excel TYPE ole2_object,
sheet TYPE ole2_object,
cells TYPE ole2_object.
CONSTANTS: row_max TYPE i VALUE 256. " change to 16384 for excel 2007
DATA index TYPE i.
DATA:
h_cell TYPE ole2_object, " cell
h_f TYPE ole2_object, " font
h_int TYPE ole2_object,
h_width TYPE ole2_object,
h_columns TYPE ole2_object,
h_rows TYPE ole2_object,
h_font TYPE ole2_object,
h_entirecol TYPE ole2_object.
DATA: h_range TYPE ole2_object.
DATA: h_merge TYPE ole2_object.
CREATE OBJECT excel 'EXCEL.APPLICATION'.
IF sy-subrc NE 0.
WRITE: / 'No EXCEL creation possible'.
STOP.
ENDIF.
SET PROPERTY OF excel 'DisplayAlerts' = 0.
CALL METHOD OF excel 'WORKBOOKS' = workbook .
SET PROPERTY OF excel 'VISIBLE' = 1.
creating workbook
SET PROPERTY OF excel 'SheetsInNewWorkbook' = 1.
CALL METHOD OF workbook 'ADD'.
CALL METHOD OF excel 'WORKSHEETS' = sheet
EXPORTING
#1 = 1.
SET PROPERTY OF sheet 'NAME' = 'Color Palette'.
CALL METHOD OF sheet 'ACTIVATE'.
DATA: col TYPE i VALUE 1,
row TYPE i VALUE 2,
col1 TYPE i VALUE 2,
col_real TYPE i VALUE 1.
row = 1.
col = 3.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'No.'.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Background'.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with white background'.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with black background'.
CALL METHOD OF excel 'Rows' = h_rows
EXPORTING
#1 = '2:2'.
SET PROPERTY OF h_rows 'WrapText' = 1.
col = 9.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'No.'.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Background'.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with white background'.
SET PROPERTY OF h_cell 'Bold' = 1.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with black background'.
CALL METHOD OF excel 'Rows' = h_rows
EXPORTING
#1 = '1:1'.
SET PROPERTY OF h_rows 'WrapText' = 1.
GET PROPERTY OF h_rows 'Font' = h_font.
SET PROPERTY OF h_font 'Bold' = 1.
count = 1.
count_real = count.
row = 2.
col = 3.
DO 56 TIMES.
PERFORM write_num_and_color.
ENDDO.
autofit
CALL METHOD OF excel 'Columns' = h_columns
EXPORTING
#1 = 'C:L'.
GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
SET PROPERTY OF h_entirecol 'Autofit' = 1.
write palette on lhs
*range
CALL METHOD OF excel 'Range' = h_range
EXPORTING
#1 = 'A2'
#2 = 'A20'.
CALL METHOD OF h_range 'Merge' = h_merge .
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = 2
#2 = 1.
SET PROPERTY OF h_cell 'Value' = 'Palette'.
SET PROPERTY OF h_cell 'Orientation' = 90. "angled.
SET PROPERTY OF h_cell 'HorizontalAlignment' = 3. "center align
GET PROPERTY OF h_cell 'Font' = h_f.
SET PROPERTY OF h_f 'Bold' = 1. "bold
SET PROPERTY OF h_f 'Name' = 'Comic Sans MS'.
SET PROPERTY OF h_f 'Size' = '14'.
SET PROPERTY OF h_cell 'VerticalAlignment' = 2. "center align
autofit
CALL METHOD OF excel 'Columns' = h_columns
EXPORTING
#1 = 'A:A'.
GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
SET PROPERTY OF h_columns 'ColumnWidth' = 4.
*& Form write_num_and_color
text
FORM write_num_and_color.
index = row_max * ( row - 1 ) + col.
CALL METHOD OF sheet 'Cells' = cells
EXPORTING
#1 = index.
SET PROPERTY OF cells 'Value' = count_real.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
GET PROPERTY OF h_cell 'Interior' = h_int.
SET PROPERTY OF h_int 'ColorIndex' = count_real.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Sample Text'.
GET PROPERTY OF h_cell 'Font' = h_f.
SET PROPERTY OF h_f 'ColorIndex' = count_real.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
GET PROPERTY OF h_cell 'Interior' = h_int.
SET PROPERTY OF h_int 'ColorIndex' = 1.
SET PROPERTY OF h_cell 'Value' = 'Sample Text'.
GET PROPERTY OF h_cell 'Font' = h_f.
SET PROPERTY OF h_f 'ColorIndex' = count_real.
row = row + 1.
col = col - 3.
count = count + 1.
IF count = 29.
count = 1.
row = 2.
col = col + 6.
ENDIF.
count_real = count_real + 1.
ENDFORM. "write_num_and_color
hope this helps.
regs,
hema. -
How do I dial a phone number from Forms6i ?? OLE2,DDE??
How do I dial a phone number from Forms6i ?? OLE2,DDE??
Is it do-able??
I have a contact form that has the contacts phone number, etc... I would like to add a button to dial the number which would open the phone line (probably through my modem) and dial the number ... where I would pickup the receiver and wait for connection...
I need an example or a "How to" link or something where if I take the time I can get it working....
IF not, is there software to do it?
Thanks, BillYes, great! I will check into my modem... but I remember years ago have a c program that I used to send error messages through the modem to my alpha-numeric pager. With that I started with that c program being called from REXX IBM language and it spoke modem language...
Is there another forum that would handle this type of request? what do you call telephone support? telephony? communication links? ....
Thanks for the input! -
OLE error code in Windows 8.1
Good day,
I tried to run vfp8 compiled executable file on windows 8.1, then i got this error...
"OLE error code 0x80040154: Unknown COM status code. Ole object is being ignored. Record number 6."
I have tried to read through similar issues but could not find my way out.
kindly help. Thanks
--- Gabriel Oladoyinbo Senior Consultant http://topmarkservices.netIt's not sufficient to simply add the missing file, activex need registering.
Your SCX knows what file it uses in it's OLE2 column.
USE your.scx
BROWSE FOR !EMPTY(Ole2)
Look inside.
And you better not only include that file in your setup, you also set it's properties so the setup registers it. And you better look out for a merge module installing an AcitveX and dependencies.
The properties of files you add to the installer project also have a COM settings tag, which includes Scan at Build, that scans for dependencies. Setting that for your EXE will make Installshield Express look out for any COM dependencies your EXE has and
will result in build warnings at least.
Bye, Olaf.
Olaf Doschke - TMN Systemberatung GmbH
http://www.tmn-systemberatung.de -
OLE2 in Oracle Report 6.0.8.13.2
I am trying to use OLE2 package for generation of an excel file in report. But there is some compilation issue here.
Details: - using following code in a formula
function CF_Excel _OpFormula return Number is
wapplication ole2.obj_type ; -- just to check if there is a support for OLE2
BEGIN
srw.message(0000, 'test message');
return(1);
RETURN NULL;
EXCEPTION
WHEN OTHERS THEN
srw.message(1003, 'Unknown error - check file path entered ');
raise srw.program_abort;
END;
I have developed this code in version 6.0.8.8.3 and there is no compilation issue, when I compile this report on my local machine (window2000).
When, I compile this report on unix (report version - 6.0.8.13.2), there is some error, whuch say ERR REP-0736: There exist uncompiled program unit(s).
ERR REP-1247: Report contains uncompiled PL/SQL.
Please, give suggestions to get rid of these errors.Hi ,
The answer is very simple OLE2 utility is valid only on MS Windows platform; actualy it is a Microsoft proprietary feature.
If you still want to use on UNIX, and you run on a web server, you can attach the WEBUTIL utility, and install it (its free from Oracle) , and implement its use only on Forms because webutil is valid only with Forms.
Otherwise - it won't work (unless you use TEXT_IO package instead).
Best Regards ,
Shimon B. -
Problem entering values in table after creating it in Word using OLE2
Hi,
I want to create a Word document from a Oracle Forms 6i application. The document will have standard text followed by a table. The cells of this table are to be populated from fields in the Forms application.
I have created a sample code below. When executed from within the Forms application, it creates a document fine. It writes the text "Hello World". It then creates a table as expected. But when I try to enter a value "Cell Value" in the table, the value does not get written to the cell of the table. Instead it writes the value outside the table.
Can someone please tell me what I am doing wrong here and what I need to do so that after writing the text on the document I can write values into the table also.
Any help will be much appreciated.
Here is the code(it works but then it doesn't ):
PROCEDURE TEST_PROC IS
hApplication OLE2.OBJ_TYPE;
hDocuments OLE2.OBJ_TYPE;
hDocument OLE2.OBJ_TYPE;
hSelection OLE2.OBJ_TYPE;
hParagraphFormat OLE2.OBJ_TYPE;
hRange OLE2.OBJ_TYPE;
hFont OLE2.OBJ_TYPE;
hTables OLE2.OBJ_TYPE;
hTable OLE2.OBJ_TYPE;
args OLE2.LIST_TYPE;
wdAlignParagraphLeft CONSTANT number(3) := 0; --Default
wdword9tablebehavior CONSTANT NUMBER (5) := 1;
wdautofitfixed CONSTANT NUMBER (5) := 0;
---- wdUnits Class members
wdcharacter CONSTANT NUMBER (5) := 1;
wdmove CONSTANT NUMBER (5) := 0; --Default
--wdBorderType Class members
wdborderleft CONSTANT NUMBER := -2;
wdborderright CONSTANT NUMBER := -4;
wdbordertop CONSTANT NUMBER := -1;
wdborderbottom CONSTANT NUMBER := -3;
--WdLineStyle Class member
wdlinestylenone CONSTANT NUMBER := 0;
BEGIN
hApplication:=OLE2.CREATE_OBJ('Word.Application');
OLE2.SET_PROPERTY(hApplication, 'Visible', 1);
hDocuments := OLE2.GET_OBJ_PROPERTY(hApplication, 'Documents');
hDocument := OLE2.INVOKE_OBJ(hDocuments, 'Add');
hSelection := OLE2.GET_OBJ_PROPERTY(hApplication, 'Selection');
hFont := OLE2.GET_OBJ_PROPERTY(hSelection, 'Font');
OLE2.SET_PROPERTY(hFont, 'Name', 'Calibri');
OLE2.SET_PROPERTY(hFont, 'Size', 11);
OLE2.SET_PROPERTY(hFont, 'Bold', FALSE );
OLE2.INVOKE(hSelection, 'TypeParagraph');
hParagraphFormat := OLE2.GET_OBJ_PROPERTY(hSelection, 'ParagraphFormat');
OLE2.SET_PROPERTY(hParagraphFormat, 'Alignment', wdAlignParagraphLeft);
OLE2.RELEASE_OBJ(hParagraphFormat);
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'Hello World');
OLE2.INVOKE(hSelection, 'TypeText', args);
OLE2.DESTROY_ARGLIST(args);
OLE2.INVOKE(hSelection, 'TypeParagraph');
htables := ole2.get_obj_property (hdocument, 'Tables');
hrange := ole2.get_obj_property (hselection, 'Range');
args := ole2.create_arglist;
ole2.add_arg_obj (args, hrange); --Range
ole2.add_arg (args, 1); --NumRows
ole2.add_arg (args, 6); --NumColumns
ole2.add_arg (args, wdword9tablebehavior); --DefaultTableBehavior
ole2.add_arg (args, wdautofitfixed); --FitBehavior
htable := ole2.invoke_obj (htables
,'Add'
,args
args := ole2.create_arglist;
ole2.add_arg (args, wdcharacter);
ole2.add_arg (args, 1);
ole2.add_arg (args, wdmove);
ole2.invoke (hselection
,'MoveLeft'
,args
ole2.destroy_arglist (args);
args := ole2.create_arglist;
ole2.add_arg (args, 'CellValue');
ole2.invoke (hselection
,'TypeText'
,args
ole2.destroy_arglist (args);
ole2.RELEASE_OBJ (happlication);
ole2.RELEASE_OBJ (hdocuments);
ole2.RELEASE_OBJ (hdocument);
ole2.RELEASE_OBJ (hfont);
ole2.RELEASE_OBJ (hparagraphformat);
ole2.RELEASE_OBJ (htables);
ole2.RELEASE_OBJ (hrange);
END;Once again thanks for the help John. Unfortunately I cannot use only bookmarks, because the text to be entered from the application is of undetermined length and therefore since the possibility of wrapping exists, it would not be able to give me the same formatting abilty as using a table.
However, the good news is that I have been able to find the solution. I am posting my code here so that it is available to anyone else who might have the same issue. Thanks again.
Here is my code and my comments in it explain what it does.
PROCEDURE extract_to_word
IS
/* First of all I would like to acknowledge the help I have got from experts who have posted a lot of this code on the web which I have used here. Special thanks go to someone by the name of sfvb
found here http://www.tek-tips.com/userinfo.cfm?member=sfvbsfvb
This procedure does the following:
1. Opens a word document.
2. Creates a header and pastes a picture in the header e.g your company logo with address. Please note that the image should have both the address and the logo in it. It can be created using paint where you can write your address at one end and paste a bmp or jpg picture of your logo at the other end.
3. Writes text with specified font and size. It calls a separate procedure PRINT_LINE to do this.
4. Creates a table on the document with specified number of columns with fixed width.
5. Populates the cells of the table-
first with headers written by calls to WRITE_HEADINGS procedure.
next with data from a block of the Forms application by calls to WRITE_DATA procedure
6. Comes out of the table and continues to write text.
The three procedures that are repeatedly called are described after the end of this procedure.
Note: While I have made every attempt to ensure that the code does not generate error on account of my writing the explanatory notes, I cannot be sure of having made some typos. If the code does not compile, it is most probably be on account of something I have missed in entering the comments and explanation.
Disclaimer:
I am not the sole author of this code. I have taken help from other open sources and copyright infringement if any is entirely unintentional.
happlication ole2.obj_type;
hwindow ole2.obj_type;
hpane ole2.obj_type;
hview ole2.obj_type;
hdocuments ole2.obj_type;
hdocument ole2.obj_type;
hselection ole2.obj_type;
hparagraphformat ole2.obj_type;
hrange ole2.obj_type;
hfields ole2.obj_type;
hfont ole2.obj_type;
hinlineshapes ole2.obj_type;
hpars ole2.obj_type;
hpar ole2.obj_type;
htabstops ole2.obj_type;
hactivedocument ole2.obj_type;
htables ole2.obj_type;
htable ole2.obj_type;
hcolumns ole2.obj_type;
hcells ole2.obj_type;
hrows ole2.obj_type;
hshading ole2.obj_type;
hinsertrow ole2.obj_type;
hborders ole2.obj_type;
hshading ole2.obj_type;
args ole2.list_type;
wdalignparagraphleft CONSTANT NUMBER (3) := 0;
wdalignparagraphcenter CONSTANT NUMBER (3) := 1;
wdalignparagraphright CONSTANT NUMBER (3) := 2;
wdseekcurrentpageheader CONSTANT NUMBER (3) := 9;
wdseekcurrentpagefooter CONSTANT NUMBER (3) := 10;
wdseekmaindocument CONSTANT NUMBER (3) := 0;
wdfieldpage CONSTANT NUMBER (3) := 33;
wdfieldnumpages CONSTANT NUMBER (3) := 26;
wdpagebreak CONSTANT NUMBER (3) := 7;
wdstory CONSTANT NUMBER (3) := 6;
wdword CONSTANT NUMBER (5) := 2;
wdsentence CONSTANT NUMBER (5) := 3;
wdword8tablebehavior CONSTANT NUMBER (5) := 0;
wdword9tablebehavior CONSTANT NUMBER (5) := 1;
wdautofitcontent CONSTANT NUMBER (5) := 1;
wdautofitfixed CONSTANT NUMBER (5) := 0;
wdautofitwindow CONSTANT NUMBER (5) := 2;
wdunderlinesingle CONSTANT NUMBER (5) := 1;
---- wdUnits Class members
wdcell CONSTANT NUMBER (5) := 12;
wdcharacter CONSTANT NUMBER (5) := 1;
wdword CONSTANT NUMBER (5) := 2;
wdsentence CONSTANT NUMBER (5) := 3;
wdline CONSTANT NUMBER (5) := 5;
---- wdMovementType Class members
wdextend CONSTANT NUMBER (5) := 1;
wdmove CONSTANT NUMBER (5) := 0;
--wdBorderType Class members
wdborderleft CONSTANT NUMBER := -2;
wdborderright CONSTANT NUMBER := -4;
wdbordertop CONSTANT NUMBER := -1;
wdborderbottom CONSTANT NUMBER := -3;
--WdLineStyle Class member
wdlinestylenone CONSTANT NUMBER := 0;
mytab CONSTANT VARCHAR2 (1) := CHR (9);
myblue CONSTANT NUMBER (8) := 16711680; --FF0000
mygreen CONSTANT NUMBER (8) := 65280; --00FF00
myred CONSTANT NUMBER (8) := 255; --0000FF
mydkgreen CONSTANT NUMBER (8) := 32768; --008000
myblack CONSTANT NUMBER (8) := 0; --000000
mytext VARCHAR2 (2000);
BEGIN
happlication := ole2.create_obj ('Word.Application');
ole2.set_property (happlication
,'Visible'
,1
hdocuments :=
ole2.get_obj_property (happlication, 'Documents');
hdocument := ole2.invoke_obj (hdocuments, 'Add');
-------- Create Header and Footer --------
hwindow :=
ole2.get_obj_property (happlication, 'ActiveWindow');
hpane := ole2.get_obj_property (hwindow, 'ActivePane');
hview := ole2.get_obj_property (hpane, 'View');
---- Header Section ---
ole2.set_property (hview
,'SeekView'
,wdseekcurrentpageheader
hselection :=
ole2.get_obj_property (happlication, 'Selection');
hfont := ole2.get_obj_property (hselection, 'Font');
ole2.set_property (hfont
,'Name'
,'Calibri'
ole2.set_property (hfont
,'Size'
,10
ole2.set_property (hfont
,'Bold'
,FALSE
ole2.set_property (hfont
,'Color'
,myblack
ole2.RELEASE_OBJ (hfont);
args := ole2.create_arglist;
--Below is the location of your jpg file that contains the logo and address
ole2.add_arg (args, 'C:\temp\AMHeader2.jpg');
hinlineshapes :=
ole2.get_obj_property (hselection, 'InlineShapes');
ole2.invoke (hinlineshapes
,'AddPicture'
,args
ole2.destroy_arglist (args);
ole2.RELEASE_OBJ (hinlineshapes);
ole2.set_property (hview
,'SeekView'
,wdseekmaindocument
ole2.RELEASE_OBJ (hview);
ole2.RELEASE_OBJ (hpane);
ole2.RELEASE_OBJ (hwindow);
-------- Insert Text --------
hfont := ole2.get_obj_property (hselection, 'Font');
ole2.set_property (hfont
,'Name'
,'Calibri'
ole2.set_property (hfont
,'Size'
,9
ole2.set_property (hfont
,'Bold'
,FALSE
ole2.set_property (hfont
,'Color'
,myblack
ole2.invoke (hselection, 'TypeParagraph');
hparagraphformat :=
ole2.get_obj_property (hselection, 'ParagraphFormat');
ole2.set_property (hparagraphformat
,'Alignment'
,wdalignparagraphleft
ole2.RELEASE_OBJ (hparagraphformat);
print_line (hselection
, 'Date ' || TO_CHAR (TRUNC (SYSDATE), 'MM/DD/YYYY')
,NULL
print_line (hselection
,NULL
--The following prints the address of the recipient of the letter.
print_line (hselection
,addr_line1
,NULL
print_line (hselection
,addr_line2
,NULL
print_line (hselection
,addr_line3
,NULL
print_line (hselection
,addr_line4
,NULL
print_line (hselection
,addr_line5
,NULL
--Call like the one below are to insert blank lines
hselection :=
ole2.get_obj_property (happlication, 'Selection');
print_line (hselection
,NULL
,NULL
print_line (hselection
,'Your salutation'
,NULL
print_line (hselection
,NULL
,'NULL
print_line (hselection
,'Ref: '
,NULL
print_line (hselection
,NULL
,NULL
print_line
(hselection
,'Whatever text you want to appear on this line.'
,NULL
print_line (hselection
,NULL
,NULL
-------- Create Table --------
htables := ole2.get_obj_property (hdocument, 'Tables');
hrange := ole2.get_obj_property (hselection, 'Range');
args := ole2.create_arglist;
ole2.add_arg_obj (args, hrange); --Range
ole2.add_arg (args, 1); --NumRows The rest of the rows are created later as and when required
ole2.add_arg (args, 6); --NumColumns This creates a table of 6 columns.
ole2.add_arg (args, wdword9tablebehavior); --DefaultTableBehavior
ole2.add_arg (args, wdautofitfixed); --FitBehavior
htable := ole2.invoke_obj (htables
,'Add'
,args
ole2.destroy_arglist (args);
-- [Borders removal start]The following piece of code removes all the borders. Use of this is optional.
hborders := ole2.get_obj_property (htable, 'Borders');
ole2.set_property (hborders
,'OutsideLineStyle'
,wdlinestylenone
ole2.set_property (hborders
,'InsideLineStyle'
,wdlinestylenone
ole2.RELEASE_OBJ (hborders);
--[Borders removal end]
--The following code makes the cursor enter the table. I took quite some time
--figuring this out.
hselection := ole2.get_obj_property (hdocument, 'Tables');
hselection := ole2.get_obj_property (happlication, 'Selection');
--WRITE_HEADINGS is the procedure called each time only to write headings.
write_headings (hselection
,'Heading 1 on cell at row 1 column 1'
,8
--The following moves the cursor to the next cell on the right.
args := ole2.create_arglist;
ole2.add_arg (args, wdcell);
ole2.add_arg (args, 1);
ole2.add_arg (args, wdmove);
ole2.invoke (hselection
,'MoveRight'
,args
ole2.destroy_arglist (args);
write_headings (hselection
,'Heading 1 on cell at row 1 column 2'
,7
args := ole2.create_arglist;
ole2.add_arg (args, wdcell);
ole2.add_arg (args, 1);
ole2.add_arg (args, wdmove);
ole2.invoke (hselection
,'MoveRight'
,args
ole2.destroy_arglist (args);
write_headings (hselection
,'Heading 1 on cell at row 1 column 3'
,7
args := ole2.create_arglist;
ole2.add_arg (args, wdcell);
ole2.add_arg (args, 1);
ole2.add_arg (args, wdmove);
ole2.invoke (hselection
,'MoveRight'
,args
ole2.destroy_arglist (args);
write_headings (hselection
,'Heading 1 on cell at row 1 column 4'
,8
args := ole2.create_arglist;
ole2.add_arg (args, wdcell);
ole2.add_arg (args, 1);
ole2.add_arg (args, wdmove);
ole2.invoke (hselection
,'MoveRight'
,args
ole2.destroy_arglist (args);
write_headings (hselection
,'Heading 1 on cell at row 1 column 5'
,5
args := ole2.create_arglist;
ole2.add_arg (args, wdcell);
ole2.add_arg (args, 1);
ole2.add_arg (args, wdmove);
ole2.invoke (hselection
,'MoveRight'
,args
ole2.destroy_arglist (args);
write_headings (hselection
,'Heading 1 on cell at row 1 column 6'
,8
--The following moves the cursor back to the first cell on row 1 column 1
args := ole2.create_arglist;
ole2.add_arg (args, wdcell);
ole2.add_arg (args, 6);
ole2.add_arg (args, wdmove);
ole2.invoke (hselection
,'MoveLeft'
,args
ole2.destroy_arglist (args);
--Now we need to write data sourced from a multi record block in Oracle Forms
GO_BLOCK ('your_block');
FIRST_RECORD;
record_cnt := 0;
LOOP
record_cnt := record_cnt + 1;
---In my application I gave the choice to the user to put a check mark on those records that he would want to print ------on the document and so the following.
IF :your_block.cb_print = 'Y'
THEN
--This creates a new row below the first row that contains the column headers.
args := ole2.create_arglist; ole2.add_arg (args, 1);
ole2.invoke (hselection
,'InsertRowsBelow'
,args
ole2.destroy_arglist (args);
--WRITE_DATA is called each time to write the data in the cells.
write_data (hselection
, :your_block.item);
args := ole2.create_arglist;
ole2.add_arg (args, wdcell);
ole2.add_arg (args, 1);
ole2.add_arg (args, wdmove);
ole2.invoke (hselection
,'MoveRight'
,args
ole2.destroy_arglist (args);
write_data (hselection
, :your_block.item);
args := ole2.create_arglist;
ole2.add_arg (args, wdcell);
ole2.add_arg (args, 1);
ole2.add_arg (args, wdmove);
ole2.invoke (hselection
,'MoveRight'
,args
ole2.destroy_arglist (args);
write_data (hselection
,:your_block.item);
args := ole2.create_arglist;
ole2.add_arg (args, wdcell);
ole2.add_arg (args, 1);
ole2.add_arg (args, wdmove);
ole2.invoke (hselection
,'MoveRight'
,args
ole2.destroy_arglist (args);
write_data (hselection
,:your_block.item);
args := ole2.create_arglist;
ole2.add_arg (args, wdcell);
ole2.add_arg (args, 1);
ole2.add_arg (args, wdmove);
ole2.invoke (hselection
,'MoveRight'
,args
ole2.destroy_arglist (args);
write_data (hselection
,:your_block.item);
args := ole2.create_arglist;
ole2.add_arg (args, wdcell);
ole2.add_arg (args, 1);
ole2.add_arg (args, wdmove);
ole2.invoke (hselection
,'MoveRight'
,args
ole2.destroy_arglist (args);
write_data (hselection
,:your_block.item);
END IF;
EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
NEXT_RECORD;
END LOOP;
--The following makes the cursor exit the table and back on document for any further
--writing of text.
args := ole2.create_arglist;
ole2.add_arg (args, wdline);
ole2.add_arg (args, 1);
ole2.add_arg (args, wdmove);
ole2.invoke (hselection
,'MoveDown'
,args
print_line (hselection --As mentioned earlier, this enters a blank line.
,NULL
,NULL
print_line (hselection
,'Boilerplate text: '
,your_variable
print_line (hselection
,'Boilerplate text: '
,your_variable
--You can print as many lines as required by making call to the PRINT_LINE procedure.
ole2.RELEASE_OBJ (htables);
ole2.RELEASE_OBJ (hfont);
ole2.RELEASE_OBJ (hselection);
ole2.RELEASE_OBJ (hdocument);
ole2.RELEASE_OBJ (hdocuments);
ole2.RELEASE_OBJ (happlication);
END;
PROCEDURE PRINT_LINE
( v_sel OLE2.OBJ_TYPE
, v_text VARCHAR2
, v_field varchar2)
IS
/* This procedure takes in three arguments.
The first v_sel is the VB selection object.
v_text is the static or boilerplate text that needs to be printed on the document.
v_field is the value of the item or variable from the program.
v_args OLE2.LIST_TYPE;
hTab CONSTANT varchar2(1) := chr(9); --This is the vb constant for tabstop
BEGIN
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, v_text);
OLE2.INVOKE(v_sel, 'TypeText', v_args);
OLE2.DESTROY_ARGLIST(v_args);
--The following replicates tabbing. This was used so that the field values are aligned at a tabstop.
--When printing a blank line NULL is passed in as the argument
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, hTab);
OLE2.INVOKE(v_sel, 'TypeText', v_args);
OLE2.DESTROY_ARGLIST(v_args);
--The following writes the value of the variable at the tabstop.
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, v_field);
OLE2.INVOKE(v_sel, 'TypeText', v_args);
OLE2.DESTROY_ARGLIST(v_args);
OLE2.INVOKE(v_sel, 'TypeParagraph');
END;
PROCEDURE WRITE_HEADINGS (SELIN OLE2.OBJ_TYPE, TEXTIN VARCHAR2, COUNTIN NUMBER)
IS
/* This procedure is used to write headings in the first row of the table.
SELIN is the Selection object
TEXTIN is the boilerplate text to be written as the header of a column.
COUNTIN is the number of characters in the header text. This is required
to replicate the action bolding the font of the header.
hFont OLE2.OBJ_TYPE;
v_args OLE2.LIST_TYPE;
wdCharacter CONSTANT number(5) := 1; --Default
--wdUnderline Class members
wdUnderlineSingle CONSTANT NUMBER(5) := 1;
---- wdMovementType Class members
wdExtend CONSTANT number(5) := 1;
wdMove CONSTANT number(5) := 0; --Default
---- WdParagraphAlignment Class members
wdAlignParagraphCenter CONSTANT number(5) := 1;
wdAlignParagraphLeft CONSTANT number(5) := 0;
wdAlignParagraphRight CONSTANT number(5) := 2;
---- HexColor = BBGGRR
myLightBlue CONSTANT number(8) := 16755370; --FFAAAA
BEGIN
hFont := OLE2.GET_OBJ_PROPERTY(selin, 'Font');
OLE2.SET_PROPERTY(hFont, 'Name', 'Calibri');
OLE2.SET_PROPERTY(hFont, 'Size', 10);
OLE2.SET_PROPERTY(hFont, 'Bold', True);
OLE2.RELEASE_OBJ(hFont);
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, textin);
OLE2.INVOKE(selin, 'TypeText', v_args);
OLE2.DESTROY_ARGLIST(v_args);
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, wdCharacter);
OLE2.ADD_ARG(v_args, countin);
OLE2.ADD_ARG(v_args, wdMove);
OLE2.INVOKE(selin, 'MoveLeft', v_args);
OLE2.DESTROY_ARGLIST(v_args);
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, wdCharacter); --Unit
OLE2.ADD_ARG(v_args, countin); --Count
OLE2.ADD_ARG(v_args, wdExtend); --Extend
OLE2.INVOKE(selin, 'MoveRight', v_args);
OLE2.DESTROY_ARGLIST(v_args);
hFont := OLE2.GET_OBJ_PROPERTY(selin, 'Font');
OLE2.SET_PROPERTY(hFont, 'Underline', wdUnderlineSingle);
OLE2.RELEASE_OBJ(hFont);
END;
PROCEDURE WRITE_DATA (SELIN OLE2.OBJ_TYPE, TEXTIN VARCHAR2)
IS
/*This procedure writes data in the cells of the table
hFont OLE2.OBJ_TYPE;
v_args OLE2.LIST_TYPE;
wdCharacter CONSTANT number(5) := 1; --Default
--wdUnderline Class members
wdUnderlineSingle CONSTANT NUMBER(5) := 0;
---- wdMovementType Class members
wdExtend CONSTANT number(5) := 1;
wdMove CONSTANT number(5) := 0; --Default
---- WdParagraphAlignment Class members
wdAlignParagraphCenter CONSTANT number(5) := 1;
wdAlignParagraphLeft CONSTANT number(5) := 0;
wdAlignParagraphRight CONSTANT number(5) := 2;
---- HexColor = BBGGRR
myLightBlue CONSTANT number(8) := 16755370; --FFAAAA
BEGIN
hFont := OLE2.GET_OBJ_PROPERTY(selin, 'Font');
OLE2.SET_PROPERTY(hFont, 'Name', 'Calibri');
OLE2.SET_PROPERTY(hFont, 'Size', 10);
OLE2.SET_PROPERTY(hFont, 'Bold', False);
OLE2.SET_PROPERTY(hFont, 'Underline', wdUnderlineSingle);
OLE2.RELEASE_OBJ(hFont);
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, textin);
OLE2.INVOKE(selin, 'TypeText', v_args);
OLE2.DESTROY_ARGLIST(v_args);
END;
Edited by: smilingbandit on 31-Mar-2010 7:05 PM
Edited by: smilingbandit on 31-Mar-2010 8:23 PM
Edited by: smilingbandit on Apr 1, 2010 6:14 AM: Reason - Fixed formatting of comments. -
Reports output delayed when exported to Excel using OLE2
Hi All,
Platform - Oracle Application Server 10g Release 2 10.1.2.3 on Windows 32 bit.
The report output is getting generated in a minute when exported to PDF i.e destype=cache & desformat=pdf. When we generate the output to excel is considerably delayed. It is taking time and internal server error is occuring.
1) Report developed with simple query
2) Used RPT2XLS procedure which uses OLE2 builtin to export report output into excel.
3) Called RPT2XLS.run procedure in After-Report trigger of the report.
4) We have relased all memory objects in the RPT2XLS package after exporting data and there is no EXCEL.exe running once the file is generated.
System parameters used in the URL.
. destype=file
desformat=pdf
CONTAINSOLE=yes (Required for exporting OLE2 objects into Excel in report)
desname=path & name of the file.
I have gone through the tuning documents for reports server and increased minengine, maxengine and initengine parameters of the reports engine and also changed maxconnect and IdleTimeout parameters in reports server configuration file.
What might be the reason for delaying in the output of the reports when exported to Excel. Can the guys with special knowledge on this area help us in getting out of this issue.
Thanks in advance.hey all,
Thanks everyone for the reply.
I am using the foloowing field cat:
l_col_pos = l_col_pos + 1.
wa_fieldcat-col_pos = l_col_pos.
wa_fieldcat-outputlen = 32.
wa_fieldcat-fieldname = 'SOLLWERT'.
wa_fieldcat-inttype = 'P'.
* wa_fieldcat-tabname = 'i_final'.
wa_fieldcat-seltext_l = text-t11. "Target Value
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
I have use this also in the field cat but stil i get space in the excel header.
wa_fieldcat-REF_FIELDNAME = 'SOLLWERT'.
* wa_fieldcat-REF_TABNAME = 'QAMV'.
Also the space comes with the descrip[tion in the cell of excel.
its like [space Target Value] and i dont need this Space.
I have also used wa_layout-colwidth_optimize = 'X'. but it doesnt wrk.
Please suggest -
Delphi 3 or Delphi XE gives Invalid class string error
I have Delphi 3 and a runtime error occurs when I RUN this project. No build errors...
The form appears correctly and I put the path to the GroupWise domain directory :
F:\opt\novell\groupwise\mail\dom1
I click on the CONNECT button and the error is :
"Project admin_api.exe raised an exception class EOleSysError with message 'Invalid class string'. Process stopped. Use Step or Run to Continue"
For Delphi XE the error is only "Invalid class string".
What am I doing wrong ?
Thank You
Have downloaded the same GroupWise Administrative Object API code
https://www.novell.com/developer/ndk...bject_api.html
unit App_obj;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, OleAuto, Ole2;
type
TForm1 = class(TForm)
Button1: TButton;
Label6: TLabel;
UserID: TEdit;
Label7: TLabel;
LastName: TEdit;
Label8: TLabel;
FirstName: TEdit;
UserDistinguishedName: TEdit;
Label10: TLabel;
SystemInfo: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
SystemDescription: TEdit;
SystemDistinguishedName: TEdit;
SystemLastModifiedBy: TEdit;
ConnectedDomainName: TEdit;
SystemObjectID: TEdit;
PostOfficeList: TComboBox;
Label11: TLabel;
Label9: TLabel;
UserContext: TEdit;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
DomainPath: TEdit;
Button2: TButton;
procedure Initialize(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
vSystem:variant;
vDomain:variant;
const
ADMIN_NAME = 'Admin';
sDOT = '.';
implementation
{$R *.DFM}
procedure TForm1.Initialize(Sender: TObject);
begin
//Initialize controls
DomainPath.Text:='';
SystemDescription.Text:='';
SystemDistinguishedName.Text:='';
SystemLastModifiedBy.Text:='';
ConnectedDomainName.Text:='';
SystemObjectID.Text:='';
UserID.Text:='';
LastName.Text:='';
FirstName.Text:='';
UserDistinguishedName.Text:='';
UserContext.Text:='';
UserID.SetFocus;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
vUsers:variant;
vUser:variant;
stemp:string;
idotpos:integer;
SelectedPO:string;
sAdmin:string;
begin
//Get Selected PostOffice
SelectedPO:=PostOfficeList.Items[PostOfficeList.ItemIndex];
//Get Users Object
vUsers:=vDomain.Users;
//Find Admin user object
vUser:=vUsers.Item(ADMIN_NAME,SelectedPO,Connected DomainName.Text);
If UserContext.Text = '' then begin
//Get Admin Context and use as Default
sAdmin:=vUser.NetID;
idotpos:=Pos(sDOT,sAdmin);
stemp:=Copy(sAdmin,idotpos,256); //Copy everything after first dot include dot
UserContext.Text:=stemp;
end else begin
//Use context string
stemp:=UserContext.Text;
end;
//Make Distinguished name by adding UserID and admin context
stemp:=UserID.Text+stemp;
//Display User distinguished name
UserDistinguishedName.Text:=stemp;
//Add user
vUser:=vUsers.Add(UserID.Text,LastName.Text,stemp,
'',SelectedPO);
//Set User first name
vUser.GivenName:=FirstName.Text;
//Commit User first name to system
vUser.Commit;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
vPostOffice:variant;
vPostOffices:variant;
vPOIterator:variant;
begin
//Get GroupWise Admin Object and connect to it
if(DomainPath.Text = '') then begin
ShowMessage('You must enter a valid Domain Path. Then press Login');
exit;
end;
vSystem:=CreateOleObject('NovellGroupWareAdmin');
vSystem.Connect(DomainPath.Text);
//Get the connected Domain
vDomain:=vSystem.ConnectedDomain;
//List some Domain properties
SystemDescription.Text:=vDomain.Description;
SystemDistinguishedName.Text:=vDomain.Distinguishe dName;
SystemLastModifiedBy.Text:=vDomain.LastModifiedBy;
ConnectedDomainName.Text:=vDomain.Name;
SystemObjectID.Text:=vDomain.ObjectID;
//Initialize controls
UserID.Text:='';
LastName.Text:='';
FirstName.Text:='';
UserDistinguishedName.Text:='';
UserContext.Text:='';
UserID.SetFocus;
//Get list of PostOffices for connected Domain
vPostOffices:=vDomain.PostOffices;
vPOIterator:=vPostOffices.CreateIterator;
vPostOffice:=vPOIterator.Next;
PostOfficeList.Clear;
While( (NOT VarIsNULL(vPostOffice)) And (NOT varisempty(vPostOffice))) do begin
PostOfficeList.Items.Add(vPostOffice.Name);
vPostOffice:=vPOIterator.Next;
end;
//Set index to first item in list
PostOfficeList.ItemIndex:=0;
end;
end.On 9/24/2013 10:46 PM, bperez wrote:
>
> I have Delphi 3 and a runtime error occurs when I RUN this project. No
> build errors...
>
> The form appears correctly and I put the path to the GroupWise domain
> directory :
>
> F:\opt\novell\groupwise\mail\dom1
>
> I click on the CONNECT button and the error is :
>
> "Project admin_api.exe raised an exception class EOleSysError with
> message 'Invalid class string'. Process stopped. Use Step or Run to
> Continue"
>
> For Delphi XE the error is only "Invalid class string".
>
> What am I doing wrong ?
>
> Thank You
>
> Have downloaded the same GroupWise Administrative Object API code
> https://www.novell.com/developer/ndk...bject_api.html
>
> {/************************************************** *************************
>
> ************************************************** **************************/}
> unit App_obj;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
> Dialogs,
> StdCtrls, OleAuto, Ole2;
>
> type
> TForm1 = class(TForm)
> Button1: TButton;
> Label6: TLabel;
> UserID: TEdit;
> Label7: TLabel;
> LastName: TEdit;
> Label8: TLabel;
> FirstName: TEdit;
> UserDistinguishedName: TEdit;
> Label10: TLabel;
> SystemInfo: TGroupBox;
> Label1: TLabel;
> Label2: TLabel;
> Label3: TLabel;
> Label4: TLabel;
> Label5: TLabel;
> SystemDescription: TEdit;
> SystemDistinguishedName: TEdit;
> SystemLastModifiedBy: TEdit;
> ConnectedDomainName: TEdit;
> SystemObjectID: TEdit;
> PostOfficeList: TComboBox;
> Label11: TLabel;
> Label9: TLabel;
> UserContext: TEdit;
> Label12: TLabel;
> Label13: TLabel;
> Label14: TLabel;
> Label15: TLabel;
> Label16: TLabel;
> DomainPath: TEdit;
> Button2: TButton;
> procedure Initialize(Sender: TObject);
> procedure Button1Click(Sender: TObject);
> procedure Button2Click(Sender: TObject);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> Form1: TForm1;
> vSystem:variant;
> vDomain:variant;
>
> const
> ADMIN_NAME = 'Admin';
> sDOT = '.';
>
> implementation
>
> {$R *.DFM}
>
> procedure TForm1.Initialize(Sender: TObject);
> begin
> //Initialize controls
> DomainPath.Text:='';
> SystemDescription.Text:='';
> SystemDistinguishedName.Text:='';
> SystemLastModifiedBy.Text:='';
> ConnectedDomainName.Text:='';
> SystemObjectID.Text:='';
>
> UserID.Text:='';
> LastName.Text:='';
> FirstName.Text:='';
> UserDistinguishedName.Text:='';
> UserContext.Text:='';
> UserID.SetFocus;
>
> end;
>
> procedure TForm1.Button1Click(Sender: TObject);
> var
> vUsers:variant;
> vUser:variant;
> stemp:string;
> idotpos:integer;
> SelectedPO:string;
> sAdmin:string;
> begin
> //Get Selected PostOffice
> SelectedPO:=PostOfficeList.Items[PostOfficeList.ItemIndex];
>
> //Get Users Object
> vUsers:=vDomain.Users;
>
> //Find Admin user object
> vUser:=vUsers.Item(ADMIN_NAME,SelectedPO,Connected DomainName.Text);
>
> If UserContext.Text = '' then begin
>
> //Get Admin Context and use as Default
> sAdmin:=vUser.NetID;
> idotpos:=Pos(sDOT,sAdmin);
> stemp:=Copy(sAdmin,idotpos,256); //Copy everything after first dot
> include dot
> UserContext.Text:=stemp;
>
> end else begin
> //Use context string
> stemp:=UserContext.Text;
> end;
>
> //Make Distinguished name by adding UserID and admin context
> stemp:=UserID.Text+stemp;
>
> //Display User distinguished name
> UserDistinguishedName.Text:=stemp;
>
> //Add user
> vUser:=vUsers.Add(UserID.Text,LastName.Text,stemp,
> '',SelectedPO);
>
> //Set User first name
> vUser.GivenName:=FirstName.Text;
>
> //Commit User first name to system
> vUser.Commit;
> end;
>
>
>
> procedure TForm1.Button2Click(Sender: TObject);
> var
> vPostOffice:variant;
> vPostOffices:variant;
> vPOIterator:variant;
>
> begin
> //Get GroupWise Admin Object and connect to it
> if(DomainPath.Text = '') then begin
> ShowMessage('You must enter a valid Domain Path. Then press
> Login');
> exit;
> end;
> vSystem:=CreateOleObject('NovellGroupWareAdmin');
>
>
> vSystem.Connect(DomainPath.Text);
> //Get the connected Domain
> vDomain:=vSystem.ConnectedDomain;
>
> //List some Domain properties
> SystemDescription.Text:=vDomain.Description;
> SystemDistinguishedName.Text:=vDomain.Distinguishe dName;
> SystemLastModifiedBy.Text:=vDomain.LastModifiedBy;
> ConnectedDomainName.Text:=vDomain.Name;
> SystemObjectID.Text:=vDomain.ObjectID;
>
> //Initialize controls
> UserID.Text:='';
> LastName.Text:='';
> FirstName.Text:='';
> UserDistinguishedName.Text:='';
> UserContext.Text:='';
> UserID.SetFocus;
>
> //Get list of PostOffices for connected Domain
> vPostOffices:=vDomain.PostOffices;
> vPOIterator:=vPostOffices.CreateIterator;
> vPostOffice:=vPOIterator.Next;
> PostOfficeList.Clear;
> While( (NOT VarIsNULL(vPostOffice)) And (NOT
> varisempty(vPostOffice))) do begin
> PostOfficeList.Items.Add(vPostOffice.Name);
> vPostOffice:=vPOIterator.Next;
> end;
>
> //Set index to first item in list
> PostOfficeList.ItemIndex:=0;
> end;
>
> end.
>
>
gw client installed? Novell client installed?
Maybe you are looking for
-
Time Machine will not delete the oldest backup when external hard drive is full
I may not understand this timemachine thing, but.... I have macbook pro, 15", mid 2011, mountain lion......I have a WD Passport Studio I have ben using to back up with time machine periodically. I tried to back up today and it says i do not have enou
-
Hello, i was wondering if i can get a value out of a switch? something like switch(example) case 1: test=1; break; case 2: test=2 break; switch(example1) case 1: test1=1; break; case 2: test1=2 break; }so i want for example the sum from the test valu
-
Cannot BULK download App Updates after iTunes 9.0.1 Update
I had a bunch of updates sitting there, and I decided to update iTunes before doing them. I thought that would be smart. However, after the iTunes update to 9.0.1 was complete I got this message when I tried to bulk download the app updates: *"The in
-
How to reset the security questions
I tried to solve my problem.. shows to go manage ID > Password and Security and I dont see send a email to rescue email adress to reset the answer help my apple ID is blocked now!!!!
-
Dual OS - 10.4.11. and 9.2 - getting rid of 9.2?
Is there any easy way to reclaim the space currently being used on my HD by OS 9.2? I have OS 10.4.11 and no longer need OS9.2. If there is some way to delete OS 9.2 I would be interested, although I don't really want to go down the road of a complet