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

Help in function modules therotical aspects

Former Member
0 Likes
884

Dear experts,

I have some confusion with function modules.So long i believe that IMPORT parameters is what we provide as parameters to

the function module and export parameters is something we take out or referred as output values.

I have seen function modules dealing in different ways where

what i stated above holds good as well as cases where instead we provide input to EXPORT parameters and take output from import.Is it true or its my confusion.Can someone let me know the exact standard ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
862

I am trying to explain it with an example:

See this FM call:

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = p_fil

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = it_dummy

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

Here input values are passed under EXPORTING parameters and output values can be get from the parameters under IMPORTING. Now if u double click on the FM and goto se37 then u can see that all export parameters in FM call are under import tab and all import parameters in FM call are under export tab. ...this is because...when u r in the FM u r getting values from import tab and results are returned using parameters under import tab.

FM call Inside FM

Export -


> Import

Import <----


Export

7 REPLIES 7
Read only

Former Member
0 Likes
863

I am trying to explain it with an example:

See this FM call:

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = p_fil

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = it_dummy

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

Here input values are passed under EXPORTING parameters and output values can be get from the parameters under IMPORTING. Now if u double click on the FM and goto se37 then u can see that all export parameters in FM call are under import tab and all import parameters in FM call are under export tab. ...this is because...when u r in the FM u r getting values from import tab and results are returned using parameters under import tab.

FM call Inside FM

Export -


> Import

Import <----


Export

Read only

0 Likes
862

This adds more to confusion than clarity.

Read only

0 Likes
862

Can somone better elaborate on the function modules in

general.We often encounter them into use yet copy-paste of working codes is of no use ,if we do not logically understand them.So i am asking this question once more ?

Read only

0 Likes
862

I think it was explained quite nicely...

Read only

0 Likes
862

It is true that you should use IMPORT parameters to import data into the function module and use the EXPORT parameter for exporting data from the function module.

But this is only true from the Function module point of view. So when you look at the function module (SE37) you can define these parameters on different tabs (import, export, changing, tables etc.). However, when you use these FM in a report (or where ever for that matter), you will see that, from the point of view of the report, that the import and export parameters have changed from import to export and export to import.

But this is from the point of view of the report. Because from within the report, you will export data to the FM where these parameters are IMPORTED. From the point of view of the report, you will get back some data (parameters) which are imported into report, but seen from the FM, you will export these parameters. Sounds complicated, but it is just a matter of the point of view you are looking at this.

Summary:

EXPORT in FM = IMPORT in report

IMPORT in FM = EXPORT in report.

But when defining the FM parameters, you should keep in mind, that IMPORT is what you get from the calling application and EXPORT is what you will give back to the calling application. The imported data you can use (not change) to do a select for example, and you can export the selected data to the calling application.

Read only

0 Likes
862

I understand now Micky.

Read only

0 Likes
862

Hi Aditya,

Dont confuse, I will try to explain u ...

see import and export name differs from the prospective of viewing it.

Means..

from the programming point of view i.e. from where u will call this function module.. The input parameters are exported to function module right..

so from this program point of view if we mention as export parameters those are importing parameters to Function module Because from program u r exporting input values to function module.

Function module is taking these values for proceesing so these are referred as importing parameters from the function modules point of view..

in the similar way from program point of view u will get values from function module so here(program) those are referred as import parameters where as function module exports those values so from function module point of view those are export parameters..

Hope i am clear..

Regards,

Sunil Kumar Mutyala