<?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 FM needed in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/fm-needed/m-p/2384814#M529859</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there any FM which will open any type of file.&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Jun 2007 10:04:36 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-19T10:04:36Z</dc:date>
    <item>
      <title>FM needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fm-needed/m-p/2384814#M529859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there any FM which will open any type of file.&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2007 10:04:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fm-needed/m-p/2384814#M529859</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-19T10:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: FM needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fm-needed/m-p/2384815#M529860</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;&lt;/P&gt;&lt;P&gt;Opening a File for Read Access&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To open a file for reading, use the FOR INPUT 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 INPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The file must already exist, otherwise, the system sets SY-SUBRC to 8, and ignores the statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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. However, it is good 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;&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 INPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;WRITE / 'File opened'.&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;WRITE / 'File not found'.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This example opens the file "myfile" for reading.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------------------" /&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 &amp;lt;&amp;gt; 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;HR originaltext="----------------------------" /&gt;&lt;P&gt;To open a file so that you can append data to the end of it, use the FOR APPENDING addition in 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 APPENDING.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This statement opens a file to which you can append data. If the file does not already exist, it is created automatically. If it does exist, but is closed, the system opens it, and sets the position to the end of the file. If the file exists and is already open (for read or write access, or for appending), the position is set to the end of the file. SY-SUBRC is always 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is good 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;&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;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;DO 5 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;OPEN DATASET FNAME FOR INPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET FNAME FOR APPENDING.&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;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 &amp;lt;&amp;gt; 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;&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;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;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Ashu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2007 10:06:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fm-needed/m-p/2384815#M529860</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-19T10:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: FM needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fm-needed/m-p/2384816#M529861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;u can use GUI_Upload but i thnk it will read all the junk data for files other than txt,csv,xls,asc&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2007 10:09:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fm-needed/m-p/2384816#M529861</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-19T10:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: FM needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fm-needed/m-p/2384817#M529862</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;If you are try to open a file on presentation server , then try this simple code .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF ITAB OCCURS 3, &lt;/P&gt;&lt;P&gt;      LINE(50), &lt;/P&gt;&lt;P&gt;      END OF ITAB. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;PARAMETERS: PROG(70) DEFAULT &lt;/P&gt;&lt;P&gt;            'C:\Program Files\Microsoft Office\Office\WINWORD.EXE'. &lt;/P&gt;&lt;P&gt;PARAMETERS: FILE1(70) DEFAULT 'C:\TEMP\TEST.TXT'. &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Tick to print the Text file after saving from MS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;WORDS &lt;/P&gt;&lt;P&gt;PARAMETERS: S_UP  AS CHECKBOX. &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Tick to create new or overwrite Text file &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;PARAMETERS: S_NEW AS CHECKBOX. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;IF S_UP = 'X'. &lt;/P&gt;&lt;P&gt;   CALL FUNCTION 'GUI_UPLOAD' &lt;/P&gt;&lt;P&gt;        EXPORTING &lt;/P&gt;&lt;P&gt;             FILENAME        = 'FILE1' &lt;/P&gt;&lt;P&gt;        TABLES &lt;/P&gt;&lt;P&gt;             DATA_TAB        = ITAB &lt;/P&gt;&lt;P&gt;        EXCEPTIONS &lt;/P&gt;&lt;P&gt;             FILE_OPEN_ERROR = 1. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;   IF SY-SUBRC = 0. &lt;/P&gt;&lt;P&gt;     LOOP AT ITAB. &lt;/P&gt;&lt;P&gt;       WRITE: / ITAB. &lt;/P&gt;&lt;P&gt;     ENDLOOP. &lt;/P&gt;&lt;P&gt;   ELSE. &lt;/P&gt;&lt;P&gt;     WRITE: / 'File open error.'. &lt;/P&gt;&lt;P&gt;   ENDIF. &lt;/P&gt;&lt;P&gt;ELSE. &lt;/P&gt;&lt;P&gt;IF S_NEW = 'X'. &lt;/P&gt;&lt;P&gt;   CALL FUNCTION 'GUI_DOWNLOAD' &lt;/P&gt;&lt;P&gt;        EXPORTING &lt;/P&gt;&lt;P&gt;             FILENAME = 'FILE1' &lt;/P&gt;&lt;P&gt;        TABLES &lt;/P&gt;&lt;P&gt;             DATA_TAB = ITAB &lt;/P&gt;&lt;P&gt;        EXCEPTIONS &lt;/P&gt;&lt;P&gt;             FILE_WRITE_ERROR              = 1 &lt;/P&gt;&lt;P&gt;             NO_BATCH                      = 2 &lt;/P&gt;&lt;P&gt;             GUI_REFUSE_FILETRANSFER       = 3 &lt;/P&gt;&lt;P&gt;             INVALID_TYPE                  = 4 &lt;/P&gt;&lt;P&gt;             OTHERS                        = 5. &lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;CASE SY-SUBRC. &lt;/P&gt;&lt;P&gt;     WHEN 1. &lt;/P&gt;&lt;P&gt;          WRITE: / 'GUI DOWNLOAD FILE WRITE ERROR'. &lt;/P&gt;&lt;P&gt;     WHEN 2. &lt;/P&gt;&lt;P&gt;          WRITE: / 'GUI DOWNLOAD NO BATCH'. &lt;/P&gt;&lt;P&gt;     WHEN 3. &lt;/P&gt;&lt;P&gt;          WRITE: / 'GUI DOWNLOAD GUI REFUSE&lt;/P&gt;&lt;P&gt;FILETRANSFER'. &lt;/P&gt;&lt;P&gt;     WHEN 4. &lt;/P&gt;&lt;P&gt;          WRITE: / 'GUI DOWNLOAD INVALID TYPE'. &lt;/P&gt;&lt;P&gt;     WHEN 5. &lt;/P&gt;&lt;P&gt;          WRITE: / 'GUI DOWNLOAD OTHERS'. &lt;/P&gt;&lt;P&gt;ENDCASE. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;CALL FUNCTION 'WS_EXECUTE' &lt;/P&gt;&lt;P&gt;  EXPORTING &lt;/P&gt;&lt;P&gt;     PROGRAM       = PROG &lt;/P&gt;&lt;P&gt;     COMMANDLINE   = 'FILE1' &lt;/P&gt;&lt;P&gt;     INFORM        = ' ' &lt;/P&gt;&lt;P&gt;  EXCEPTIONS &lt;/P&gt;&lt;P&gt;     FRONTEND_ERROR           = 1 &lt;/P&gt;&lt;P&gt;     NO_BATCH                 = 2 &lt;/P&gt;&lt;P&gt;     PROG_NOT_FOUND           = 3 &lt;/P&gt;&lt;P&gt;     ILLEGAL_OPTION           = 4 &lt;/P&gt;&lt;P&gt;     GUI_REFUSE_EXECUTE       = 5 &lt;/P&gt;&lt;P&gt;     OTHERS                   = 6. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;CASE SY-SUBRC. &lt;/P&gt;&lt;P&gt;   WHEN 1. &lt;/P&gt;&lt;P&gt;     WRITE: / 'FRONTEND ERROR'. &lt;/P&gt;&lt;P&gt;   WHEN 2. &lt;/P&gt;&lt;P&gt;     WRITE: / 'NO BATCH'. &lt;/P&gt;&lt;P&gt;   WHEN 3. &lt;/P&gt;&lt;P&gt;     WRITE: / 'PROGRAM NOT FOUND'. &lt;/P&gt;&lt;P&gt;   WHEN 4. &lt;/P&gt;&lt;P&gt;     WRITE: / 'ILLEGA OPTION'. &lt;/P&gt;&lt;P&gt;   WHEN 5. &lt;/P&gt;&lt;P&gt;     WRITE: / 'GUI REFUSE EXECUTE'. &lt;/P&gt;&lt;P&gt;   WHEN 6. &lt;/P&gt;&lt;P&gt;     WRITE: / 'OTHERS'. &lt;/P&gt;&lt;P&gt;ENDCASE. &lt;/P&gt;&lt;P&gt;ENDIF.&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;Padmam.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2007 10:13:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fm-needed/m-p/2384817#M529862</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-19T10:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: FM needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fm-needed/m-p/2384818#M529863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vijay,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Use OPEN DATASET, READ DATASET and CLOSE DATASET to open the file.&lt;/P&gt;&lt;P&gt;Refer to this sample program&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  zuploadtab                    .

PARAMETERS: p_infile  LIKE rlgrap-filename
                        OBLIGATORY DEFAULT  '/usr/sap/'..

DATA: ld_file LIKE rlgrap-filename.

*Internal tabe to store upload data
TYPES: BEGIN OF t_record,
    name1 like pa0002-VORNA,
    name2 like pa0002-name2,
    age   type i,
    END OF t_record.
DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
      wa_record TYPE t_record.

*Text version of data table
TYPES: begin of t_uploadtxt,
  name1(10) type c,
  name2(15) type c,
  age(5)  type c,
 end of t_uploadtxt.
DATA: wa_uploadtxt TYPE t_uploadtxt.

*String value to data in initially.
DATA: wa_string(255) type c.

constants: con_tab TYPE x VALUE '09'.

*If you have Unicode check active in program attributes then you will
*need to declare constants as follows:

*class cl_abap_char_utilities definition load.
*constants:
*    con_tab  type c value cl_abap_char_utilities=&amp;gt;HORIZONTAL_TAB.



************************************************************************
*START-OF-SELECTION
START-OF-SELECTION.
ld_file = p_infile.
OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
ELSE.
  DO.
    CLEAR: wa_string, wa_uploadtxt.
    READ DATASET ld_file INTO wa_string.
    IF sy-subrc NE 0.
      EXIT.
    ELSE.
      SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
                                      wa_uploadtxt-name2
                                      wa_uploadtxt-age.
      MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
      APPEND wa_upload TO it_record.
    ENDIF.
  ENDDO.
  CLOSE DATASET ld_file.
ENDIF.


************************************************************************
*END-OF-SELECTION
END-OF-SELECTION.
*!! Text data is now contained within the internal table IT_RECORD

* Display report data for illustration purposes
  loop at it_record into wa_record.
    write:/     sy-vline,
           (10) wa_record-name1, sy-vline,
           (10) wa_record-name2, sy-vline,
           (10) wa_record-age, sy-vline.
  endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2007 10:15:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fm-needed/m-p/2384818#M529863</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-19T10:15:14Z</dc:date>
    </item>
  </channel>
</rss>

