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

Populating a interface with values

Former Member
0 Likes
839

I have been asked to populate an export variable that actually references the table type of an interface. So in SE11 the Zxxxx table type actually uses the reference type definition of a 'Z' interface.

The requirement is to retrun a table of locations and then pass this to parameter e_locations.

e_locations = TABLE TYPE OF Zxxxx (and Zxxx = reference type ZIFxxxxx)

My questions is this possible and if so what is the correct syntax.

5 REPLIES 5
Read only

brad_bohn
Active Contributor
0 Likes
786

It sounds like you want to use a table type as an export (import) parameter for a function module? Declare your table type in the DDIC as 'ZTT_XXXXX...'. Your function parameter would just be defined using TYPE 'ZTT_XXXXX' in the interface. In your code, populate an internal table (defined using the table type) with a work area (defined using the line type which also is your Z-table line type). Assign the internal table to the function parameter in the call.

Read only

Former Member
0 Likes
786

Halo,

Suppose you have an interface ZINTF

Go to Se11 and create a global table type ZTT_INTF where reference line is ZINTF.

Then in your FM the exporting parameter should be type ZTT_INTF.

Regards

Arshad

Read only

Former Member
0 Likes
786

This message was moderated.

Read only

Former Member
0 Likes
786

You can declare your parameter as TYPE STANDARD TABLE it will accept any table types.

Please let me know if this helps.

Thanks

Read only

Former Member
0 Likes
786

HI, what I had to do was to instantiate the class first and then pass the results to my table referencing the interface.

loop at it_warehouse into s_warehouse.

    try.
*     Instantiate the warehouse for each record
      call method zcl_warehouse=>make_warehouse         "static method
        exporting
          i_warehouse_no = s_warehouse-warehouse_no
        receiving
          r_warehouse    = lco_warehouse.
    endtry.

*   and then populate the interface with the resulting instances
    append lco_warehouse to rit_locations.

  endloop.