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

Pass multiple values to Function Module export parameter?

Former Member
0 Likes
4,687

Is it possible to return multiple items in a FM export parameter? 

Scenario:

I need to create an RFC that returns the current totals for each Measurement Point for a piece of Equipment.  I am passing Object Number from EQUI Table to get Measurement Points in IMPTT table; then I am passing the POINT field from IMPTT Table to IMRG table-RECDV (which contains the current measurement point total).  This is working fine and returning data for the First Measurement Point, but I am not sure how to make this work for all the Measurement Points instead of just one.  I tried a 'SELECT - END SELECT' statement, but that just returned the data for the Last Measurement Point.  What is the best way to return data for all of the Measurement Point fields? 

Here is the code I have:

FUNCTION Z_MEAS_PT_INFO .
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(IV_EQUNR) TYPE  EQUI-EQUNR
*"  EXPORTING
*"     VALUE(EV_OBJNR) TYPE  EQUI-OBJNR
*"     VALUE(EV_POINT) TYPE  IMPTT-POINT
*"     VALUE(EV_RECDV) TYPE  IMRG-RECDV
*"----------------------------------------------------------------------


SELECT SINGLE OBJNR
  FROM  EQUI
  INTO  (EV_OBJNR  )
  WHERE  EQUNR = IV_EQUNR.


SELECT SINGLE POINT
   FROM IMPTT
   INTO (EV_POINT )
   WHERE MPOBJ = EV_OBJNR.


SELECT SINGLE RECDV
   FROM IMRG
   INTO (EV_RECDV )
   WHERE POINT = EV_POINT.

ENDFUNCTION.
 

12 REPLIES 12
Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,672

Change the returned parameters type  to ddic internal table type, ans change your select to SELECT INTO TABLE, and FOR ALL ENTRIES IN to build the returned internal table parameter.

Regards,

Raymond

Read only

0 Likes
2,672

hello,

the FM has a option of tables. you could define a table and use that to transfer your values.

best regards,

swanand

Read only

0 Likes
2,672

Thanks for responding Raymond.  Are you recommending that I create a table in the Data dictionary that contains the fields that I am interested in returning (EQUI-OBJNR, IMPTT-MPOBJ, IMRG-POINT, IMRG-RECDV) and then pass them to an internal table in the function?  (For previous tasks I have been creating Database Views that contain the fields I want, but for some reason making a Database View did not work for me for this objective; I think because I have to pass values to get to the field POINT, so I can’t just put them all in a View and SELECT *)

  Would my ‘DDIC internal table type’ be a Tables parameter?  If you don’t mind can you elaborate? I am a new ABAP Programmer and this capability is a next step for me.  Thanks.

Read only

0 Likes
2,672

Eric,

Table type should go under export/import parameters.

Check this FM as an example - LWMS_LIKP_GET

IMPORT TAB:

IV_OBCLSTYPELTRM_OBCLS
IV_VBELNTYPELWMS_VBELN_VL
IT_VBELNTYPETT_VBELN
IV_WHERETYPEXFELD

TT_VBELN is a table type and is used in import paramters.

Thanks,

VM

Read only

0 Likes
2,672

You create table type via SE11 (check "Data Type" and select "Table type" in pop-up window) Here you define the type of line records using a structure or other ddic object , choose a standard table with default values in last two tabs.

Regards,

Raymond

Read only

Former Member
0 Likes
2,672

For multiple records, please use table parameter. Export/Import will work for single field value.

Regards,

Deepti

Read only

0 Likes
2,672

Not true. You can use Export/Import for multiple values, if you use a table type (as explained by above)

Read only

0 Likes
2,672

And TABLE parameters in FM are now obsolete, allowed but obsolete.

Table parameters are obsolete CHANGING parameters that are typed as standard tables with a header line.

Regards,

Raymond

Read only

0 Likes
2,672

In Remote-enabled Function Modules, TABLES is a valid use... this is preferred, in fact, for RFC's.  If not remote enabled, then use the table types to pass tables of data, as noted.

Read only

0 Likes
2,672

Only if you don't use basXML is not selected as the RFC protocol. (Protocol available from Release 7.0, EhP2)

Regards,

Raymond

Read only

Former Member
0 Likes
2,672

Can someone please demonstrate a simple example of passing multiple export variables in a function module using a Data Dictionary Table Type and an internal table?  I have not ever created a table type in the data dictionary.  Thank you.

Read only

0 Likes
2,672

hello,

please refer below link for creating table type -

http://help.sap.com/saphelp_erp60_sp/helpdata/en/90/8d731fb1af11d194f600a0c929b3c3/content.htm

For help on function module -

http://help.sap.com/abapdocu_702/en/abenfunction.htm

See below screen, once you define the table type under the associated type you put the name of it and use it in the FM. The table in the FM code will be populated with multiple rows for use.

best regards,

swanand