cancel
Showing results for 
Search instead for 
Did you mean: 

Records Management - automaticaly add element to record

Former Member
0 Kudos

Hello,

I try to add an element to a record using the bapi "bapi_record_addelement", but I get an error-message that the number of poid-parameters is not equal to those in the registry information.

My ABAP-Code is the following:

*&---------------------------------------------------------------------*
*& Report  Z_RECORD_ADDELEMENT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  Z_RECORD_ADDELEMENT.
*{   INSERT         I50K900139                                        1
data:
wa_ELEMENT_SP_POID     type      BAPIPROPTB,
wa_ELEMENT_PROPERTIES  type      BAPIPROPTB,
wa_ELEMENT_VISIBILITY  type      BAPIPROPTB,
element_sp_poid type standard table of BAPIPROPTB,
element_properties type standard table of BAPIPROPTB,
wa_insertion_by_modelid type BAPISRMREC_MODELIDINS,
return like BAPIRET2.

* Fill SP POID table

start-of-selection.
CLEAR element_sp_poid.

wa_element_sp_poid-NAME  = 'DOC_ID'.

wa_element_sp_poid-VALUE = '03F65C4630552864E1000000AC15C293'.

APPEND wa_element_sp_poid TO element_sp_poid.

wa_element_sp_poid-NAME  = 'VARIANT'.

wa_element_sp_poid-VALUE = '0'.

APPEND wa_element_sp_poid TO element_sp_poid.

wa_element_sp_poid-NAME  = 'VERSION'.

wa_element_sp_poid-VALUE = '2'.

APPEND wa_element_sp_poid TO element_sp_poid.

wa_insertion_by_modelid-MODEL_ID = 'D7F85C462E55770CE1000000AC15C293'.

wa_insertion_by_modelid-PARENT_NODE_ID = '3'.

*********************************************************************
** add element
CALL FUNCTION 'BAPI_RECORD_ADDELEMENT'
        EXPORTING

          objectid = 'E1A55C462F0C790CE1000000AC15C293'

          DocumentClass = 'ZRMSR04'

          sps_id = 'Z_RM_MIETAKT'

          anchor = 'Schriftverkehr'

          description = 'Testdokument eingefügt mit ABAP'

         IMPORTING
          return        = return.

write: return-message,
       return-type.

*}   INSERT

I hope someone can help me because I am trying for one week.

hootzter

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hey...

Good information.

I get an error in trying to add element to record, van you help me out.

The error reads the following:

Source: CL_SRM_GENERIC_SP0============CP , CL_SRM_GENERIC_SP0============CM002 , 102

General error: Could not connect to repository.

This is the code Iam using

*&----


*

*& Report ZTESTPRG

*&

*&----


*

*&

*&

*&----


*

REPORT ZTESTPRG.

  • Definition of local data types for DOC_ID

types: begin of ty_doc_id,

docclass type bapisrmdoc-docclass,

objectid type bapisrmdoc-guid,

end of ty_doc_id.

  • Structure of the correct Document-ID

data: ls_doc_id type ty_doc_id,

lt_sp_poid type standard table of bapiproptb,

ls_sp_poid type bapiproptb,

ls_return like bapiret2,

ls_insertion_by_anchor type bapisrmrec_anchorins.

clear: lt_sp_poid, ls_doc_id, ls_doc_id.

ls_doc_id-docclass = 'ZSNG09'.

    • Document Class des einzufügenden Dokumentes

ls_doc_id-objectid = '466E6A24DED600A100000000AC10A015'.

    • Objektid des einzufügenden Dokumentes

clear: ls_sp_poid. " clear weg und ls_sp_poid clearen

ls_sp_poid-name = 'DOC_ID'.

ls_sp_poid-value = ls_doc_id.

    • Document Class und Objektid als Struktur des Dokumentes

append ls_sp_poid to lt_sp_poid.

clear: ls_doc_id.

ls_sp_poid-name = 'VARIANT'.

ls_sp_poid-value = '0'.

append ls_sp_poid to lt_sp_poid.

clear: ls_doc_id.

ls_sp_poid-name = 'VERSION'.

ls_sp_poid-value = '0'.

append ls_sp_poid to lt_sp_poid.

clear: ls_insertion_by_anchor.

ls_insertion_by_anchor-parent_node_id = '5'.

call function 'BAPI_RECORD_ADDELEMENT'

exporting

objectid = '466E9223F887013A00000000AC10A015'

    • Objectid der Akte

documentclass = 'ZSNG08'

    • Document Class der Akte

sps_id = 'ZSCMG_SPS_NUCLEAR_PROCEDURE'

    • Einzufügende Elementart

anchor = 'NP02'

    • Im Aktenmodell hinterlegt beim Modellknoten

description = 'Test Document'

    • Beschreibung des Dokumentes in der Akte

element_type = 'I'

    • Instanz

importing

return = ls_return

tables

element_sp_poid = lt_sp_poid.

write: ls_return-message,

ls_return-type.

.

Former Member
0 Kudos

Hi,

I had the same error. In my case the parameters for

ls_doc_id-docclass and ls_doc_id-objectid were wrong.

After I corrected this, all went fine.

Former Member
0 Kudos

Thank you for the response.

I think I have given the correct parameters.

Doc class is what I see when i right click the record and click information..right?

Looks like this.

Document ID ZSNG09 466E879ADED600A100000000AC10A015

Am I right?

Former Member
0 Kudos

And, what is this anchor . Is it what we see when we right click on the node of the record.

Former Member
0 Kudos

ANCHOR is an attribute that is to be set in the record model. It defines the place where documents can automaticaly can be put in.

Former Member
0 Kudos

"Doc class is what I see when i right click the record and click information..right?

Looks like this.

Document ID ZSNG09 466E879ADED600A100000000AC10A015 "

yes thats right, then I don't know the solution to the problem

Message was edited by:

hootzter

Former Member
0 Kudos

About Anchor, as you say it is the place where document needs to be put in.

To tell you my record structure,

I have two subfolders in a folder under the record.

I want to insert the file into the second subfolder.

Now, how do I give the anchor id.

For example, in your code, why did you give the value 'Schriftverkehr' for anchor.

Please help me out.

Thanks,

NSP

Message was edited by:

nsp nsp

Message was edited by:

nsp nsp

Former Member
0 Kudos

Hi ,

My node is a modelnode and has the node-id = 6 and the attribute anchor is set to "Schriftverkehr". Maybe the example is correct by only defining the parent-node-id and not defining the anchor-name in the code. But I am not shure.

Former Member
0 Kudos

Even by using model id and parent node id, i get the same error

Former Member
0 Kudos

hmm, sorry I don't know how to solve the error. If I'll get an idea, I will post it.

Former Member
0 Kudos

@nsp_nsp: Do you know how to use MS-Word-Templates and how to customize them?

Former Member
0 Kudos

sorry that was the wrong code. here's the right one:

*&---------------------------------------------------------------------*
*& Report  Z_RECORD_ADDELEMENT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  Z_RECORD_ADDELEMENT.
*{   INSERT         I50K900139                                        1
data:
wa_ELEMENT_SP_POID     type      BAPIPROPTB,
wa_ELEMENT_PROPERTIES  type      BAPIPROPTB,
wa_ELEMENT_VISIBILITY  type      BAPIPROPTB,
element_sp_poid type standard table of BAPIPROPTB,
element_properties type standard table of BAPIPROPTB,
wa_insertion_by_modelid type BAPISRMREC_MODELIDINS,
return like BAPIRET2.

* Fill SP POID table

start-of-selection.
CLEAR element_sp_poid.

wa_element_sp_poid-NAME  = 'DOC_ID'.

wa_element_sp_poid-VALUE = '03F65C4630552864E1000000AC15C293'.

APPEND wa_element_sp_poid TO element_sp_poid.


wa_element_sp_poid-NAME  = 'VARIANT'.

wa_element_sp_poid-VALUE = '0'.

APPEND wa_element_sp_poid TO element_sp_poid.


wa_element_sp_poid-NAME  = 'VERSION'.

wa_element_sp_poid-VALUE = '2'.

APPEND wa_element_sp_poid TO element_sp_poid.


wa_insertion_by_modelid-MODEL_ID = 'D7F85C462E55770CE1000000AC15C293'.

wa_insertion_by_modelid-PARENT_NODE_ID = '3'.

*********************************************************************
** add element
CALL FUNCTION 'BAPI_RECORD_ADDELEMENT'
        EXPORTING
          objectid = 'E1A55C462F0C790CE1000000AC15C293'
          DocumentClass = 'ZRMSR04'
          sps_id = 'Z_RM_MIETAKT'
          description = 'Testdokument eingefügt mit ABAP'
          insertion_by_modelid = wa_insertion_by_modelid
         IMPORTING
          return        = return
         Tables
           element_sp_poid = element_sp_poid.

write: return-message,
       return-type.

*}   INSERT

Former Member
0 Kudos

with some help, now it works fine

* Store document into selected record

* Definition of local data types for DOC_ID
  types: begin of ty_doc_id,
            docclass type bapisrmdoc-docclass,
            objectid type bapisrmdoc-guid,
         end of ty_doc_id.
* Structure of the correct Document-ID
  data: ls_doc_id type ty_doc_id,
        lt_sp_poid type standard table of bapiproptb,
        ls_sp_poid type bapiproptb,
        ls_return like bapiret2,
        ls_insertion_by_anchor type bapisrmrec_anchorins.


    clear: lt_sp_poid, ls_doc_id, ls_doc_id.

    ls_doc_id-docclass = 'ZRMSR03'.				
**   Document Class des einzufügenden Dokumentes
    ls_doc_id-objectid = '42B35C4630552864E1000000AC15C293'.	
**    Objektid des einzufügenden Dokumentes

    clear: ls_sp_poid. " clear weg und ls_sp_poid clearen
    ls_sp_poid-name  = 'DOC_ID'.
    ls_sp_poid-value = ls_doc_id.				
**    Document Class und Objektid als Struktur des Dokumentes
    append ls_sp_poid to lt_sp_poid.

    clear: ls_doc_id.
    ls_sp_poid-name  = 'VARIANT'.
    ls_sp_poid-value = '0'.
    append ls_sp_poid to lt_sp_poid.

    clear: ls_doc_id.
    ls_sp_poid-name  = 'VERSION'.
    ls_sp_poid-value = '0'.
    append ls_sp_poid to lt_sp_poid.

    clear: ls_insertion_by_anchor.
    ls_insertion_by_anchor-parent_node_id = '6'.


    call function 'BAPI_RECORD_ADDELEMENT'
      exporting
        objectid        = 'E1A55C462F0C790CE1000000AC15C293'	
**        Objectid der Akte
        documentclass   = 'ZRMSR04'				
**        Document Class der Akte
        sps_id          = 'Z_RM_MIETAKTDOC'			
**        Einzufügende Elementart
        anchor          = 'Schriftverkehr'				
**        Im Aktenmodell hinterlegt beim Modellknoten
        description     = 'Test eingefügt aus ABAP'	
		
**        Beschreibung des Dokumentes in der Akte
        element_type    = 'I'					
**        Instanz

      importing
        return          = ls_return
      tables
        element_sp_poid = lt_sp_poid.

        write: ls_return-message,
               ls_return-type.

paulagarca
Explorer
0 Kudos

OMG! Thanks a lot!!! I had the same problem and you have saved my life!!!