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: 

BAPI_DOCUMENT_CREATE2 : How to link a DIR with network activity

former_member246786
Participant
0 Kudos
193

Hi,

I try to create a DIR and to link it with a network activty. The puprose is to create a dir, deals with dir issue and link add originals to the dir and link it with the aticty 10 (vornr =0010) of a gived network.

I tried to do it using existing transaction : CN22

I follow tehse steps : launch CN22, select the network, select the activity >> menu EXTRA>> create document

The system launch CV01N transaction, I create the document in CV01N , Save

This is what I see in SE16 , table DRAW :

Document Type = ZCL

Document = myDocNumber

version = 00

part = 000

Object = VORGNET

Object key= SUYCL010010

Where SUYCL01 == Aufnr of the network

0010 = vornr of activty 10 ... so, I conclude that the following code wil do the same :

clear ls_doc.

ls_doc-documentnumber = lw_aufnr.

ls_doc-documenttype = 'ZCL'.

ls_doc-documentversion = '00'.

ls_doc-documentpart = '000'.

clear: li_objectlinks,li_objectlinks[].

li_objectlinks-objectkey = lw_dockey.

li_objectlinks-objecttype = lk_dokob_vorgnet.

APPEND li_objectlinks.

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'

EXPORTING

documentdata = ls_doc

IMPORTING

DOCUMENTTYPE = lw_doctype

DOCUMENTNUMBER = lw_docnumber

DOCUMENTPART = lw_docpart

DOCUMENTVERSION = lw_docversion

return = ls_return

TABLES

objectlinks = li_objectlinks.

IF ls_return IS INITIAL .

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'.

.

ENDIF.

There is no problem during my code execution, ls_return is empty, the commit statment works , the dir is created but there is no link between the link and Network activity ... I don't understand why.

Is there something I forgot ? Is opbjectkey something else than aufnr+vornr ? Is there specific cases in wich i have to give additional parameters to make links functionnality works?

please help cause I really don't understand what is happening.

Regards ,

Morgan

1 REPLY 1

former_member246786
Participant
0 Kudos
67

I solved it but I don't know why the new solution works and no the first one : I create the document without objectlinks table and call function DOCUMENT_ASSIGNMENT_DIRECT just after and it creates the link...