cancel
Showing results for 
Search instead for 
Did you mean: 

JCO error in storing document in KPRO

Former Member
0 Kudos

Hi Expert,

I have one BAPI to store the document in KPRO. BAPI_DOCUMENT_CREATE2

If call that BAPI in java class program it is working fine.

If i call that java class in web Dynpro application it is not working.

Below code to store the file in to KPRO



public static boolean doUpload(String path,String number){
		JCO.Client client = null,client1 = null;
		JCO.Repository repository = null,repository1 = null;
		JCO.ParameterList inputParameter = null, outputParameter = null,inputParameter1 = null;
		JCO.Function bapiDocument = null,bapiDocument1 = null;
		JCO.Table table_lsdoc=null,table_Doc_Details=null;
		JCO.Table table_in_FilePath=null,table_out_Return=null;
		JCO.Structure st=null,st1=null;
		String file_Path="",return_Message="",doc_Type="",stor_Cat="";
		try{
			client = ConnectToR3.getConnection();
			
			System.out.println("1");	
			repository = new JCO.Repository("SearchRepository", client);
			System.out.println("2");
			//System.out.println("Connected to repositry");	
			bapiDocument = repository.getFunctionTemplate("Z_DOCUMENT_CREATE").getFunction();
			System.out.println("3");
			JCO.setMiddlewareProperty("jco.middleware.allow_start_of_programs", "ftp;sapftp;sapftpa;sapkprotp;http;saphttp;saphttpa");
			System.out.println("4");
			if (bapiDocument != null){
				table_in_FilePath=bapiDocument.getTableParameterList().getTable("S_DOCUMENTFILES");
				table_in_FilePath.appendRow();
				
				table_in_FilePath.setValue(number, "DOCUMENTNUMBER");
				table_in_FilePath.setValue(path, "DOCPATH");
				client.execute(bapiDocument);
				System.out.println("5");
				table_out_Return=bapiDocument.getTableParameterList().getTable("S_DOCUMENTFILES");
				System.out.println("6");
				int flag=0;
				if(table_out_Return.getNumRows()>0){
					System.out.println("7");
					table_out_Return.firstRow();
					for(int i=0;i<table_out_Return.getNumRows();i++){
						System.out.println("8");
						System.out.println(table_out_Return.getValue("DELETEVALUE").toString());
						if(table_out_Return.getValue("DELETEVALUE").toString().equalsIgnoreCase("s")){
							flag=1;
							break;
						}else{
							flag=0;
							break;
						}
						//table_out_Return.nextRow();
					}
					if(flag==1)
						return true;
					else
						return false;
						
				}else
					return false;
				//return false;
			}else
				return false;
			//return false;
		}catch(Exception e){
			System.out.println("Exception in Upload "+e);
			return false;
			
		}
		finally{
			try{
				if (client != null){
					ConnectToR3.closeConnection(client);		
					
				}
			} 
			catch (Exception ef){
				System.out.println("Exception in Finally Block in SAPConnect."+ ef.getMessage());
				return false;
				
			}
		}

In above code i created Z RFC for some customization. Actual Bapi to Store the file in KPRO "BAPI_DOCUMENT_CREATE2".

To execute this bapi from webdynpro any exe or dll file required.I saw some other thread 2 exe are required to execute the above RFC(<b>SAPFTP.exe, SAPHTTP.exe</b>).

If it is required to place the above 2 exe, where to place that exe's in webdynpro application.

Please help me.. Urgent....

Regards,

Satya 😞

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member182374
Active Contributor
0 Kudos

Hi Sunil,

The correct way of running BAPIs from Web Dynpro is using Adaptive RFC.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/49f2ea90-0201-0010-ce8e-de1...

From there go to

Creating A Web Dynpro Application Accessing ABAP Functions

Regards,

Omri

Former Member
0 Kudos

Hi,

I tried using Adaptive RFC also, i am not able to upload the document into KRPO. This uploading is similar to storing the document into DMS.

Any where you used 2exe's (SAPFTP.exe & SAPHTTP.exe).

Regards,

Sunil