Home » Developer & Programmer » Forms » Problem with Add_Olearg(Object,VT_DISAPTCH)
Problem with Add_Olearg(Object,VT_DISAPTCH) [message #261201] Wed, 22 August 2007 02:42 Go to next message
Deval
Messages: 2
Registered: August 2007
Location: Ahemedabad
Junior Member
Hi all
I am calling SAP BAPI using BAPI Activex Control from within Forms6i. in SAP_CWdoAuto package there is a functon named DimAs
internally this function uses Add_olearg(Object,VT_DISPATCH) built-in procedure.

from with in Add_olearg(Object,VT_DISPATCH) i am getting error like
FRM-40922: An OLE Error occured: 0x80020005.

Here is my entire code for your reference.
DECLARE
-- constant for user identification
  cstrMUsrClient          constant char (3)                            := '100';
  cstrMUsrUser            constant varchar2 (10)                   := 'UPPLDEV';
  cstrMUsrPassword        constant varchar2 (10)                  := 'UPPLSTAR';
  cstrMUsrLanguage        constant varchar2 (10)                        := 'EN';
-- constant for system identification
  cstrMSysSystem          constant varchar2 (10)                       := 'DEV';
  cstrMSysMessageServer   constant varchar2 (10)                    := 'ECCDEV';
  cstrMSysGroupName       constant varchar2 (10)                    := 'PUBLIC';
  vConCtrl                         OleObj;
  hWnd                             olevar;
  v_args                           OLE2.LIST_TYPE;
  vBAPICtrl                        SAPBAPIControlLib_CONSTANTS.SAPBAPIControl;
  v_conn_result                    SAPLogonCtrl_CONSTANTS.CRfcConnectionStatus;
  v_dummy                          olevar;
  vLogonControl                    OleObj;
  vGoodsMovement                   oleobj;
  vGoodsMovementHeader             oleobj;
  vGoodsMvtHeaderReturn            oleobj;
  vGoodsMovementCode               oleobj;
  vTabGoodsMovementItem            oleobj;
  vGoodsMovementReturn             oleobj;
  vGMSerialNumber                  oleobj;
  v_Item_rows                      oleobj;
  helpcontextid                    PLS_INTEGER;
  helpfile                         VARCHAR2 (255);
  source                           VARCHAR2 (255);
  description                      VARCHAR2 (255);
  errornumber                      PLS_INTEGER;
  errnum                           PLS_INTEGER;
BEGIN
--   create BAPI ActiveX control object
  vBAPICtrl              := ole2.Create_Obj ('SAP.BAPI.1');
--   create R/3 logon control object
  vLogonControl          := ole2.Create_Obj ('SAP.Logoncontrol.1');
  vConCtrl               := SAP_CSAPLogonControl.NewConnection (vLogonControl);
  SAP_CSAPLogonConnection.SYSTEM (vConCtrl, cstrMSysSystem);
  SAP_CSAPLogonConnection.MessageServer (vConCtrl, cstrMSysMessageServer);
  SAP_CSAPLogonConnection.GroupName (vConCtrl, cstrMSysGroupName);
  SAP_CSAPLogonConnection.Client (vConCtrl, cstrMUsrClient);
  SAP_CSAPLogonConnection.User (vConCtrl, cstrMUsrUser);
  SAP_CSAPLogonConnection.Password (vConCtrl, cstrMUsrPassword);
  SAP_CSAPLogonConnection.Language (vConCtrl, cstrMUsrLanguage);
  SAP_CWdoAuto.Connection (vBAPICtrl, vConCtrl);
  if SAP_CSAPLogonConnection.Logon (vConCtrl, hWnd, 0) = 0 then
    MESSAGE ('SAP Logon Fail');
    message ('SAP Logon Fail');
  else
    message ('SAP Logon Success');
    message ('SAP Logon Success');
  end if;
  vGoodsMovement         := SAP_CWdoAuto.GetSAPObject (vBAPICtrl,
                                                       'GoodsMovement');
  vGoodsMovementHeader   := SAP_CWdoAuto.DimAs (vBAPICtrl,
                                                vGoodsMovement,
                                                'CreateFromData',
                                                'GoodsmvtHeader');
  vGoodsMovementCode     := SAP_CWdoAuto.DimAs (vBAPICtrl,
                                                vGoodsMovement,
                                                'CreateFromData',
                                                'GoodsmvtCode');
  vGoodsMvtHeaderReturn  := SAP_CWdoAuto.DimAs (vBAPICtrl,
                                                vGoodsMovement,
                                                'CreateFromData',
                                                'GoodsmvtHeadret');
  vTabGoodsMovementItem  := SAP_CWdoAuto.DimAs (vBAPICtrl,
                                                vGoodsMovement,
                                                'CreateFromData',
                                                'GoodsmvtItem');
  vGoodsMovementReturn   := SAP_CWdoAuto.DimAs (vBAPICtrl,
                                                vGoodsMovement,
                                                'CreateFromData',
                                                'Return');
  vGMSerialNumber        := SAP_CWdoAuto.DimAs (vBAPICtrl,
                                                vGoodsMovement,
                                                'CreateFromData',
                                                'GoodsmvtSerialnumber');
  SAP_IStructure.Value (vGoodsMovementHeader,
                        to_variant ('20040226'),
                        to_variant ('PSTNG_DATE'));
  SAP_IStructure.Value (vGoodsMovementCode,
                        to_variant ('04'),
                        to_variant ('GM_CODE'));
  v_Item_rows            := SAP_CSAPTaFacTable.AppendRow (vTabGoodsMovementItem);
  SAP_CSAPTaFacTable.Value (vTabGoodsMovementItem,
                            1,
                            TO_VARIANT ('1865E29H01'),
                            to_variant (1));
  v_args                 := OLE2.CREATE_ARGLIST;
  OLE2.ADD_ARG_OBJ (v_args, vGoodsMovementHeader);
  OLE2.ADD_ARG_OBJ (v_args, vGoodsMovementCode);
  OLE2.ADD_ARG_OBJ (v_args, vGoodsMvtHeaderReturn);
  OLE2.ADD_ARG_OBJ (v_args, vTabGoodsMovementItem);
  OLE2.ADD_ARG_OBJ (v_args, vGMSerialNumber);
  OLE2.ADD_ARG_OBJ (v_args, vGoodsMovementReturn);
  OLE2.ADD_ARG (v_args, ' ');
  OLE2.INVOKE (vGoodsMovement, 'CreateFromData', v_args);
exception
  when FORM_OLE_FAILURE then
    errnum  := LAST_OLE_EXCEPTION (source, description, helpfile,
                                   helpcontextid);
    message (source);
    message (source);
END;

here is DimAs function of SAP_CWdoAuto package.
FUNCTION DimAs (
  interface   OleObj,
  Object      OleObj,
  Method      VARCHAR2,
  Parameter   VARCHAR2)
  RETURN OleObj IS
  my_new_value   OleObj;
BEGIN
  Init_OleArgs (3);
  Add_OleArg (Object, VT_DISPATCH);
  Add_OleArg (Method);
  Add_OleArg (Parameter);
  my_new_value  := Call_Ole_Obj (interface, 5);
  return my_new_value;
End;

Please any one can help me to solve this error?

Thanks in advance.
Deval Bhatt.

[Updated on: Thu, 23 August 2007 19:38] by Moderator

Report message to a moderator

Re: Problem with Add_Olearg(Object,VT_DISAPTCH) [message #261858 is a reply to message #261201] Thu, 23 August 2007 19:49 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Deval,

Does this code fail everytime or does it work the first time but not thereafter? I have reformatted your code as per the instructions in the sticky (but using TOAD's reformatter). What is the name of the first block of code? Also, use 'message; pause;' pairs between EVERY line of your code to determine exactly which line is failing.

Also, search this forum for 'CREATE_ARGLIST' and see what other people have been doing.

David
Re: Problem with Add_Olearg(Object,VT_DISAPTCH) [message #262021 is a reply to message #261858] Fri, 24 August 2007 06:21 Go to previous messageGo to next message
Deval
Messages: 2
Registered: August 2007
Location: Ahemedabad
Junior Member
Hi David Thanks for your reply,

I have taken only one push Button and write the entire code in 'When-Button-Pressed' Trigger block.

It gives error every time. I know where the error is but not able to rectify it. I have debug that program and it gives error when calling DimAS function. In DimAS Function it gives error at Add_OleArg(Object, VT_DISPATCH) statement.

Re: Problem with Add_Olearg(Object,VT_DISAPTCH) [message #262393 is a reply to message #262021] Sun, 26 August 2007 23:06 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Please find 'Add_OleArg' as it is not a Forms command. Is it in one of the SAP pll files?

David
Previous Topic: hrlp FRM-40106 No navigable items
Next Topic: pll migration problem
Goto Forum:
  


Current Time: Sat Dec 03 11:46:20 CST 2016

Total time taken to generate the page: 0.12110 seconds