ā2013 Jul 17 10:34 AM
Hi I have created a sample code with select-options.
I have a include in the program...
This include contains the sub-routines of the main program...
program ztest1.
Include ztest2.
select-options: s_werks for pa0001-werks.
start-of-selection.
perform start.
end-of-selection.
perform end.
___________________________________-
In the ztest2 Include
form start.
write: 'sample end'.
endform.
form end.
if pa0001-werks in S_WERKS.
WRITE: 'SELECT-OPTIONS is calling'.
else.
write: 'Select-options is not calling'.
endif.
endform.
here report is trigerring error S_WERKS is not available.....................................
So I modified the code to export import ...But no luck still...
program ztest1.
Include ztest2.
select-options: s_werks for pa0001-werks.
start-of-selection.
Export S_WERKS to memory id 'SAS'.
perform start.
end-of-selection.
perform end.
___________________________________-
In the ztest2 Include
form start.
write: 'sample end'.
endform.
form end.
ranges: s_werks1 for pa0001-werk.s
import S_WERKS1 from memory id 'SAS'.
if pa0001-werks in S_WERKS.
WRITE: 'SELECT-OPTIONS is calling'.
else.
write: 'Select-options is not calling'.
endif.
endform.
But I can see no export import happening...
Please throw some light if any idea???
ā2013 Jul 17 10:42 AM
HI,
The best solution would be to more your select option definition before the include statement,
program ztest1.
select-options: s_werks for pa0001-werks.
Include ztest2.
Now your select option is accessible in include ztest2.
Another option would be to pass your select option as a parameter to the subroutine.
Regards,
Kartik
ā2013 Jul 17 10:48 AM
ā2013 Jul 17 11:00 AM
Hi,
program ztest1.
tables: pa0001.
select-options: s_werks for pa0001-werks.
Include ztest2.
start-of-selection.
perform start.
end-of-selection.
perform end.
___________________________________-
In the ztest2 Include
form start.
write: 'sample end'.
endform.
form end.
if pa0001-werks in S_WERKS.
WRITE: 'SELECT-OPTIONS is calling'.
else.
write: 'Select-options is not calling'.
endif.
endform.
Place select-option before include and add tables : pa0001.
Regards,
Azhar
ā2013 Jul 17 11:03 AM
Hi Saslove,
Try like this
program ztest1.
select-options: s_werks for pa0001-werks.
Include ztest2.
select-options: s_werks for pa0001-werks.
start-of-selection.
perform start.
end-of-selection.
perform end.
___________________________________-
In the ztest2 Include
form start.
write: 'sample end'.
endform.
form end.
if pa0001-werks in S_WERKS.
WRITE: 'SELECT-OPTIONS is calling'.
else.
write: 'Select-options is not calling'.
endif.
endform.
here report is trigerring error S_WERKS is not available.....................................
So I modified the code to export import ...But no luck still...
program ztest1.
select-options: s_werks for pa0001-werks. " Make change like this
Include ztest2.
select-options: s_werks for pa0001-werks.
start-of-selection.
Export S_WERKS to memory id 'SAS'.
perform start.
end-of-selection.
perform end.
___________________________________-
In the ztest2 Include
form start.
write: 'sample end'.
endform.
form end.
ranges: s_werks1 for pa0001-werk.s
import S_WERKS1 from memory id 'SAS'.
if pa0001-werks in S_WERKS.
WRITE: 'SELECT-OPTIONS is calling'.
else.
write: 'Select-options is not calling'.
endif.
endform.
ā2013 Jul 17 11:04 AM
Hi,
The MEMORY ID addition expects flat character type data object. Here the ranges act as more of a table with the usual fields of SIGN, OPTION, HIGH, LOW as row fields. Try INTERNAL TABLE alternative of the IMPORT.. EXPORT keywords. Check the link below.
http://help.sap.com/abapdocu_702/en/abapexport_data_cluster_medium.htm
Cheers,
Arindam
ā2013 Jul 17 11:10 AM
Hi
1. Put Export statement - after end-of-selection
2. Put SELECT-OPION before INCLUDE statement
ā2013 Jul 17 11:12 AM
Hi,
the line, where you include ZTEST2 is the location, where the FORM routines are positioned in your program.
Therefore S_WERKS is undefined in the form routines. You have to place the definition of select-option S_WERKS before the include, where you access this definition.
You don't need to EXPORT or IMPORT it.
It's the same issue as in the following code:
report xyz.
write field1.
data: field1 type c.
Regards,
Klaus
ā2013 Jul 17 11:15 AM
BTW: Please check, if you need a report or a program line in your code.
ā2013 Jul 17 11:19 AM
Hi Saslove,
ABAP compiler will check the Include first as it is the first statement in the Program.While compiling it encounters S_WERKS which is not declared prior to it. So you have to place SELECT-OPTIONS statement first and then INCLUDE statement.
ā2013 Jul 23 9:06 AM