Tuesday, April 24, 2018

scan to pdf from oracle forms 10g to shared folder


To scan document from oracle forms to shared folder

In This post, we will explain one way to scan document to pdf or image forms, the attached forms use the following third party tool (naps2) which scan to pdf using command line parameter

In addition, we will call VBscipt  which in turn call naps2 file using command prompt using java bean, this java bean simply execute any command prompt from oracle forms as below code

Step :-1 frist add bean to your forms
Step :-2 add button to your forms which will call the following code:-
FILE_NAME will be file location example d:\f.pdf or \\filserver\doc\a.pdf
pdfscan.vbs is the vbscript wich accept filename as input and it call naps2 file
pdfscan.vbs can be on clinet user machine or smpliy in sahred folder like \\filserver\doc\

declare

               CMD varchar2(300);
begin
CMD:='cmd /c wscript \\filserver\doc\pdfscan.vbs '||:FILE_NAME;
 Set_Custom_Property( 'BL.BEAN', 1, 'SET_PROG', CMD ) ;
 

END;

Step :-3 using notpade past this code and save it as pdfscan.vbs and put this file in location we can be accessed from any forms like \\filserver\doc\pdfscan.vbs
=====================================================
Option Explicit
Dim oTxtFile
Dim InputFile
Dim objFSO, strDoc, objFile,oWord,oShell
InputFile= WScript.Arguments(0)
 'Msgbox InputFile
With (CreateObject("Scripting.FileSystemObject"))
  If .FileExists(InputFile) Then
      Msgbox "File Exist"
      Set oShell = WScript.CreateObject ("WScript.Shell")
      'Msgbox "C:\NAPS2\NAPS2.Console.exe -i "& InputFile &" -o "& InputFile &" -f"
      oShell.run   "C:\NAPS2\NAPS2.Console.exe -i "& InputFile &" -o "& InputFile &" -f"
      Set oShell = Nothing'
  Else
      'Set oTxtFile = .CreateTextFile(InputFile)
      Msgbox "File Created"
     
      Set oShell = WScript.CreateObject ("WScript.Shell")
      oShell.run   """C:\NAPS2\NAPS2.Console.exe"" -o" &InputFile
      Set oShell = Nothing'
  End If

End With

WScript.Quit(1) 

=========================================

Step :-4 just scan
Thanks

attached form:-

Monday, January 1, 2018

Could not reserve record 2 tries keep trying oracle forms -Sloution


  1. This error happens because there is locked session and the solution to kill the session using the following steps :-
  • first fin the locked session using this query from db account select sid,serial# from v$session where sid in (select a.SESSION_ID from v$locked_object a, dba_objects b where a.object_id = b.object_id and a.SESSION_ID not in (select a.SESSION_ID from v$locked_object a, dba_objects b where a.object_id = b.object_id and session_id in (select sid from v$lock where block = 1)));
  • Then kill the locked session using sid,serial# from the first query  using this :- alter system kill session '119,148 ' immediate;

Open Word Document From Oracle 10g Form

1-Configure webutil as per this post
10g.htmlhttp://oracleformtips.blogspot.com/2017/12/setup-webutil-for-developer-suite-10g.html
2-on button press use this
begin
app CLIENT_OLE2.OBJ_TYPE;
docs CLIENT_OLE2.OBJ_TYPE;
doc CLIENT_OLE2.OBJ_TYPE;
selection CLIENT_OLE2.OBJ_TYPE;
args CLIENT_OLE2.LIST_TYPE;
pid WEBUTIL_HOST.PROCESS_ID;
FilePath varchar2(250);
file_doc_no varchar2(80);
c number;
 AppID PLS_INTEGER;
BEGIN

   --example : FilePath:=d:\d.doc
   --you can pass this from function
  FilePath:='d:\d.doc';
 
   
if webutil_file.file_exists (FilePath) then
 


app := CLIENT_OLE2.CREATE_OBJ('Word.Application');
CLIENT_OLE2.SET_PROPERTY(app,'Visible', 1);
docs := CLIENT_OLE2.INVOKE_OBJ(app, 'documents'); 
args := CLIENT_OLE2.create_arglist;
CLIENT_OLE2.add_arg(args, FilePath);
doc := CLIENT_OLE2.INVOKE_OBJ(docs,'Open', args);
CLIENT_OLE2.destroy_arglist(args);
CLIENT_OLE2.release_obj(docs);
CLIENT_OLE2.release_obj(app);


   
else
 

  app := CLIENT_OLE2.CREATE_OBJ('Word.Application');

  CLIENT_OLE2.SET_PROPERTY(app,'Visible',1);
  docs := CLIENT_OLE2.GET_OBJ_PROPERTY(app, 'Documents');
  doc  := CLIENT_OLE2.INVOKE_OBJ(docs, 'add'); 
  selection := CLIENT_OLE2.GET_OBJ_PROPERTY(app, 'Selection');

  -- insert data into new document from long item
  --CLIENT_OLE2.SET_PROPERTY(selection, 'Text', :ole.oletext);

  -- save document as example.tmp
  args := CLIENT_OLE2.CREATE_ARGLIST;
 
  CLIENT_OLE2.ADD_ARG(args, FilePath);

  CLIENT_OLE2.INVOKE(doc, 'SaveAs', args);
  CLIENT_OLE2.DESTROY_ARGLIST(args);

end if;

end;

How to create the Hierarchical Tree menu for system in oracle forms

1-create Schema object Table and USER object
CREATE TABLE  SCM_OBJECTS
(
  OBJECT_ID         VARCHAR2(100 BYTE),
  OBJECT_TYPE       VARCHAR2(1 BYTE),
  PARENT_OBJECT_ID  VARCHAR2(60 BYTE),
  SEQUENCE_NUMBER   NUMBER(4),
  CLASSIFICATION    VARCHAR2(2 BYTE),
  OBJECT_DESC_A     VARCHAR2(150 BYTE),
  OBJECT_DESC_E     VARCHAR2(150 BYTE),
  A_OBJECT_NAME     VARCHAR2(25 BYTE),
  APPL_TYPE         NUMBER,
  OBJECT_PRVLG      NUMBER,
  ACCESS_MODE       NUMBER,
  REPT_PARAM        VARCHAR2(300 BYTE),
  PARENT_SEQUENCE   NUMBER,
  CHILD_SEQUENCE    NUMBER,
  ICON              VARCHAR2(60 BYTE)
)

OBJECT_ID  -forms name or report or menu name
OBJECT_TYPE -Forms or report or Menu
PARENT_OBJECT_ID  ID -for PARENT
OBJECT_DESC_A   Title in ARABIC
 OBJECT_DESC_E  Title IN ENGLISH
A_OBJECT_NAME  Object name
 PARENT_SEQUENCE -PARENT sequence represent the order of the PARENT
CHILD_SEQUENCE -CHILD sequence represent the order of the PARENT-CHILD order
ICON -ICON name should appear need to put all icon in gif  using jar file

CREATE TABLE USER_OBJECTS
(
  EMP_CODE       NUMBER(6)                      NOT NULL,
  OBJECT_ID      VARCHAR2(200 BYTE)             NOT NULL,
  FORM_ACCESS    CHAR(1 BYTE),
  FORM_INSERT    CHAR(1 BYTE),
  FORM_UPDATE    CHAR(1 BYTE),
  FORM_DELETE    CHAR(1 BYTE),
  CREATED_BY     VARCHAR2(50 BYTE),
  CREATED_DATE   DATE,
  MODIFIED_BY    VARCHAR2(50 BYTE),
  MODIFIED_DATE  DATE,
  ACCESS_MODE    NUMBER
)

2-create tree object



3-create PROCEDURE :-Create_tree
PROCEDURE Create_tree IS
BEGIN
declare
Treerg Recordgroup;
  X Number ; 
  rg_id RECORDGROUP;
begin


       
rg_id := FIND_GROUP('MAIN.Tree');

IF NOT ID_NULL(rg_id) THEN

DELETE_GROUP(rg_id);

END IF;
rg_id := CREATE_GROUP_FROM_QUERY('G' ,' SELECT 1,level,Description,icon NODE_ICON,object_id
  from (
  SELECT object_id,OBJECT_DESC_A Description,icon,parent_object_id,PARENT_SEQUENCE,CHILD_SEQUENCE  
                     FROM scm_objects
                    WHERE object_type = '||''''||'M'||''''||
                     'and object_id IN(
                                             select  
                                              PARENT_OBJECT_ID
                                              from USER_OBJECTS,SCM_OBJECTS
                                              where EMP_CODE='||''''||:PARAMETER.P_EMP_NO||''''||
                                              'and USER_OBJECTS.OBJECT_ID =SCM_OBJECTS.OBJECT_ID 
                                              group by PARENT_OBJECT_ID)
                                              union SELECT SCM_OBJECTS.object_id,OBJECT_DESC_A Description,icon,parent_object_id,PARENT_SEQUENCE,CHILD_SEQUENCE  
                     FROM USER_OBJECTS,SCM_OBJECTS
                     where    USER_OBJECTS.OBJECT_ID =SCM_OBJECTS.OBJECT_ID 
                     and EMP_CODE='||''''||:PARAMETER.P_EMP_NO||''''||')'||
                     
             'CONNECT BY PRIOR object_id = NVL(parent_object_id,0) 
             START WITH   parent_object_id  is null
           ORDER BY PARENT_SEQUENCE,CHILD_SEQUENCE  ');--parent_object_id =0 order by ');

           X := Populate_Group('G');
Ftree.Set_Tree_Property('MAIN.Tree', Ftree.Record_Group, 'G');
Delete_Group ('G');
exception when others then 
message(sqlerrm ) ; 
End ;
end;


Note:-:PARAMETER.P_EMP_NO Come from Login Screen 

4-on WHEN-NEW-FORM-INSTANCE add this;
       Create_tree;


Wednesday, December 27, 2017

Setup WebUtil for Developer Suite 10g or Oracle AS 10g

How to install and configure Webutil on Oracle Application Server 10g/Developer 10g both on Windows/Linux
Setup WebUtil for Developer Suite 10g or Oracle AS 10g

WebUtil is a powerful component in Oracle Form 9i,10g, but setting up WebUtil is a nightmare for most of the developer. I hope the guideline below is useful for people who wish to setup WebUtil at Windows environment.

Steps to setup WebUtil in Developer Suite or Oracle AS
=======================================================

1. Download WebUtil and Jacob library
1.1.Webutil_106.zip from:
http://www.oracle.com/technology/software/product/forms/files/webutil/webutil_106.zip

1.2.Extract the zip file and put into the Oracle AS or Developer Suite 10g\forms

1.3.Download Jacob library from:
http://prdownloads.sourceforge.net/jacob-project/jacob_18.zip

1.4.Extract the zip file then:
1.4.1. COPY JACOB.JAR file on D:\DevSuiteHome_1\forms\java
1.4.2. COPY JACOB.DLL file on D:\DevSuiteHome_1\forms\webutil

2.Signing frmwebutil.jar and Jacob.jar.
2.1. On Dos Prompt Sign frmwebutil.jar and jacob.jar with following commands
C:\>set path=D:\DevSuiteHome_1\jdk\bin;%PATH%

Sign the files by using
C:\>D:\oracle\DevSuiteHome_1\forms\webutil\sign_webutil D:\DevSuiteHome_1\forms\java\frmwebutil.jar

Output
Generating a self signing certificate for key=webutil2...
...successfully done.


Backing up D:\DevSuiteHome_1\forms\java\frmwebutil.jar as D:\DevSuiteHome_1\forms\java\frmwebutil.jar.old...
1 file(s) copied.
Signing D:\DevSuiteHome_1\forms\java\frmwebutil.jar using key=webutil2...
...successfully done.

C:\>D:\DevSuiteHome_1\forms\webutil\sign_webutil D:\DevSuiteHome_1\forms\java\jacob.jar

Output
Generating a self signing certificate for key=webutil2...
keytool error: java.lang.Exception: Key pair not generated, alias already exists
.
There were warnings or errors while generating a self signing certificate. Please review them.
.
Backing up D:\DevSuiteHome_1\forms\java\jacob.jar as D:\DevSuiteHome_1\forms\java\jacob.jar.old...
1 file(s) copied.
Signing D:\DevSuiteHome_1\forms\java\jacob.jar using key=webutil2...
...successfully done.


3.Create webutil package in the database.
3.1 Open sqlplus and run create_webutil_db.sql at \forms.
3.2 The script will create webutil package in the database user.
3.3 You need to run create_webutil_db.sql for all database users which need to make use of Webutil.


4.Compile the webutil.pll.
4.1 You can compile using Oracle Forms Developer or run the command below:
a.frmcmp module=ORACLE_HOME\forms\webutil.pll userid= module_type=library compile_all=yes


5.Modify the DEFAULT.ENV file,
you can find default.env file at D:\DevSuiteHome_1\forms\server\Default.env
append the following path in CLASSPATH entry
;D:\DevSuiteHome_1\jdk\jre\lib\rt.jar

append the following path in FORMS_PATH
;D:\DevSuiteHome_1\forms\webutil

6.Modify the FORMSWEB.CFG file,
you can find this file at D:\DevSuiteHome_1\forms\server\formsweb.cfg
add:
archive_jini=frmall_jinit.jar,frmwebutil.jar,jacob.jar
archive=frmall.jar
also add :
[webutil]
WebUtilArchive=frmwebutil.jar,jacob.jar,f90all.jar
WebUtilLogging=off
WebUtilLoggingDetail=normal
WebUtilErrorMode=Alert
WebUtilDispatchMonitorInterval=5
WebUtilTrustInternal=true
WebUtilMaxTransferSize=16384
baseHTMLjinitiator=webutiljini.htm
baseHTMLjpi=webutiljpi.htm
archive_jini=frmall_jinit.jar
archive=frmall.jar,f90all.jar
lookAndFeel=oracle

7.Modify the WEBUTIL.CFG file
locate at the same place where you found the FORMSWEB.CFG file and change the following
#transfer.database.enabled=FALSE (default value)
transfer.database.enabled=TRUE
#transfer.appsrv.enabled=FALSE (default value)
transfer.appsrv.enabled=TRUE


signer information does not match signer information of other classes in the same package in Oracle forms java bean

The Main issue to this , is there are many jar File have same package name on it To Solve the issue ,used  JDeveloper or any java develo...