How to map a Document from a subprocess to a main process

Hi, mapping a document from a main process to a subrocess is clear and works. It is written in the documentation in the section “Documents and subprocesses” http://documentation.bonitasoft.com/documents

But how does it work the other way around. I have a subprocess where i upload a document and i want to map that document to a document in the main process.

Thank you and greetings
Nikola

Got it myself. If you want to map a document from a subprocess to a main process you have to map the document value first.
After upload from the document, you have to make a automatic task with a operation where the sub_DocumentValue takes the
value:

import org.bonitasoft.engine.bpm.document.Document;
import org.bonitasoft.engine.bpm.document.DocumentValue;

long id = apiAccessor.getProcessAPI().getLastDocument(processInstanceId, “sub_document”).getId();
Document doc=apiAccessor.getProcessAPI().getDocument(id);
DocumentValue docValue=new DocumentValue(apiAccessor.getProcessAPI().getDocumentContent(doc.getContentStorageId()), doc.getContentMimeType(), doc.getContentFileName());
return docValue;

In main process you have to add a value data variable and map it to the sub_DocumentValue. After that make a operation where the document takes this value.

Greetings
Nikola