cancel
Showing results for 
Search instead for 
Did you mean: 

Impossible File content conversion?

Former Member
0 Kudos

Hi everyone,

I have a problem as I need convert a flat file in xml strcuture but I cant do that.

The flat file is like this:

PRxx1

CLxxx

ALxxx

PTxxx

PTxx

PTxx

...

TAxx

CLxx

ALxx

PTxx

PTxx

PTxx

...

TAxx

PRxx2

CLxx

...

I need to send an IDOC (ORDERS) for each CL, but I also need post the PR -root tag- in each CL. The PR is not always the same. I mean, I need something like that:

PR1

CL

AL

PT

PT

...

TA

CL

...

PR2

CL

AL

PT

PT

...

CL

...

First of all, I don`t know exactly where the problem could be located, if it is in File either Content Conversion or in Mapping program or in both.

I have tried everythig but I didn't get successful results.

Maybe there is no solution for this problem as I think the File content conversion can't convert in nested substructures?

Any idea?

Thanks for everything

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

We will handle this inside mapping as follows

Crate an Intermediate structure Identical to your input structure. Just you need to add an sub element (Let’s say "T" to your CL node.

This sub element will be used to remember CL node belongs to which PR node.

Map your Input structure to Intermediate structure.

While mapping PR Node of input to PR Node of Intermediate structure use a user defined function as follows

Integer ii;

GlobalContainer g;

g=container.getGlobalContainer();

Object o= g.getParameter("_&HLID");

if (o==null) ii=new Integer(0);

else

ii =(Integer)o;

ii =new Integer(ii.intValue()+1);

g.setParameter("_&HLID",ii);

Use another user defined function to retrieve the value of this _&HLID and put it to T as follows:

GlobalContainer g;

g=container.getGlobalContainer();

Object o= g.getParameter("_&HLID");return o.toString();

For all other fields just do a 1:1 mapping.

Then

Map your intermediate structure to destination structure (IDOC)

Here the only catch is:

For populating the value of PR for each CL

Pass both the element T and the element of PR from which you want to pick the value to a user-defined function (raise the context of both elements to the top node).

In array a we have the value of T

In array b we have the value of element of PR

int j=0;

for(int k=0;k<b.length;k++){

for (int i=0;i<a.length;i++)

{

if (a<i>.equals(new Integer(j+1).toString())){

System.out.println(b[j]);

}

}

j=j+1;

}

Hope this takes care of your problem.

If you don't get anything please get back to me.

Abinash

Former Member
0 Kudos

I have done something similar to do this long back with user defined functions and intermediate mapping.

Give me sometime I will get the solution for you.

Thanks

Abinash.

Shabarish_Nair
Active Contributor
0 Kudos

Maybe there is no solution for this problem as I think the File content conversion can't convert in nested substructures?

>> note tht FCC works only for a single level .. say

<root>

<A>XXX</A>

.......

<B>YYY</B>

.......

......

</root>

It cannot have

<root>

<b><A>

<AA>XYZ

</AA>

</A></b>

.......

<B>YYY</B>

.......

......

</root

former_member206604
Active Contributor
0 Kudos

Hi,

Please post more details, also the source file structure and few sample records and source XML structure. It can be done may be bit complex. If content conversion dose'nt help you can achieve it in Mapping or in Adapter Module. If you are not comfortable with Adapter module you can also have a look at Item Field Conversion Agent.

Thanks,

Prakash