Application Development 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: 

Select-Option to be passed in FM

Former Member
0 Kudos

Hi all,

I have one requirement where I want to pass select-options variable ( which contains one or more plants 'WERKS' ) to the function module <b> 'YBAPI_MATERIAL_AVAILABILITY' [b/] . How do I achieve this.

Please help.

Thank You.

4 REPLIES 4

Former Member
0 Kudos

Hi ,

Do one thing,

select * from <table> into it_plants where plants in so_option.

use then FM to pass plants it_plants.

Reward if useful!

former_member150733
Contributor
0 Kudos

Since it is a custom made BAPI you can include one more internal table of type as below.

You can create a Zstructure in R/3 and use it as the reference structure.

The strucute is like

DATA: BEGIN OF sel,

SIGN(1),

OPTION(2),

LOW LIKE f,

HIGH LIKE f,

END OF sel.

Rather than passing the user inputs to the FM, alternativly you can pass the values from the table based on the selection made form the user input.

Former Member
0 Kudos

Hi Premal,

I'm not sure if you mean the standard BAPI or a Custom Version.

Assuming that the BAPI must be called once for each plant in the list....

Define an internal table of plant codes.

then

SELECT WERKS

INTO TABLE IT_PLANTS

FROM T001W

WHERE WERKS IN S_WERKS.

This will build a table of all selected plants.

Then Loop through IT_PLANTS call the BAPI once for each value.

uwe_schieferstein
Active Contributor
0 Kudos

Hello Premal

Select-options are nothing else but internal tables with header line. Since you are apparently developing a customer BAPI have a look how this is solved in the standard BAPI <b>BAPI_MATERIAL_GETLIST</b>. This BAPI uses a TABLES parameter <b>MATNRSELECTION</b> having BAPIMATRAM as line type.

Assuming that you have defined your select-option like this:

SELECT-OPTIONS:
  o_matnr      FOR matnr.

Add a TABLES parameter MATNRSELECTION to your y-BAPI and call it like this:

  CALL FUNCTION  'YBAPI_MATERIAL_AVAILABILITY'
    EXPORTING
      ...
    IMPORTING
    ...
    TABLES
      MATNRSELECTION = o_matnr
      RETURN                 = gt_return.

Regards

Uwe