‎2006 Dec 13 5:10 AM
Hi,
We've created a function module and it is their requirement to have a default value for the tables in the FM? How do we do this? Cause if it is just an import parameter there is a column for default values, but for tables there is none. How do we code this?
Thanks.
‎2006 Dec 13 5:15 AM
Hi,
In the start of the function module you can check the table and set your default values.
FUNCTION ...
"Check whether the table is initial
"Do not override the value passed by the user
IF itab[] IS INITIAL.
itab-field = 'DEFAULT'. "Set your default value
APPEND itab.
ENDIF.
- - - Your functionality
...
Regards
Wenceslaus.
‎2006 Dec 13 5:15 AM
Hi,
In the start of the function module you can check the table and set your default values.
FUNCTION ...
"Check whether the table is initial
"Do not override the value passed by the user
IF itab[] IS INITIAL.
itab-field = 'DEFAULT'. "Set your default value
APPEND itab.
ENDIF.
- - - Your functionality
...
Regards
Wenceslaus.
‎2006 Dec 13 5:20 AM
Thanks Wenceslaus.
Would your suggestion happen after the user has entered some data?
What we want to happen is when we execute the FM (like in SE37) the values will already be there by default even before the user enters some data. Is this possible?
Thanks again.
‎2006 Dec 13 5:23 AM
Hi Rous,
That's why I had checked with IS INITIAL.
Just check the table whether it is empty or not. If it is empty set the default values.
But however this approach will not show the default values for the tables parameter. The default values are set programmatically.
Regards
Wenceslaus
Message was edited by: Wenceslaus
‎2006 Dec 13 5:27 AM
Ok, then how are the default values set programmatically? Is there a way?
Thanks again.
‎2006 Dec 13 5:33 AM
Hi Rous,
I don't know whether you have understood my previous posts.
See, there is no straightforward approach to set the default values for TABLES parameters.
You could only possibly check whether the parameter is empty in your FM, and if it is empty set the preferred default value in the parameter, which is illustrated in the code,
IF itab[] IS INITIAL.
itab-field = 'DEF_VALUE'.
APPEND itab.
ENDIF.
Regards
Wenceslaus.
‎2006 Dec 13 5:40 AM
Hi Rous,
You can use 'Test Data Directoy' to save the default value for parameter and tables.
Regards,
Hendy.
‎2006 Dec 13 5:20 AM
Hi Rous ,
I do not feel there is a way to default data in an internal table .
At alternative is that in the FM you check if the value of the passed internal table i intial or not . If it is initial the appned your default values.
Regards
Arun
‎2006 Dec 13 5:28 AM
hi,
check whether the table is initial and then assign the table's field as default.
check this link.
hope this helps!!!
Message was edited by:
Gayatri M