‎2012 Oct 23 7:17 PM
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.
‎2012 Oct 23 7:38 PM
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
‎2012 Oct 23 8:58 PM
hello,
the FM has a option of tables. you could define a table and use that to transfer your values.
best regards,
swanand
‎2012 Oct 23 9:00 PM
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.
‎2012 Oct 23 9:13 PM
Eric,
Table type should go under export/import parameters.
Check this FM as an example - LWMS_LIKP_GET
IMPORT TAB:
| IV_OBCLS | TYPE | LTRM_OBCLS |
| IV_VBELN | TYPE | LWMS_VBELN_VL |
| IT_VBELN | TYPE | TT_VBELN |
| IV_WHERE | TYPE | XFELD |
TT_VBELN is a table type and is used in import paramters.
Thanks,
VM
‎2012 Oct 24 7:01 AM
‎2012 Oct 24 4:16 AM
For multiple records, please use table parameter. Export/Import will work for single field value.
Regards,
Deepti
‎2012 Oct 24 6:12 AM
‎2012 Oct 24 6:56 AM
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
‎2012 Oct 26 8:05 PM
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.
‎2012 Oct 27 9:51 AM
Only if you don't use basXML is not selected as the RFC protocol. (Protocol available from Release 7.0, EhP2)
Regards,
Raymond
‎2012 Oct 24 8:44 PM
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.
‎2012 Oct 26 4:24 PM
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