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

Putting Flat file on Application Server

Former Member
0 Likes
400

Hi,

I am using following report to transfer a flat file to application server.

REPORT Z_DOWNLOAD.

PARAMETERS: P_FILE LIKE IBIPPARMS-PATH,

P_FILE1(100) default '/usr/sap/put' lower case.

DATA: WS_FILE TYPE STRING.

DATA: BEGIN OF T_DATA OCCURS 0,

RECORD(200),

END OF T_DATA.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = ' '

IMPORTING

FILE_NAME = P_FILE

.

START-OF-SELECTION.

WS_FILE = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = WS_FILE

FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = T_DATA

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

  • Creating the file at Appl ...........

OPEN DATASET P_FILE1 FOR OUTPUT IN TEXT MODE encoding utf-8.

if sy-subrc ne 0.

message e000(--) with 'Error in opening file'.

endif.

  • Trasfer the records to file.............

loop at t_data.

transfer t_data to p_file1.

endloop.

close dataset p_file1.

if sy-subrc eq 0.

write: / 'Written the files at ', p_file1.

Now when I am uploading Flat file1 with following data it gets updated but when I use Flat file2, it does not work.

Please help me out..

I am posting the data of both flat files.

Flat file1:(File getting transferred successfully to application server)

1,NPOBL,ABC

1,NPOBL,CDE

1,NPOBL,FGH

Flat file2: (Getting error when trying to transfer this file on application server)

DS04,1,NPOBL,200,CREATE1,NEW YORK,X

DS04,1,NPOBL,200,CREATE2,NEW YORK,X

DS04,1,NPOBL,200,CREATE3,NEW YORK,X

<b>Please help me out...</b>

-Tushar

2 REPLIES 2
Read only

Former Member
0 Likes
371

hi Rajesh,

I guess your in ternal table is not able to hold the data as is of 200 characters ... try increasing the length ..


DATA: BEGIN OF T_DATA OCCURS 0,
RECORD(2000),
END OF T_DATA.

Regards,

Santosh

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
371

Just tested, worked fine for me. You may want to put a file extension on your file name, like put.txt

Regards,

Rich heilman