on 07-27-2007 6:30 AM
Hi
I have an incoming file which contains a (Header, Details, Trailer) in which Details are repeating. for example:
H, X,123,...... --->(Header)
D, ABC, HYG,0009 --->(Details)
D,UHU,KKK,088
D,OOO,LOK,077
T,RecordCount,...--->(Trailer)
My need is I have to write a java code to count the number of Details records and compare it with the RecordCount field in the Trailer. After validation if it is true then
the Header and Trailer Records has to be removed and first record of the Details shud end with Y . For example the above file should look like this.
D, ABC, HYG,0009,Y
D,UHU,KKK,088
D,OOO,LOK,077
Can anyone please help me out this
Hi,
Here is some pseudo code o get you started
Use an Advanced user defined function
Input 1 -> Details record
Input 2-> Count Field in Trailer.
Inside UDF, have a for loop that will be like
int count= 0;
for(int i=0;i<Input1[].length;i++){
count = i ;
}
count= count +1;
If ( count == Input2) {
result.addValue("Y")
}
hope this helps
regards
krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh k ..
Then try this pseudo code
public static byte[] getBytesFromFile(File file) throws IOException {
BufferedReader in = new BufferedReader(new FileReader("infilename"));
// Get the size of the file
long length = file.length();
String str;
int count;
int getcount;
while ((str = in.readLine()) != null) {
if (str.startsWith("D") {
count++;
}
if (str.startsWith("T") {
// write code to get the length of the count in the Trailer record and assign it to getcount variable
}
}
if ( count == getcount )
{
Then open up a Buffered writer to write a new file without the Records that start with "D",
}
regards
krishna
Hema,
How you designed the Data type, can u give us the structure?
Best regards,
raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
create UDF
below links will help u
This link for User Defined Functions,
http://help.sap.com/saphelp_nw04/helpdata/en/d9/718e40496f6f1de10000000a1550b0/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/4b/a20c4cfea96b498b1e1af3f32f0670/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/4b/a20c4cfea96b498b1e1af3f32f0670/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/4b/a20c4cfea96b498b1e1af3f32f0670/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/4b/a20c4cfea96b498b1e1af3f32f0670/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/4b/a20c4cfea96b498b1e1af3f32f0670/frameset.htm
/people/stefan.grube/blog/2005/12/30/test-user-defined-functions-for-the-xi-graphical-mapping-tool-in-developer-studio
/people/harrison.holland5/blog/2006/12/08/mapping-context-changes-in-xi
hope this will help u ...
pls reward if useful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi hemalatha,
You need to use a Advanced UDF - java program, where you are loading the entire payload in to the container in your program, so you will have the values of your header data also.
Regards,
Ramesh P
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.