‎2009 Sep 15 3:45 PM
Hello,
we have a Zprogram copied fron non unicode system to unicode system which will create the XML files and the data stream will be in binary mode,
in NON-UNICODE system it is working finr but in UNICODE system it is not comming as binary data strem can some one help on this,
DATA STREAM IN OLD SYSTEM WHICH IS CORRECT
M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAA EAAAaAAAAAEAAAD+////AAAAAAAAAAD///////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////9 ////awAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8A AAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAA AB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACQAAAAlAAAAJgAAACcAAAAoAAAAKQAAACoAAAArAAAA LAAAAC0AAAAuAAAALwAAADAAAAAxAAAAMgAAADMAAAA0AAAANQAAADYAAAA3AAAAOAAAADkAAAA6
DATA STREAM IN NEW SYSTEM,
D0CF11E0A1B11AE1000000000000000000000000000000003E000300FEFF0900060000000000000000000000010000000100000000000000001000001B00000001000000FEFFFFFF0000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000
CAN SOME ON HELP WHAT NEEDS TO BE DONE
THANKS
‎2009 Sep 15 4:11 PM
Did you adapt this program so that it is unicode compliant?
how can we help you if you don't post the code (only post the concerned code of course).
‎2009 Sep 15 4:17 PM
here is the code how do we adpat to unicode,
MODULE user_command_0003 INPUT.
CASE ok_code.
WHEN 'ATT_UPLOAD'.
DATA: BEGIN OF hex_record,
myhex(1024) TYPE x,
END OF hex_record.
DATA: lw_fname TYPE string,
*{ REPLACE SPDK904979 1
tab LIKE hex_record OCCURS 1 WITH HEADER LINE,
tab like OCS_F_DATA occurs 1 with header line,
begin of tab occurs 0,
data(255) type x,
end of tab,
*} REPLACE
lw_lines TYPE sy-index,
file_ref TYPE REF TO cl_gui_frontend_services,
lw_filesize TYPE i.
*--Get data.
CHECK rlgrap-filename IS NOT INITIAL.
READ TABLE gt_att_alv INTO gw_att_alv
WITH KEY filename = rlgrap-filename.
IF sy-subrc EQ 0.
MESSAGE e007.
ENDIF.
lw_fname = rlgrap-filename.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lw_fname
filetype = 'BIN'
TABLES
data_tab = tab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc = '13'.
MESSAGE e026 WITH
'The access to the file was denied!'
' Please close the file if you have it opened'
' and try again.'.
ENDIF.
IF sy-subrc = '5'.
MESSAGE e026 WITH
'Invalid file type!'
' Please try again with a different file.'.
ENDIF.
*--Insure that the file has data (not empty) "DR1K913055
IF tab[] IS INITIAL. "DR1K913094
MESSAGE e026 WITH "DR1K913055
'The file failed to upload correctly.' "DR1K913055
' Please try again.'. "DR1K913055
ENDIF. "DR1K913055
*--Get file size
CREATE OBJECT file_ref.
CALL METHOD file_ref->file_get_size
EXPORTING
file_name = lw_fname
IMPORTING
file_size = lw_filesize
EXCEPTIONS
file_get_size_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
ENDIF.
FREE file_ref.
**--Calculate the file size limit
ADD lw_filesize TO gw_attachment_limit.
IF gw_attachment_limit GT gc_attachment_limit.
MESSAGE e008.
ENDIF.
*--Get file properties
DATA:
l_file TYPE string,
l_path TYPE string,
l_file_parts TYPE STANDARD TABLE OF string,
l_count TYPE i,
l_mime_type TYPE mimetypes-type,
l_extension TYPE mimetypes-extension.
PERFORM split_path
USING
lw_fname l_path l_file.
SPLIT l_file AT '.' INTO l_file l_extension.
*--Get mimetype
CALL FUNCTION 'SDOK_MIMETYPE_GET'
EXPORTING
extension = l_extension
x_use_local_registry = 'X'
IMPORTING
mimetype = l_mime_type.
*--Append the attachment data to the attachment itab
CLEAR gw_attachment_data.
lw_lines = LINES( gt_attachment_data ).
gw_attachment_data-att_index = lw_lines + 1.
gw_attachment_data-name = l_file.
gw_attachment_data-filetype = l_mime_type.
gw_attachment_data-fileextn = l_extension.
LOOP AT tab.
*{ REPLACE SPDK904979 2
CONCATENATE gw_attachment_data-datastream tab-myhex
CONCATENATE gw_attachment_data-datastream tab-data
*} REPLACE
INTO gw_attachment_data-datastream IN BYTE MODE.
ENDLOOP.
APPEND gw_attachment_data TO gt_attachment_data.
*--Append file information
gw_att_alv-filename = rlgrap-filename.
gw_att_alv-filetype = l_mime_type.
gw_att_alv-fileext = l_extension.
gw_att_alv-filesize = lw_filesize.
APPEND gw_att_alv TO gt_att_alv.
ENDCASE.
ENDMODULE. " USER_COMMAND_0003 INPUT
DATA: u_zpropay_item TYPE STANDARD TABLE OF zpropay_cpay,
uw_zpropay_item LIKE LINE OF u_zpropay_item.
DATA: u_zpropay_wfstat TYPE STANDARD TABLE OF zpropay_wfstat,
uw_zpropay_wfstat LIKE LINE OF u_zpropay_wfstat.
DATA lw_reb_payment_lines LIKE LINE OF gt_reb_payment_lines.
DATA lw_exp_payment_lines LIKE LINE OF gt_exp_payment_lines.
DATA lw_ipay_payment_lines LIKE LINE OF gt_icomp_payment_lines.
DATA lw_gl_lines LIKE LINE OF gt_gl_lines.
DATA lw_wfstat_lines LIKE LINE OF gt_wfstat_lines.
DATA lw_commit_flag TYPE cdchngind.
CLASS cl_ai_factory DEFINITION LOAD.
DATA: l_controller TYPE REF TO if_ai_posting_controller.
*--Transaction data
DATA:
lcl_sapto_esker_class TYPE REF TO zcl_co_mi_sape_pprout,
lcl_sapto_esker_data TYPE zcl_mt_sape_pprto_esker.
*--Attachment data
DATA:
lcl_sapto_esker_class_att TYPE REF TO zcl_co_mi_sape_pprout_attach,
lcl_sapto_esker_attach TYPE zcl_mt_sap_epprto_esker_attach.
DATA: l_attachment TYPE REF TO if_ai_attachment,
lt_attach TYPE prx_attach.
CASE ip_activity.
WHEN '01'.
*
**--Set the transaction Header.
CALL METHOD me->set_header
EXPORTING
event_type = ip_event_type.
*--Update header
MOVE-CORRESPONDING gw_header TO u_zpropay_hdr.
MODIFY zpropay_hdr FROM u_zpropay_hdr.
MOVE gw_header-trans_id TO ep_event_id.
*--Update items
IF sy-subrc EQ 0.
IF ( NOT gt_reb_payment_lines[] IS INITIAL ) OR
( NOT gt_exp_payment_lines[] IS INITIAL ) OR
( NOT gt_gl_lines[] IS INITIAL ) OR
( NOT gt_icomp_payment_lines[] IS INITIAL ).
*--Rebate Lines
REFRESH u_zpropay_item.
LOOP AT gt_reb_payment_lines INTO lw_reb_payment_lines.
CLEAR uw_zpropay_item.
MOVE-CORRESPONDING lw_reb_payment_lines TO uw_zpropay_item.
APPEND uw_zpropay_item TO u_zpropay_item.
ENDLOOP.
*--G/L Lines
LOOP AT gt_gl_lines INTO lw_gl_lines.
CLEAR uw_zpropay_item.
MOVE-CORRESPONDING lw_gl_lines TO uw_zpropay_item.
APPEND uw_zpropay_item TO u_zpropay_item.
ENDLOOP.
*--Expense Lines
LOOP AT gt_exp_payment_lines INTO lw_exp_payment_lines.
CLEAR uw_zpropay_item.
MOVE-CORRESPONDING lw_exp_payment_lines TO uw_zpropay_item.
APPEND uw_zpropay_item TO u_zpropay_item.
ENDLOOP.
*--Inter-Company Lines
LOOP AT gt_icomp_payment_lines INTO lw_ipay_payment_lines.
CLEAR uw_zpropay_item.
MOVE-CORRESPONDING lw_ipay_payment_lines TO uw_zpropay_item.
APPEND uw_zpropay_item TO u_zpropay_item.
ENDLOOP.
MODIFY zpropay_cpay FROM TABLE u_zpropay_item.
ENDIF.
*--Workflow Status
IF NOT gt_wfstat_lines[] IS INITIAL.
REFRESH u_zpropay_wfstat.
LOOP AT gt_wfstat_lines INTO lw_wfstat_lines.
CLEAR uw_zpropay_wfstat.
MOVE-CORRESPONDING lw_wfstat_lines TO uw_zpropay_wfstat.
APPEND uw_zpropay_wfstat TO u_zpropay_wfstat.
ENDLOOP.
MODIFY zpropay_wfstat FROM TABLE u_zpropay_wfstat.
ENDIF.
ep_return_code = 0.
*--Call function in update task
IF gw_trans_mode = '01'.
lw_commit_flag = 'I'.
ELSEIF gw_trans_mode = '02'.
lw_commit_flag = 'U'.
ENDIF.
CALL FUNCTION 'ZPROPAY_DB_SAVE'
IN UPDATE TASK
EXPORTING
trans_id = gw_header-trans_id
commit_flag = lw_commit_flag
header = gw_header
TABLES
item = u_zpropay_item
wfstat = u_zpropay_wfstat.
*----
IF sy-subrc EQ 0.
ep_return_code = 0.
COMMIT WORK.
ELSE.
ep_return_code = 4.
ENDIF.
ELSE.
ep_return_code = 4.
ENDIF.
*--Return Code
IF ep_return_code = 0.
IF ip_event_type = 'A' OR ip_event_type = 'F'.
*--Move Header values
MOVE gw_proxy_header TO lcl_sapto_esker_data-mt_sape_pprto_esker-header.
*--Move Item Values
MOVE gw_proxy_item TO lcl_sapto_esker_data-mt_sape_pprto_esker-item.
*--Set approver details.
MOVE:gw_proxy_wf_detail TO lcl_sapto_esker_data-mt_sape_pprto_esker-wf_detail.
*--Move Attachment Details.
MOVE gw_attach_comments TO lcl_sapto_esker_data-mt_sape_pprto_esker-attachments-comments.
MOVE gw_proxy_att_detail TO lcl_sapto_esker_data-mt_sape_pprto_esker-attachments-unit.
*--Call proxy to send data.
l_controller = cl_ai_factory=>create_controller( ).
CREATE OBJECT lcl_sapto_esker_class.
TRY.
CALL METHOD lcl_sapto_esker_class->execute_asynchronous
EXPORTING
output = lcl_sapto_esker_data.
CATCH cx_ai_system_fault .
CATCH cx_ai_application_fault .
ENDTRY.
COMMIT WORK.
*break shankaa.
**--Call proxy to send the attachments
DATA lw_attachment_list TYPE zst_propay_attachment.
DATA lw_proxy_att_detail LIKE LINE OF gw_proxy_att_detail.
*
LOOP AT gt_attachments INTO lw_attachment_list.
REFRESH: lt_attach.
CLEAR: lcl_sapto_esker_attach.
FREE: l_attachment, l_controller, lcl_sapto_esker_class_att.
*
READ TABLE gw_proxy_att_detail INTO lw_proxy_att_detail INDEX sy-tabix.
APPEND lw_proxy_att_detail TO
lcl_sapto_esker_attach-mt_sap_epprto_esker_attach-attachments-name.
*
TRY.
l_attachment =
cl_ai_factory=>create_attachment_from_binary(
p_data = lw_attachment_list-datastream
p_type = lw_attachment_list-filetype
p_name = lw_attachment_list-fileextn ).
CATCH cx_ai_system_fault .
CATCH cx_ai_application_fault .
ENDTRY.
APPEND l_attachment TO lt_attach.
**--
l_controller = cl_ai_factory=>create_controller( ).
l_controller->set_attachments( lt_attach ).
**--
CREATE OBJECT lcl_sapto_esker_class_att.
TRY.
CALL METHOD lcl_sapto_esker_class_att->execute_asynchronous
EXPORTING
controller = l_controller
output = lcl_sapto_esker_attach.
COMMIT WORK.
CATCH cx_ai_system_fault .
CATCH cx_ai_application_fault .
ENDTRY.
ENDLOOP.
ENDIF.
ENDIF.
WHEN '02'.
**--Workflow Status
IF NOT gt_wfstat_lines[] IS INITIAL.
REFRESH u_zpropay_wfstat.
LOOP AT gt_wfstat_lines INTO lw_wfstat_lines.
CLEAR uw_zpropay_wfstat.
MOVE-CORRESPONDING lw_wfstat_lines TO uw_zpropay_wfstat.
APPEND uw_zpropay_wfstat TO u_zpropay_wfstat.
ENDLOOP.
MODIFY zpropay_wfstat FROM TABLE u_zpropay_wfstat.
ENDIF.
*
IF sy-subrc EQ 0.
ep_return_code = 0.
COMMIT WORK.
ENDIF.
ENDCASE.
IF lcl_sapto_esker_class IS NOT INITIAL.
FREE lcl_sapto_esker_class.
ENDIF.
thanks,
‎2009 Sep 15 4:35 PM
you don't format correctly your posts, please insert "newline" every 100 characters for very wide data, avoid using or
for very wide data, or cut it. Use preview also before posting.
To convert to unicode, go to program attributes, check the "unicode" flag, and execute a syntax check.
What I quickly see is that you read the text file in BIN mode, while your system is probably unicode, how do you convert from binary to unicode? Just replace BIN with ASC. Be sure that your text file is unicode or if it needs a code page conversion.
Edited by: Sandra Rossi on Sep 15, 2009 5:36 PM. Added: insert "newline" every 100 characters for very wide data