‎2008 Jul 07 5:29 PM
Hi All,
I am writing data to a file in AL11 from an internal table and I'm facing alignment issue when I open the file in the AL11 folder.
Here is the scenario.
1. The internal table has 10 records.
2. Below is the how the 10 records are coming out in the text file.
000050001141
000050004054
000050004062
000050004068
000050004072
Each line gets displaced for a certain number of tabs. Any ideas ?
Thanks.
‎2008 Jul 07 5:30 PM
‎2008 Jul 07 5:31 PM
the output in al11 is not the final or exact output.. the server tries to compress the file and display.. so you better download the file to presentation server and then view the exact file format... Tr. CG3Y / CG3Z
‎2008 Jul 07 5:34 PM
Hi,
I am not seeing the text file from AL11. I am directly acessing the file from the application server folder which is the real text file.
Thanks,
Nandha.
‎2008 Jul 07 5:34 PM
000050001141
000050004054
000050004062
000050004068
000050004072
This is how the output in the file gets displaced in each line
‎2008 Jul 07 5:38 PM
when you get the data into internal table using Open dataset... you can use Condense No gaps which will remove the gaps..
you can even use the same before writing the file UNIX server..
‎2008 Jul 07 5:52 PM
Condense won't work because it will condense all the fields which is not the required functionality
‎2008 Jul 07 5:55 PM
Hi,
Do u want to write file with field length as it is in Internal table?
or do u want to write fixed length file.?
‎2008 Jul 07 6:18 PM
I want to write it as it is in the internal table. If the internal table has 10 rows with 10 columns, just transfer them as it is
‎2008 Jul 07 6:21 PM
Lets see your code.. how you are transfering data... ASC mode Binary mode? what delimitor are u using..
‎2008 Jul 07 6:23 PM
IF p_appsrv <> space.
*Write the data to the application server file
*Open the file
OPEN DATASET p_file FOR OUTPUT IN BINARY MODE .
IF sy-subrc <> 0.
WRITE :/1 'Server File Not Found'(002).
ELSE.
*Transfer data
LOOP AT it_data INTO wa_output.
v_count = v_count + 1.
TRANSFER wa_output TO p_file.
CLEAR wa_output.
ENDLOOP.
*Close the file
CLOSE DATASET p_file.
ENDIF.
ENDIF.
‎2008 Jul 07 6:25 PM
try this way..
*Transfer data
LOOP AT it_data INTO wa_output.
TRANSFER wa_output TO p_file.
CLEAR wa_output.
v_count = v_count + 1.
ENDLOOP.check this sample code.. it works perfect..
IF NOT p_ufile IS INITIAL.
OPEN DATASET p_ufile FOR OUTPUT IN TEXT MODE.
IF sy-subrc <> 0.
EXIT.
ENDIF.
LOOP AT p_output INTO wa_file.
TRANSFER wa_file TO p_ufile.
CLEAR wa_file.
ENDLOOP.
CLOSE DATASET p_ufile.
‎2008 Jul 07 6:27 PM
then u have to write the code like this.
data : <fs> type any.
data : begin of ty_struc1,
f1 type c value space.
f2 tyep c value '[',
end of ty_struc1.
data : begin of ty_struc2,
f1 type c value '[',
f2 type c value space,
end of ty_struc.
loop at itab.
assing commponent of itab to <fs>.
translate <fs> using ty_struc1.
concatenate v_temp <fs> to v_temp.
translate v_temp using ty_struc2.
transfer th v_temp to file
endloop.
hope this works
‎2008 Jul 07 6:34 PM
‎2008 Jul 08 8:02 PM
Figured out the issue. Should be using Text mode Default encoding with smart linefeed