2006 May 02 12:55 PM
Hi,
I'am downloading a table to a txt file with gui_download and the table have many fields.i would like to know if there is anyway to write, for example, half of the fields in one line of the file, and the other half in other line.i something like this:
table:
1234 peridb 2847646 736473 7256463 726456 hwfyegfu 727646
file - i have this:
1234 peridb 2847646 736473 7256463 726456 hwfyegfu 727646
file - i want this:
1234 peridb 2847646 736473 7256463
726456 hwfyegfu 727646
Hi,
I'am downloading a table to a txt file with gui_download and the table have many fields.i would like to know if there is anyway to write, for example, half of the fields in one line of the file, and the other half in other line.i something like this:
table:
1234 peridb 2847646 736473 7256463 726456 hwfyegfu 727646
file - i have this:
1234 peridb 2847646 736473 7256463 726456 hwfyegfu 727646
file - i want this:
1234 peridb 2847646 736473 7256463
726456 hwfyegfu 727646
2006 May 02 1:11 PM
Try this:
data: begin of Original_Tbl occurs 0,
OrigFieldStr(100),
end of Original_Tbl.
data: begin of New_Tbl occurs 0,
NewFieldStr(50),
end of New_Tbl.
loop at Original_Tab.
move Original_Tab+0(49) to New_Tbl-NewFieldStr.
append New_Tbl.
move Original_Tab+50(49) to New_Tbl-NewFieldStr.
append New_Tbl.
endloop.
Now use GUI_DOWNLOAD and push down the New_Tbl internal instead - which is now split.
Please reward points for helpful answers.
2006 May 02 1:24 PM
Hi
Yes! But you should know where you have to break the file:
LOOP AT T_FILE.
LEN = STRLEN( T_FILE ).
LEN = LEN / 2.
WA = T_FILE(LEN).
TRANSFER WA TO FILE.
WA = T_FILE+LEN.
TRANSFER WA TO FILE.
ENDLOOP.
Max
2006 May 02 1:39 PM
Hi,
Here I am assuming that the data is originally in the internal table itab with five variables of data type string ( You can have more varibles also as per your requirement ) .
Then you can use this :
Data : str type string.
data: begin of itab1 occurs 0,
field type str.
end of New_Tbl.
loop at itab.
concatenate <itab-fld1> <itab-fld2> <itab-fld3> <itab-fld4> <itab-fld5> into str.
endloop.
itab1-field = str+0(49).
append itab1.
itab1-field = str+50.
append itab1.
Now you just can use the fm GUI_Download and pass itab1 as the internal table.
Thanks and Regards,
Kunal.
Message was edited by: Kunal Kumar
2006 May 02 1:51 PM
Hi Ricardo,
Try using the FM "G_SPLIT_LINE".
We usually end up writing a big code for splitting the string at 72 characters. Instead, the function module G_SPLIT_LINE can be used to split the string to 72 characters. The resultant table can be used for directly updating the standard text. Use the sample code below:
CLEAR str_len .
str_len = strlen( w_string ) .
IF str_len GT split_len .
CALL FUNCTION 'G_SPLIT_LINE'
EXPORTING
input_line = w_string
TABLES
export_lines = split_tab.
* Updating the internal table of structure TLINE
LOOP AT split_tab .
MOVE split_tab-txt_line TO txt_tab-tdline .
APPEND txt_tab .
ENDLOOP .
ELSE.
.........
ENDIF.Cheers
VJ
2006 May 02 1:58 PM
Hi ,
You straight away try out this code .
Here zkunal3 is a database tabvle with 3 fields fanme, lname and place.
Start of program.
REPORT ZKUN_FILE10 .
data str type string.
tables : zkunal3.
data : begin of itab occurs 0.
include structure zkunal3.
data : end of itab.
select * from zkunal3 into table itab up to 1 rows.
loop at itab.
concatenate itab-fname itab-lname itab-place into str separated by space
.
endloop.
data : begin of itab1 occurs 0,
fld type str,
end of itab1.
itab1-fld = str+0(10).
append itab1.
itab1-fld = str+10.
append itab1.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = 'C:\test.doc'
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
IMPORTING
FILELENGTH =
tables
data_tab = itab1
FIELDNAMES =
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 <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
End of program.
Regards,
Kunal.
2006 May 02 2:06 PM
Hi,
check out the following code.
loop at itab.
itab_final-field1 = itab-field1.
itab_final-field2 = itab-field2.
append itab_final.
clear itab_final.
itab_final-field1 = itab-field3.
itab_final-field2 = itab-field4.
append itab_final.
clear itab_final.
endloop.
Now u can pass itab_final to the function module.
Regards,
Neelima.
2006 May 02 2:41 PM
Ricardo,
Have we resolved your issue?
If so, please reward points accordingly and close the thread.
Thanks!
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |