‎2008 Apr 21 2:57 PM
All,
I have requirement to write common function module to convert data from itab --> string and string --> itab in unicode environment. I am planning to use class cl_abap_container_utilities and methods
1). FILL_CONTAINER_C
2). READ_CONTAINER_C
The following is the function module for string --> itab
function z_test_unicode.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(XINPUT) TYPE STRING OPTIONAL
*" EXPORTING
*" REFERENCE(XOUTPUT) TYPE STANDARD TABLE
*"----------------------------------------------------------------------
class cl_abap_container_utilities definition load.
call method cl_abap_container_utilities=>read_container_c
exporting
im_container = xinput
importing
ex_value = xoutput
exceptions
illegal_parameter_type = 1
others = 2.
endfunction.
and i am calling this in the program
report zaRs
no standard page heading
line-size 255.
data: begin of itab occurs 0,
detail(2047) type c,
end of itab.
data: begin of i_yatt occurs 0.
data: mandt like sy-mandt.
data: docno like vbak-vbeln.
data: end of i_yatt.
move '0301000' to itab-detail.
append itab.
loop at itab.
call function 'Z_TEST_UNICODE'
EXPORTING
XINPUT = itab-detail
IMPORTING
XOUTPUT = i_yatt.
append i_yatt.
endloop.
But i am getting DUMP
"Type conflict when calling a function module."
How to overcome this , i need to work with all input length and all xoutput internal tables?
Any info?
a®
‎2008 Apr 21 7:03 PM
‎2008 Apr 21 7:30 PM
inside the loop you pass the itab-detail value to one string variable and pass it to function module.
‎2008 Apr 21 7:46 PM
Alagu,
It not nothing related to loop. real problem is type conflict error in INPUT and OUTPUT . My input parameter always not of string. length varied every instance.
and the OUTPUT internal table is also not static it will get differed on each call
a®
‎2008 Apr 21 7:50 PM
Hi a®s,
i tried its mainly of type conflict with input and output. check my previous code.
Regards
Muthu
‎2008 Apr 21 7:49 PM
Try like this
REPORT ZTEST_FUNCTION
*report zaRs
no standard page heading
line-size 255.
data: begin of itab occurs 0,
detail(2047) type c,
end of itab.
types: begin of w_yatt ,
mandt like sy-mandt,
docno like vbak-vbeln,
end of w_yatt.
data: i_yatt type table of w_yatt,
wa_yatt type w_yatt.
move '0301000' to itab-detail.
append itab.
data v_string type string.
loop at itab.
clear v_string.
v_string = itab-detail.
break-point.
call function 'ZTEST_FM'
EXPORTING
XINPUT = v_string
IMPORTING
XOUTPUT = i_yatt.
append wa_yatt to i_yatt.
endloop.
‎2008 Apr 21 7:53 PM
as XINPUT is type string, why dont you make itab-detail also of type string ?
Isn't that the reason why tis giving a dump ?
‎2008 Apr 21 8:01 PM
Sugamol,
I cannot declare the ITAB-DETAIL as string in every code . and also i cannot able to do like Alagu asked for
move data v_string type string.
This is where i stuck.
a®
‎2008 Apr 21 8:12 PM
Do like this.
data v_string type string.
loop at itab.
clear v_string.
v_string = itab-detail. " move your detail value to v_string
call function 'ZTEST_FM'
EXPORTING
XINPUT = v_string
IMPORTING
XOUTPUT = i_yatt.
Its working for me. check again
‎2008 Apr 21 8:08 PM
In you function, make the importing parameter without any type, and then move the importing parameter to a STRING type field internally.
function z_test_unicode.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(XINPUT)
*" EXPORTING
*" REFERENCE(XOUTPUT) TYPE STANDARD TABLE
*"----------------------------------------------------------------------
data: lv_string type string.
lv_string = xinput.
class cl_abap_container_utilities definition load.
call method cl_abap_container_utilities=>read_container_c
exporting
im_container = lv_string "<--- Change here
importing
ex_value = xoutput
exceptions
illegal_parameter_type = 1
others = 2.
endfunction.Regards,
Rich Heilman
‎2008 Apr 21 8:17 PM
Oh, and also, if XOUTPUT is typed as a STANDARD TABLE, then this is wrong as well....
loop at itab.
call function 'Z_TEST_UNICODE'
EXPORTING
XINPUT = itab-detail
IMPORTING
XOUTPUT = i_yatt. "<-- this represents the header line, not the table
append i_yatt.
endloop.So you should actually have a sepearete workaread for you header line, but if you don't want to do that, then you need brakets here I think.
loop at itab.
call function 'Z_TEST_UNICODE'
EXPORTING
XINPUT = itab-detail
IMPORTING
XOUTPUT = i_yatt[]. "<--Brakets to specify the table body
append i_yatt. "<-- and you wouldn't need this
endloop.Also, I'm not 100% sure that the STATIC method within the function will actually bring back a table, hence making all this invalid as well..
Regards,
Rich Heilman
‎2008 Apr 21 8:19 PM
Yes correct. either you need to declare seperate work area or brackets you need to add. and no need for append there.
‎2008 Apr 21 8:45 PM
Rich you are right.
after the cl_abap_container_utilities=>read_container_c system is not returning the value.
May be i need to look some other alternative.
a®
‎2008 Apr 23 4:50 PM