Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

creating a flat file in the IDOC format

Former Member
0 Kudos

Hi everybody,

Need help.....urgently. Can somebody please tell me how to create a flat file in the IDOC format? I am creating a bill of lading/Documentary payments (EDI 858) and can't figure out a way to write the data generate through the report in a flat file in IDOC format. My deadline is right around the corner and I need help.

Thanks,

M

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Minal,

You need to do following -

1. first create a variable for structure EDIDC which will hold the control record information, if you are putting multiple IDOC's then this can be an internal table.

2. Create an internal table for EDIDD, which will hold the segment data.

4. Open a file in text mode.

5. Then for each IDOC first fill the EDIDC variable and write to the file.

6. For each IDOC fill the EDIDDD internal table as follows -

i) For each segment create a variable and fill the variable (structure) with relevant data.

ii)For each segment fill EDIDD work area and put that into SDATA field of EDIDD.

7. Write all records of internal table to the file.

8. Repeat 5-7 if there are more IDOC's to be written.

9. Close the file.

Hope this helps.

Regards,

Sanjeev

15 REPLIES 15

Former Member
0 Kudos

Hi Minal,

I don't fully understand your question, but to create a flat file idoc, then you can use a FILE port.

Just setup the idoc processing as per normal, but create a port of type file, and attach that to your partner.

Cheers,

Brad

0 Kudos

Hey Brad,

Thanks for the reply. Well, the situation is this. I have to create a flat file document which will be uploaded manually to a website. Now this flat file is the shipment information (EDI 858), the bill of lading. The file has to be written in the idoc format which is name1233rgddsg....and so on. There is no linking of this program to anything but internal tables. So I am basically writing a report to pull out the data for each vendor for each day and write it to a flat file on the application as well as presentation server. Now, do you think my understanding of the requirement is correct, that I have to generate a report in which the output has to be written to a file (in this case a flat file) which is in the same way as an IDOC is written. Depending on this requirement, can you please suggest what I should do more explicitly?

0 Kudos

Hi guys,

Thanks all for helping me. It was a big help. The requirements given to me by the company were misleading.

I cleared all the doubts with them and then did the work.

Regards,

Minal

0 Kudos

Hi Minal,

No problems. Please remember to acknowledge those answers that helped you by awarding them points.

This can be done by clicking on the the little stars next to each response in the thread.

Cheers,

Brad

0 Kudos

Hey Brad,

Another question....I have to write the table that I created which does not have the structure of an internal table to the flat file. How do I do that? I have to do this soon. Please help me. I am kind of new to ABAP programming. So am having a lot of problems. My table is defined as:

data: begin of tablename occurs 100,

--

-

endof tablename.

Please help me with this.

In general, anybody who knows anything about this, apart from brad, please help me asap.

And I did assign points to the answers.

Thanks,

Minal

Former Member
0 Kudos

Hi Minal,

You need to do following -

1. first create a variable for structure EDIDC which will hold the control record information, if you are putting multiple IDOC's then this can be an internal table.

2. Create an internal table for EDIDD, which will hold the segment data.

4. Open a file in text mode.

5. Then for each IDOC first fill the EDIDC variable and write to the file.

6. For each IDOC fill the EDIDDD internal table as follows -

i) For each segment create a variable and fill the variable (structure) with relevant data.

ii)For each segment fill EDIDD work area and put that into SDATA field of EDIDD.

7. Write all records of internal table to the file.

8. Repeat 5-7 if there are more IDOC's to be written.

9. Close the file.

Hope this helps.

Regards,

Sanjeev

0 Kudos

Hey Sanjeev,

Thanks for the reply. Well, the situation is this. I have to create a flat file document which will be uploaded manually to a website. Now this flat file is the shipment information (EDI 858), the bill of lading. The file has to be written in the idoc format which is name1233rgddsg....and so on. There is no linking of this program to anything but internal tables. So I am basically writing a report to pull out the data for each vendor for each day and write it to a flat file on the application as well as presentation server. Now, do you think my understanding of the requirement is correct, that I have to generate a report in which the output has to be written to a file (in this case a flat file) which is in the same way as an IDOC is written. Depending on this requirement, can you please suggest what I should do more explicitly?

I don't think I have to perform the steps that you have suggested but I am not sure. The flat file will be given to somebody to be uploaded by them on to another website and this process is not automated.

Thanks,

Minal

Thanks for your help,

Minal

0 Kudos

Hi Minal,

I still don't understand your question.

So, you have a report which selects data and puts it into an internal table. This part looks fine.

You want to create a flat file? Ok, to create a flat file on the application server then use the commands OPEN DATASET, TRANSFER, and CLOSE DATASET. To create a flat file on the presentation server then use the FM GUI_DOWNLOAD (or the GUI class, I forgets its name for the moment).

In both cases you should build up an internal table which has the exact structure required for your (EDIFACT?) EDI message, and then use the appropriate method to write the file.

If the following steps are manual then there is nothing more for you to do.

I don't see any need to use Idoc technology, or make any reference to it in your solution.

I hope that helps. If not, please be more specific when asking your questions.

Brad

0 Kudos

Hey Brad,

Thanks for your reply...I really appreciate your help.

See the problem I am facing is that I cannot makeout how to write data in my flat file in the IDOC format...by this I mean that after my data is getting stored in the internal table that I am creating through the report, this data has to be written to a flat file. The format in which the data needs to be written has to be the same as that which is of an IDOC i.e. seperated by *. Now I cannot make out if I have to write XML to convert the content of the flat file that will be generated by my program into IDOC form??? or when I write my output to the flat file, at that time only in my write statement I will have to give the field names seperated by asterix like this:

Write: / b_of_l-kunnr,'',b_of_l-vbeln,''.....and so on.

Please let me know.

Thanks & regards,

Minal

0 Kudos

Hi Minal,

you should probably describe in more detail what you're trying to accomplish. From your last posting it does not sound as if you're looking for the format IDocs are stored in flat files.

The IDocs written by SAP to a flat file use a fixed length structure format (i.e. no field separators, each field can be identified by offset and length). So it looks like your requirement actually deviates from that format, as you mention asterisks ('*') to separate fields.

Best wishes, harald

0 Kudos

Hey Harald,

Thanks for your help....

The requirement is to create a bill of lading or what you call as documentary payments. Now the output i.e. the file that is to be generated is a flat file which has to be written to the application server and the presentation from where it will be given to another person to upload this file on a website manually every day. There is a EDI 858 (shipment Information document) which has a specific format, the one that I mentioned above. I have to write the data in the flat file in the same format. Can you please help me with this.

I would appreciate your help very much.

Thanks,

Minal

0 Kudos

Hi Minal,

IDOCs are SAP specific but EDI messages are industry standards. To convert one into another you need the help of a EDI subsystem like Gentran. In the absence of such a translator, you have to insert all the translation logic in your program and it is not an easy task.

If you are asking about how to write out the IDOC data itself, then all you need is your internal table(in the format of EDIDD). Loop through it and write it out to the file. But I think what you are looking for is to convert the IDOC into an EDI message and then write it out to the file. If it is converting it into an EDI message, then I am afraid it is almost impossible without the help of an EDI subsystem.

Hope this helps,

Srinivas

0 Kudos

Hi Minal,

I think you need to clarify your requirement first. Do you want to write a file in IDOC format or EDI format. IDOC formats comply with EDI standards EDIFACT and ANSI X12, which only means that IDOC's can be mapped to their corresponding EDI message (as mentioned by Srinivas). I doubt if you even know which IDOC in SAP correspond to 858 message.

Regards,

Sanjeev

0 Kudos

Hi Minal,

I still have difficulties understanding your question/problem: Are you facing functional or technical difficulties. In the first case I don't think you will be able to get much help from the forum as those issues are likely to be specific to your project.

If there are technical issues you are facing, then we are probably able to help, if you point us in the right direction.

Best wishes, harald

0 Kudos

Hi Minal

I've just given a short look on the discussion. But why do not use an XML port to convert the IDoc to an XML file stored at the application server. You can then read it and store at some frontend or send it directly. I guess this may be more appropriate for your partner to parse for the web use.

Regards

*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>