Hello guys,
I would like to ask your advice on some custom code we're developing, our target is to connect on SAP, create a link on TOA01 table that is compatible with Archive Services for SAP and create a dm_relation. By saying it must be compatible with ASSAP I mean that SAP will call ASSAP and ASSAP must find our document in the repository.
We already did all oac0, oac2 and oac3 config, and archived a file using FB03 transaction and "Store Business Document" option.
We are doing the following to write on SAP:
DctmSAPFunctionProcessor functionProcessor = new DctmSAPFunctionProcessor("ARCHIV_CONNECTION_INSERT");
functionProcessor.addImportParameterList(this.config.getArchiveID(), "ARCHIV_ID"); //as configured in oac0
functionProcessor.addImportParameterList(this.config.getMandant(), "MANDANT");
functionProcessor.addImportParameterList(this.config.getArObject(), "AR_OBJECT"); //as configured in oac2
functionProcessor.addImportParameterList(this.config.getRepository()+":/DCTM"+sapRelationId.toUpperCase(), "ARC_DOC_ID"); //uses sap_link_relation ID
functionProcessor.addImportParameterList(this.config.getDocumentType(), "DOC_TYPE"); // PDF
functionProcessor.addImportParameterList(idDocument, "OBJECT_ID"); //document name = COMPANY_CODE + DOC_NUMBER + YEAR
functionProcessor.addImportParameterList(this.config.getObjectType(), "SAP_OBJECT"); // BKPF
functionProcessor.addExportParameterInfo("ECHOTEXT", JCO.TYPE_CHAR, 255);
functionProcessor.addExportParameterInfo("RESPTEXT", JCO.TYPE_CHAR, 255);
functionProcessor.execute();
functionProcessor.disconnect();
And we're creating the following relation on DCTM:
IDfPersistentObject sapLinkRelation = session.newObject("sap_link_relation");
String r_object_id = sapDocument.getString("r_object_id");
sapLinkRelation.setString("parent_id", sapDocument.getString("i_chronicle_id")); //chronicle ID
sapLinkRelation.setString("child_id", r_object_id); //object ID
sapLinkRelation.setString("child_label", "");
sapLinkRelation.setString("description", "2@rcud@@);
sapLinkRelation.setString("sap_object_key", documentNumber); //documentNumber = COMPANY_CODE + DOC_NUMBER + YEAR
sapLinkRelation.setTime("effective_date", new DfTime());
sapLinkRelation.setRepeatingString("doc_protection", 0, "rcud");
sapLinkRelation.setRepeatingString("comp_id", 0, "data");
sapLinkRelation.setRepeatingString("format_name", 0, sapDocument.getContentType());
sapLinkRelation.setRepeatingTime("creation_date", 0, new DfTime());
sapLinkRelation.setString("relation_name", "sap_link");
sapLinkRelation.setString("sap_context", DfId.DF_NULLID_STR);
sapLinkRelation.setBoolean("sap_exclusive_link", false);
sapLinkRelation.save();
sapLinkRelation.setString("sap_doc_id", "DCTM"+sapLinkRelation.getObjectId().getId().toUpperCase()); DCTM + relation id
sapLinkRelation.save();
Is this correct? Are we missing any parameter or information that ASSAP would set when archiving natively? Or maybe setting some wrong info...
If someone also need this kind of custom code, I'll be happy to help.
Thanks,
Gustavo