Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Add New Collaborator in all Master Agreements

Hi

I am new to SAP sourcing

I have a requirement to add a new Collaborator in all Master Agreements. My problem is now I have written a script that works perfectly when I run it for a single Master Agreement. But when I expand my list and add all the master agreements, I get a problem that some of the already saved Master agreements have errors that have arisen from:

1. For Example: a new "required" field is added to the Master Agreement. As a result, the script cannot go add the required field on the old Master      Agreements.

Different Master Agreements have different errors once opened.

Please assist me by helping me to be able to continue adding my collaborator without having problems with the errors or My script should skip all those cannot be saved.

Below is my script

collab = doc.getExtensionField("Add_Collaborator").get();

userHome=IBeanHomeLocator.lookup(session,NewUserAccountIBeanHomeIfc.sHOME_NAME);

masterHome = IBeanHomeLocator.lookup(session, ContractIBeanHomeIfc.sHOME_NAME);

contractList = masterHome.findAll();

nameHome = IBeanHomeLocator.lookup(session,UserDefinedMasterData1IBeanHomeIfc.sHOME_NAME);

n = doc.getExtensionField("Add_Collaborator").get();

if (contractList != null)

    iter = contractList.iterator();

  

   while (iter.hasNext())

   {

     

      member = iter.next();

   

      masterHome.upgradeToEdit(member);

      collabColln=member.getCollaborators();

       //doc.setDisplayName(""+collabColln.size());  

    

      newMember=collabColln.create();

      newMember.setApprovalRule(new CollaboratorApprovalRuleType(new Integer(0)));

      newMember.setCollaboratorEmail("EmailAddress");

     //Get display name

    

     newMember.setPrincipal(n); 

  

     

   //add the collection member to the collection

     collabColln.add(newMember);

     //save the document

      member.getIBeanHomeIfc().save(member);

   }

}

Tags:
Former Member
Former Member replied

Hello,

It would be a lot easier and more controllable to handle this via Excel Workbook, rather than scripting.

You will need:

  • Extract all MA IDs from the system (via some report)
  • Create an xls file with template:
UNIQUE_DOC_NAMECOLLABORATOR_1 OR GROUP_1
**MA Document ID****either username (for user collab) or External ID (for group collab)**
  • Populate the template with document IDs and values as explained
  • Import excel file via Setup -> Import Data -> Master Agreement

This procedure will result in processing ALL the MAs. The result will be a trace file with:

  • List of processed MAs
  • List of failed MAs (and error details)

If you really want to use scripting than simply use:

   

//save the document

try {

     member.getIBeanHomeIfc().save(member);

} catch (Exception e) {

     //maybe log something here.

}

Bogdan

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question