# How do I seperate a doc into multiple files?

**URL:** <https://techcommunity.softwareag.com/t/how-do-i-seperate-a-doc-into-multiple-files/110259>\
**Category:** Forum\
**Tags:** EDI\
**Created:** [February 10, 2011, 10:12pm UTC](https://techcommunity.softwareag.com/t/how-do-i-seperate-a-doc-into-multiple-files/110259 "2011-02-10T22:12:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [February 10, 2011, 10:12pm UTC](https://techcommunity.softwareag.com/t/how-do-i-seperate-a-doc-into-multiple-files/110259/1 "2011-02-10T22:12:15Z")

</div>

Hi,

I have a situation where I will be receiving an IDOC that has multiple files in it. Each file is seperated by EDI\_DC. How can I loop through each IDOC, then publish each individual file?

thanks

---

<div class="post-metadata">

**Author:** ![gupta\_r.17495](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@gupta\_r.17495](https://techcommunity.softwareag.com/u/gupta_r.17495)\
**Post date:** [February 10, 2011, 10:23pm UTC](https://techcommunity.softwareag.com/t/how-do-i-seperate-a-doc-into-multiple-files/110259/2 "2011-02-10T22:23:43Z")

</div>

You cannot break each individual IDOC automatically…Basically you have to loop thru IDOC and create a temp\_IDOC document (with each EDI\_DC40 init) and with in the loop publish it and drop the temp IDOC.

Another option would be you have to map each iteration of to target document (Canonical/EDI/XML depends on your requirement) and publish the canonical downstream etc…

HTH,  
RMG

---

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [February 10, 2011, 10:30pm UTC](https://techcommunity.softwareag.com/t/how-do-i-seperate-a-doc-into-multiple-files/110259/3 "2011-02-10T22:30:03Z")

</div>

Thanks for your response. But my question then is how can I distinguish within the loop? How do I tell the loop when to begin and end?

---

<div class="post-metadata">

**Author:** ![gupta\_r.17495](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@gupta\_r.17495](https://techcommunity.softwareag.com/u/gupta_r.17495)\
**Post date:** [February 10, 2011, 10:55pm UTC](https://techcommunity.softwareag.com/t/how-do-i-seperate-a-doc-into-multiple-files/110259/4 "2011-02-10T22:55:00Z")

</div>

Basically in your custom subscribed service,you have to loop on /IDOC and map (one to one of each each segment/fields including EDI\_DC) to a temp document called (extract\_singleIDOC) and publish it at that moment and drop the temp and it continue next iterations which will perform same above steps and once all iterations done it will end the loop.So make sure you have all the individual publishes happened.

Sorry If I misunderstood your question above:

HTH,  
RMG

---

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [February 11, 2011, 8:11pm UTC](https://techcommunity.softwareag.com/t/how-do-i-seperate-a-doc-into-multiple-files/110259/5 "2011-02-11T20:11:23Z")

</div>

The thing is, we receive the document. In that document there are multiple records. Each individual record is seperated by a line that starts with EDI\_DC. How can I seperate each record by this line?

I apologize for the ambiguity of my question before.

Thank you!

---

<div class="post-metadata">

**Author:** ![gupta\_r.17495](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@gupta\_r.17495](https://techcommunity.softwareag.com/u/gupta_r.17495)\
**Post date:** [February 11, 2011, 9:13pm UTC](https://techcommunity.softwareag.com/t/how-do-i-seperate-a-doc-into-multiple-files/110259/6 "2011-02-11T21:13:04Z")

</div>

Are you receiving raw idoc file from SAP to a folder or ALE notification mechanism?

Basically you should first parse the receiving IDOC (subscibed in the subscribed service:

pub.sap.idoc:iDocToDocument and the document will have the IDOC list of documents.Make sense?

HTH,  
RMG

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:06pm UTC](https://techcommunity.softwareag.com/t/how-do-i-seperate-a-doc-into-multiple-files/110259/7 "2021-04-02T15:06:05Z")

</div>


