cancel
Showing results for 
Search instead for 
Did you mean: 

How to use BAPI_DOCUMENT_CHECKOUTVIEW2 when there is more than one document

0 Kudos

Hello everybody,

I have a problem to check out a document, when there is more than one document attached to one document number(JCO 2.0.8).

I use getDocumentDetails() to get the FILE_ID of the requested document, but somehow I have no success to pass the FILE_ID to BAPI_DOCUMENT_CHECKOUTVIEW2.

Anybody here with a clue ?

Best regards

Andreas

--- Code Snippet -


public static void getDocument(IRepository repository, JCO.Client client, String docNumber,String docType, String docVer, String docPart) throws Exception {

String fileID=getDocumentDetails( repository, client, docNumber, docType, docVer, docPart);

JCO.setMiddlewareProperty("jco.middleware.allow_start_of_programs", "sapftp");

IFunctionTemplate ftemplate = repository.getFunctionTemplate("BAPI_DOCUMENT_CHECKOUTVIEW2");

// Create a function from the template

JCO.Function function = new JCO.Function(ftemplate);

JCO.ParameterList input = function.getImportParameterList();

input.appendValue("DOCUMENTTYPE", JCO.TYPE_CHAR, 3, docType);

input.appendValue("DOCUMENTNUMBER", JCO.TYPE_CHAR, 25, docNumber);

input.appendValue("DOCUMENTVERSION", JCO.TYPE_CHAR, 2, docVer);

input.appendValue("DOCUMENTPART", JCO.TYPE_CHAR, 3, docPart);

input.appendValue("ORIGINALPATH", JCO.TYPE_CHAR, 255, "D:
SAPTemp
");

//this does not work

input.appendValue("DOCUMENTFILE-FILE_ID", JCO.TYPE_CHAR, 32, "fileID");

//this does not work either

JCO.Structure struct = (JCO.Structure)function.getImportParameterList().getStructure("DOCUMENTFILE");

struct.setValue(docType, "DOCUMENTTYPE");

struct.setValue(docPart, "DOCUMENTNUMBER");

struct.setValue(docVer, "DOCUMENTVERSION");

struct.setValue(docPart, "DOCUMENTPART");

struct.setValue(fileID, "FILE_ID");

client.execute(function); //-> Exception

...

}

public static String getDocumentDetails(IRepository repository, JCO.Client client, String docNumber,String docType, String docVer, String docPart) throws Exception {

String fileID="";

IFunctionTemplate ftemplate = repository.getFunctionTemplate("BAPI_DOCUMENT_GETDETAIL2");

// Create a function from the template

JCO.Function function = new JCO.Function(ftemplate);

JCO.ParameterList input = function.getImportParameterList();

input.appendValue("DOCUMENTTYPE", JCO.TYPE_CHAR, 3, docType);

input.appendValue("DOCUMENTNUMBER", JCO.TYPE_CHAR, 25, docNumber);

input.appendValue("DOCUMENTVERSION", JCO.TYPE_CHAR, 2, docVer);

input.appendValue("DOCUMENTPART", JCO.TYPE_CHAR, 3, docPart);

client.execute(function);

....

JCO.Table docList = function.getTableParameterList().getTable("DOCUMENTFILES");

...

fileID= (String) docList.getValue("FILE_ID");

..

return fileID;

}

Message was edited by: Andreas Schmidt

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Check if the File_ID is being returned by getDocumentDetails() by Printing out or Logging the File_ID value after the file_id retrival step in your code.

And do check if there is any attribute which is unique like timestamp of the file similar to File_Id and try to use that attribute in your code to checkout the desired file.

Hope this will help you

0 Kudos

Hello,

I was able to solve the problem.

Somehow the params FILE_ID, APPLICATION_ID or CREATED_AT did not work.

Instead the param WSAPPLICATION did the job (fortunately this will be unique in our case).

0 Kudos

Hello,

the params FILE_ID, APPLICATION_ID and CHANGED_AT did not work, but WSAPPLICATION did the job

Answers (1)

Answers (1)

Former Member
0 Kudos

Cool you got the Output !!