cancel
Showing results for 
Search instead for 
Did you mean: 

file content conversion query

former_member183906
Active Contributor
0 Kudos


hi,

i have sender and received side -file content conversion.

in sender communication channel -

Recordset structure is -> Header,1,Detail,*

Message type structure is

MT1 has 2 subnodes Header and Detail.

In my message type,there is no field identical in Header and Details. All fields are different.

(1) Is Key Field Name mandatory in this case ? If I am not giving Key field name,sender channel gives error. How to resolve it ?

(2) Input file comes from customer and in the input file there is no specific data to identify header and detail. 1st line shud be header and other lines shud be Detail ,they say. If no identification coming in incoming data,how can we set the key field name ?

rgds

Accepted Solutions (1)

Accepted Solutions (1)

former_member184720
Active Contributor
0 Kudos

(1) Is Key Field Name mandatory in this case ? If I am not giving Key field name,sender channel gives error. How to resolve it ?


It's already confirmed by Anshu.


(2) Input file comes from customer and in the input file there is no specific data to identify header and detail. 1st line shud be header and other lines shud be Detail ,they say. If no identification coming in incoming data,how can we set the key field name ?


Is that a CSV? fixed length???


If it is feasible then treat entire file as details for the content conversion part but in the mapping you can read the fist line to get the header values..


content conversion -> detail,*

during the mapping ->copy value[0]  will return header value.



former_member183906
Active Contributor
0 Kudos

the input file is TXT

sample test data is as follows - 1st line is header and rest are details -

03456      TESTDATA

12344       60042

45678        60043

How to select key field in these as there are all field dynamic coming from customer. How we can generate unique identifier or key and use it ? Any idea.

former_member184720
Active Contributor
0 Kudos

Looks like it's a fixed length file.

if the content conversion parameters(lengths for header n detail) remains same for first line and other lines then as i suggested configure the recordset strcture as detail,*

change your source data type to just have Details segment.. remove Header...

content conversion something like-

Detail.fieldName - field1,field2

Detail.fieldFixedLenths - 10,10

former_member183906
Active Contributor
0 Kudos

03456451     TESTDATABC 7645649 8746464

12344       60042

45678        60043

header line is having different field and different lenghts.

details lines are having n number of lines and they have same fixed lengths..

former_member184720
Active Contributor
0 Kudos

Then in such case,

Read each line into one field and during the mapping you have to make use of sub string to get the actual value.

Refer to Greg's suggestion in the below thread.

else you might have to go with Java mapping..

Former Member
0 Kudos

Hi ,

If you check the file the second field of the data record seems to be in some sequence(60042) .As well as header is having filename or something as such(string TESTDATA)

So you can specify key values easily .It can be achieved by message mapping .

Check with the functional consultant if the actual data is going to be same as this

Give key value for header ->file name i.e Test Data

Give key value for record ->second field name  with value 600.

Thanks

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi SAP PI,

Why don't you use JavaMapping?

Regards,

Gavaksh Saxena

former_member183906
Active Contributor
0 Kudos

I want to use standard FCC. Only issue is in KEY field. Can we add key field for header and detail line items as the TXT file comes to PI and use it somehow ?

If java mapping can solve KEY field issue,pls provide d code.

former_member183906
Active Contributor
0 Kudos

Is there any Java code to add H  prefix in first header line and D prefix in item lines.. Can you pls share d java code to do so..

anupam_ghosh2
Active Contributor
0 Kudos

Hi SAP PI,

                      Can you please explain why you need that?

Regards

Anupam

former_member183906
Active Contributor
0 Kudos

Hi,

Recordset structure is -> Header,1,Detail,*

In PI sender communication channel, Its asking for Key field. In my input file there is no key field to identify header and detail lines.

Thus, I wanted to add a key in header and detail lines.

Regards

former_member184720
Active Contributor
0 Kudos

Did you try what i suggested earlier?

Read entire line into a string and use substring function to do the content conversion in the graphical mapping.

Else below blog for your reference on Java mapping -

Java Mapping Sample Code - Process Integration - SCN Wiki

You don't need to add "H"/ "D" .. based on the line number you can check weather it is header or details in java mapping..

anupam_ghosh2
Active Contributor
0 Kudos

Hi SAP PI,

                      For this moment try this.

Let the file content is like this

03456451     TESTDATABC 7645649 8746464

12344       60042

45678        60043

You try reading the file like this

<MT_S>

     <RECORDSET>

         <ROW>

                  <field1>03456451</field1>

                  <field2>TESTDATABC 7645649 8746464</field1>

        </ROW>

          <ROW>

                  <field1>03456451</field1>

                  <field2>TESTDATABC 7645649 8746464</field1>

        </ROW>

          <ROW>

                  <field1>03456451</field1>

                  <field2>TESTDATABC 7645649 8746464</field1>

        </ROW>

</RECORDSET>

</MT_S>

FCC is like this

Document Name : MT_S


Document Namespace: "put name space here"



Recordset Name: RECORDSET



Recordset Structure: ROW,*


ROW.fieldNames  field1,field2

ROW.endSeparator   'nl'

ROW.fieldSeparator   0x20

Once you get this in mapping use a simple UDF to ignore the first ROW values and read the rest.

Populate the target structure from the output of UDF for each field value.

Please let me know if you need the uDF and further mapping for this.

Regards

Anupam

Former Member
0 Kudos

(1) Is Key Field Name mandatory in this case ? If I am not giving Key field name,sender channel gives error. How to resolve it ?

Yes.Key field is mandatory to be specified .

(2) Input file comes from customer and in the input file there is no specific data to identify header and detail. 1st line shud be header and other lines shud be Detail ,they say. If no identification coming in incoming data,how can we set the key field name ?

This can be done by writing java code in mapping or adapter module .Their can be an easier way also to handle it in message mapping too.Please attach the sample file structure .

Thanks