on 02-21-2014 10:21 AM
Hi All,
I am trying to read a flat file which is seperated by "|" in to once Recoed set and then split it to different fields.
Can you help me by giving UDF to read this strucure.
Below are the deatils.
Source File:
1173|2524457A|07/27/2013|USD|UNILEVER HPC EXECUTIVE MATTERS Unilever/HPC Executive Matters|500.00|2611=1000010045|=12107001|=|500.00|
1173|1038246A|08/08/2013|USD|IOS Litigation|1000.00|2611=1000010045|=12107001|=|500.00|2611=1000010200|=12107002|=|250.00|2611=1000010100|=12107006|=|250.00|
HI Mahi,
Try this code, will read the particular string in complete line by giving the N`th position of the '|' symbol.
public String StrPosition(String var1, int N, Container container) throws StreamTransformationException{
int count=0;
String str="";
N = N - 1;
for(int i=0;i<var1.length();i++)
{
if(var1.charAt(i)=='|') count++;
if(count==N)
{
if(var1.charAt(i)!='|')
str=str+var1.charAt(i);
}
if(count==(N+1))
break;
}
return str+"";
}
Thanks,
Dhileep.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mahi,
I assume you have a specific delimiter and a line separator (may be 'nl'). You can use FCC to incorporate your requirement.
If you have identified keyfields in your structure, you can post your fields accordingly in the header & line structure.
However, what do you mean by set of charater. Could you please elaborate on this?
Regards,
Akshay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mahi,
It is suggested to use File content conversion for splitting records based on delimiter.
If there is no control record to be mentioned for Header and Line Item, I suggest you to use FCC to split fields into single hierarchy structure and then map fields to Header, Line_Item node based on some condition.
Are you looking to add any specific condition for splitting at mapping step.
Regards,
Pranav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mahi,
Import your flat file using the below function module.
Sample code:
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = ls_filename "your file name
filetype = 'ASC'
has_field_separator = lc_x
read_by_line = lc_x
TABLES
data_tab = gt_filedata. "internal table built with the fields you need
Loop your internal table 'gt_filedata' and split by '|'.
ex.
split gt_filedata at '|' into (your work area)
Try this. It will help you.
Regards,
Swadini Sujanaranjan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mahi,
You mean to say you are reading a | separated file line by line and then in mapping you want to split the fields using your own logic ?
can u explain how do want to split in mapping ,so that i can help you on this.
Regards
Venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Hareesh,
Above logic is working only for one charater, it is reading only one character.
But my input contains set of character.
Input: 1173|2524457A|07/27/2013|USD|HPC EXECUTIVE MATTERS /HPC Executive Matters|500.00|2611=1000010045|=12107001|=|500.00|
Please help me on above issue.
Thanks & Regards,
Madhavi.G
Hi Mahi,
Refer the below links
SAPTechnical.COM - Step by Step Guide to Validate EDI ANSI X12 Document using Java Mapping (XI/PI)
Read Input Text File as a Single Field. - Process Integration - SCN Wiki
Regards
Bhargava krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
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.