2008 Mar 18 11:47 PM
Hello Friends
I am desperately trying to findout how to send a variable length string from XI and save it in a table.
However, SAP Note Number: 953823 says that STRING is not supported in FM but the work around it suggests is as follows:
========================================================
The only work around for this is :
To wrap the Function module used in function control with the custom function module,which substitutes the STRING parameter with CHAR datatype.
========================================================
But the problem is that for CHAR datatype you have to give the field length, the requirement I have is to send a VARIABLE LENGTH data.
Could some one help me in understanding how this can be achieved?
Thanks a lot in advance
Ram
2008 Mar 20 12:56 PM
You have to find out what the maximum length is and use that in the declaration.
Regards, Rob.
2008 Mar 20 1:14 PM
Interesting question. Maybe I don't completely understand. When you say store it in a table, do you mean a database table or an itab?
I seem to be able to pass a string to a FM. Am I doing something wrong?
I created a type of string called "ZTYSTR".
I then created this FM.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(I_STR) TYPE ZTYSTR
*"----------------------------------------------------------------------
DATA:
l_string type string.
l_string = i_str.
ENDFUNCTION.
Then I call the function module as such.
REPORT zz_temp.
DATA: g_str TYPE string VALUE 'Hello World'.
CALL FUNCTION 'Z_TEMP'
EXPORTING
i_str = g_str.
Debugging the FM, it says that both the parameter and local variable are of type string.
2008 Mar 20 1:48 PM
Hi Jerry
Thanks for taking time to create an example function. I appreciate it.
But the main problem that arises is when you try to save this string in a database table. That is when it gives an error message as follows,
When I try to activate the bapi it gives an error message that says
<DATABASE_TABLE> must be a flat structure. You cannot use internal tables,
strings, references, or structures as components.
In your example, you are just sending the String back. I tried and it worked. But when I enter the code to update my database table (in my BAPI) and try to activate, that is when I see this error message.
If you have any other suggestions, please let me know.
Thanks a lot
Ram
Edited by: Ram Prasad on Mar 20, 2008 2:48 PM
2008 Mar 20 1:55 PM
A database table has fixed columns, unless you use a type of RAWSTRING. In Oracle, that's converted to a type BLOB (binary large object).
Please see table REPOSRC for an example of that. Maybe that would allow you to store the string. Storing it may be easy enough, but using RAWSTRINGS probably aren't very convenient. You might be better off using a very large CHAR field.
2008 Mar 20 1:59 PM
Jerry,
Thanks for your quick response.
yes I tried using VARILRAW (that they have used in a table called VARI).
However, eventhough it is storing the string successfully, it is storing it in Binary format and I have problems in converting it back to string again.
Any ideas on this?
Thanks a lot
Ram
2008 Mar 20 2:24 PM
Thanks a lot Jerry,
I tried your suggestion of using 'RAWSTRINGS', but again the same problem in updating the table from BAPI or a program from SE38. I get the following error
'<DATABASE_TABLE> must be a flat structure. You cannot use internal tables,
strings, references, or structures as components.'
Any suggestions will be highly appreciated.
Tks
Ram