cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert IDOC to flat file in XI

Former Member
0 Kudos

Hello SDNers

I have a scenario IDOC --> XI --> Flat file. My question is how to conver IDOC to flat file. At least there are two ways to do that:

1) Define a flat structure in PI that reflects the IDOC structure, then using content conversion to convert the flat structure to flat file in hte receiver communication channel.

2) There is a [document |https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/46759682-0401-0010-1791-bd1972bc0b8a] talking about using a generic ABAP mapping to map any IDOC to flat file.

For the option 1, I don't want that way, because I would need to define a flat structure in PI for each IDOC which is too much effort. (I would have dozens of IDOC scenarios)

The second one is very attractive. However the document is not complete to follow. Basically it does not explain how the inbound flat structure looks like. I guess the generic ABAP mapping is used to map any IDOC_XML structure to a flat structure, then in the file receiver communication channel to convert the flat structure to flat file format. But the document does not mention how the flat structure looks like. Has somebody tried this scenario? If yes, can you please let me know the steps to do in ESR (IR) and ID? Basically what structure the IDOC_XML should be mapped to using the generic ABAP mapping class?

Or somebody has other ideas on how to convert IDOC to flat file?

Thank you so much

Eric

Accepted Solutions (1)

Accepted Solutions (1)

bhavesh_kantilal
Active Contributor
0 Kudos

1. You will defintely need to use the ABAP mapping option here. The other option is too difficult.

2. The Target Structure can be anything . Both ABAP and Java Mapping work on Stream's and hence there is no validation against the message type and hence create a Dummy Target message type and associate this with the Inbound Interface and Interface Mapping.

3. Also, I remember reading some SAP Literature that PI 7.1 will have standard modules to do Idoc to XML and XML to Idoc conversion's but not sure if this is available as yet.

Regards

Bhavesh

Former Member
0 Kudos

Hi Bhavesh,

your information is very valuable. Can you please answer my additional questions?

1) You are saying that for Java mapping and abap mapping, the target data type (messag type) is just a dummy one, the real (XML) message the receiver will recieve is the one (stream) produced by the java or abap mapping. Is that correct?

2) For the abap mapping option, I would define a dummy target data type. Do I need to do any content conversion in the receiver adapter (communication channel)?

3) I tried with a dummy target data type as mentioned in my second post, can you see any clue in the error message what is wrong?

Thank you so much.

Eric

bhavesh_kantilal
Active Contributor
0 Kudos

> 1) You are saying that for Java mapping and abap mapping, the target data type (messag type) is just a dummy one, the real (XML) message the receiver will recieve is the one (stream) produced by the java or abap mapping. Is that correct?

Definitely yes!

>

> 2) For the abap mapping option, I would define a dummy target data type. Do I need to do any content conversion in the receiver adapter (communication channel)?

None wat so ever.The output of your Java Mapping will be the Native Idoc Format.

>

> 3) I tried with a dummy target data type as mentioned in my second post, can you see any clue in the error message what is wrong?

Dats one thing I cant help much. Just make sure that the ABAP report is valid and take the help of a ABAP'er to debug what is going wrong. Not much of a ABAP guy, can read ABAP code, but cant write one myself

Try to test the program standalone to see how it works. Maybe take some Idoc XML file as input and then dump the output to a .txt file and so on.

Regards

Bhavesh

PS : All this is from what I have read of this guide. I have not convert Idoc XML to Native Idoc but have used this guide to convert Native Idoc to Idoc XML .

Former Member
0 Kudos

Thanks, Bhavesh. Points assigned.

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Eric,

Did it work? What was the exact problem?

Regards

Bhavesh

Former Member
0 Kudos

No, Bhavesh, I want to debug into abap mapping, but didn't work. I am still struggling to figure out the problem.

But the generic ABAP mapping is the way to go.

Former Member
0 Kudos

Hi Guys,

Did you got the solution? I am also wondering to convert IDOC to a Flat file with out any xml tags.

Could any one can light on this issue.

Thanks

Rajeev

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Eric

You can do XML to flat file using Java as well as XSLT mapping. But for any of the mappings you need target structure.

We have faced requirement earlier and what we did was we use XSLT mapping and converted XML file into a single field. We had to convert to CSV format and pass it to single field.

Thanks

Gaurav

Former Member
0 Kudos

BTW, I tried the inbound flat structure of <row><data>XXX</data></row><row><data>XXX</data></row>, and used the ABAP mapping class to map an IDOC to the flat structure in ID. I got error in SXMB_MONI like:

<SAP:Stack>Error in mapping program Z_ABAP_MAPPING_IDOC_TO_FLAT (type SAP-ABAP, kernel error ID UNCAUGHT_EXCEPTION) An exception with the type CX_SY_DYN_CALL_PARAM_NOT_FOUND occurred, but was neither handled locally, nor declared in a RAISING clause Call of the function ZSOTR_SERV_TABLE_TO_STRING failed; the formal parameter TEXT does not exist</SAP:Stack>

Don't know how to fix it as I am not sure the flat structure is correct.

Former Member
0 Kudos

Hello Eric,

Irrespective of the method 1 or 2, you need to create target structure for the target system.

You cannot escape in that matter.

The only thing is whether you can choose idoc adapter or proxies for transmitting from R/3 to Target.

Moreover making ABAP mapping would be little cumbersome, I would always prefer to use standard xi message mapping which is easier to monitor and debug.

Java and ABAP mapping must be only used where complex mapping involves.

Regardes

Krish

Former Member
0 Kudos

Hi Krish

I understand we need a target structure (Data Type). I suppose with the 2nd option, the target data type would be a very simple one and can be reused anywhere where IDOC to flat file is concerned. That case, very little effort would be needed.

As for hte 1st option, I need to define a flat data type for each IDOC, some IDOC contains hundreds of fields, defining the target structure and mapping IDOC to the structure would take lot of effort, that's why I want to avoid it.

Do you have any better idea?

Thanks

Jayson

VijayKonam
Active Contributor
0 Kudos

For second option also, you need not do an ABAP mapping unless u have something that can not be implemented using Graphical Mapping.

Other thing is the receiver file adapter only supports particualr xml strucuture and you must map your IDoc to that xml format only to generate a flat file.

refer - http://help.sap.com/saphelp_nw70/helpdata/EN/d2/bab440c97f3716e10000000a155106/content.htm

VJ

Former Member
0 Kudos

VJ,

I don't quite understand your opinion.

Nevertheless, you can map IDOC to a simple structure, then convert the simple structure to file in the file content conversion. However in this case you need do a mapping for each IDOC, while the proposed solution is to have the same mapping for all IDOCs. The only thing I don't know is how the target structure looks like. Really on one tried this solution?

BTW, when IDOC converted to IDOC_XML, isn't the leading spaces or ending spaces in the IDOC fields got lost?

Thanks

Jayson