Customer-Specific Column for Texts on WBS Elements (Example)
You want to display a column for customer-specific texts to the right of the column for WBS elements in the data entry area of the CATS notebook. You want the column to display an explanatory text from the WBS element picklist for each WBS element to simplify data entry for the user.
Java Source Code
package com.sap.mycats.customer.examples;
import com.sap.mycats.basics.tools.badi.IFieldReadOnly;
import com.sap.mycats.basics.tools.badi.IRecordReadOnly;
import com.sap.mycats.basics.tools.badi.ITableReadOnly;
import com.sap.mycats.customer.businessLogic.IPicklist;
import com.sap.mycats.customer.businessLogic.ITimeSheetReader;
import com.sap.mycats.customer.userInterface.IColumnModelCustomer;
public class ZColumnModel
implements IColumnModelCustomer
{
private final static String WBS_ELEMENT = "POSID";
public boolean isActive (String aProfileId,
String aFieldSelectionId) {
return true;
}
public String getReferenceColumnId (String[] aColumnIdTable) {
return WBS_ELEMENT;
}
public int getColumnDisplayWidth () {
return 15;
}
public int getMaxLength () {
return 30;
}
public String getColumnTitle (ITimeSheetReader aTimeSheetReader) {
return aTimeSheetReader.getTextResourceShort(WBS_ELEMENT) + " text";
}
public String getCellValue (ITableReadOnly aRecordVersionTable,
ITimeSheetReader aTimeSheetReader) {
try {
IRecordReadOnly record
= aRecordVersionTable.getRecordReadOnly(0);
IPicklist picklist
= aTimeSheetReader.getPicklist(WBS_ELEMENT);
IFieldReadOnly rproj
= record.getFieldReadOnly(WBS_ELEMENT);
ITableReadOnly picklistRecords
= picklist.select(rproj.getValueAsString(),
rproj.getValueAsString());
if (picklistRecords.getRowCount() != 0) {
return picklistRecords.getRecordReadOnly(0).getFieldAsString("POST1");
}
} catch (Throwable e) {
}
return "";
}
}