Skip to Content
author's profile photo Former Member
Former Member

File to Application Layer

Hi Gurus,

How to transfer a file which is output for my report to application layer, its really urgent.

Thanks and Regards,

Varun.K

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

11 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 05:27 AM

    Check the final internal table of your report, and

    Loop at itab.

    OPEN DATASET (filename) FOR OUTPUT IN TEXT MODE DEFAULT ENCODING.

    if sy-subrc eq 0.

    TRANSFER itab TO (filename).

    endif.

    CLOSE DATASET (filename).

    Regards

    Kannaiah

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      I want the output to be displeyed on the output screena and at the same time it should be saved in the App. Layer, can this done using above solutions ?

      Thanks for the quick reply.

      Thanks again.

      Varun.K

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 05:29 AM

    Example:

    parameters: p_app LIKE rlgrap-filename DEFAULT

    '/interf/Direct/test/Out/'.

    OPEN DATASET p_app FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

    TRANSFER t_file TO p_app.

    t_file internal table will contain the data.

    Regards,

    DhanaLakshmi M S

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 19, 2008 at 05:29 AM

    Hi Varun,

    Here is the sample program to upload the file intothe applicaiton server.

      IF NOT it_success[] IS INITIAL .
        CLEAR v_unix .
        CONCATENATE '/tmp/' 'SAP_TRAVEL_SUCCESS_' v_dformat  '_' sy-uzeit '.TXT' INTO v_unix .
    
        OPEN DATASET v_unix FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    * If Network file could not be opened, give a message.
    
        IF sy-subrc <> 0.
          EXIT.
        ELSE.
          LOOP AT it_success.
    
            DO.
              ASSIGN COMPONENT sy-index OF STRUCTURE it_success TO <field>.
              IF sy-subrc <> 0.
                EXIT.
              ENDIF.
    * Look for Pipes in the field value.  If it exists, put quotes around
    * value so that the file opens correctly with all the columns aligned
    * in Excel.
    
              SEARCH <field> FOR '|' IN CHARACTER MODE.
    
    * If search for Pipes was successful.
              IF sy-subrc = 0.
    
                CONCATENATE '"' <field> '"' INTO <field> IN CHARACTER MODE.
    
              ENDIF.
              IF sy-index = 1.
                it_dload-dload = <field>.
    
              ELSE.
    * Put Pipe as a separator for values in IT_DLOAD internal table
    
                CONCATENATE it_dload-dload <field> INTO it_dload-dload
                            SEPARATED BY '|' IN CHARACTER MODE.
              ENDIF.
            ENDDO.
            TRANSFER it_dload-dload TO v_unix .
            CLEAR: it_dload-dload.
    
          ENDLOOP.
          v_trv_suc = v_unix .
        ENDIF.
        CLOSE DATASET v_unix .
      ENDIF .
    
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 05:29 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 05:31 AM

    Hi,

    First Open data set that means you have to give application server path name and it will open that.

    second transfer data set means you are transfer the data into application server path.

    third close your data set.

    below is the code

    DATA: w_temp(25) TYPE c,
    
    BEGIN OF itab OCCURS 0,
    f1(2) TYPE c,
    f2(6) TYPE c,
    f3(16) TYPE c,
    END OF itab.
    
    OPEN DATASET <file name and path> FOR OUTPUT IN TEXT MODE ENCODE DEFAULT.
    IF sy-subrc EQ 0.
    LOOP AT itab.
    
    w_temp = itab-f1.
    
    CONCATENATE w_temp
    itab-f2
    INTO w_temp.
    
    CONCATENATE w_temp
    itab-f3
    INTO w_temp.
    
    TRANSFER w_temp TO <file name and path>.
    
    ENDLOOP.
    CLOSE DATASET <file name and path>.
    ENDIF.

    Thanks

    Vikranth

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 05:35 AM

    Hi,

    use

    data : l_line type string.

    Open dataset p_filename for output in text mode encoding default.

    If sy-subrc = 0.

    loop at t_output into w_output.

    concatenate w_output-field1

    w_output-field2

    .

    .

    into l_line seperated by ','.

    transfer l_line to p_filename.

    endloop.

    endif.

    close dataset p_filename.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 05:26 AM

    Hi,

    Use

    OPEN DATASET,

    TRANFER DATASET,

    CLOSE DATASET.

    Check online help for documentation .

    Regards,

    Subramanian

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 05:27 AM

    Hi,

    you have 2 methods

    1) writing internal table data to the application using OPEN DATASET

    2) download the file onto the presentation server and then using CG3Z tcode UPLOAD to application server.

    Thanks and regards.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 06:07 AM

    Hi,

    Yes u can see it in AL11 tcode.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 06:18 AM

    hi....

    in whatver internal table you get the data,tranft the data from internal table to application server using open dataset and close dataset.

    CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'

    EXPORTING

    i_field_seperator = ';'

    • I_LINE_HEADER =

    • I_FILENAME =

    • I_APPL_KEEP = ' '

    TABLES

    i_tab_sap_data = tfile_data

    CHANGING

    i_tab_converted_data = it_trans

    • EXCEPTIONS

    • CONVERSION_FAILED = 1

    • OTHERS = 2

    .

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    IF sy-subrc NE 0.

    MESSAGE e000(yw) WITH 'Data is not available'.

    ENDIF.

    SELECT SINGLE paramval FROM zmm_params

    INTO path

    WHERE pgmna = 'ZREP_SAP_TO_CLRTY'

    AND paramid = 'PATH'

    AND fromdt <= sy-datum

    AND todt >= sy-datum.

    IF sy-mandt EQ '300'.

    path = '/statd40/'.

    ENDIF.

    CONDENSE path.

    CONCATENATE path 'BNP_SAP_SCR_STATUS_' sy-datum '.CSV' INTO dsn.

    CONDENSE dsn.

    OPEN DATASET dsn FOR OUTPUT IN TEXT MODE.

    IF sy-subrc EQ 0.

    LOOP AT it_trans INTO wt_trans.

    CLEAR line.

    TRANSLATE wt_trans-truxs_t_text_data USING ';,'.

    MOVE wt_trans-truxs_t_text_data TO line.

    TRANSFER line TO dsn.

    ENDLOOP.

    CLOSE DATASET dsn.

    *ENDIF.

    CLEAR : cmdtxt.

    • concatenate 'chmod 777' '/infocomm/mm/getfile' into

    CONCATENATE 'chmod 777' dsn INTO

    cmdtxt SEPARATED BY space.

    CALL 'SYSTEM' ID 'COMMAND' FIELD cmdtxt

    ID 'TAB' FIELD i_tty[].

    MESSAGE i001(yw) WITH 'File is downloaded successfully'.

    ENDIF.

    ENDFORM. " FILE_DOWNLOAD

    something like this....You can transfr the data on application server using this.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.