Skip to Content
author's profile photo Former Member
Former Member

Conversion of Chinese flat file (GB18030) to XML in SAP PI 7.11

Hi All,

There is a requirement in my project to convert incoming Chinese flat file (GB18030 encoding) to XML as below:

Input Chinese flat file:

So, the input XML in PI should look as below :

<RECORD>

<TITLE>

<Title01>SJJK0201</Title01>

<Title02>已开发票传出897</Title02>

<Title03>20151026</Title03>

<Title04>20151026</Title04>

</TITLE>

<HEADER>

<Header01>//发票1</Header01>

<Header02>0</Header02>

<Header03>1</Header03>

<Header04>2</Header04>

<Header05>3100143320</Header05>

...

<Header25>郑谨</Header25>

</HEADER>

<ITEM>

<Item01>0</Item01>

<Item02>照明产品31145 欣美LED吊灯白色20W 240V</Item02>

...

<Item11>11520</Item11>

</ITEM>

<ITEM>

<Item01>1</Item01>

<Item02>折扣行数1(39.261%)</Item02>

...

<Item11>11520</Item11>

</ITEM>

<ITEM>

<Item01>0</Item01>

<Item02>照明产品33350 恒典(方形)LED吸顶灯</Item02>

...

<Item11>11520</Item11>

</ITEM>

<ITEM>

<Item01>1</Item01>

<Item02>折扣行数1(39.262%)</Item02>

...

<Item11>11520</Item11>

</ITEM>

</RECORD>

<RECORD>

<HEADER>

<Header01>//发票2</Header02>

<Header02>0</Header02>

<Header03>0</Header03>

<Header04>2</Header04>

<Header05>3100143320</Header05>

...

<Header25>郑谨</Header25>

</HEADER>

<ITEM>

<Item01>0</Item01>

<Item02>照明产品31205 木忆LED吸顶灯(钱柜)60W 230V</Item02>

...

</RECORD>

We are using SAP PI 7.11 and source adapter is SFTP.

In the source adapter, we have used below modules:
1. localejbs/Seeburger/CharsetConversion -> for converting gb18030 to utf-8

2. localejbs/AF_Modules/MessageTransformBean -> for content conversion

But we are unable to handle it MessageTransformBean module.

Can you please suggest ?

Input.jpg (375.5 kB)
Input.jpg (375.5 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Nov 13, 2015 at 08:17 AM

    Hi Debashis,

    As per your requirement only way to create this using FCC is KeyFieldValue.

    I am not sure whether you have any keyFieldvalue defined or not in the incoming file. If it has then you can use that to identify Title, Header,ITEM and create your target structure else you have two ways to handle this -

    1. Define only single parameter in sender DT and Target like below -

    Source

    Record - 0.unbound

    Text - 0.1

    Target

    Record - 0.unbound

    Title -0.1

    TitleFieldValue - 0.unbound

    Header - 0.1

    HeaderFieldValue - 0.unbound

    ITEM - 0.unbound

    ITEMFieldValue - 0.unbound

    Using simple FCC put your whole file content in Text parameter and then write a UDF to extract the values there and populate in the target side using multiple result List


    2. Else use JAVA Mapping.


    Thanks,

    Apu

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Denashis,

      It can be handled through single UDF.

      But if you find it difficult you cal write 3 UDFs.

      One for Title fields generation

      One for Header fields generation

      One for Item fields generation


      For all required output parameters you just need to create result List accordingly.

      Like for UDF of Header you will have 5 resultlists - one for Root Header target and 4 others for target parameters.


      Thanks,

      Apu

  • author's profile photo Former Member
    Former Member
    Posted on Nov 19, 2015 at 07:28 AM

    Hi All,

    The Chinese flat file has been handled by use of 4 UDFs in PI mapping.
    Now I'm facing one more challenge.


    The target structure is an xsd version of IDOC and we have to populate the target fields RCVPRT, RCVPRN dynamically.

    It has to be populated dynamically because the values of RCVPRT, RCVPRN changes as per environment like Dev, Quality, Prod.

    Can you please help with this ?

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 13, 2015 at 07:39 AM

    Hi Debashis,

    Can you try the steps mentioned in this blog?

    Character Encoding Handled the right way

    Regards,

    Mark

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Mark,

      Thanks for the blog.

      The conversion of GB18030 encoding to UTF-8 has been handled via module localejbs/Seeburger/CharsetConversion.

      But the problem I'm facing with is how to arrange the input flat file as per the required XML structure. Unable to handle it with MessageTransformBean module.

      Regards,

      Debashis

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.