on 11-10-2010 2:36 PM
Hi Guys,
I am working on Idoc to file scenario and generating a file at the target.
at the file...for each line i have to add a line count.
i have 2 header and 5 detail records set..and details are repeating multiple times.
For Ex:
H1........001
H2....002
D1------003
D2----
004
D3----
005
D4-------006
D5----
007
Footer-----008
Could someone help me in resolving this issue?
Thanks
sahil
Hi Sahil,
You can write UDF as follow
AbstractTrace trace= (AbstractTrace)container.getTrace();
GlobalContainer globalContainer = container.getGlobalContainer();
String str = (String) globalContainer.getParameter ("COUNTER");
if(str!=null){
int tempRowCounter =(new Integer (str)).intValue();
globalContainer.setParameter("COUNTER",tempRowCounter++);
return tempRowCounter+"";
}else{
globalContainer.setParameter("COUNTER", "1");
return "1";
}
Regards
Ritu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ritu,
Your Given UDF is working for the first 2 records only..for the rest it showing an error as
"Runtime exception when processing target-field mapping /ns0:ProductionOrderCreateChange_Async_V01/PoItem/FileRecordNum; root message: Exception:[java.lang.ClassCastException: class java.lang.Integer:null incompatible with class java.lang.String:null] in class".
can you please guide me as to what could be the problem is?
Thanks
sahil
replace the code by
GlobalContainer globalContainer = container.getGlobalContainer();
String str = (String) globalContainer.getParameter ("COUNTER");
if(str!=null){
int tempRowCounter =(new Integer (str)).intValue();
tempRowCounter = tempRowCounter+1;
globalContainer.setParameter("COUNTER",tempRowCounter+"");
return tempRowCounter+"";
}else{
globalContainer.setParameter("COUNTER", "1");
return "1";
}
Hi.
You can make a module or you can add one element and in your mapping put as counter.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sahil
if you're using the Receiver File Adapter using the NFS mode (not FTP) you can think to write a very simple Operating System Command to be executed after message processing.
This script will calculate the number of records and write down the footer.
Francesco
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.