‎2007 Jun 25 9:52 AM
hello expert:
I am using CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
to read local file into a internal table 'A'.
and i have a B structure
data: begin of g_file_item_rec,
stype type bbseg-stype,"Batch Input Interface Record Type
newbs type bbseg-newbs,"Posting Key for the Next Line Item
newko type bbseg-newko,"Account or Matchcode for Next Line Item
wrbtr type bbseg-wrbtr,"Amount in document currency
dmbtr type bbseg-dmbtr,"Amount in local currency
fwbas type bbseg-fwbas, "Tax Base Amount in Document Currency
hwbas type bbseg-hwbas, "Tax Base Amount in Local Currency
mwskz type bbseg-mwskz,"Tax on Sales/Purchases Code
zuonr type bbseg-zuonr,"Assignment number
sgtxt type bbseg-sgtxt,"Item Text
fdlev type bbseg-fdlev,"Planning level
zfbdt type bbseg-zfbdt,"Baseline Date
zterm type bbseg-zterm,"Terms of payment key
zlsch type bbseg-zlsch,"Payment Method
zlspr type bbseg-zlspr,"Payment Block Key
qsskz_i type bbseg-qsskz,"Withholding Tax Code for Invoice
qsskz_p type bbseg-qsskz,"Withholding Tax Code for Payment
kostl type bbseg-kostl,"Cost Center
aufnr type bbseg-aufnr,"Order Number
prctr type bbseg-prctr,"Profit Center
vbund type bbseg-vbund,"Company ID of Trading Partner
newum like bbseg-newum, "Spl G/L Indicator for Next Line Item
newbw like bbseg-newbw, "asset transaction type
gsber like bbseg-gsber, "business area
hbkid like bbseg-hbkid, "house bank
for extended withholding tax at invoice
witht_i like bwith-witht, "withhold tax type
wt_qsshb_i like bwith-wt_qsshb, "withhold tax base amt in Doc Curry
wt_qsshh_i like bwith-wt_qsshh, "withhold tax base amt in Loc Curry
wt_qbuihb_i like bwith-wt_qbuihb, "withholding tax amt in Doc Curry
wt_qbuihh_i like bwith-wt_qbuihh, "withholding tax amt in Loc Curry
for extended withholding tax at payment
witht_p like bwith-witht, "withhold tax type
wt_qsshb_p like bwith-wt_qsshb, "withhold tax base amt in Doc Curry
wt_qsshh_p like bwith-wt_qsshh, "withhold tax base amt in Loc Curry
wt_qbuihb_p like bwith-wt_qbuihb, "withholding tax amt in Doc Curry
wt_qbuihh_p like bwith-wt_qbuihh, "withholding tax amt in Loc Curry
valut like bbseg-valut, "value date
bewar like bbseg-bewar, "consolidation transaction type
end of g_file_item_rec.
How can i copy A to B in unicode system.
thank you in advance
Kevin
‎2007 Jun 25 9:59 AM
Hi,
DATA: ITAB_A type table of A,
WA_A like line of ITAB_A,
ITAB_B type table of B,
WA_B like line of ITAB_B.
LOOP AT ITAB_A into WA_A.
MOVE-CORRESPONDING WA_A to WA_B.
APPEND WA_B to ITAB_B.
ENDLOOP.
Regards,
Sesh
‎2007 Jun 25 9:58 AM
hi Kevin,
If A and B are of same structure then u can very well write:
b[] = a[].
if they are of different structure then,
you have to create a work area for internal table b and move one by one from table a.
hope it solves your query.
regards,
Navneeth K.
‎2007 Jun 25 9:59 AM
Hi,
DATA: ITAB_A type table of A,
WA_A like line of ITAB_A,
ITAB_B type table of B,
WA_B like line of ITAB_B.
LOOP AT ITAB_A into WA_A.
MOVE-CORRESPONDING WA_A to WA_B.
APPEND WA_B to ITAB_B.
ENDLOOP.
Regards,
Sesh
‎2007 Jun 25 10:35 AM
‎2007 Jun 25 11:33 AM
hi Kevin.
can u paste the structure of table A.
regards,
Navneeth K.
‎2007 Jun 25 2:24 PM
data: t_rawfile(1000) occurs 0 with header line,
call function 'GUI_UPLOAD'
exporting
filename = l_pc_filename
filetype = 'ASC'
has_field_separator = ' '
tables
data_tab = t_rawfile
exceptions
file_open_error = 1
file_read_error = 2
others = 17.
loop at t_rawfile.
l_line = t_rawfile.
add 1 to l_file_row_no.
if l_line(1) = '1'.
l_runno = l_runno + 1.
g_file_hdr_rec = l_line.
clear t_doc_hdr.
move-corresponding g_file_hdr_rec to t_doc_hdr.
t_doc_hdr-runno = l_runno.
t_doc_hdr-file_row_no = l_file_row_no.
perform get_internal_format changing t_doc_hdr-runno.
t_doc_hdr-runno(01) = 'D'.
append t_doc_hdr.
elseif l_line(1) = '2'.
clear g_file_item_rec.
g_file_item_rec = l_line.
move-corresponding g_file_item_rec to t_doc_item.
t_doc_item-runno = t_doc_hdr-runno.
t_doc_item-file_row_no = l_file_row_no.
append t_doc_item.
else.
l_str = l_line.
condense l_str.
if not l_str is initial.
l_str = l_line.
write: at /3 'Unknown record type found:',
(70) l_str(1).
write: at /3 'Error record is: ',
(70) l_str.
write: at /3 'Read # as space in error record'.
perform stop_processing.
endif.
endif.
endloop.
‎2007 Jun 25 2:32 PM
hi kevin,
try by using Field-symbols....
data: begin of STRUC,
F1(3) type x,
F2(8) type p, F3(10) type c
end of STRUC,
CONTAINER(1000) type c.
field-symbols: <C_STRUC> type c.
assign STRUC to <C_STRUC> casting.
<C_STRUC> = CONTAINER.
or u can also use the FM SO_CHAR_TO_STRUCT.
regards,
priya.
‎2007 Jun 25 4:50 PM
Priya,
thank u very much.
I will try it tomorrow.
if okey. i will award points
Kevin
CALL METHOD cl_abap_container_utilities=>read_container_c
it also doesnot work in unicode system
Message was edited by:
Kevin Gao
Message was edited by:
Kevin Gao
‎2007 Jun 26 10:57 AM
Who have met such case?
The source string is including Chinese.
So the result is some fields are slip off
thank u
‎2007 Jul 06 2:04 AM
DATA:
my_dest TYPE rfcdest VALUE 'my_dest',
my_tab TYPE TABLE OF t100,
cp_tab TYPE nls_langu_cp_tab,
cc TYPE REF TO cl_nls_struc_container,
stru LIKE t100u.
FIELD-SYMBOLS <fs> TYPE t100.
Do the remote function call.
CALL FUNCTION 'MY_F' DESTINATION my_dest
TABLES
tab = my_tab.
Get the code page information.
CALL FUNCTION 'NLS_GET_LANGU_CP_TAB'
EXPORTING
destination = my_dest
TABLES
cp_tab = cp_tab.
Create an instance of the alignment correction class.
cc = cl_nls_struc_container=>create( cp_tab = cp_tab ).
Process contents of my_tab.
LOOP AT my_tab ASSIGNING <fs>.
Convert the container <fs>-text into the structure stru with
correct alignment, taking into account the language key <fs>-sprsl.
cc->cont_to_struc( EXPORTING langu = <fs>-sprsl
cont = <fs>-text
IMPORTING struc = stru ).
Continue processing stru ...
ENDLOOP.
If just the name of the structure (but not a structure variable) is available when the alignment correction is done, the class CL_NLS_STRUC_CONTAINER_SNAME can be used:
Create an instance of the alignment correction class;
needs the name of the structure.
cc = cl_nls_struc_container_sname=>create( cp_tab = cp_tab
struc_name = 'T100U' ).
Correct the alignment of the container <fs>-text,
taking into account the language key <fs>-sprsl.
DATA cont like t100-text.
cont = <fs>-text.
cc->cont_to_struc( EXPORTING langu = <fs>-sprsl
CHANGING cont = cont ).
In the most generic case, the lengths of the fields of the structure can be specified in an internal table and the class CL_NLS_STRUC_CONTAINER_OFFS is used:
DATA:
cc TYPE REF TO cl_nls_struc_container_offs,
len_tab TYPE nls_length_tab,
cont(31) TYPE c,
truncation_pos TYPE i.
Create an instance of the alignment correction class.
cc = cl_nls_struc_container_offs=>create( cp_tab = cp_tab ).
Register a structure.
APPEND 1 TO len_tab.
APPEND 10 TO len_tab.
APPEND 20 TO len_tab.
cc->register_struc( EXPORTING struc_name = 'STRUC1'
len_tab = len_tab ).
Register another structure.
REFRESH len_tab.
APPEND 3 TO len_tab.
APPEND 1 TO len_tab.
APPEND 15 TO len_tab.
cc->register_struc( EXPORTING struc_name = 'STRUC2'
len_tab = len_tab ).
... Get data into the container CONT ...
Correct the alignment of the container CONT,
taking into account the language key.
cc->cont_to_struc( EXPORTING langu = 'F'
struc_name = 'STRUC1'
IMPORTING truncation_pos = truncation_pos
CHANGING cont = cont ).
‎2007 Jul 06 2:05 AM