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 to Create Object Links to MARA

Former Member
0 Kudos

I have a simple test program that (tries) to create an object link in a DIR. When I run it in DEV it works, when I transport it and run it in our QAS system it does not create the link. In both instances I am using a user that has SAP_ALL authorizations. Both systems are on the same SP level (these are 4.7 UNicode Systems). And I triple checked, both the DIR and Material Master are on both systems, none have the delete indicator set and I can set the link manually on both systems. It is probably something really dumb, but I just can't see it.. Thanks in advance for any help.

Here is the source.

 

*&---------------------------------------------------------------------*

*& Report ZTESTADDLINK *

*& *

*&---------------------------------------------------------------------*

*& *

*& *

*&---------------------------------------------------------------------*

 

REPORT ZTESTADDLINK .

DATA: ls_doc LIKE bapi_doc_draw2,

 

* Flag for change relevance

 

ls_docx LIKE bapi_doc_drawx2,

 

* Bapi-Return structure

 

ls_return LIKE bapiret2,

 

* Originals

 

lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,

 

* Brief texts

 

lt_drat LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE,

 

* Object links

 

lt_drad LIKE bapi_doc_drad OCCURS 0 WITH HEADER LINE.

 

*******************************************

 

** Assign the document data (which document should be changed)

 

******************************************

 

ls_doc-documenttype = '2DD'.

ls_doc-documentnumber = 'TOM-113'.

ls_doc-documentversion = '00'.

ls_doc-documentpart = '000'.

 

*2. Example: Object links

*a) Add object links

*clear internal table and header line

 

CLEAR lt_drad.

REFRESH lt_drad.

 

*Attach object type and object key to internal table lt_drad

 

lt_drad-objecttype = 'MARA'.

lt_drad-objectkey = '8E0013482849'.

APPEND lt_drad.

 

** call BAPI, which changes the document

 

********************************************************************

 

CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'

EXPORTING:

documenttype = ls_doc-documenttype

documentnumber = ls_doc-documentnumber

documentpart = ls_doc-documentpart

documentversion = ls_doc-documentversion

documentdata = ls_doc

documentdatax = ls_docx

IMPORTING:

return = ls_return

TABLES:

OBJECTLINKS = lt_drad.

 

** Errors occurred ??

 

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = ls_return.

IF ls_return-type CA 'IEA'.

MESSAGE ID '26' TYPE 'I' NUMBER '000'

WITH ls_return-message.

ELSE.

WRITE: / 'Change Commit Completed'.

ENDIF.

CLEAR lt_drad.

REFRESH lt_drad.

CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'

EXPORTING

documenttype = ls_doc-documenttype

documentnumber = ls_doc-documentnumber

documentpart = ls_doc-documentpart

documentversion = ls_doc-documentversion

getactivefiles = 'X'

getdocdescriptions = 'X'

getobjectlinks = 'X'

getdocfiles = 'X'

IMPORTING

documentdata = ls_doc

return = ls_return

TABLES

objectlinks = lt_drad.

LOOP AT lt_drad. "

WRITE: / 'Existing Material Link to ', lt_drad-objectkey.

ENDLOOP.

1 REPLY 1

Former Member
0 Kudos

I found an article about note  880077, so I reset ann reimplemented the note and it solved the problem.