Home » Developer & Programmer » Forms » Problem with WEBUTIL_C_API
Problem with WEBUTIL_C_API [message #519696] Tue, 16 August 2011 06:27 Go to next message
asgard
Messages: 3
Registered: August 2011
Junior Member
Good morning.
Sorry for my bad English.
I'm using WEBUTIL_C_API, to perform functions of a DLL coupon issuer and I try to tax problems.

problems:
1) performs the function and the application closes. The code that does this is below:
FUNCTION FUN_REDUCAO_Z (impressora varchar2) RETURN pls_integer IS
DLL_FUNCAO webutil_c_api.FunctionHandle;
lv_plist webutil_c_api.ParameterList;
param1 webutil_c_api.ParameterHandle;
ret PLS_INTEGER:=0;
BEGIN

IF IMPRESSORA ='BEMATECH' THEN
BEGIN

DLL_FUNCAO := WEBUTIL_C_API.register_function(RTRIM(LTRIM(:PARAMETER.P_CF_DIRETORIO))||'\BemaFI32.dll','Bematech_FI_ReducaoZ');

IF NOT WEBUTIL_C_API.ID_NULL(lv_plist) THEN
WEBUTIL_C_API.Destroy_Parameter_List(lv_plist);
END IF;

lv_plist := webutil_c_api.create_parameter_list;

ret := WEBUTIL_C_API.INVOKE_INT(DLL_FUNCAO, lv_plist);

WEBUTIL_C_API.Destroy_Parameter_List(lv_plist);

---SYNCHRONIZE;
RETURN ret;
EXCEPTION
WHEN OTHERS THEN
MESSAGE('ERRO REDUCAO Z:'||SQLERRM);
MESSAGE('ERRO REDUCAO Z:'||SQLERRM);
CLEAR_MESSAGE;
END;
end if;
END;

2) I am unable to receive the return of a variable that in addition to performing the function, the application also closes. The code is below:
FUNCTION fun_NumeroSerie_web ( NumeroSerie IN out VARCHAR2 , impressora in varchar2) RETURN PLS_INTEGER IS
DLL_FUNCAO webutil_c_api.FunctionHandle;
lv_plist webutil_c_api.ParameterList;
param1 webutil_c_api.ParameterHandle;
ret PLS_INTEGER:=0;
BEGIN
NumeroSerie:='';
/*FOR I IN 1..15 LOOP
NumeroSerie := NumeroSerie||' ';
END LOOP;*/

IF IMPRESSORA ='BEMATECH' THEN
BEGIN

DLL_FUNCAO := WEBUTIL_C_API.register_function(RTRIM(LTRIM(:PARAMETER.P_CF_DIRETORIO))||'\BemaFI32.dll','Bematech_FI_NumeroSerie');

IF NOT WEBUTIL_C_API.ID_NULL(lv_plist) THEN
WEBUTIL_C_API.Destroy_Parameter_List(lv_plist);
END IF;


lv_plist := webutil_c_api.create_parameter_list;
param1 := webutil_c_api.add_parameter(lv_plist,webutil_c_api.c_char_ptr,webutil_c_api.param_out,NumeroSerie,length(NumeroSerie));


ret := WEBUTIL_C_API.INVOKE_INT(DLL_FUNCAO, lv_plist);


WEBUTIL_C_API.Destroy_Parameter_List(lv_plist);
WEBUTIL_C_API.Deregister_Function(DLL_FUNCAO);


RETURN ret;
EXCEPTION
WHEN OTHERS THEN
MESSAGE('ERRO :'||SQLERRM);
MESSAGE('ERRO :'||SQLERRM);
CLEAR_MESSAGE;
END;
end if;
END;


The codes have something wrong.
I am running these functions in the web client.
Re: Problem with WEBUTIL_C_API [message #519713 is a reply to message #519696] Tue, 16 August 2011 07:49 Go to previous messageGo to next message
Michel Cadot
Messages: 68667
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version, with 4 decimals.

Regards
Michel
Re: Problem with WEBUTIL_C_API [message #519758 is a reply to message #519713] Tue, 16 August 2011 13:03 Go to previous messageGo to next message
asgard
Messages: 3
Registered: August 2011
Junior Member
Michel,
Good afternoon

I am sending the formatted data.

Oracle DB version : 10.2.0.5
Operating System (OS) : Linux
Operating System Client : Microsoft Windows Server 2003 Enterprise Edition - Service Pack 2

problems:
1) performs the function and the application closes. The code that does this is below:
FUNCTION FUN_REDUCAO_Z (impressora varchar2) RETURN pls_integer IS
   DLL_FUNCAO webutil_c_api.FunctionHandle;
   lv_plist webutil_c_api.ParameterList;
   param1 webutil_c_api.ParameterHandle;
   ret PLS_INTEGER:=0;
 BEGIN
   IF IMPRESSORA ='BEMATECH' THEN
      BEGIN
        DLL_FUNCAO := WEBUTIL_C_API.register_function(RTRIM(LTRIM(:PARAMETER.P_CF_DIRETORIO))
                      ||'\BemaFI32.dll','Bematech_FI_ReducaoZ');
        IF NOT WEBUTIL_C_API.ID_NULL(lv_plist) THEN
           WEBUTIL_C_API.Destroy_Parameter_List(lv_plist);
        END IF;
        lv_plist := webutil_c_api.create_parameter_list;
        ret := WEBUTIL_C_API.INVOKE_INT(DLL_FUNCAO, lv_pl  ist);
        WEBUTIL_C_API.Destroy_Parameter_List(lv_plist);
        SYNCHRONIZE; 
        RETURN ret;
      EXCEPTION
        WHEN OTHERS THEN
           MESSAGE('ERRO REDUCAO Z:'||SQLERRM);
           MESSAGE('ERRO REDUCAO Z:'||SQLERRM);
           CLEAR_MESSAGE;
      END;
   end if;
 END;


2) I am unable to receive the return of a variable that in addition to performing the function, the application also closes. The code is below:

FUNCTION fun_NumeroSerie_web ( NumeroSerie IN out VARCHAR2 ,     
                               impressora in varchar2) RETURN PLS_INTEGER IS
   DLL_FUNCAO webutil_c_api.FunctionHandle;
   lv_plist webutil_c_api.ParameterList;
   param1 webutil_c_api.ParameterHandle;
   ret PLS_INTEGER:=0;
 BEGIN
   NumeroSerie:='';
   FOR I IN 1..15 LOOP
      NumeroSerie := NumeroSerie||' ';
   END LOOP;
   IF IMPRESSORA ='BEMATECH' THEN
      BEGIN
        DLL_FUNCAO := WEBUTIL_C_API.register_function(RTRIM(LTRIM(:PARAMETER.P_CF_DIRETORIO))
                    ||'\BemaFI32.dll','Bematech_FI_NumeroSerie');
        IF NOT WEBUTIL_C_API.ID_NULL(lv_plist) THEN
           WEBUTIL_C_API.Destroy_Parameter_List(lv_plist);
        END IF;
        lv_plist := webutil_c_api.create_parameter_list;
        param1 := webutil_c_api.add_parameter(lv_plist,webutil_c_api.c_char_ptr,webutil_c_api.param_out,NumeroSerie,length(NumeroSerie));
        ret := WEBUTIL_C_API.INVOKE_INT(DLL_FUNCAO, lv_plist);
        WEBUTIL_C_API.Destroy_Parameter_List(lv_plist);
        WEBUTIL_C_API.Deregister_Function(DLL_FUNCAO);
        RETURN ret;
      EXCEPTION
         WHEN OTHERS THEN
           MESSAGE('ERRO :'||SQLERRM);
           MESSAGE('ERRO :'||SQLERRM);
           CLEAR_MESSAGE;
      END;
   end if;
END;


The codes have something wrong?
Re: Problem with WEBUTIL_C_API [message #519767 is a reply to message #519758] Tue, 16 August 2011 14:15 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
No idea, except the fact that both functions will fail if IMPRESORA <> 'BEMATECH', because functions will end without returning a value.

Also, remove WHEN OTHERS because you aren't handling any errors at all. Let Oracle raise an exception.
Re: Problem with WEBUTIL_C_API [message #519772 is a reply to message #519767] Tue, 16 August 2011 15:54 Go to previous message
asgard
Messages: 3
Registered: August 2011
Junior Member
Good afternoon

Littlefoot, thanks for the tip, but the problem appears not to be, because there is another function like fun_reducao_z, which is only changed the function call this DLL and running. What I realized was that when the line is driven code ret: = WEBUTIL_C_API.INVOKE_INT (DLL_FUNCAO, lv_pl ist) runs showing the result in fiscal printer and closes the application.
Previous Topic: Trim issue
Next Topic: Forms 6i-To show detail block when a button is pressed
Goto Forum:
  


Current Time: Fri Jul 26 07:33:16 CDT 2024