Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

about unicode program

Former Member
0 Likes
1,194

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

1 ACCEPTED SOLUTION
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
1,138

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

10 REPLIES 10
Read only

Former Member
0 Likes
1,138

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.

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
1,139

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

Read only

0 Likes
1,138

i am programing on a unicode system

please consider that

Read only

Former Member
0 Likes
1,138

hi Kevin.

can u paste the structure of table A.

regards,

Navneeth K.

Read only

0 Likes
1,138

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.

Read only

0 Likes
1,138

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.

Read only

0 Likes
1,138

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

Read only

0 Likes
1,138

Who have met such case?

The source string is including Chinese.

So the result is some fields are slip off

thank u

Read only

0 Likes
1,138

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 ).

Read only

Former Member
0 Likes
1,138

answered by myself