<?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: Internal table vaules in application server in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-vaules-in-application-server/m-p/3656975#M880907</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;the code sample is&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basic Form of the OPEN DATASET Statement &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To open a file on the application server, use the OPEN statement as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET &amp;lt;dsn&amp;gt; Additions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This statement opens the file &amp;lt;dsn&amp;gt;. If you do not specify any additions for the mode, the file is opened in binary mode for reading. SY-SUBRC returns 0 if the system opens the file. Otherwise, SY-SUBRC is set to 8.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You enter the filename &amp;lt;dsn&amp;gt; either as a literal or as a field containing the actual name of the file. If you do not specify a path, the system opens the file in the directory in which the R/3 System is running on the application server. To open a file, the user under which the R/3 System is running must have the requisite authorizations at operating system level. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Filenames are platform-specific. You must therefore use file- and pathnames that conform to the rules of the operating system under which your R/3 System is running. However, you can also use logical filenames to ensure that your programs are not operating system-specific. For further information, refer to Using Platform-Independent Filenames.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA FNAME(60).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FNAME = '/tmp/myfile'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET 'myfile'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This example works as long as your R/3 System is running under UNIX. The program opens the file "myfile" in the directory in which the R/3 System is running, and also opens the file "myfile" in directory "/tmp". However, you would have to change the filename for other operating systems. For example, for OpenVMS, you could write the following: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FNAME = 'TMPmyfile.BIN'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET 'myfile.BIN'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Opening a File for Write Access &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To open a file for writing, use the FOR OUTPUT addition to the OPEN DATASET statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET &amp;lt;dsn&amp;gt; FOR OUTPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the file does not already exist, it is created automatically. If it does already exist, but is closed, its contents are overwritten. If the file exists and is already open (for read or write access, or for appending), the position is reset to the beginning of the file. If the system can open the file &amp;lt;dsn&amp;gt; successfully, SY-SUBRC is set to 0. If not, it is set to 8.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: MESS(60),&lt;/P&gt;&lt;P&gt;FNAME(10) VALUE '/tmp'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR OUTPUT MESSAGE MESS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF SY-SUBRC 0.&lt;/P&gt;&lt;P&gt;WRITE: 'SY-SUBRC:', SY-SUBRC,&lt;/P&gt;&lt;P&gt;/ 'System Message:', MESS.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the R/3 System is ruining under UNIX, the output looks like this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The system cannot open the file, since the name you specified is that of a directory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following program shows how the system sets the position when you open a file for writing. However, it is better programming style to close files that are already open before you reopen them for a different operation (for further information about closing files, refer to Closing a File).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA FNAME(60) VALUE 'myfile'.&lt;/P&gt;&lt;P&gt;DATA NUM TYPE I.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR OUTPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO 10 TIMES.&lt;/P&gt;&lt;P&gt;NUM = NUM + 1.&lt;/P&gt;&lt;P&gt;TRANSFER NUM TO FNAME.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM INPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR OUTPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NUM = 0.&lt;/P&gt;&lt;P&gt;DO 5 TIMES.&lt;/P&gt;&lt;P&gt;NUM = NUM + 10.&lt;/P&gt;&lt;P&gt;TRANSFER NUM TO FNAME.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM INPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLOSE DATASET FNAME.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR OUTPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NUM = 0.&lt;/P&gt;&lt;P&gt;DO 5 TIMES.&lt;/P&gt;&lt;P&gt;NUM = NUM + 20.&lt;/P&gt;&lt;P&gt;TRANSFER NUM TO FNAME.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM INPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM INPUT.&lt;/P&gt;&lt;P&gt;SKIP.&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR INPUT.&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;READ DATASET FNAME INTO NUM.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC 0.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WRITE / NUM.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output appears as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;7&lt;/P&gt;&lt;P&gt;8&lt;/P&gt;&lt;P&gt;9&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;20&lt;/P&gt;&lt;P&gt;30&lt;/P&gt;&lt;P&gt;40&lt;/P&gt;&lt;P&gt;50&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;7&lt;/P&gt;&lt;P&gt;8&lt;/P&gt;&lt;P&gt;9&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;20&lt;/P&gt;&lt;P&gt;40&lt;/P&gt;&lt;P&gt;60&lt;/P&gt;&lt;P&gt;80&lt;/P&gt;&lt;P&gt;100&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This example performs the following steps using the file "myfile":&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is opened for writing &lt;/P&gt;&lt;P&gt;It is filled with 10 integers (for information about the TRANSFER statement, refer to Writing Data to Files) &lt;/P&gt;&lt;P&gt;It is then opened for reading. The position is reset accordingly to the beginning of the file. &lt;/P&gt;&lt;P&gt;It is read into the field NUM. For information about the READ DATASET statement, refer to Reading Data from Files. The values of NUM are displayed on the screen. &lt;/P&gt;&lt;P&gt;It is reopened for writing The position is reset to the beginning of the file. &lt;/P&gt;&lt;P&gt;It is filled with five integers, which overwrite the previous contents of the file. &lt;/P&gt;&lt;P&gt;It is then reopened for reading. The position is reset to the beginning of the file. &lt;/P&gt;&lt;P&gt;The file is read into the field NUM. The values of NUM are displayed on the screen. &lt;/P&gt;&lt;P&gt;It is closed (for information about the CLOSE DATASET statement, refer to Closing a File). &lt;/P&gt;&lt;P&gt;It is then reopened for writing. The system deletes the existing contents of the file. &lt;/P&gt;&lt;P&gt;It is filled with 5 integers. &lt;/P&gt;&lt;P&gt;It is then opened for reading. The position is reset to the beginning of the file. &lt;/P&gt;&lt;P&gt;The file is read into the field NUM. The values of NUM are displayed on the screen. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Closing a File &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To close a file on the application server, use the close statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLOSE DATASET &amp;lt;dsn&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This statement closes the file &amp;lt;dsn&amp;gt;. The naming convention is described in the section Opening a File.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You only need to close a file if you want to delete its contents the next time you open it for write access. For further information and an example, refer to Opening a File for Write Access.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, to avoid errors, and to make your programs easier to read, you should always close a file before the next OPEN DATASET statement. The CLOSE statement divides your program into logical blocks, and makes them easier to maintain. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA FNAME(60) VALUE 'myfile'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR OUTPUT.&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;CLOSE FNAME.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR INPUT.&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;CLOSE FNAME.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR INPUT AT POSITION &amp;lt;pos&amp;gt;.&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;CLOSE FNAME.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The CLOSE statement is not obligatory in this example, but it does improve the layout of the program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;have alook at this code also&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hi check this example..,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;----&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;*&amp;amp; Report ZTESTPROGRAMFORDOWNLOAD&lt;/P&gt;&lt;P&gt;*&amp;amp;&lt;/P&gt;&lt;P&gt;&amp;amp;----&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;*&amp;amp;&lt;/P&gt;&lt;P&gt;*&amp;amp;&lt;/P&gt;&lt;P&gt;&amp;amp;----&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;report ztestprogramfordownload.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables:zupload.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:it_pa0002(200).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of ty_pa0002 ,&lt;/P&gt;&lt;P&gt;pernr like pa0002-pernr,&lt;/P&gt;&lt;P&gt;begda like pa0002-begda,&lt;/P&gt;&lt;P&gt;endda like pa0002-endda,&lt;/P&gt;&lt;P&gt;vorna like pa0002-vorna,&lt;/P&gt;&lt;P&gt;nachn like pa0002-nachn,&lt;/P&gt;&lt;P&gt;end of ty_pa0002.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:begin of it_error occurs 0 ,&lt;/P&gt;&lt;P&gt;pernr like pa0000-pernr,&lt;/P&gt;&lt;P&gt;end of it_error .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:it_final type standard table of ty_pa0002 with header line.&lt;/P&gt;&lt;P&gt;data:it_temp type standard table of ty_pa0002 with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;parameters:p_file like rlgrap-filename default 'F:\usr\sap\EC6\DVEBMGS00\work\entiraledu1'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;open dataset p_file for input in text mode encoding default.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read dataset p_file into it_pa0002.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it_final-pernr = it_pa0002+0(8).&lt;/P&gt;&lt;P&gt;it_final-begda = it_pa0002+18(8).&lt;/P&gt;&lt;P&gt;it_final-endda = it_pa0002+36(8).&lt;/P&gt;&lt;P&gt;it_final-vorna = it_pa0002+54(40).&lt;/P&gt;&lt;P&gt;it_final-nachn = it_pa0002+104(40).&lt;/P&gt;&lt;P&gt;append it_final.&lt;/P&gt;&lt;P&gt;clear it_final.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;exit.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not it_final[] is initial.&lt;/P&gt;&lt;P&gt;sort it_final by pernr begda descending.&lt;/P&gt;&lt;P&gt;delete adjacent duplicates from it_final comparing pernr .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select pernr&lt;/P&gt;&lt;P&gt;begda&lt;/P&gt;&lt;P&gt;endda&lt;/P&gt;&lt;P&gt;vorna&lt;/P&gt;&lt;P&gt;nachn&lt;/P&gt;&lt;P&gt;from pa0002&lt;/P&gt;&lt;P&gt;into table it_temp&lt;/P&gt;&lt;P&gt;for all entries in it_final&lt;/P&gt;&lt;P&gt;where pernr = it_final-pernr.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_temp.&lt;/P&gt;&lt;P&gt;zupload-pernr = it_temp-pernr.&lt;/P&gt;&lt;P&gt;zupload-begda = it_temp-begda.&lt;/P&gt;&lt;P&gt;zupload-endda = it_temp-endda.&lt;/P&gt;&lt;P&gt;zupload-vorna = it_temp-vorna.&lt;/P&gt;&lt;P&gt;zupload-nachn = it_temp-nachn.&lt;/P&gt;&lt;P&gt;insert zupload.&lt;/P&gt;&lt;P&gt;clear it_temp.&lt;/P&gt;&lt;P&gt;clear zupload.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;close dataset p_file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Do reward if helpful&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Apr 2008 09:17:53 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-03T09:17:53Z</dc:date>
    <item>
      <title>Internal table vaules in application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-vaules-in-application-server/m-p/3656971#M880903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to download my internal table values in application server,&lt;/P&gt;&lt;P&gt;Please give me some idea how i can do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rajneesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 09:09:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-vaules-in-application-server/m-p/3656971#M880903</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T09:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table vaules in application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-vaules-in-application-server/m-p/3656972#M880904</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;Use the FM - GUI_DOWNLOAD&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just see this sample code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;----&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;*&amp;amp; Report ZSD_EXCEL_INT_APP&lt;/P&gt;&lt;P&gt;*&amp;amp;&lt;/P&gt;&lt;P&gt;&amp;amp;----&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;*&amp;amp;&lt;/P&gt;&lt;P&gt;*&amp;amp;&lt;/P&gt;&lt;P&gt;&amp;amp;----&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;REPORT ZSD_EXCEL_INT_APP.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;parameter: file_nm type localfile.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;types : begin of it_tab1,&lt;/P&gt;&lt;P&gt;f1(20),&lt;/P&gt;&lt;P&gt;f2(40),&lt;/P&gt;&lt;P&gt;f3(20),&lt;/P&gt;&lt;P&gt;end of it_tab1.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;data : it_tab type table of ALSMEX_TABLINE with header line,&lt;/P&gt;&lt;P&gt;file type rlgrap-filename.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;data : it_tab2 type it_tab1 occurs 1,&lt;/P&gt;&lt;P&gt;wa_tab2 type it_tab1,&lt;/P&gt;&lt;P&gt;w_message(100) TYPE c.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;at selection-screen on value-request for file_nm.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;CALL FUNCTION 'KD_GET_FILENAME_ON_F4'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;PROGRAM_NAME = SYST-REPID &lt;/P&gt;&lt;P&gt;DYNPRO_NUMBER = SYST-DYNNR &lt;/P&gt;&lt;P&gt;FIELD_NAME = ' ' &lt;/P&gt;&lt;P&gt;STATIC = 'X'&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;MASK = ' ' &lt;/P&gt;&lt;P&gt;CHANGING&lt;/P&gt;&lt;P&gt;file_name = file_nm&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;MASK_TOO_LONG = 1&lt;/P&gt;&lt;P&gt;OTHERS = 2&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;IF sy-subrc 0.&lt;/P&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;P&gt;WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;refresh it_tab2[].clear wa_tab2.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;file = file_nm.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;filename = file&lt;/P&gt;&lt;P&gt;i_begin_col = '1'&lt;/P&gt;&lt;P&gt;i_begin_row = '1'&lt;/P&gt;&lt;P&gt;i_end_col = '10'&lt;/P&gt;&lt;P&gt;i_end_row = '35'&lt;/P&gt;&lt;P&gt;tables&lt;/P&gt;&lt;P&gt;intern = it_tab&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;INCONSISTENT_PARAMETERS = 1&lt;/P&gt;&lt;P&gt;UPLOAD_OLE = 2&lt;/P&gt;&lt;P&gt;OTHERS = 3&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;IF sy-subrc 0.&lt;/P&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;P&gt;WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;loop at it_tab.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;case it_tab-col.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;when '002'.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;wa_tab2-f1 = it_tab-value.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;when '004'.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;wa_tab2-f2 = it_tab-value.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;when '008'.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;wa_tab2-f3 = it_tab-value.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;endcase.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;at end of row.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;append wa_tab2 to it_tab2.&lt;/P&gt;&lt;P&gt;clear wa_tab2.&lt;/P&gt;&lt;P&gt;endat.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;data : p_file TYPE rlgrap-filename value 'TEST3.txt'.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Display error messages if any. &lt;/P&gt;&lt;P&gt;IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;MESSAGE e001(zsd_mes).&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;*---Data is downloaded to the application server file path&lt;/P&gt;&lt;P&gt;LOOP AT it_tab2 INTO wa_tab2.&lt;/P&gt;&lt;P&gt;TRANSFER wa_tab2 TO p_file.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;*--Close the Application server file (Mandatory).&lt;/P&gt;&lt;P&gt;CLOSE DATASET p_file.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;loop at it_tab2 into wa_tab2.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also refer this link :&lt;/P&gt;&lt;P&gt;Check this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.sdn.sap.com/search.jspa?threadID=&amp;amp;q=open+dataset&amp;amp;objID=f50&amp;amp;dateRange=last90days&amp;amp;numResults=15" target="test_blank"&gt;https://forums.sdn.sap.com/search.jspa?threadID=&amp;amp;q=open+dataset&amp;amp;objID=f50&amp;amp;dateRange=last90days&amp;amp;numResults=15&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Reward Points if found helpfull..&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Cheers,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Chandra Sekhar.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 09:13:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-vaules-in-application-server/m-p/3656972#M880904</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T09:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table vaules in application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-vaules-in-application-server/m-p/3656973#M880905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can do that using OPEN DATASET , TRANSFER , CLOSE DATASET.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using open dataset you create the file or open the file for editing or reading.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Transfer will write the contents to application server file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Close Dataset will close the file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read the Help on OpenDatset .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 09:15:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-vaules-in-application-server/m-p/3656973#M880905</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T09:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table vaules in application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-vaules-in-application-server/m-p/3656974#M880906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you want to create a file on server containing your internal table?&lt;/P&gt;&lt;P&gt;In this case you must use the command  'open dataset ' .&lt;/P&gt;&lt;P&gt;See the documentation of command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3c99358411d1829f0000e829fbfe/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3c99358411d1829f0000e829fbfe/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 09:16:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-vaules-in-application-server/m-p/3656974#M880906</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T09:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table vaules in application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-vaules-in-application-server/m-p/3656975#M880907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;the code sample is&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basic Form of the OPEN DATASET Statement &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To open a file on the application server, use the OPEN statement as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET &amp;lt;dsn&amp;gt; Additions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This statement opens the file &amp;lt;dsn&amp;gt;. If you do not specify any additions for the mode, the file is opened in binary mode for reading. SY-SUBRC returns 0 if the system opens the file. Otherwise, SY-SUBRC is set to 8.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You enter the filename &amp;lt;dsn&amp;gt; either as a literal or as a field containing the actual name of the file. If you do not specify a path, the system opens the file in the directory in which the R/3 System is running on the application server. To open a file, the user under which the R/3 System is running must have the requisite authorizations at operating system level. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Filenames are platform-specific. You must therefore use file- and pathnames that conform to the rules of the operating system under which your R/3 System is running. However, you can also use logical filenames to ensure that your programs are not operating system-specific. For further information, refer to Using Platform-Independent Filenames.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA FNAME(60).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FNAME = '/tmp/myfile'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET 'myfile'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This example works as long as your R/3 System is running under UNIX. The program opens the file "myfile" in the directory in which the R/3 System is running, and also opens the file "myfile" in directory "/tmp". However, you would have to change the filename for other operating systems. For example, for OpenVMS, you could write the following: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FNAME = 'TMPmyfile.BIN'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET 'myfile.BIN'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Opening a File for Write Access &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To open a file for writing, use the FOR OUTPUT addition to the OPEN DATASET statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET &amp;lt;dsn&amp;gt; FOR OUTPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the file does not already exist, it is created automatically. If it does already exist, but is closed, its contents are overwritten. If the file exists and is already open (for read or write access, or for appending), the position is reset to the beginning of the file. If the system can open the file &amp;lt;dsn&amp;gt; successfully, SY-SUBRC is set to 0. If not, it is set to 8.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: MESS(60),&lt;/P&gt;&lt;P&gt;FNAME(10) VALUE '/tmp'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR OUTPUT MESSAGE MESS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF SY-SUBRC 0.&lt;/P&gt;&lt;P&gt;WRITE: 'SY-SUBRC:', SY-SUBRC,&lt;/P&gt;&lt;P&gt;/ 'System Message:', MESS.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the R/3 System is ruining under UNIX, the output looks like this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The system cannot open the file, since the name you specified is that of a directory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following program shows how the system sets the position when you open a file for writing. However, it is better programming style to close files that are already open before you reopen them for a different operation (for further information about closing files, refer to Closing a File).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA FNAME(60) VALUE 'myfile'.&lt;/P&gt;&lt;P&gt;DATA NUM TYPE I.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR OUTPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO 10 TIMES.&lt;/P&gt;&lt;P&gt;NUM = NUM + 1.&lt;/P&gt;&lt;P&gt;TRANSFER NUM TO FNAME.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM INPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR OUTPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NUM = 0.&lt;/P&gt;&lt;P&gt;DO 5 TIMES.&lt;/P&gt;&lt;P&gt;NUM = NUM + 10.&lt;/P&gt;&lt;P&gt;TRANSFER NUM TO FNAME.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM INPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLOSE DATASET FNAME.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR OUTPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NUM = 0.&lt;/P&gt;&lt;P&gt;DO 5 TIMES.&lt;/P&gt;&lt;P&gt;NUM = NUM + 20.&lt;/P&gt;&lt;P&gt;TRANSFER NUM TO FNAME.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM INPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM INPUT.&lt;/P&gt;&lt;P&gt;SKIP.&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR INPUT.&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;READ DATASET FNAME INTO NUM.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC 0.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WRITE / NUM.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output appears as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;7&lt;/P&gt;&lt;P&gt;8&lt;/P&gt;&lt;P&gt;9&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;20&lt;/P&gt;&lt;P&gt;30&lt;/P&gt;&lt;P&gt;40&lt;/P&gt;&lt;P&gt;50&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;7&lt;/P&gt;&lt;P&gt;8&lt;/P&gt;&lt;P&gt;9&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;20&lt;/P&gt;&lt;P&gt;40&lt;/P&gt;&lt;P&gt;60&lt;/P&gt;&lt;P&gt;80&lt;/P&gt;&lt;P&gt;100&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This example performs the following steps using the file "myfile":&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is opened for writing &lt;/P&gt;&lt;P&gt;It is filled with 10 integers (for information about the TRANSFER statement, refer to Writing Data to Files) &lt;/P&gt;&lt;P&gt;It is then opened for reading. The position is reset accordingly to the beginning of the file. &lt;/P&gt;&lt;P&gt;It is read into the field NUM. For information about the READ DATASET statement, refer to Reading Data from Files. The values of NUM are displayed on the screen. &lt;/P&gt;&lt;P&gt;It is reopened for writing The position is reset to the beginning of the file. &lt;/P&gt;&lt;P&gt;It is filled with five integers, which overwrite the previous contents of the file. &lt;/P&gt;&lt;P&gt;It is then reopened for reading. The position is reset to the beginning of the file. &lt;/P&gt;&lt;P&gt;The file is read into the field NUM. The values of NUM are displayed on the screen. &lt;/P&gt;&lt;P&gt;It is closed (for information about the CLOSE DATASET statement, refer to Closing a File). &lt;/P&gt;&lt;P&gt;It is then reopened for writing. The system deletes the existing contents of the file. &lt;/P&gt;&lt;P&gt;It is filled with 5 integers. &lt;/P&gt;&lt;P&gt;It is then opened for reading. The position is reset to the beginning of the file. &lt;/P&gt;&lt;P&gt;The file is read into the field NUM. The values of NUM are displayed on the screen. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Closing a File &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To close a file on the application server, use the close statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLOSE DATASET &amp;lt;dsn&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This statement closes the file &amp;lt;dsn&amp;gt;. The naming convention is described in the section Opening a File.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You only need to close a file if you want to delete its contents the next time you open it for write access. For further information and an example, refer to Opening a File for Write Access.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, to avoid errors, and to make your programs easier to read, you should always close a file before the next OPEN DATASET statement. The CLOSE statement divides your program into logical blocks, and makes them easier to maintain. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA FNAME(60) VALUE 'myfile'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR OUTPUT.&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;CLOSE FNAME.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR INPUT.&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;CLOSE FNAME.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR INPUT AT POSITION &amp;lt;pos&amp;gt;.&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;CLOSE FNAME.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The CLOSE statement is not obligatory in this example, but it does improve the layout of the program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;have alook at this code also&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hi check this example..,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;----&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;*&amp;amp; Report ZTESTPROGRAMFORDOWNLOAD&lt;/P&gt;&lt;P&gt;*&amp;amp;&lt;/P&gt;&lt;P&gt;&amp;amp;----&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;*&amp;amp;&lt;/P&gt;&lt;P&gt;*&amp;amp;&lt;/P&gt;&lt;P&gt;&amp;amp;----&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;report ztestprogramfordownload.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables:zupload.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:it_pa0002(200).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of ty_pa0002 ,&lt;/P&gt;&lt;P&gt;pernr like pa0002-pernr,&lt;/P&gt;&lt;P&gt;begda like pa0002-begda,&lt;/P&gt;&lt;P&gt;endda like pa0002-endda,&lt;/P&gt;&lt;P&gt;vorna like pa0002-vorna,&lt;/P&gt;&lt;P&gt;nachn like pa0002-nachn,&lt;/P&gt;&lt;P&gt;end of ty_pa0002.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:begin of it_error occurs 0 ,&lt;/P&gt;&lt;P&gt;pernr like pa0000-pernr,&lt;/P&gt;&lt;P&gt;end of it_error .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:it_final type standard table of ty_pa0002 with header line.&lt;/P&gt;&lt;P&gt;data:it_temp type standard table of ty_pa0002 with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;parameters:p_file like rlgrap-filename default 'F:\usr\sap\EC6\DVEBMGS00\work\entiraledu1'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;open dataset p_file for input in text mode encoding default.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read dataset p_file into it_pa0002.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it_final-pernr = it_pa0002+0(8).&lt;/P&gt;&lt;P&gt;it_final-begda = it_pa0002+18(8).&lt;/P&gt;&lt;P&gt;it_final-endda = it_pa0002+36(8).&lt;/P&gt;&lt;P&gt;it_final-vorna = it_pa0002+54(40).&lt;/P&gt;&lt;P&gt;it_final-nachn = it_pa0002+104(40).&lt;/P&gt;&lt;P&gt;append it_final.&lt;/P&gt;&lt;P&gt;clear it_final.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;exit.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not it_final[] is initial.&lt;/P&gt;&lt;P&gt;sort it_final by pernr begda descending.&lt;/P&gt;&lt;P&gt;delete adjacent duplicates from it_final comparing pernr .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select pernr&lt;/P&gt;&lt;P&gt;begda&lt;/P&gt;&lt;P&gt;endda&lt;/P&gt;&lt;P&gt;vorna&lt;/P&gt;&lt;P&gt;nachn&lt;/P&gt;&lt;P&gt;from pa0002&lt;/P&gt;&lt;P&gt;into table it_temp&lt;/P&gt;&lt;P&gt;for all entries in it_final&lt;/P&gt;&lt;P&gt;where pernr = it_final-pernr.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_temp.&lt;/P&gt;&lt;P&gt;zupload-pernr = it_temp-pernr.&lt;/P&gt;&lt;P&gt;zupload-begda = it_temp-begda.&lt;/P&gt;&lt;P&gt;zupload-endda = it_temp-endda.&lt;/P&gt;&lt;P&gt;zupload-vorna = it_temp-vorna.&lt;/P&gt;&lt;P&gt;zupload-nachn = it_temp-nachn.&lt;/P&gt;&lt;P&gt;insert zupload.&lt;/P&gt;&lt;P&gt;clear it_temp.&lt;/P&gt;&lt;P&gt;clear zupload.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;close dataset p_file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Do reward if helpful&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 09:17:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-vaules-in-application-server/m-p/3656975#M880907</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T09:17:53Z</dc:date>
    </item>
  </channel>
</rss>

