cancel
Showing results for 
Search instead for 
Did you mean: 

work manager 6.5.11.0 - Add New Workorder enhancement

0 Kudos

Hello Experts,

I have a scenario in posting new workorder with custom fields for operation and parts. Issue is with updating Operation details in IT_OPERATION and IT_SERVICELINES tables.

We are using SAP Work Manager 6.5.11.0
Workorder Object Operation collection
Ø  Standard field 1 
Ø  Standard field 2
Ø  Custom field 1
Ø  Custom field 2
Ø  Custom field 3 
Part collection – This is updating in table IT_COMPONENT as expected.
Ø  Standard field 1 
Ø  Standard field 2
Ø  Custom field 1
Ø  Custom field 2
Ø  Custom field 3

Issue is in extended class, setOperationParameters() is not getting overridden to update
the custom fields. It still triggers the setOperationParameters() from standard WorkorderAddBAPI
class

Custom Java 
ZWorkorderAddPostBAPI extends WorkorderAddPostBAPI which extends WorkorderAddBAPI. 

Issue is setOperationParameters() is not getting overridden in extended class(ZWorkorderAddPostBAPI).
WorkorderAddBAPI
  public void setParameters(SAPObject obj) throws Exception {
   this._log.entry();
    super.setParameters(obj);
setOperationParameters();
}

protected void setOperationParameters() throws Exception {
    JCO.Table tbl = this._tables.getTable("IT_OPERATION");
    JCO.Table tblx = this._tables.getTable("IT_OPERATION_UP");
    tbl.appendRow();
    tbl.setRow(0);
    tblx.appendRow();
    tblx.setRow(0);
Ø  Standard field 1 
Ø  Standard field 2
. . . Standard fields are updated

ZWorkorderAddPostBAPI
In this extended class I am overriding the method setOperationParameters called in WorkorderAddBAPI class.

protected void setOperationParameters() throws Exception {
 JCO.Table tbl = this._tables.getTable("IT_OPERATION");
 tbl.appendRow();
 tbl.setRow(0);
// Standard fields    
setValue(tbl, "ACTIVITY", "0010");
setValue(tbl, "DESCRIPTION", "TEST OP");
setValue(tbl, "LANGU", this._user.getConnection().getLanguage());
setValue(tbl, "PLANT", this._wo.getPlanningPlant());
setValue(tbl, "CONTROL_KEY", this._wo.getControlKey());
setValue(tbl, "WORK_CNTR", this._wo.getWorkCenter());
// Another table where few custom fields to be updated as part of requirement
JCO.Table sltbl = this._tables.getTable("IT_SERVICELINES");
 sltbl.appendRow();
 sltbl.setRow(0);
int numOps = (this._wo.getOperations()).length;
for (int i = 0; i < numOps; i++) {
ZWorkorderOperation op = (ZWorkorderOperation) this._wo.getOperations()[i];
//IT Servicelines table - Custom fields
setValue(sltbl, "ACTIVITY", "0010");
setValue(sltbl, "SRV_LINE", "0000000001");
setValue(sltbl, "SERVICE", op.getZServiceCode());
setValue(sltbl, "GROSS_PRICE", op.getZPrice());
setValue(sltbl, "UOM", op.getZUOM());
setValue(sltbl, "CURRENCY", op.getZCurrency());
setValue(sltbl, "QUANTITY", op.getZQuantity());
setValue(sltbl, "MATL_GROUP", op.getZMatGroup());
 //IT Operations Table - Custom fields
setValue(tbl, "MATL_GROUP", op.getZMatGroup());
setValue(tbl, "PUR_GROUP", op.getZPurchaseGroup());
 } }

As an alternative I tried below.
Created a custom method  in ZWorkorderAddPostBAPI where only custom fields was updated into table.

setParameters(SAPObject obj) in WorkorderAddBAPI calls the method setOperationParameters() to update standard fields which is fine. In ZWorkorderAddPostBAPI in setParameters(SAPObject obj) I am calling custom method (setCustomOperationParameters)to update custom fields. As I am initiating IT_OPERATION table one more time here in this method I assume it is updating as second record in backend. How do I address this issue. 

protected void setCustomOperationParameters() throws Exception {
JCO.Table optbl = this._tables.getTable("IT_OPERATION");
optbl.appendRow();
optbl.setRow(0);
JCO.Table sltbl = this._tables.getTable("IT_SERVICELINES");
sltbl.appendRow();
sltbl.setRow(0);
//New Fields
int numOps = (this._wo.getOperations()).length;
for (int i = 0; i < numOps; i++) {
ZWorkorderOperation op = (ZWorkorderOperation) this._wo.getOperations()[i];
//IT Servicelines table - Custom fields
setValue(sltbl, "ACTIVITY", "0010");
setValue(sltbl, "SRV_LINE", "0000000001");
setValue(sltbl, "SERVICE", op.getZServiceCode());
setValue(sltbl, "GROSS_PRICE", op.getZPrice());
setValue(sltbl, "CURRENCY", op.getZCurrency());
setValue(sltbl, "QUANTITY", op.getZQuantity());
setValue(sltbl, "MATL_GROUP", op.getZMatGroup());
//IT Operations Table -  Custom fields
setValue(optbl, "MATL_GROUP", op.getZMatGroup());
setValue(optbl, "PUR_GROUP", op.getZPurchaseGroup());
}}


Any guidance/help in resolving the issue would be much appreciated.

Thanks.
Ashwin.V

Accepted Solutions (0)

Answers (5)

Answers (5)

former_member559541
Discoverer
0 Kudos

Hello,

For the above issues I am not able to figure from where the Standard method setOperationParameters is being called in WorkorderAddBAPI where Operation table is being updated for new workorder.

I tried overriding the method in ZWorkorderAddPostBAPI which extends WorkorderAddPostBAPI which inturn extends WorkorderAddBAPI.

Note : we are on SAP WM 6.5.11.0 : Navigation is WorkOrderPostSteplet > WorkOrderPostStepHandler > ZWorkorderAddPostBAPI(extends WorkorderAddPostBAPI extends WorkorderAddBAPI)

A quick guidance really helps.

Thanks in advance.

Regards,

Ashwin.V

0 Kudos

Hi ,

I have attached the complete class for your reference. I was trying with custom method, so have commented the standard method..

Note : we are on SAP WM 6.5.11.0 : Navigation is WorkOrderPostSteplet > WorkOrderPostStepHandler > ZWorkorderAddPostBAPI(extends WorkorderAddPostBAPI extends WorkorderAddBAPI)

package com.syclo.sap.custom.component.workorder.bapi;


import com.syclo.sap.User;
import java.text.DecimalFormat;
import com.syclo.sap.component.workorder.bapi.WorkorderAddPostBAPI;
import com.syclo.sap.custom.component.workorder.object.ZPart;
import com.syclo.sap.custom.component.workorder.object.ZWorkorderOperation;
import com.syclo.sap.jco.JCO;
import com.syclo.sap.ConversionUtility;
import com.syclo.sap.Ex12nManager;
import com.syclo.sap.SAPObject;


public class ZWorkorderAddPostBAPI extends WorkorderAddPostBAPI {
	// protected ZWorkorder _wo = null;


	public ZWorkorderAddPostBAPI(User u) throws Exception {
		super(u);
		_log.info("Inside Constructor of ZWorkorderAddPostBAPI");
	}


	/*
	 * public void init() throws Exception {
	 * _log.info("Inside ZWorkOrderPostSteplet init 1 ");
	 * this._wo.setProperties(this._user, this); }
	 */


	public void setParameters(SAPObject obj) throws Exception {
		this._log.entry();
		setCommonParameters((SAPObject)this._wo);
		setTransactionParameters((SAPObject)this._wo);
		int numLines = setLongText();
		setITText(numLines);
		setHeaderParameters();
		setPartnerParameters();
		setMethodParameters();
		setMethodPartParameters(); 
		setNumberParameters();
		
//custom method to update custom fields - START
		setCustomOperationParameters();




		int numOps = (this._wo.getOperations()).length;
		for (int i = 0; i < numOps; i++) {
			ZWorkorderOperation op = (ZWorkorderOperation) this._wo.getOperations()[i];      


			if (op.isEdited())
				setOperationParameters(op); 
		} 
// Custom code to update components
		int numParts = (this._wo.getParts()).length;
		for (int j = 0; j < numParts; j++) {
			ZPart p = (ZPart) this._wo.getParts()[j];
			if (p.isEdited().booleanValue())
				setPartParameters(p); 
		} 
		this._log.exit();
	}
	
	/*@Override
	  protected void setOperationParameters() throws Exception {
		    _log.info("Inside setOperationParameters of ZWorkorderAddPostBAPI");
		    JCO.Table tbl = this._tables.getTable("IT_OPERATION");
		    tbl.appendRow();
		    tbl.setRow(0);
// Standard fields		   
		    setValue(tbl, "ACTIVITY", "0010");
		    setValue(tbl, "DESCRIPTION", "TEST OP");
		    setValue(tbl, "LANGU", this._user.getConnection().getLanguage());
		    setValue(tbl, "PLANT", this._wo.getPlanningPlant());
		    setValue(tbl, "CONTROL_KEY", this._wo.getControlKey());
		    setValue(tbl, "WORK_CNTR", this._wo.getWorkCenter());
		  
		    
		    JCO.Table sltbl = this._tables.getTable("IT_SERVICELINES");
			sltbl.appendRow();
			sltbl.setRow(0);
			
		    int numOps = (_wo.getOperations()).length;//this._wo.getOperations()).length;
			for (int i = 0; i < numOps; i++) {
				ZWorkorderOperation op = (ZWorkorderOperation) _wo.getOperations()[i];//this._wo.getOperations()[i];
		    
//IT Servicelines table - Custom fields
				_log.info("Inside Servicelines of ZWorkorderAddPostBAPI");
				setValue(sltbl, "ACTIVITY", "0010");
				setValue(sltbl, "SRV_LINE", "0000000001");
				setValue(sltbl, "SERVICE", op.getZServiceCode());
				setValue(sltbl, "GROSS_PRICE", op.getZPrice());
				setValue(sltbl, "UOM", op.getZUOM());
				setValue(sltbl, "CURRENCY", op.getZCurrency());
				setValue(sltbl, "QUANTITY", op.getZQuantity());
				setValue(sltbl, "MATL_GROUP", op.getZMatGroup());
	//IT Operations Table -  Custom fields
				_log.info("Inside Operations of ZWorkorderAddPostBAPI");
				setValue(tbl, "MATL_GROUP", op.getZMatGroup());
				setValue(tbl, "PUR_GROUP", op.getZPurchaseGroup());


			}
		    
		  }*/
//custom method to update custom fields for Operation	 
protected void setCustomOperationParameters() throws Exception {


		JCO.Table optbl = this._tables.getTable("IT_OPERATION");
		optbl.appendRow();
		//optbl.setRow(0);
		optbl.setRow(optbl.getNumRows() - 1);
		JCO.Table sltbl = this._tables.getTable("IT_SERVICELINES");
		sltbl.appendRow();
		sltbl.setRow(0);
		 /*setValue(optbl, "ACTIVITY", "0010");
		    setValue(optbl, "DESCRIPTION", "TEST OP");
		    setValue(optbl, "LANGU", this._user.getConnection().getLanguage());
		    setValue(optbl, "PLANT", this._wo.getPlanningPlant());
		    setValue(optbl, "CONTROL_KEY", this._wo.getControlKey());
		    setValue(optbl, "WORK_CNTR", this._wo.getWorkCenter());*/
		//New Fields
		int numOps = (this._wo.getOperations()).length;
		for (int i = 0; i < numOps; i++) {
			ZWorkorderOperation op = (ZWorkorderOperation) this._wo.getOperations()[i];


//IT Servicelines table - Custom fields
			_log.info("Inside Servicelines of ZWorkorderAddPostBAPI");
			setValue(sltbl, "ACTIVITY", "0010");
			setValue(sltbl, "SRV_LINE", "0000000001");
			setValue(sltbl, "SERVICE", op.getZServiceCode());
			setValue(sltbl, "GROSS_PRICE", op.getZPrice());
			setValue(sltbl, "UOM", op.getZUOM());
			setValue(sltbl, "CURRENCY", op.getZCurrency());
			setValue(sltbl, "QUANTITY", op.getZQuantity());
			setValue(sltbl, "MATL_GROUP", op.getZMatGroup());
//IT Operations Table -  Custom fields
			_log.info("Inside Operations of ZWorkorderAddPostBAPI");
			setValue(optbl, "MATL_GROUP", op.getZMatGroup());
			setValue(optbl, "PUR_GROUP", op.getZPurchaseGroup());


		}
	}


	protected void setOperationParameters(ZWorkorderOperation op) throws Exception {
		this._assignmentTypeBAPI.setOperationAssignmentType(op);
		if (op.getNewNotes().length() != 0)
			setOperationNotes(op); 
	}
//custom method to update custom fields for Components Part
	protected void setPartParameters(ZPart p) throws Exception {
		JCO.Table tbl = this._tables.getTable("IT_COMPONENT");
		JCO.Table xtbl = this._tables.getTable("IT_COMPONENT_UP");
		tbl.appendRow();
		xtbl.appendRow();


//IT COMPONENT Table -  Custom fields
		setValue(tbl,  "PRICE", p.getZPrice());
		setValue(tbl,  "PUR_GROUP", p.getZPurchaseGroup());
		setValue(tbl,  "CURRENCY", p.getZCurrency());


//IT COMPONENT Table -  Standard fields		
		setEditValue(tbl, xtbl, "ITEM_NUMBER", p.getItemID());
		setEditValueWithConversion(tbl, xtbl, p.getFieldName(getClass(), "TRANSACTION.MATERIAL"), p.getItemNum());
		setEditValue(tbl, xtbl, "PLANT", p.getPlant());
		setEditValue(tbl, xtbl, "ACTIVITY", p.getOperation());
		setEditValue(tbl, xtbl, "REQUIREMENT_QUANTITY", ConversionUtility
				.convertForDevice((new DecimalFormat("#.000")).format(Double.parseDouble(p.getQuantity()))));
		setEditValue(tbl, xtbl, "REQUIREMENT_QUANTITY_UNIT", p.getUOM());
		if (p.isText()) {
			setEditValue(tbl, xtbl, "ITEM_CAT", "T");
			setEditValue(tbl, xtbl, "ITEM_TEXT1", p.getDescription());
		} else {
			setValue(tbl, "ITEM_CAT", p.getCategory());
		}
	}




}



0 Kudos

Yes I have setParameters(SAPObject obj) in my extended class and I did call setOperationParameters() of WorkorderAddBAPI and here I had required changes to post custom fields. Unfortunately setOperationParameters is not getting triggered in extended class whereas other function calls are happening(custom Part fields updating to IT_COMPONENT).

Thanks.

Ashwin

jorismermans
Participant
0 Kudos

Can you please post the complete custom class code?

jorismermans
Participant
0 Kudos

Did you try to put method setParameters(SAPObject obj) in your custom class (copy from std class) and check if that is called?

jorismermans
Participant
0 Kudos

Hi,

Try using some extra logging in your custom Java code like:

Logger log = new Logger(this._user, "ZWorkorderAddPostBAPI"); log.info("ZWorkorderAddPostBAPI-setHeaderParameters()-start");

check the log afterwards to see if your custom code is called and try logging some variables.

If the standard java code is called, also check the backend configuration in syclo configpanel.

0 Kudos

Thanks Joris for the reply.

As I am extending standard WorkorderAddPostBAPI, I have logs and its getting triggered in extended class, also as mentioned i have enhance parts with custom fields which works fine when called from

public void setParameters(SAPObject obj)

Solution to be achieved either of two ways

1. override the setOperationParameters() of WorkorderAddBAPI in my extended class which is not triggering.

2. update only the custom fields in custom method from ZWorkorderAddPostBAPI into the same table as used in WorkorderAddBAPI - Issues is its getting updated, but in two rows, one for standard fields and 2 row for custom fields.

Please advice if you get any clue that can be tried out.

Thanks.

Ashwin