Q
Problem solve Get help with specific problems with your technologies, process and projects.

Trying to call SAP BAPI from Oracle Forms

I am trying to call SAP BAPI from Oracle Forms 5.0 PL/SQL using BAPI Activex control. I wrote the following code.
Start of code
DECLARE
     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;            
BEGIN
     vBAPICtrl := ole2.create_obj('SAP.BAPI.1');       
     vLogonControl := ole2.create_obj('SAP.LOGONCONTROL.1');       
     SAP_CWdoAuto.Connection(vBAPICtrl,SAP_CSAPLogonControl.NewConnection(vLogonControl)); 
     
     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);              
     pu_release(vBAPICtrl);
     pu_release(vLogonControl);
     END LOOP;  
END;
End of code.

The packages are created from OLE Importer. When I run this code, an error is reported in the trace file. The following is the text from trace file.

2144: >>Invoke ID 1 (GoodsMovement.)
2144: >>Invoke: dispid 11 = VerbType M, Verb CREATEFROMDATA
Thu Feb 26 12:18:46 2004
2144: *** ERROR => Parameter GOODSMVTHEADRET must be passed by reference [wdostub.cpp 1934]
2144: *** ERROR => [-2147352571] Data type mismatch or data conversion failed.
Parameter or attribute GOODSMVTHEADRET. [wdostub.cpp 3817]

Can you tell me what I am doing wrong?
Did you provide me the entire code? What type of trigger in Form does this code belong to? I see an END LOOP in your PL/SQL code... but I do not see the beginning of the loop. Can you provide me with the complete code so I can better respond to your question.

On the surface it seems that the program unit parameters (IN, vs. OUT vs. IN OUT) binding need to be examined. But I could be quite off base on this one. So, please do provide me with the complete text of your PL/SQL trigger code (I say that because I see a DECLARE keyword in your PL/SQL).

Dig Deeper on Using Oracle PL-SQL

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close