cancel
Showing results for 
Search instead for 
Did you mean: 

UDF Using Dynamic Configuration for Counter Reset

Former Member
0 Kudos

Hi All,

In an Idoc to file scenario we want to have counter option at the end of the file.we are using NFS so that we wil not face any problem of counter reset on a j2ee restart

But when the counter turns 999999 it has to be reset to 0000001

So we are trying to dynamically create a file name using the counter and check whether it has reached 999999 then resetting back . I had written a code for the same but it is throwing an error while mapping and activating.

UDF CODE is below

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION) ;

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName") ;

String FileName = conf.get(key) ;

int inc = 1 ;

String temp = FileName.substring(10,6);

String temp1 = FileName.substring(0,10);

Integer seqNo = Integer.parseInt(temp) ;

if(seqNo == 0 || seqNo == 999999) {

seqNo = new Integer(inc) ;

}

else {

int num = seqNo.intValue() + inc ;

seqNo = new Integer(num) ;

}

container.setParameter("seqNo", seqNo);

String File_Name = temp1 + Integer.toString(seqNo);

conf.put(key, File_Name);

return File_Name;

}

ERROR it is throwing

'class' or 'interface' expected public String Decimal$(String Sample,Container container){ ^ /usr/sap/PJD/DVEBMGS58/j2ee/cluster/server0/./temp/classpath_resolver/Map76d12330b43811df8c1500e000a6fabc/source/com/sap/xi/tf/_MM_Sample_to_TRGT_.java:127: 'class' or 'interface' expected }

So can anyone please advice.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Instead of this-

Integer seqNo = Integer.parseInt(temp) ;

use this -

int seqNo = Integer.parseInt(temp) ;

It's a problem with type mis-match.

Former Member
0 Kudos

Hi,

Thanks for your advices.

Actually we found that it could not be achieved by the Dynamic configuration since it is at the receiver's end and no input is coming for the UDF to increment or reset the file name.

Thanks

Answers (1)

Answers (1)

stefan_grube
Active Contributor
0 Kudos

remove the last }

Former Member
0 Kudos

Hi Stefan,

I removed the last }

But stil it is throwing the below error:

Activation of the change list canceled Check result for Message Mapping MM_Sample_to_Trgt | : Starting compilation Source code has syntax error: /usr/sap/PJD/DVEBMGS58/j2ee/cluster/server0/./temp/classpath_resolver/Map8e67b780b44111dfbc4100e000a6fabc/source/com/sap/xi/tf/_MM_Sample_to_Trgt .java:98: FileName is already defined in File$(java.lang.String,com.sap.aii.mappingtool.tf3.rt.Container) String FileName = conf.get(key) ; ^ /usr/sap/PJD/DVEBMGS58/j2ee/cluster/server0/./temp/classpathresolver/Map8e67b780b44111dfbc4100e000a6fabc/source/com/sap/xi/tf/_MM_Sample_to_Trgt .java:102: incompatible types found : int required: java.lang.Integer Integer seqNo = Integer.parseInt(temp) ; ^ /usr/sap/PJD/DVEBMGS58/j2ee/cluster/server0/./temp/classpathresolver/Map8e67b780b44111dfbc4100e000a6fabc/source/com/sap/xi/tf/_MM_Sample_to_Trgt .java:103: operator == cannot be applied to java.lang.Integer,int if(seqNo == 0 || seqNo == 999999) { ^ /usr/sap/PJD/DVEBMGS58/j2ee/cluster/server0/./temp/classpathresolver/Map8e67b780b44111dfbc4100e000a6fabc/source/com/sap/xi/tf/_MM_Sample_to_Trgt .java:103: operator == cannot be applied to java.lang.Integer,int if(seqNo == 0 || seqNo == 999999) { ^ /usr/sap/PJD/DVEBMGS58/j2ee/cluster/server0/./temp/classpathresolver/Map8e67b780b44111dfbc4100e000a6fabc/source/com/sap/xi/tf/_MM_Sample_to_Trgt .java:111: cannot resolve symbol symbol : method toString (java.lang.Integer) location: class java.lang.Integer String FileName = temp1 + Integer.toString(seqNo);

Edited by: mallavarapu soundarya on Aug 30, 2010 4:44 PM

stefan_grube
Active Contributor
0 Kudos

Those are all syntax errors which should be self-evident.

correct the errors.