<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: read file in a different structure in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-in-a-different-structure/m-p/5480057#M1254606</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U can use different structure as workarea for reading file, anyway you know which kind file you're reading in order to know which structure has to be used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Usually there's a symbol or a sign at the beginning of the file in order to define the kind of file&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* Open file:
OPEN DATASET &amp;lt;FILE&amp;gt; ..........
IF SY-SUBRC = 0.
* Check first record
READ DATASET &amp;lt;FILE&amp;gt; INTO F.
* Suppose the first four characters indicate the kind of file
IF F(4) = 'HEAD'.
   FL_KIND = 'H'. "&amp;lt;-------Header
ELSE.
   FL_KIND = 'I'.  "&amp;lt;--------Item
ENDIF. 
IF FL_KIND = 'H'.
  H = F.
ELSE.
  I = F.
ENDIF.
* Read the next record
DO.
  READ DATASET &amp;lt;FILE&amp;gt; INTO F.
  IF FL_KIND = 'H'.
    H = F.
  ELSE.
    I = F.
  ENDIF.
ENDDO.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is only a sample we should know how your files are and when u read them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Apr 2009 15:28:12 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-04-15T15:28:12Z</dc:date>
    <item>
      <title>read file in a different structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-in-a-different-structure/m-p/5480055#M1254604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have two different files, which I want to read in a structure one after another. Later I have to distinguish which entry is from which file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First I thought I can use function READ DATASET dsn INTO f for that purpose. But it seems that you have to use the same structures in this case, but then I have no differentiating factor within my structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think there must be an easy way to do what. Unfortanately, I have not found something so far.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone has an idea? Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tobias&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Apr 2009 15:15:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-in-a-different-structure/m-p/5480055#M1254604</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-15T15:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: read file in a different structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-in-a-different-structure/m-p/5480056#M1254605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Tobias, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you have to differentiate later you entries anyway, why cant you use 2 different structures at first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read datased 1 into f1&lt;/P&gt;&lt;P&gt;read dataset 2 into f2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and now you can move them to internal tables or structures with some differentiating flag.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MaryM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Apr 2009 15:27:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-in-a-different-structure/m-p/5480056#M1254605</guid>
      <dc:creator>MaryM</dc:creator>
      <dc:date>2009-04-15T15:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: read file in a different structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-in-a-different-structure/m-p/5480057#M1254606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U can use different structure as workarea for reading file, anyway you know which kind file you're reading in order to know which structure has to be used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Usually there's a symbol or a sign at the beginning of the file in order to define the kind of file&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* Open file:
OPEN DATASET &amp;lt;FILE&amp;gt; ..........
IF SY-SUBRC = 0.
* Check first record
READ DATASET &amp;lt;FILE&amp;gt; INTO F.
* Suppose the first four characters indicate the kind of file
IF F(4) = 'HEAD'.
   FL_KIND = 'H'. "&amp;lt;-------Header
ELSE.
   FL_KIND = 'I'.  "&amp;lt;--------Item
ENDIF. 
IF FL_KIND = 'H'.
  H = F.
ELSE.
  I = F.
ENDIF.
* Read the next record
DO.
  READ DATASET &amp;lt;FILE&amp;gt; INTO F.
  IF FL_KIND = 'H'.
    H = F.
  ELSE.
    I = F.
  ENDIF.
ENDDO.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is only a sample we should know how your files are and when u read them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Apr 2009 15:28:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-in-a-different-structure/m-p/5480057#M1254606</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-15T15:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: read file in a different structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-in-a-different-structure/m-p/5480058#M1254607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, MaryM`s idea was simple and good. Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But anyway I am interested if it would be possible to read in two files, which have the following structure&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATE&lt;/P&gt;&lt;P&gt;ISO_CODE&lt;/P&gt;&lt;P&gt;RATE&lt;/P&gt;&lt;P&gt;NOTATION&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;into a structure (internal table):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF ITAB OCCURS 1000, &lt;/P&gt;&lt;P&gt;      DAT          TYPE D,&lt;/P&gt;&lt;P&gt;      CUR          LIKE TCURR-FCURR,&lt;/P&gt;&lt;P&gt;      RATE(16)      TYPE C,&lt;/P&gt;&lt;P&gt;      NOT(1)  TYPE C&lt;/P&gt;&lt;P&gt;      FIL(1) TYPE C.&lt;/P&gt;&lt;P&gt;DATA: END OF ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with the following commands:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;READ DATASET DAT_IN1 INTO ITAB.&lt;/P&gt;&lt;P&gt;   move '1' to ITAB-FIL.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;READ DATASET DAT_IN2 INTO ITAB.&lt;/P&gt;&lt;P&gt;   MOVE '2' to ITAB-FIL.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tobias&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Tobias Meiler on Apr 17, 2009 1:58 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Apr 2009 11:58:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-in-a-different-structure/m-p/5480058#M1254607</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-17T11:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: read file in a different structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-in-a-different-structure/m-p/5480059#M1254608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;that should be totally possible. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: wa like line of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;READ DATASET DAT_IN1 INTO wa.&lt;/P&gt;&lt;P&gt;move '1' to wa-FIL.&lt;/P&gt;&lt;P&gt;append wa to itab.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;READ DATASET DAT_IN2 INTO ITAB.&lt;/P&gt;&lt;P&gt;MOVE '2' to wa-FIL.&lt;/P&gt;&lt;P&gt;append wa to itab.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let us know if it dosen't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, &lt;/P&gt;&lt;P&gt;MaryM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Apr 2009 12:06:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-in-a-different-structure/m-p/5480059#M1254608</guid>
      <dc:creator>MaryM</dc:creator>
      <dc:date>2009-04-17T12:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: read file in a different structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-in-a-different-structure/m-p/5480060#M1254609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A part of the question is answered but not overall. There is a point I am still interested in.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Apr 2009 12:09:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-in-a-different-structure/m-p/5480060#M1254609</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-17T12:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: read file in a different structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-in-a-different-structure/m-p/5480061#M1254610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;What i believe is that for the solution u can add one more column in the structure say the Differentiator, and pass some value into it depending upon the file from which it is getting&lt;/P&gt;&lt;P&gt;for eg:&lt;/P&gt;&lt;P&gt;u can pass F1 if it is being read from file one&lt;/P&gt;&lt;P&gt;and F2 if it is being read from file two.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can carry on with the calculation giving the conditions as &lt;/P&gt;&lt;P&gt;if Differentiator = F1&lt;/P&gt;&lt;P&gt;Do sme calculation&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;do the other calculation&lt;/P&gt;&lt;P&gt;Endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Richa Wahi on Apr 17, 2009 2:13 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Apr 2009 12:13:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-file-in-a-different-structure/m-p/5480061#M1254610</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-17T12:13:15Z</dc:date>
    </item>
  </channel>
</rss>

