Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

File upload to application server - urgent

Former Member
0 Kudos
351

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
181

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.

6 REPLIES 6

Former Member
0 Kudos
181

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

Former Member
0 Kudos
181

try changing the filetypes and test

have u used ASC

Former Member
0 Kudos
181

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.

Former Member
0 Kudos
181

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

Former Member
0 Kudos
181

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.

Former Member
0 Kudos
182

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.