Skip to Content
0
Dec 02, 2020 at 08:08 PM

work manager 6.5.11.0 - Add New Workorder enhancement

43 Views

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