08-17-2006 8:21 AM
I'm trying to pass a field symbol to a subroutine.How to declare the field symbol in parameter interface?
08-17-2006 8:35 AM
Hey,
See the sample code below
REPORT zkar_001.
FIELD-SYMBOLS: <fs> TYPE ANY.
PARAMETERS: test(2) TYPE c.
ASSIGN test TO <fs>.
PERFORM write USING <fs>.
&----
*& Form write
----
FORM write USING p_fs TYPE any.
WRITE 😕 p_fs.
ENDFORM. " write
-Kiran
08-17-2006 8:35 AM
Hey,
See the sample code below
REPORT zkar_001.
FIELD-SYMBOLS: <fs> TYPE ANY.
PARAMETERS: test(2) TYPE c.
ASSIGN test TO <fs>.
PERFORM write USING <fs>.
&----
*& Form write
----
FORM write USING p_fs TYPE any.
WRITE 😕 p_fs.
ENDFORM. " write
-Kiran
08-17-2006 8:49 AM
Kiran, thx for your reply.
But what i'm really want to do is to define the <fs> outside the subroutine and assign value inside. And the program may be somgthing like,
REPORT zkar_001.
FIELD-SYMBOLS: <fs> TYPE ANY.
PARAMETERS: test(2) TYPE c.
PERFORM write USING <fs>.
&----
*& Form write
----
FORM write USING p_fs TYPE any.
<b>ASSIGN test TO p_fs.</b>
WRITE 😕 p_fs.
ENDFORM. " write
When activating, an error message of <b>"p_fs is not defined as a field symbol"</b> will pop up.
08-17-2006 8:55 AM
I did get the error. I am not sure how to define the field symbol to meet your requirement. Well, if you have defined <FS> as a global variable then you can directly use it inside the subroutine. See code below.
REPORT zkar_001.
FIELD-SYMBOLS: <fs> TYPE c.
PARAMETERS: test(2) TYPE c.
PERFORM write.
&----
*& Form write
----
FORM write.
ASSIGN test TO <fs>.
WRITE 😕 <fs>.
ENDFORM. " write
-Kiran
*Please mark useful answers
08-17-2006 9:11 AM
Before passing the FS to the perform, assign a value to it.
REPORT zkar_001.
FIELD-SYMBOLS: <fs> TYPE ANY.
PARAMETERS: test(2) TYPE c.
***********
assign test to <FS>.
***********
PERFORM write USING <fs>.
&----
*& Form write
----
FORM write USING p_fs TYPE any.
*ASSIGN test TO p_fs.
WRITE 😕 p_fs.
ENDFORM. " write
08-17-2006 9:14 AM
Hello Cindy,
If you are not passing any value to the <fs>, then why do you want to use it as a paramter on the perform.
You could create the field symbol inside the form, and assign value and use it within the perform.
Please explain why you want to pass a FS without any value assigned to it.
08-17-2006 9:16 AM
Hi,
I have a suggesstion ... you generally pass actual parameters to your subroutine in order to manipulate values of the interface. If this being the case, in your scenario you can assign the field-symbol globally and you can pass the parameters directly. After assignment, field-symbols always address to the assigned varaible.
Reward if helpful.
Regards