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: 

Problem in uploading file from application server

Former Member
0 Kudos

Hi Friends,

I have a file on the Applicatioin server, I want to upload it but the format of the file is not having any separator values. I am finding difficult to upload it.

Ex:

D0000000000825000C000000016494458120066

000000521174706832006110120061101CAS CHQ XFER WD TRF TO 0052117555252 BY TR 000217063 D0000000001627800C000000016331678120066

000000521174706832006110120061101CAS CHQ XFER WD TRF TO 0052117555252 BY TR 000217070

Can you please tell me how to upload it,

Thanx in advance,

Line

11 REPLIES 11

Former Member
0 Kudos

Hi Line

U have to know the structure of that file, for ex.:

DATA: BEGIN OF W_FILE OCCURS 0,
              FIELD1,
              FIELD2,
              FIELD3,
              ...........,
              FIELDN,
           END    OF W_FILE.

OPEN DATASET <FILE> FOR OUTPUT IN TEXT MODE.

DO.
   READ DATASET <FIELD> INTO W_FILE.
   IF SY-SUBRC <> 0. EXIT. ENDIF.
   APPEND W_FILE.
ENDDO.

Max

Former Member
0 Kudos

Now, from application server u get the data into internal table which is like a string(600).

loop at internal table.

itab-field1 = int+0(6).

itab-field2 = int+6(10).............

append itab.

endloop.

Here each record is of fixed length. so check at what point u need to split the string into field values and do it.

0 Kudos

Hi,

I am getting the record as a string I want to split that record and save it in excel file again. How to do it.

Thanx,

Line

0 Kudos

If you don't have any separators, i assume it must be a fixed length file.

i.e. for example, the first 10 characters are the field1 , the next 5 chracters are field2 etc.So, you have to define an internal table with exactly the same structure.

data: begin of itab occurs 0,

field1(10),

field2(5),

field3(15),

end of itab.

then you can simple use the following commands:

read dataset dsn for input in text mode.

if sy-subrc = 0.

do.

read dataset dsn into itab.

if sy-subrc = 0.

append itab.

clear itab.

else.

exit.

endif.

enddo.

close dataset dsn.

endif.

Regards,

ravi

0 Kudos

Hi Ravi,

I am getting the file in the proper format but I need to keep '~' between the fields and store it in another file.

Thanx in advance,

Parvez

0 Kudos

data: begin of itab occurs 0,

field1(11), "inc field length by 1 fior all fields

field2(6),

field3(16),

end of itab.

In addtiion to RAvi's reply,once u have data in Itab.

loop at itab.

itab-filed1+9(1) = '~'

...........

........

modify itab.

endloop.

then to writ this table to another file use -

OPEN DATASET P_DSNI FOR OUTPUT IN LEGACY TEXT MODE.

loop at itab.

TRANSFER ITAB TO P_DSNI.

endloop.

close datset p_dsni..

hope this helps..

reward points if helpfull

amit

0 Kudos

Hi Line,

if you just want to read and write the file without really changing the content then ask your basis people to do that on file system level using unix GREP command for the '~' insertion. What could possibly be the reason for processing in SAP/ABAP?

Regards,

Clemens

0 Kudos

Hi,

if you want to have a ~ in between the fields of the internal table, you can do the following:

data: begin of itab_new occurs 0,

data(400),

end of itab.

loop at itab.

concatenate itab-field1 itab-field2 itab-field3 into itab_new-data separated by '~'.

append itab_new.

clear itab_new.

endloop.

Regards,

ravi

Clemenss
Active Contributor
0 Kudos

Hi,

reading files on application server is not called UPLOAD because UPLOAD usually implies transfer from one system (i.e. presentation server) to another system (application server) via network.

You can define a string and read the whole file at once and later split it into records of an internal table.

Your example looks like records (separated by <NEWLINE>) with records of different length.

OPEN DATASET ... IN CHARACTER MODE ENCODING DEFAULT.
DO.
READ DATASET ... INTO lv_string.
  IF SY-SUBRC <> 0.
    EXIT.
  ENDIF.
  CASE lv_string(02).
    WHEN 'D0'.
* process...D0 way
    WHEN '00'.
* process...00 way
  ENDCASE.
ENDDO.

Hope this wokrs for you although kind of symbolic code.

Regards,

Clemens

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

You can read the single line and then replace the space by ~ and store it in another file.

On seeing the output you specified,it seems space is used in between two fields.

REPLACE ALL OCCURRENCES OF ' ' IN v_line WITH ' ~'.

Here v_line should contain the each line before this statement.