05-27-2005 3:48 AM
Many thanks for your help.
Could you clarify Step3 & 4 (refer as below Raja's post) since 'strlen' is not working for xstring (rawstring)?
And how to reverse the 'CONCATENATE' process to store xstring to itab ? Rawstring seems take maximum length of 10,880 char and we have to compress our big file at first.
Have a nice weekend!
Waylan
-
Here is the step by step approach.
1. read the raw string from the table.
2. unzip using
CALL METHOD cl_abap_gzip=>decompress_binary EXPORTING gzip_in = <compressed binary string > IMPORTING raw_out = <decompressed binary string>.
3. find the length of the xstring - strlen( <variable> )
4. move the decomressed xstring to a itab
5. use GUI_download , passing file size and setting the file type to BIN
Hope this helps.
Regards
Raja
05-27-2005 8:59 AM
Any clue to store rawstring to internal table ?
strlen is not available for rawstring as well.
Thanks,
05-27-2005 8:59 AM
Any clue to store rawstring to internal table ?
strlen is not available for rawstring as well.
Thanks,
05-27-2005 5:03 PM
Hi Waylan,
you should use xstrlen in place of strlen to get the length of xstring.
By the way , you can check the program below that converts a text file --> xtring -->binary --->text file again and then downloads on your PC as 'C:\stringtest.txt'.
REPORT ZTEST_XSTRING .
TYPES : BEGIN OF ty_text,
text_field(1000) TYPE C,
END OF ty_text.
TYPES : BEGIN OF ty_binary,
BINARY_field(1000) TYPE C,
END OF ty_binary.
DATA : lv_xstring type XSTRING.
DATA : lt_binary type table of ty_binary with header line.
DATA : lt_text type table of ty_text with header line.
DATA : lt_text_out type table of ty_text with header line.
DATA : X_OUTFILE type string.
lt_text-text_field = 'Hello'.
append lt_text.
lt_text-text_field = 'Hi'.
append lt_text.
lt_text-text_field = 'How r u?'.
append lt_text.
CALL FUNCTION 'SCMS_TEXT_TO_XSTRING'
* EXPORTING
* FIRST_LINE = 0
* LAST_LINE = 0
* MIMETYPE = ' '
IMPORTING
BUFFER = lv_XSTRING
TABLES
TEXT_TAB = lt_text
EXCEPTIONS
FAILED = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = lv_XSTRING
* APPEND_TO_TABLE = ' '
* IMPORTING
* OUTPUT_LENGTH =
TABLES
BINARY_TAB = lt_binary
.
CALL FUNCTION 'SCMS_BINARY_TO_TEXT'
EXPORTING
INPUT_LENGTH = 100
* FIRST_LINE = 0
* LAST_LINE = 0
* APPEND_TO_TABLE = ' '
* MIMETYPE = ' '
WRAP_LINES = 'X'
* IMPORTING
* OUTPUT_LENGTH =
TABLES
BINARY_TAB = lt_binary
TEXT_TAB = lt_text_out
* EXCEPTIONS
* FAILED = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
X_OUTFILE = 'C:stringtest.txt'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = X_OUTFILE
FILETYPE = 'ASC'
TABLES
DATA_TAB = lt_text_out
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.
* Status of download
CASE SY-subrc.
WHEN 0.
MESSAGE I002(AQ) WITH
'www.rmtiwari.com webviewer:Code converted to HTML and downloaded as
' X_OUTFILE.
WHEN OTHERS.
* Upload unsuccessful - error message
MESSAGE ID SY-MSGID TYPE 'E' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDCASE.
05-28-2005 5:59 AM
Hi,
Sorry, it was weekend (thursdaty and friday), thus couldnt reply on time.
to compute the xstring length.
use xstrlen ( xstring ).
itab for storing the xstring.
data: begin of bin_tab ,
val type xstring ,
end of bin_tab .
now move the raw value which you read from the DB table into this table and use gui_download with file type 'BIN'.
Hope this is clear.
Regards
Raja
05-28-2005 8:22 AM
I don't think it will work that way.
You can't download Hexa value as a Binary. You need to first convert it to Binary.
Check my previous posting.
Thanks,
Ram
05-28-2005 8:30 AM
05-28-2005 9:31 AM
Oops...
So you guys are discussing this for quite some time and I just jumped into it...
Ok..in that case it might work
Sorry, but not sure. I mean, the itab that you declared has a xstring ( Hexa String ) as the component. And then it is being downloaded as Binary.
Does that work?
Cheers,
Ram
05-30-2005 2:56 AM
Thanks for your timely response.
We already solved it ourselves. Xstring works perfectly.
Best regards,
Waylan
05-30-2005 5:42 AM