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

File upload to application server - urgent

Hi

I need to upload a file (either .txt or .xls) which is tab delimited from presentation server to application server (AL11). I used the transaction CG3Z to do this. Even though the file gets uploaded, all the tabs would be replaced by #. How can I avoid this and retain those tabs which were there in the file.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 11:43 AM

    Tab will be stored as # when it goes to the application server.

    You cant see as tab how you find in the notepad or XL sheet.

    When you are uploading we have to handle in the program again.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 11:17 AM

    use this demo code to upload.download a file to and from application server -

    &----


    *& Report ZGILL_AS *

    *& *

    &----


    *& *

    *& *

    &----


    REPORT ZGILL_AS message-id rp .

    tables: pa0001,pa0002.

    select-options s_pernr for pa0001-pernr no intervals MODIF ID XYZ.

    parameters: p_dwnld AS CHECKBOX ,

    p_upld AS CHECKBOX DEFAULT 'X'.

    parameters: P_DSNI(75) TYPE C MODIF ID ABG DEFAULT

    '/usr/local/sapdata/amit.dat' LOWER CASE.

    data: begin of itab occurs 0,

    pernr(8),

    sp1(1) value ',',

    werks(4),

    sp2(1) value ',',

    persg(1),

    sp3(1) value ',',

    persk(2),

    end of itab.

    data: s_eof(3).

    start-of-selection.

    if p_upld = 'X'.

    OPEN DATASET P_DSNI FOR OUTPUT IN LEGACY TEXT MODE.

    PERFORM FETCH_DATA.

    STOP.

    elseif p_dwnld = 'X'.

    OPEN DATASET P_DSNI FOR INPUT IN LEGACY TEXT MODE.

    IF SY-SUBRC NE 0.

    MESSAGE E016 WITH

    'Error opening seq. file, RC:' SY-SUBRC.

    EXIT.

    ENDIF.

    CLEAR S_EOF.

    DO.

    PERFORM FETCH_file.

    IF S_EOF EQ 'YES'. stop. ENDIF.

    ENDDO.

    endif.

    END-OF-SELECTION.

    if itab[] is not initial.

    perform print_file1 tables itab.

    else.

    write:/ 'No records exists'.

    endif.

    &----


    *& Form FETCH_DATA

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM FETCH_DATA .

    SELECT * FROM PA0001 WHERE PERNR IN S_PERNR.

    MOVE-CORRESPONDING PA0001 TO ITAB.

    TRANSFER ITAB TO P_DSNI.

    APPEND ITAB.

    ENDSELECT.

    CLOSE DATASET P_DSNI.

    ENDFORM. " FETCH_DATA

    &----


    *& Form FETCH_file

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM FETCH_file .

    READ DATASET P_DSNI INTO itab.

    append itab.

    clear itab.

    IF SY-SUBRC NE 0.

    S_EOF = 'YES'. EXIT.

    ENDIF.

    ENDFORM. " FETCH_file

    &----


    *& Form print_file1

    &----


    • text

    ----


    • -->P_ITAB text

    ----


    FORM print_file1 tables P_ITAB structure itab .

    write:/2 'EmpNo',

    14 'Personnel Area',

    34 'Emp Group',

    47 'Emp SubGroup'.

    skip 1.

    loop at p_itab.

    write:2 p_itab-pernr,

    14 p_itab-werks,

    34 p_itab-persg,

    47 p_itab-persk.

    skip 1.

    endloop.

    ENDFORM. " print_file1

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 11:17 AM

    try changing the filetypes and test

    have u used ASC

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 11:17 AM

    hi Vijay..

    You can do something like this.

    report ztest .
     
     
    parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt'.
     
     
    data: begin of itab occurs 0,
          fld1(20) type c,
          fld2(20) type c,
          end of itab.
    data: str type string.
     
     
    itab-fld1 = 'ABC'.
    itab-fld2 = 'DEF'.
    append itab.
     
    start-of-selection.
     
     
      open dataset d1 for output in text mode.
      loop at itab.
    <b>    concatenate itab-fld1 itab-fld2 into str
               separated by cl_abap_char_utilities=>horizontal_tab.
        transfer str to d1.</b>
      endloop.
      close dataset d1.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 11:22 AM

    Hi Vijay,

    Probably you have a different character set in the 2 systems : presentation server and application server.

    If you know the ASCII code of the TAB character in both systems, in the moment of the transfer maybe you can convert that character.

    If you do the upload with some application for file transfer, prabably you can refer the character sets of the source and destination server to convert the file characters and them you get the correct result.

    I hope this can help.

    Best regards,

    Paulo Sousa

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 11:23 AM

    Hi Vijay,

    When we see the file using AL11 , the tabs get replaced by #. But when you actually download the file from the application server in .txt format or .xls format, you can see the actual tabs in between the fields, instead of '#'.

    Regards,

    Siddhesh Sanghvi.

    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.