Application Development and Automation 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: 
Read only

text file upload-Problem

Former Member
0 Likes
623

Dear all,

Using Tcode CG3Z,I have uploaded the text file into application server with BIN&ASC both format. But the problem while reading from the program values are coming in ASC format.

"OPEN DATASET ds_name FOR INPUT IN BINARY MODE."

Can on help me on this?

Thanks in advance.

Regards,

4 REPLIES 4
Read only

anversha_s
Active Contributor
0 Likes
532

hi,

chk this sa,ple code.

CG3Z - Upload a empty file to a application server from presentation server.it create a file in application server.

parameters: p_file like rlgrap-filename obligatory

default '/usr/sap/upload.xls'.

types: begin of t_data,

vbeln like vbap-vbeln,

posnr like vbap-posnr,

matnr like vbap-matnr,

werks like vbap-werks,

megne like vbap-zmeng,

end of t_data.

data: it_data type standard table of t_data,

wa_data type t_data.

open dataset p_file for output in text mode encoding default.

if sy-subrc ne 0.

write:/ 'Unable to open file:', p_file.

else.

do.

read dataset p_file into wa_data.

if sy-subrc ne 0.

exit.

else.

append wa_data to it_data.

endif.

enddo.

close dataset p_file.

endif.

rgds

anver

Read only

Former Member
0 Likes
532

Hi,

Then use the following code to read the file from application server.

CALL FUNCTION 'FILE_GET_NAME'

EXPORTING

LOGICAL_FILENAME = P_INFILE

IMPORTING

FILE_NAME = INPUTFILE

EXCEPTIONS

FILE_NOT_FOUND = 1

OTHERS = 2.

IF SY-SUBRC NE 0.

MESSAGE E899 WITH text-064 P_INFILE text-065.

ENDIF.

  • Open the inputfile for reading in text mode

OPEN DATASET INPUTFILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF SY-SUBRC NE 0.

MESSAGE E899 WITH text-066 INPUTFILE text-067.

ENDIF.

DO.

READ DATASET INPUTFILE INTO TEXT2 . "LENGTH LENG.

MOVE TEXT2 TO I_MATCONV.

APPEND I_MATCONV.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET INPUTFILE.

also, look at this one http://www.sap-img.com/ab004.htm

Regards

Sudheer

Read only

Former Member
0 Likes
532

hi

good

did you debug your program properly, i dont think there should not be any prob if your data is correct. Go through this link, i hope this ll give you some better idea about the OPEN DATASET STATEMENT

http://www.sapfans.com/sapfans/alex.htm

thanks

mrutyun^

Read only

Former Member
0 Likes
532

Thanks to all for reply.

If it is 'Z' program we can do. I'm using SAP Std program "rvafss00" Billing Interface program.

I did debug and i checked the data after read from the file values are coming in ASC .

Regards,