Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
Read only

Issue with subroutine calling & Memory Export & Import

Former Member
0 Likes
1,102

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???

10 REPLIES 10
Read only

Kartik2
Contributor
0 Likes
1,033

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

Read only

Former Member
0 Likes
1,033

Place your select options above the include statement.

Read only

Former Member
0 Likes
1,033

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

Read only

former_member209120
Active Contributor
0 Likes
1,033

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.

Read only

arindam_m
Active Contributor
0 Likes
1,033

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

Read only

venkateswaran_k
Active Contributor
0 Likes
1,033

Hi

1.  Put  Export statement -  after end-of-selection

2.  Put SELECT-OPION before INCLUDE statement

Read only

Former Member
0 Likes
1,033

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

Read only

0 Likes
1,033

BTW: Please check, if you need a report or a program line in your code.

Read only

NagaPrakashT
Contributor
0 Likes
1,033

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.

Read only

0 Likes
1,033

hi ,

please declare the TABLES: pa0001.