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

read file on application server

Former Member
0 Likes
635

Hi Experts,

my file is in form of

UNBUNOC:2INTTRA:ZZZMGH:ZZZ090721:2334100053501'UNH1IFTSTA:D:99B:UN'BGM23++++++++++++++++++++++++

on application server.

now i want to read this file in following form.....DESIRED FORM

UNBUNOC:2INTTRA:ZZZMGH:ZZZ090721:2334+100053501

UNH1IFTSTA:D:99B:UN

BGM23

means where i get seperator ' rest of the data append in next line....this will go on till last separator ' find.

i have use a file

P_FILE(255) TYPE C.

it only read 255 charactor in a row and have file on application server like above i mention IT CAN HAVE MORE THAN 255 CHARACTOR.......SO i want to seperate this is in seperate rows......

please suggest me the way i read my file in desired form....

thanks

babbal

3 REPLIES 3
Read only

Former Member
0 Likes
593

Hello Babal ,

i am gving u the logic ...

1) Read your file from application to your internal table .

loop the internal table into wa_itab . .

do .

if wa_itab is not initial .

split wa_itab at <seprator> into var1 var2 .

wa_itab = var2 .

endif .

enddo .

endloop.

if feel any problem , please ....ask

Thanks and Regards..

Priyank

Read only

Former Member
0 Likes
593

Hello,

You can read file into string using DATASET.

After that split it into internal of single column at delimiter "'".

SPLIT string AT sep INTO TABLE ITAB.

Thanks,

Augustin.

Read only

venkat_o
Active Contributor
0 Likes
593

Hi Babbal singh, try this way. It works.

REPORT ztest_notepad.

DATA:it_data TYPE TABLE OF string,
     wa_data LIKE LINE OF it_data.


DATA:p_app_file(100) TYPE c VALUE '/user/sap/tmp',
     p_separator     TYPE c VALUE ''''. "quote separator
"START-OF-SELECTION

START-OF-SELECTION.

  OPEN DATASET p_app_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
  IF sy-subrc = 0.
    DO.
      READ DATASET p_app_file INTO wa_data.
      IF wa_data IS INITIAL.
        EXIT.
      ELSE.
        SPLIT wa_data AT p_separator INTO TABLE it_data.
      ENDIF.
    ENDDO.
  ENDIF.
  CLOSE DATASET p_app_file.
Thanks Venkat.O