cancel
Showing results for 
Search instead for 
Did you mean: 

Requirement to create RFX lineitem Specifications

Former Member
0 Kudos

Hello Experts ,

We are using Sourcing 10 and using RFX module  . We have the requirement to create RFX lineitem Specifications automatically based on certain parameters while RFX is created . We are trying with the below code in save target but getting an error -

import com.frictionless.api.common.log.*;

import java.util.HashMap;

import com.frictionless.sap.integration.exporter.ExporterIfc;

import com.frictionless.sap.integration.exporter.SmartExporter;

import java.util.List;

import java.math.BigDecimal;

import com.sap.odp.api.common.types.*;

import com.sap.eso.api.doccommon.ont.types.*;

import com.sap.eso.api.projects.ProjectIBeanIfc;

import com.sap.eso.api.projects.ProjectIBeanHomeIfc;

import com.sap.odp.api.ibean.IBeanHomeLocator;

import com.sap.eso.api.rfx.*;

import com.sap.odp.api.ibean.IBeanIfc;

import com.sap.odp.api.ibean.IBeanHomeIfc;

import com.sap.odp.api.ibean.*;

import com.sap.odp.api.common.types.TypeFactory;

import com.sap.odp.api.doc.IapiDocumentLockManager;

import com.sap.eso.api.rfx.lineitem.*;

import com.sap.eso.api.rfx.*;

import com.sap.eso.api.doccommon.spec.*;

import com.sap.eso.api.doccommon.doc.question.QuestionTypeEnumType;

import com.sap.eso.api.doccommon.specItemSpecIBeanIfc;

rfx_docline = doc.getLineItems().create();

OrderedSubordinateCollectionIfc specgroup =(OrderedSubordinateCollectionIfc) rfx_docline.getBuyerSpecGroup();

QuestionTypeEnumType Q = new QuestionTypeEnumType(1);

lineItemSpec=specgroup.create();

lineItemSpec.setDisplayName("hello");

lineItemSpec.setQuestionType(Q);

lineItemSpec.setWidth(50);

specgroup.add(lineItemSpec);

Error : 

import com.frictionless.api.common.log.*; i . . . '' : Error in method invocation: Method setQuestionType( com.sap.eso.api.doccommon.doc.question.QuestionTypeEnumType ) not found in class'com.sap.eso.api.doccommon.spec.ItemSpecGroupIBeanImpl'


Can you please suggest if any mistake in the code or anything we would need to add ?


Thanks

Sudipta

Accepted Solutions (1)

Accepted Solutions (1)

former_member190023
Contributor
0 Kudos

Hello Sudipta,

There is a problem with your code:

  • specGroup is just the placeholder (group) of specs; not the spec itself
  • you have to go one-level deeper to get the ItemSpecIBean itself

You will have to do:

lineItemSpec=specgroup.create(); // this is the Spec Group

groupItemSpecs = lineItemSpec.getItemSpecs();

itemSpecBo = groupItemSpecs.create(); // this is the Spec

itemSpecBo.setQuestionType(Q);

...

groupItemSpecs.add(itemSpecBo);

specgroup.add(lineItemSpec);


Two extra recommendations:

  • rename variables to correctly reflect the objects
  • reconsider using the 'Saved' target. If you want to add this at creation time it's more advisable to use the 'Created' target. If you use 'Saved' target buyers will need to refresh the document after each save action.

Bogdan

Former Member
0 Kudos

Thank you very much Bogdan for suggestions .  I have tried this below code in RFX save target . This time no error appearing but no litem specifications are being added also in RFX setup->Line Item Specifications tab . Can you please suggest ?

QuestionTypeEnumType QstnType = new QuestionTypeEnumType(1);

rfx_docline = doc.getLineItems().create();

OrderedSubordinateCollectionIfc specgroup =(OrderedSubordinateCollectionIfc) rfx_docline.getBuyerSpecGroup();

lineItemSpec=specgroup.create(); // this is the Spec Group

groupItemSpecs = lineItemSpec.getItemSpecs();

itemSpecBo = groupItemSpecs.create(); // this is the Spec

itemSpecBo.setDisplayName("Test Description");

itemSpecBo.setWidth(50);

itemSpecBo.setQuestionType(QstnType);

groupItemSpecs.add(itemSpecBo);

specgroup.add(lineItemSpec);


Thanks for your help .

former_member190023
Contributor
0 Kudos

Hello Sudipta,

That is what I was explaining about the 'Saved' target. Even if it works correctly it will not display in your open document:

This is what happens technically:

  • You open/create an RFX - new doc
  • Fill in some info and click save
  • System saves the doc and refreshes your browser - doc_V1
  • 'Saved' script triggers and updates document - doc_V2
  • Your browser is NOT refreshed and still displays doc_V1
  • Furthermore, you will not be able to do ANOTHER save on your browser because system will throw error "Document has already been changed by ... and you cannot save."

My suggestion is to put the script in target 'Validate' or 'Created' depending on your requirements.

Bogdan

former_member190023
Contributor
0 Kudos

Please check the info provided in Sourcing Scripting and Workflow Guide for V10.

Note the warnings related to:

  • exceptions on Saved script
  • altering business documents on Saved script

Regards,

Bogdan

Former Member
0 Kudos

Thanks a lot  Bogdan for your help . 

I have tried this same script for validated and created phase but unfortunately the same result . There is no error but line item specifications are not getting added . Also I tried in toolbar script  but with no luck .

Thanks

former_member190023
Contributor
0 Kudos

Hmm, seems like I was also looking in the wrong place.

ItemSpecs are defined in Document->Setup also for RFX. On the line item itself they will be automatically picked up once created in Setup.

In your case, you should have:

     setupOption = doc.getCollectionMetadata("SETUP_OPTIONS").get(doc).get(0);

     specgroup = specgroup.getBuyerSpecGroup();

     ...

As soon as you'll create a line item then item specs will be displayed as they are defined in Setup.

Bogdan

Former Member
0 Kudos

Thanks for your reply .

Not sure if I am clear on my requirement -

We need to create line item specification(RFX setup) automatically during the RFX is created . Line litem specification navigation path: RFX -> setup -> Line Item Specifications tab .

The above coding I have placed in RFX created phase to test if the lineitem specifications are getting created or not .Once the code works , I would place the other conditions to select specification name to be generated dynamically. The same specifications will be reflected in lineitems and user can enter value against them.

Now , while I create RFX , the coding is executed in creation phase and no error also . But when I go to setup -> line item specifications tab to check if the record is created , it's appearing blank ..

According to the coding it should have created a row in item specification tab in RFX  -

Name : Test Description

Question type : freetext

Width :  50

Please correct me if I am misunderstanding your explanation .

Thanks

Sudipta

former_member190023
Contributor
0 Kudos

No, it should be ok. I haven't tested on my side but I will do it maybe tomorrow and update you

Bogdan

former_member190023
Contributor
0 Kudos

Hello Sudipta,

This is the script I used to create LI Spec:


import com.sap.eso.api.doccommon.doc.question.QuestionTypeEnumType;

//

setupBean = doc.getCollectionMetadata("SETUP_OPTIONS").get(doc).get(0);

//

buyerSpecGroup = setupBean.getBuyerSpecGroup().create();

buyerSpecGroup.setDisplayName("Test Group BTOMA");

//

itemSpec = buyerSpecGroup.getItemSpecs().create();

itemSpec.setPrompt("Test Spec BTOMA");

itemSpec.setQuestionType(new QuestionTypeEnumType(1));

itemSpec.setWidth(50);

//

buyerSpecGroup.getItemSpecs().add(itemSpec);

setupBean.getBuyerSpecGroup().add(buyerSpecGroup);

Bogdan

Former Member
0 Kudos

Bogdan,

We have requirement to create line item specification while createing Rfx from ECC Rfq. I went through this blog and code that you provided which is really help full.

I have a question regarding below statement

setupBean  = doc.getCollectionMetadata("SETUP_OPTIONS").get(doc).get(0); 


till doc.getCollectionMetadata("SETUP_OPTIONS") I understood can you help understand what get(doc) and get(0) will be doing.


How can we map this particular line item specification to corresponding line item ?


Thanks,

Venu.

Answers (0)