This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getGlobalParameter(String Parameter, Container container) throws StreamTransformationException{ | |
String ParameterValue = ""; | |
try{ | |
GlobalContainer gc = container.getGlobalContainer(); | |
ParameterValue = (String) gc.getParameter(parameter); | |
}catch(Exception ee){ | |
ParameterValue = ""; | |
} | |
return ParameterValue; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String validateFieldLength(String minLength, String maxLength, String FieldValue, Container container) throws StreamTransformationException{ | |
try{ | |
if ( FieldValue.length() < Integer.parseInt(minLength)) //check if FieldValue lenght is less than minlength | |
{ | |
throw new RuntimeException(FieldValue + " length is incorrect"); | |
} | |
if( FieldValue.length() > Integer.parseInt(maxLength) ) //check if FieldValue lenght is greater than maxLength. If yes, then truncate fieldValue | |
{ | |
FieldValue = FieldValue.substring(0, Integer.parseInt(maxLength) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String changeTimeZone(Container container) throws StreamTransformationException{ | |
String stTime = ""; | |
try{ | |
Calendar calendar = Calendar.getInstance(); | |
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); //Formatter to get the desired time stamp format | |
formatter.setTimeZone( TimeZone.getTimeZone("GMT") ); //Change to desired GMT timezone from here | |
stTime = formatter.format( calendar.getTime() ); | |
}catch(Exception ee){ | |
stTime= ""; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getTime(Container container) throws StreamTransformationException{ | |
String stTime, stHH, stmm, stss; | |
stTime = "000000"; //Defaults | |
try{ | |
Calendar cal = Calendar.getInstance(); | |
//stTime = cal.getTime().toString(); -- Another short way | |
stHH = Integer.toString(cal.get(Calendar.HOUR_OF_DAY)); | |
if(stHH.length()<2){ | |
stHH = "0" + stHH; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean setDynamicFileName(String FieldValue, Container container) throws StreamTransformationException{ | |
boolean success = false; | |
try{ | |
//Get the DynamicConfiguration instance | |
DynamicConfiguration config = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); | |
//Define key to write in the Dynamic Configuration | |
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName"); | |
//Write the FileName parameter from the Dynamic Configuration based on the key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getDynamicFileName(Container container) throws StreamTransformationException{ | |
String FileValue = ""; | |
try{ | |
//Get the DynamicConfiguration instance | |
DynamicConfiguration config = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); | |
//Define key to read from the Dynamic Configuration | |
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName"); | |
//Read the FileName parameter from the Dynamic Configuration based on the key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getMessageID(Container container) throws StreamTransformationException{ | |
String messageID = ""; | |
java.util.Map map = container.getTransformationParameters(); | |
messageID = (String) map.get( StreamTransformationConstants.MESSAGE_ID); | |
return messageID; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean setDynamicConfiguration(String Namespace, String FieldName, String FieldValue, Container container) throws StreamTransformationException{ | |
boolean success = false; | |
try{ | |
//Get the DynamicConfiguration instance | |
DynamicConfiguration config = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); | |
//Define key to write in the Dynamic Configuration | |
DynamicConfigurationKey key1 = DynamicConfigurationKey.create(Namespace, FieldName); | |
//Write the parameter from the Dynamic Configuration based on the key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getDynamicConfiguration(String Namespace, String FieldName, Container container) throws StreamTransformationException{ | |
String FieldValue = ""; | |
try{ | |
//Get the DynamicConfiguration instance | |
DynamicConfiguration config = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); | |
//Define key to read from the Dynamic Configuration | |
DynamicConfigurationKey key1 = DynamicConfigurationKey.create(Namespace, FieldName); | |
//Read the parameter from the Dynamic Configuration based on the key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
*/ | |
package com.sap.adaptermodule; | |
import javax.ejb.CreateException; | |
import javax.ejb.SessionBean; | |
import javax.ejb.SessionContext; |