cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

how to build a custom utility to import BOM?

rkumar-10
5-Regular Member

how to build a custom utility to import BOM?

Hi

I am building a utility to import BOM in customer format.

Requirement is:--

1. User will upload BOM in CSV format.

2. User can preview CSV in HTML and validate before uploading to windchill.

3. CSV wont be uploaded or lets say BOM wont be uploaded if there is any error in Line item.

4. Result of Upload Process should appear against CSV rows in HTML.

Please suggest.

//Rakesh

7 REPLIES 7

Hi Rakesh,

so you'll have to identify the part you want to link, export the structures (with expected config) from Windchill and build the part structure in your tool for the display before validation (pre-run).

For building your merged structure (windchill + what you want to import), you'll need some strategy. The most common would be either to replace the existing links, or only add new links...

Something you could consider is whether to create a baseline object from your import or not. It can be usefull to trace which version of the part were imported.

Regards,

Loïc

rkumar-10
5-Regular Member
(To:lmouchard)

Hi Loïc


Thanks for the base line Idea.

I want to build logic only to update usage attributes value for existing link. UsageLink wont be created or deleted.

I cant figure out how to show error result on back to CSV upload page.

Steps are:--

  1. Upload CSV in HTML
  2. Preview and Validate with javaScript for input fields.
  3. Highlight error cells.
  4. How to Disable Ok wizard Button if CSV is not valid.
  5. Ok button will sumit wizard for processing.
  6. How to Highlight or Mark rows with error after Processing in same html load csv page?

Thank in advance for help. 🙂

//Rakesh

I don't know whether you already looked at what is available out of the box - Importable spreadsheets - http://support.ptc.com/cs/help/windchill_hc/wc110_hc/index.jspx?id=WPCOverview&action=show/ Import from Excel

rkumar-10
5-Regular Member
(To:BineshKumar1)

Hi Binesh

we have explored this but we have specific format through which user will update BOM.

//Rakesh

Rakesh,

The import from spreadsheet functionality is customizable, I believe you can extend this as per your import format instead writing whole new codes.

rkumar-10
5-Regular Member
(To:mkumar-10-11-126)

Hi Mohan

can you please share some information on "How to Customize Import from Spread Sheet".

//Rakesh

Not sure how much this is going to be helpful to you, but below are OOTB code for the 'Import from Spreadsheet'. It looks complicate to extend but this is the place to start with if it need/can be extended.

ImportJob job = new ImportJob();
ImportSpec importSpec = new ImportSpec();
WTContainer myContainer = part.getContainer();
ApplicationData appData =<Get you application Data Here, the spreadsheet attached to part/ doc etc..>
     importSpec.setContainerRef(WTContainerRef.newWTContainerRef(myContainer));
     importSpec.setAction(ImportAction.ADD_ONLY);
     importSpec.setPreview(true);
     importSpec.setFilename(appData.getFileName());

     job.setSpec(importSpec);
     job.setStatus(ImportJobStatus.DEFINING);
     OwnershipHelper.setOwner(job, SessionHelper.manager.getPrincipal());
     AdminDomainRef admindomainref = myContainer.getDefaultDomainReference();
     job.setDomainRef(admindomainref);
     job.setContainerReference(WTContainerRef.newWTContainerRef(myContainer));
     ImportJobEvent importjobevent = new ImportJobEvent(ImportJobEvent.CREATED, job);
     ImportExportEventHelper.service.dispatchVetoableEvent(importjobevent, importjobevent.getEventKey());

     job = (ImportJob) PersistenceHelper.manager.save(job);

     wt.content.ContentHolder contentHolder = (wt.content.ContentHolder) job;
     ApplicationData applicationData = ApplicationData.newApplicationData(contentHolder);
     applicationData.setRole(ContentRoleType.PRIMARY);
     applicationData.setFileName(appData.getFileName());

     ContentServerHelper.service.updateContent(contentHolder, applicationData, filePath);
     job = StandardImportService.importSpreadsheet(job.getPersistInfo().getObjectIdentifier());

Announcements

Top Tags