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: 

Adding spaces at trailing in lines while creating txt file in SAP ABAP

deepak_dhamat
Active Contributor
0 Kudos
2,423

hdfc.txt

Hi All ,

My query is i want to generate TXT file with specific format and requirement in which

i want to add spaces at end of line in each row till .

Example is i have attached file in that file at end of row i have added dot so that i can insert spaces in between , but i dont want to add that dot at end of row but need add space say

length of row is 100 character but i have character till 80 only and rest of the spaces from 81 to 100 i need to add spaces .

how to achive that i have done all possible i could in SAP abap , dont want to use any other than SAP .

Please suggest as my file is created as per attached file .

Regards

Deepak Dhamat

7 REPLIES 7

FredericGirod
Active Contributor
1,306

You have to create a structure (or a type) for each line type. This structure will contain elements corresponding to the fields of the line, but everything declared in CHAR.

The size of the structure have to be 100 ... so you have to complete with field like DUMMY1

After that, your file is only a set of line type with the exact size 100char.

It is how IDOCs and direct Input works

Sandra_Rossi
Active Contributor
1,306

I know that some old systems require that the lines are padded with blanks so that all lines have the same width, but make sure that it's the case; sometimes, people say this kind of thing without checking the system requirements.

Is it to write on the file system of the frontend or server? Because that will be a different answer.

deepak_dhamat
Active Contributor
0 Kudos
1,306

Hi Frederic ,

Thanks for you prompt reply and suggestion .

I did this workaround  and it worked  .
replaced dot at  each end of line  with space by below method  .

SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S32 {
color: #3399FF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}

DATA : t_len TYPE i .

  DATA: lv_space TYPE string.

  lv_space = cl_abap_conv_in_ce=>uccp( '00a0' ).

  LOOP AT txtlines .

    t_len = strlen( txtlines ) .

    t_len = t_len - 1 .

    CONCATENATE txtlines+0(t_len) lv_space INTO txtlines .
    MODIFY txtlines .
    CLEAR txtlines .

    CLEAR t_len .
  ENDLOOP.

I have now send file for checking waiting for their confirmation .

Thanks and Regards 
Deepak Dhamat  

1,306

concatenate is not a friend of string & text, most of the time you will loose your space.

try to replace it by |{ txtlines+0(t_len) }{ lv_space }|

0 Kudos
1,306

U+00A0 is not a space, it's a non-breaking space. I doubt that the target application will like that !

Your main problem is not to produce an internal table with trailing spaces, it's to write the internal table to the file without deleting the trailing spaces. Is it to write on the file system of the frontend or server? Because that will lead to a different answer.

deepak_dhamat
Active Contributor
0 Kudos
1,306

Dear Frederic ,

I tried doing it by directly replacing but it does not work in required manner .

we will have to use concatenate .

Thanks Frederic

1,306

Please use the COMMENT button for comments, questions, adding details, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.

If you do a comment under a question/answer and you want to target someone else than the question/answer' author, the only solution is to copy/paste their hyperlinked name so that the person receives a warning (NB: @ doesn't work)