‎2008 Jul 15 11:56 AM
Hello!
I use FUNCTION 'GUI_DOWNLOAD' for creating txt file. But this file is consist of head length 175 and body length 472.
I'm appending this two IT into DOWN.
DATA: BEGIN OF down OCCURS 0,
text type c length 472,
END OF down.
I also used
trunc_trailing_blanks = ' '
trunc_trailing_blanks_eol = ' '
because I want lines to be 472.
but the first line should be 175, instead of 472....hot to do that
Example:
IF p_down = 'X'.
CONCATENATE p_tmpdir d '.TXT' INTO file_gui.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = file_gui
trunc_trailing_blanks = ' '
trunc_trailing_blanks_eol = ' '
TABLES
data_tab = down
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
lp,
Nadja
Edited by: Nadja Susnjar on Jul 15, 2008 12:56 PM
Edited by: Nadja Susnjar on Jul 15, 2008 12:57 PM
‎2008 Jul 16 9:07 AM
Ok . I see .
Then use another table to do it.
DATA: BEGIN OF down OCCURS 0,
text type c length 472,
END OF down.Enf of the loop of items ,
DATA: BEGIN OF down_2 OCCURS 0,
text type string,
END OF down_2.LOOP AT DOWN.
IF sy-tabix EQ 1.
DOWN_2-text = down+0(175).
ELSE.
DOWN_2-text = down+0(472).
ENDIF.
APPEND down_2
ENDLOOP.
this is gonna work.
‎2008 Jul 15 8:48 PM
Hi Nadja ,
Use the structure below. String fields length is determined at runtime. This will solve your question.
DATA: BEGIN OF down OCCURS 0,
text type string,
END OF down.regards.
‎2008 Jul 16 8:54 AM
I used your code, but the poroblem is:
Error:
Program /KPL/HR_TRIGLAV1
At the write position, you cannot use offset and length with fields of
type "STRING" or "XSTRING" . . . . . . . . . .
lp,
Nadja
‎2008 Jul 16 8:58 AM
LOOP AT items.
sum_cnt = sum_cnt + 1.
sum_amt = sum_amt + items-m_pay.
ENDLOOP.
D string
d(1) = '1'.
d+1(10) = p_st_os.
d+11(35) = p_naziv.
concatenate p_datum(4) p_datum4(2) p_datum6(2)
into pdatum separated by '-'.
d+46(10) = pdatum.
E string
e(1) = '+'.
e+1(5) = sum_cnt.
e6(1) = ''.
e+7(15) = sum_amt.
e22(1) = ''.
e+23(15) = sum_amt.
e+38(10) = p_st_rac.
e+48(3) = p_nac.
concatenate p_rok(4) p_rok4(2) p_rok6(2)
into prok separated by '-'.
e+51(10) = prok.
e+61(3) = p_zast.
e+64(35) = p_trr.
e+99(20) = p_sklic.
D+E strings into DOWN
down-text(56) = d.
down-text+56(119) = e.
concatenate d e into f.
down-text = f.
APPEND down.
F strings into DOWN
LOOP AT items.
down-text(1) = items-oznaka.
down-text+1(20) = items-perid.
down-text+21(10) = items-zakoga.
down-text+31(35) = items-nchmc.
down-text+66(25) = items-vnamc.
down-text+91(10) = items-zakoga.
down-text+101(35) = items-nchmc.
down-text+136(25) = items-vnamc.
down-text+161(10) = items-zakoga.
down-text+171(35) = items-nchmc.
down-text+206(25) = items-vnamc.
down-text+231(10) = items-polica.
down-text+241(4) = items-ozn.
down-text+245(35) = p_nazivz.
down-text+289(4) = items-emfna.
concatenate p_begda(4) p_begda4(2) p_begda6(2)
into pbegda separated by '-'.
down-text+280(10) = pbegda.
concatenate p_endda(4) p_endda4(2) p_endda6(2)
into pendda separated by '-'.
down-text+290(10) = pendda.
down-text+300(3) = ' '.
down-text303(1) = ''.
down-text+304(15) = items-m_pay.
down-text319(1) = ''.
down-text+320(15) = items-m_pay.
down-text335(1) = ''.
down-text+336(15) = '000000000000000'.
down-text351(1) = ''.
down-text+352(5) = '00000'.
down-text+357(35) = ' '.
down-text+392(10) = p_st_rac.
down-text+402(10) = items-zakoga.
down-text+412(35) = items-nchmc.
down-text+447(25) = items-vnamc.
APPEND down.
ENDLOOP.
Error is at line::::
down-text(56) = d.
Definition of d and e::::
d(56),
e(119),
lp,Nadja
‎2008 Jul 16 9:02 AM
When transferring the data to your down table , don't use offset.
DATA: BEGIN OF down OCCURS 0,
text type string,
END OF down.
LOOP AT another_table.
For the first record
IF sy-tabix EQ 1.
down-text = another_table-your_field+0(175).
ELSE.
down-text = another_table-your_field+0(472).
ENDIF.
ENDLOOP.
‎2008 Jul 16 9:07 AM
Ok . I see .
Then use another table to do it.
DATA: BEGIN OF down OCCURS 0,
text type c length 472,
END OF down.Enf of the loop of items ,
DATA: BEGIN OF down_2 OCCURS 0,
text type string,
END OF down_2.LOOP AT DOWN.
IF sy-tabix EQ 1.
DOWN_2-text = down+0(175).
ELSE.
DOWN_2-text = down+0(472).
ENDIF.
APPEND down_2
ENDLOOP.
this is gonna work.
‎2008 Jul 16 10:07 AM
‎2008 Jul 16 11:50 AM
Hi again!
The last fild of line has different length. If I work with string, then line is not 472, but less.
The code:
LOOP AT DOWN.
IF sy-tabix EQ 1.
DOWN_2-text = down+0(175).
ELSE.
DOWN_2-text = down+0(472).
ENDIF.
APPEND down_2.
ENDLOOP.
IF p_down = 'X'.
CONCATENATE p_tmpdir d '.TXT' INTO file_gui.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = file_gui
trunc_trailing_blanks = ' '
trunc_trailing_blanks_eol = ' '
TABLES
data_tab = down_2
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc NE 0.
WRITE: / text-e01, sy-subrc, text-e02, file_gui.
ELSE.
WRITE: / text-i01, file_gui.
ENDIF.
ENDIF.
lp,
Nadja
‎2008 Jul 16 12:15 PM
Hi Nadja,
instead of ;
down_2 = down.
use the code below. It won't avoid space characters.
CALL METHOD cl_abap_string_utilities=>c2str_preserving_blanks
EXPORTING
SOURCE = down
IMPORTING
dest = down_2.
Reward if it's helpfull.
Regards.
‎2008 Jul 16 12:59 PM
Hi!
Sorry but I still have a problem:
Corrected code:::::
IF sy-tabix EQ 1.
CALL METHOD cl_abap_string_utilities=>c2str_preserving_blanks
EXPORTING
SOURCE = down+0(175)
IMPORTING
dest = down_2-text.
ELSE.
CALL METHOD cl_abap_string_utilities=>c2str_preserving_blanks
EXPORTING
SOURCE = down+0(472)
IMPORTING
dest = down_2-text.
ENDIF.
APPEND down_2.
ENDLOOP.
Error::::::
"DOWN" is not type-compatible with formal parameter "SOURCE".
lp,
Nadja
‎2008 Jul 16 1:08 PM
Hi ,
Simply change your code as below ;
LOOP AT down.
if sy-tabix eq 1.
CONCATENATE space space INTO down_2 SEPARATED BY down+0(175).
else.
CONCATENATE space space INTO down_2 SEPARATED BY down+0(472).
endif.
append down_2.
endloop.
hope it is usefull.
‎2008 Jul 16 1:18 PM
Sorry, but I have still a problem:
Error:::::::
"DOWN_2" must be a character-type data object (data type C, N, D, T or
STRING) .
lp,
Nadja
‎2008 Jul 16 1:28 PM
Hi ,
I've forgotten to add field name (text) . Here is the code ;
LOOP AT down.
if sy-tabix eq 1.
CONCATENATE space space INTO down_2-text SEPARATED BY down-text+0(175).
else.
CONCATENATE space space INTO down_2-text SEPARATED BY down-text+0(472).
endif.
append down_2.
endloop.
‎2008 Jul 16 1:35 PM
Yes!
If I add text also previous CALL METHOD cl_abap_string_utilities=>c2str_preserving_blanks works.
thanks a lot,
have a nice day,
Nadja
‎2008 Jul 16 1:46 PM