Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Loading documents and attaching them to business objects

Former Member
0 Kudos
614

Hi,

I am trying to load documents (Word and PDF files) into a content management server linked to a SAP CRM system. The documents need to be attached to business objects such as interaction records (BUS2000126) and service tickets (BUS2000116).

I have experimented with FMs <b>BDS_BUSINESSDOCUMENT_CREATEF</b> and <b>ARCHIV_CONNECTION_INSERT</b> but haven't yet found the right combination of values. The best I have done is to create a link which is visible in the GUI as an icon, but when I double click on it, I get an error message saying that the document does not exist (error 404).

The import parameters I am using in BDS_BUSINESSDOCUMENT_CREATEF are:

LOGICAL_SYSTEM = [blank]

CLASSNAME = ZCSIP_LTR (a value from table TOADV)

CLASSTYPE = BO

CLIENT = [default]

OBJECT_KEY = [blank]

FILES

DOC_COUNT = 00000001

COMP_COUNT = 00000001

COMP_ID = [blank]

DIRECTORY = U:\DOCUMENTS\TEST DATA\

FILENAME = FA.PDF

MIMETYPE = application/pdf

SIGNATURE

DOC_COUNT = 00000001

PROP_NAME = BDS_CONTREP

PROP_VALUE = ZT (my content repository name)

The FM returns a GUID as the OBJECT_KEY ...

Then I am using ARCHIV_CONNECTION_INSERT as follows:

ARCHIV_ID = ZT

ARC_DOC_ID = [GUID returned by BDS_BUSINESSDOCUMENT_CREATEF]

AR_OBJECT = ZCSIP_LTR (a value from table TOADV - as above)

MANDANT = [default client as above]

OBJECT_ID = [GUID of the object I want to attach the document to]

SAP_OBJECT = [Business object identifier] e.g. BUS2000126

DOC_TYPE = PDF

Can what I need to do be achieved through just using BDS_BUSINESSDOCUMENT_CREATEF? What import parameters should I use? What values should they contain?

Many thanks in advance,

Peter

4 REPLIES 4

Former Member
0 Kudos
161

Hi,

BDS classname BUS2032 and classtype BO

but function module 'BDS_BUSINESSDOCUMENT_CREATEF' and cl_bds_document_set class method

here is the code..

DATA: o_document_set TYPE REF TO cl_bds_document_set,

wa_signature LIKE bapisignat,

i_signature LIKE bapisignat OCCURS 1,

wa_files LIKE bapifiles,

i_files LIKE bapifiles OCCURS 1,

i_object_key LIKE bapibds01-objkey.

CREATE OBJECT o_document_set.

MOVE: '1' TO wa_signature-doc_count,

'1' TO wa_files-doc_count,

'c:\temp' TO wa_files-directory,

'1.jpg' TO wa_files-filename.

APPEND wa_signature TO i_signature.

APPEND wa_files TO i_files.

i_object_key = '0000261877'.

BREAK-POINT.

CALL METHOD o_document_set->create_with_files

EXPORTING

classname = 'BUS2032'

classtype = 'BO'

CHANGING

object_key = i_object_key

files = i_files

signature = i_signature

  • .

DATA : files LIkE BAPIFILES OCCURS 1 WITH header line.

files-doc_count = '1'.

files-directory = 'c:\temp\'.

files-filename = '1.jpg'.

APPEND files.

CALL FUNCTION 'BDS_BUSINESSDOCUMENT_CREATEF'

EXPORTING

  • LOGICAL_SYSTEM =

classname = 'BUS2032'

classtype = 'BO'

  • CLIENT = SY-MANDT

OBJECT_KEY = '0000261877'

  • IMPORTING

  • OBJECT_KEY =

tables

files = files

  • SIGNATURE =

EXCEPTIONS

NOTHING_FOUND = 1

PARAMETER_ERROR = 2

NOT_ALLOWED = 3

ERROR_KPRO = 4

INTERNAL_ERROR = 5

NOT_AUTHORIZED = 6

OTHERS = 7

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF

And check the OSS Note 317250.

<b>Reward points</b>

Regards

0 Kudos
161

Hi,

Many thanks for your reply and code. However, I am still getting the same error message - I was wondering if there was some configuration missing in my system - please suggest areas I should check.

Regards,

Peter

0 Kudos
161

Hi,

Have you checked to see whether config for your business object is needed in txn sbdsv1?

By the way, thanks to both of you, you have enabled me to cut much time off my project.

Jim

0 Kudos
161

Hi,

I have checked in txn sbdsv1 and there is config for all the document types I am using.

I've found another FM which loads a document from a file and assigns it to a business object all at once: ARCHIV_CREATE_DIALOG_META

ARCHIV_ID = repository ID (table TOAAR)

AR_OBJECT = document type (table TOADV)

NOTE = free text

OBJECT_ID = GUID of the business object

SAP_OBJECT = Business object ID (table TOJTB)

FILE = Name and path of the document

A successful load will populate the ARC_DOC_ID, CONTREP_ID and DOC_CLASS fields in OUTDOCTAB

You can even delete a link and a document using FM ARCHIV_DELETE_META ...

Peter