Agnostic Guides
...
Developers Guide
Useful / Common Link Enterpris...

Store and Link a Document

6min

Storing and linking a document is an extremely common functionality.

Storing be done by either providing content via a filename to upload or by providing the binary content itself.

The Link Enterprise store and link method can also create folder structures (with and without content...note content is stored in the top level folder), and in that scenario optionally apply metadata to the top level folder as well (to apply metadata to subfolders or documents, use the method /dflow/cl_docmanager_helper=>send_metadata_update. You can also choose which level of multi-folder heirachy you create in which to place content if applicable.

/dflow/cl_docmanager_helper=>store_and_link_document

Parameters

Parameter

Description

Sample Value

IV_CALLER

Describes who is calling the method. Logged in the Link Enterprise API Gateway as such.

/dflow/cl_common_super=>

gc_caller_docmanager_custom

IV_MODE

Create can be passed file content (C), the name and path of a file to upload and store (F), as well just create folder with no content (N).

'C' = Content 'F' = File 'N' = No Content

IV_SAP_OBJECT

ArchiveLink SAP Object

BKPF

IV_AR_OBJECT

ArchiveLink doctype

ZINVOICE01

IV_OBJECT_ID

ArchiveLink SAP key. Note this can be a compound key for certain SAP objects or line item/company code level.

300019000000012020

IV_FILE_WITH_PATH

Determine File, Content, or Contentless

'C' = Content 'F' = File 'N' = No Content

IV_NO_CREATE_LINK

Optional: does NOT create a link after successful document storage



IV_NO_METADATA_TRANSFER

Optional: Overrides the docManager rule of whether to send metadata



IV_SIZE

Mandatory if File or Content mode. Size of content in bytes.



IV_RFC

Optional: Name of RFC to override docManager rule



IV_FOLDER_METADATA

Optional: Boolen to indicate if update is to a folder. Note that this is applied to the top level folder only.

X = folder metadata EMPTY = file metadata

IT_METADATA

Table of key value pairs of your CMS properties and the values to update

sapCompanyCode 3000

IT_CONTENT

Optional (if contentless or file mode). Table of binary content.



IT_SAPLINK_METADATA

Optional: no used at this point - future functionality



IT_CUSTOM

Optional: If supported by your CMS repository, the list of folder(s) to create. The first line is the parent folder, lines 2 and above are subfolders (optional). By default, Link Enterprise places the content (when applicable) in the top level folder (ie: the first line). You can override this by placing a ~ tild preceding the folder name. Also by default, the structure will be created as 1 parent and the rest subfolders of that parent. If you wish to create a nested folder structure, set the flag IV_FOLDER_NESTED to X.

SAP_PO_HEADER_4500012349 SAP_PO_LINE_00010 SAP_PO_LINE_00020 (content will be placed in top folder) SAP_PO_HEADER_4500012349 SAP_PO_LINE_00010 ~SAP_PO_LINE_00020 (content will be placed in lowest sub-folder)

EV_DOCUMENT_STORED

N/A if mode is Contentless, else flag indicating whether a document was stored successfully



EV_DOCUMENT_LINKED

N/A if mode is Contentless, else flag indicating whether a document was linked successfully after storage (assuming IV_NO_CREATE_LINK is empty)



EV_ARC_DOC_ID

document ID created in the CMS repository

{FC2F11EF-9AB9-C08E-86B0-74E484400000} or 124057761318

EV_FILENAME

Link Enterprise automatically trims the extension off and passed back just the filename as a parameters



ET_RETURN 

Table that indicates a success of an error. The TYPE field will contain an ‘S’ or ‘E’ respectively and the MESSAGE field will contain information in the case of an error. When you use the IT_CUSTOM folder to create folders, the return table will also pass back the folder ID's created. The parent folder is indicated by a ! exclamation point, all sub-folders are indicated by a ~ tild.

Example of return table when folders are created:

!SAP_4500017723,147811962292

~SAP_SubFolder1,938382828

~SAP_SubFolder2,938382829

~SAP_SubFolder3,938382830 Refer to the below examples for more return table samples.



NOTE: a commit work is required.

Example

note Folder creation is only if supported by your CMS

An easy way to see an example for the parameter is to put a breakpoint in the Link Enterprise DocManager code that will be triggered when storing a document from any Services for Object enabled transaction:

/dflow/cl_docmanager_helper=>store_and_link_document, approximately line 713.

Below are sample values:

Document image




Metadata passed

Document image


Custom table passed

In this example, we instructed Link Enterprise to create a 1 level subfolder. This is done by filling the CUSTOM table with the folder name:



Document image


To implement this folder creation with Store and Link, you can implement in your code that calls Store and LInk, or, implement the BADI /DFLOW/BADI_DOCMGR_STORE_LINK at the point BEFORE the document storage (ie: IV_CALLER 'B' in the BADI). Please refer to the BADI section of this document for more information. Using the BADI ensures that all methods of storing business documents (ie: Migrator, Publisher, standard Link Enterprise DocManager via Services for Object, custom use of Store and Link) all follow the same logic.

Return Table Received

Document image


note: in this return table, we see that we also have Link Enterprise configured to create a folder. When this occurs, the '!' indicates the folder name and the second value is the folder ID.