2008 Mar 06 4:46 AM
hi gurus,
i hav to make a fuction module .
the function module takes personnnel numbers as and give out recors of the personnel number,.
my question is if i have only one personnel number then i can use import parameter,
but here i have table for personnel number.
means i am taking the value of personnel number from selectio screen which look like this .
personnel from _______ to ________
so my selection would be
select*...
where pernr in personnel.
and
not pernr = personnel.
so how can i make this function module.
thanks regrads
point ll be surely rewarded.
anuj.
2008 Mar 06 4:56 AM
Hi,
In import parameters you can use two variables,one the low value and the other for the high value of the personal number.These values can be fetched from selection screen,using select-options low and high.
In select statement,you can use where condition between these two values.
Hope this will help you.
Regards
Shibin
Hi,
In import parameters you can use two variables,one the low value and the other for the high value of the personal number.These values can be fetched from selection screen,using select-options low and high.
In select statement,you can use where condition between these two values.
Hope this will help you.
Regards
Shibin
2008 Mar 06 4:55 AM
First option, you can have two personal_no in import parameter of the FM :
1. Personal_no_high
2. Personal_no_low.
( when calling this FM you need to passthe high value of personal no to Personal_no_high & low value to Personal_no_low)
In the source code of the FM,
create a range from those high and low value ,And use that range in the select query.
To create a range :
ranges: r_pernr for pernr.
r_pernr-sign = 'I'.
r_pernr-option = 'EQ'.
r_pernr-high = Personal_no_high.
r_pernr-low = Personal_no_low.
append r_pernr to r_pernr.
select * from database_table
into table itab
where pernr in r_pernr.
Second option, Instead of Import parameter take a table for personal no and pass it through table parameter of the FM you are trying to create. And in select query use that table.
( Here from calling program fetch all the personal no from the personal no base table and populated Personal_no_tab table and pass that table to your FM)
If Personal_no_tab[] is not initial.
Select * from database_table
into table itab
for all entries in Personal_no_tab
where personal_no EG Personal_no_tab-personal_no.
endif.
Now to have a table parameter which will contain personal no, you have to create a dictionary structure for the same.
2008 Mar 06 5:12 AM
hi abhishek
i agree with your second solution but for the first one . If the user selects low and high values in the selection screen but also chooses to exclude some value in that interval (using the exclude thing in select option only ) .. then in that case there would be a problem in the first solution as the range created in the fn module will have that excluded number also.
Second solution is better and easy one.
Thanks,
2008 Mar 06 8:16 AM
Hi,
When personnel number has been used as selection options then ranges declaration is not needed, instead you can pass as a TABLES in FM parameters. If a user enters any number without sequence then also it will work.
hope this will clear your issue for point one.
Regards,
Ramesh
2008 Mar 06 10:03 AM
Since select-option is can not be a element of functional modules, in that case you also have to pass the exclude elements seperately,
In such case you can add two parameters in FM like,
3. person_no_exclude_high
4. person_no_exclude_low
and add another row for the exclude personal no like follows:
ranges: r_pernr for pernr.
r_pernr-sign = 'I'.
r_pernr-option = 'EQ'.
r_pernr-high = Personal_no_high.
r_pernr-low = Personal_no_low.
append r_pernr to r_pernr.
r_pernr-sign = 'E'.
r_pernr-option = 'EQ'.
r_pernr-high = person_no_exclude_high.
r_pernr-low = person_no_exclude_low.
append r_pernr to r_pernr.
select * from database_table
into table itab
where pernr in r_pernr.
2008 Mar 06 4:56 AM
Hi,
In import parameters you can use two variables,one the low value and the other for the high value of the personal number.These values can be fetched from selection screen,using select-options low and high.
In select statement,you can use where condition between these two values.
Hope this will help you.
Regards
Shibin
2008 Mar 06 8:06 AM
hi thanks for ur reply
but how i can use the value of a selection screen to my function module
anuj
2008 Mar 06 10:07 AM
See you can not have a selection option or ramge in a import parameter of a function module. What you can do is to pass each element of the select option seperately and in FM you can create a range using those values.
Only single value, structure and tables are possible to pass to FM. Now you can also create a range table and add it to table parameter of the FM and pass the select-option through the table parameter.
2008 Mar 06 5:04 AM
Hi,
If you want to use a table in import parameter.
You can use define the structure Z_STRUCT with type declaration.
DATA: itab TYPE TABLE OF Z_STRUCT.
Then you can use it as TABLE TYPE for import parameter.
In source code,
You should start with following code:
IF NOT itab[] is initial.
Select query from desired database table.
sy-subrc check.
endif.
Please reward points if its helpful.
Thanks,
Abhishek
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |