cancel
Showing results for 
Search instead for 
Did you mean: 

File 2 Proxy, error when ignoring all the file lines

Marçal_Oliveras
Active Contributor
0 Kudos

Hi, Iu2019m doing a file 2 proxy scenario and Iu2019m mapping only the file lines that contains a key field with 10 chars (and ignoring the lines where the key field is 13 chars).

The problem is, when all the lines of the file have to be ignored (because the ID length is 13), the message mapping crashes. Iu2019ve changed the occurrence of the message in the message mapping signature but still is giving me an error when there arenu2019t valid lines on file.

My question is: Is possible to detect a file without any valid ID in the receiver determination to avoid calling the mapping? I think itu2019s not possible because I donu2019t know how to check the length of a string with xpathu2026

But if I canu2019t detect this files, how can I solve the problem of empty target message after the mapping?

Accepted Solutions (1)

Accepted Solutions (1)

former_member187339
Active Contributor
0 Kudos

Hi Marshal,

It will be helpful if we can see the source and target structure with their occurrences.

Also a sample input data

Regards

Suraj

Marçal_Oliveras
Active Contributor
0 Kudos

Hi Suraj, here you have a copy paste of the XMLfrom a test file. The 1st item is a valid line of the file because the lenght of field "id_pedido" is 10. The 2nd item is not valid because the length is 13



<?xml version="1.0" encoding="utf-8"?>
<ns:LO_MT_ConfEDIEYES xmlns:ns="HIDDEN">
<Confirmacion>
	<items>
		<tipreg>R01</tipreg>
		<ctrl_ref>I0027187</ctrl_ref>
		<id_pedido>4500000467</id_pedido>
		<fecha_pedido>200612220910</fecha_pedido>
		<id_cliente>0626485</id_cliente>
		<id_cliente_dest>0</id_cliente_dest>
		<fecha_resp>200612220910</fecha_resp>
		<divisa></divisa>
		<fecha_serv></fecha_serv>
		<aceptado>S</aceptado>
		<cantidad>00</cantidad>
		<valorado>N</valorado>
		<pre><code>000000</code></pre>
		<id_entrega>000007486</id_entrega>
		<observaciones>Sin error</observaciones>
	</items>
	<items>
		<tipreg>R01</tipreg>
		<ctrl_ref>I0027187</ctrl_ref>
		<id_pedido>0123456789123</id_pedido>
		<fecha_pedido>200612220910</fecha_pedido>
		<id_cliente>0626485</id_cliente>
		<id_cliente_dest>0</id_cliente_dest>
		<fecha_resp>200612220910</fecha_resp>
		<divisa></divisa>
		<fecha_serv></fecha_serv>
		<aceptado>S</aceptado>
		<cantidad>00</cantidad>
		<valorado>N</valorado>
		<pre><code>000000</code></pre>
		<id_entrega>000007486</id_entrega>
		<observaciones>Sin error</observaciones>
	</items>
</Confirmacion>
</ns:LO_MT_ConfEDIEYES>

The target structure after the mapping in this case is that:


<?xml version="1.0" encoding="UTF-8"?>
<ns0:LO_MT_Conf_in xmlns:ns0="HIDDEN">
   <Confirmacion>
      <items>
         <id_pedido>4500000467</id_pedido>
         <aceptado>S</aceptado>
      </items>
   </Confirmacion>
</ns0:LO_MT_Conf_in>

Edited by: Marshal on Oct 7, 2009 12:00 PM

former_member187339
Active Contributor
0 Kudos

Hi Marshal,

Here three cases can occure:

Case I : id_pedido in all record is of length 10

Case2 : id_pedido in all record is of length 13

Case3: id_pedido length in some record will 10 and in some it will be 13

and i guess Case3 will be the frequent case. So its better to handle the problem in Message Mapping rather than in the condition editor of Receiver determination

Of the mixed records (ie in Case3), filter the record which have id_pedido as length 10. Then do your mapping. So in interface mapping you need to add two mappign, first which will remove records with id_pedido's length =13 and second which will map the record to proxy structure.

Now if case 2 came then the first mapping will return empty output and this one need to be mapped to target so the min occurrence of the target should be as mentioned below.


<?xml version="1.0" encoding="UTF-8"?>
<ns0:LO_MT_Conf_in xmlns:ns0="HIDDEN">
   <Confirmacion> occurrence 1..1
      <items> occurrence 0..unbounded
         <id_pedido>4500000467</id_pedido> occurrence 1..1
         <aceptado>S</aceptado> occurrence 1..1
      </items>
   </Confirmacion>
</ns0:LO_MT_Conf_in>

A second approach is do handle this problem in Proxy. Process only those records which have id_pedido value to be of length 10

Regards

suraj

Marçal_Oliveras
Active Contributor
0 Kudos

Thanks Suraj for your extended solution. The case 3 was already solved by me but now as you tell me in your second approach I think that I'm going to handle the problem in the proxy because it looks easy to understand and mantain.

Thank you very much

Answers (1)

Answers (1)

former_member200962
Active Contributor
0 Kudos

Referring this blog: /people/shabarish.vijayakumar/blog/2006/06/07/customise-your-xpath-expressions-in-receiver-determination

You can try with below condition:

Left Operand -->

 /p1:MT_Pickfile/Header[string-length(field1) = 10]

Middle Operand --> EX

Give it a try....let me know if it works.

Regards,

Abhishek.

Marçal_Oliveras
Active Contributor
0 Kudos

Abhishek salvi: I've tried your approach too but it doesn't work. In the message trace of receiver determination the condition is always "OK", even when there is only 1 line with more than 10 chars in "id_pedido" in the file