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

Fixed Width in Notepad

Former Member
0 Likes
1,519

Hi all i am uploading text file into application server, i want the data that is uploaded in fixed length delimiter.

My code is like

DATA:char_35(35) type c VALUE ' '. "35 spaces

LOOP AT it_output INTO fs_output.

concatenate

char_35

fs_output-werks

fs_output-wort01

fs_output-wregio

fs_output-invoice

Line_feed

into FS_output1 separated by htab.

TRANSFER fs_output1 TO filepath.

endloop.

With this i'm getting the file with tab delimiter as i gave separated by hextab.

I want to display the data in different positions like fs_output-werks should start from 36, fs_output-wort01 should start from 40, fs_output-wregio should start from 65 like i want to display the txt file in my specified length. So any suggestions on this.

Regards

VEnk@

Edited by: Venkat Reddy on Mar 23, 2010 12:03 PM

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,079

Then i think you have to define fs_output1 as TYPE string & use offsets

DATA:
fs_output1 TYPE STRING.

fs_output1+35 = fs_output-werks.
fs_output1+40 = fs_output-werks.
fs_output1+35 = fs_output-wregio.

At the end do not forget to use the Line Feed .

BR,

Suhas

8 REPLIES 8
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,080

Then i think you have to define fs_output1 as TYPE string & use offsets

DATA:
fs_output1 TYPE STRING.

fs_output1+35 = fs_output-werks.
fs_output1+40 = fs_output-werks.
fs_output1+35 = fs_output-wregio.

At the end do not forget to use the Line Feed .

BR,

Suhas

Read only

Former Member
0 Likes
1,079

HI Suhas,

Thks for the prompt reply.

I have chnaged the code as suggested by you but line feed is not supporting, it is saying like. Statement "Line feed" is not defined. Here is my code below data is coming as expecting by in a single line.

Line_feed = cl_abap_char_utilities=>cr_lf.

LOOP AT it_output INTO fs_output.

fs_output1+36(4) = fs_output-werks.

fs_output1+40(25) = fs_output-wort01.

fs_output1+65(3) = fs_output-wregio.

fs_output1+68(10) = fs_output-invoice.

Line_Feed.

endloop.

What needs to be done for the Line feed, so that i can get the data in each line.

Regards

VEnk@

Read only

GauthamV
Active Contributor
0 Likes
1,079

You already got fs_output1 data in required format,but where did you use

concatenate statement for line feed ?

Read only

venkat_o
Active Contributor
0 Likes
1,079

Hi, Define line feed like below. "Define linefeed.

DATA line_feed(2) TYPE c VALUE cl_abap_char_utilities=>cr_lf.

LOOP AT it_output INTO fs_output.
  fs_output1+36(4) = fs_output-werks.
  fs_output1+40(25) = fs_output-wort01.
  fs_output1+65(3) = fs_output-wregio.
  fs_output1+68(10) = fs_output-invoice.
  fs_output1+78(2)  = line_feed.         "Pass this way.
ENDLOOP.
Thanks Venkat.O

Read only

Former Member
0 Likes
1,079

Hi Gautham,

Let me make you clear.

LOOP AT it_output INTO fs_output.

fs_output1+36(4) = fs_output-werks.

fs_output1+40(25) = fs_output-wort01.

fs_output1+65(3) = fs_output-wregio.

fs_output1+68(10) = fs_output-invoice.

TRANSFER fs_output1 TO filepath.

*Line_Feed. "Any other way where i can break the line after first loop and so on since line feed is not working.

endloop.

I have total 5 records in my it_output in that when first loop run fs_output1 willl carry the 4 records and when second time loop starts then i need to display the records in second line. I am getting all the records in single line.

My data is like

<35 spaces> 2145 MS 091454455 2145 MS 09454546....

I want 2145 MS 091454455

2145 MS 094545464 in this way.

REgards

VEnk@

Read only

Former Member
0 Likes
1,079

Thks Venkat thks alot for your reply it is solved now. Make me clear why we need to take this line feed as 2 characters.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,079

This is not just a line feed. CL_ABAP_CHAR_UTILITIES=>CR_LF consists of Carriage Return (1 character) & Line Feed (1 character).

Hence 2 characters

If you use CL_ABAP_CHAR_UTILITIES=>NEWLINE which is the constant for LineFeed you have to use 1 character only.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,079

Duplicate post ... Please ignore ...

Edited by: Suhas Saha on Mar 23, 2010 12:12 PM