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 in function module

Former Member
0 Kudos

I have:

select-options: s_date for oijne-astdtt. in my screen.

I want to put my code in a function module, but as known that the s_date structure is

s_date-low

s_date-high

also in select statment,

select nomtk into table int_fnomtk from oijne where astdtf in s_date.

I want to pass the s_date value to the where condition in the select statment.

how i can u solve this problem.

1 ACCEPTED SOLUTION

faisal_altaf2
Active Contributor
0 Kudos

Hi,

In Tables Tab define s_date with out giving any Typeing or Associated Type and while calling function pass Select-Option ore Range and you can also use this u2018S_dateu201D just like you did in excitable Program using IN .

Hope will solve out your problem,

Kind Regards,

Faisal

33 REPLIES 33

Sm1tje
Active Contributor
0 Kudos

Use this structure as your import parameter:

RSDSSELOPT

faisal_altaf2
Active Contributor
0 Kudos

Hi,

In Tables Tab define s_date with out giving any Typeing or Associated Type and while calling function pass Select-Option ore Range and you can also use this u2018S_dateu201D just like you did in excitable Program using IN .

Hope will solve out your problem,

Kind Regards,

Faisal

Former Member
0 Kudos

wat u can do is to create a structure for the range or use existing strucrure....

refer structure: VDDATE_RANGE

former_member222860
Active Contributor
0 Kudos

Hi,

Say if you have two import parameters in your FM for 'date_low' and 'date_high', then this code works:

DATA: BEGIN OF ITAB OCCURS 0.
       INCLUDE STRUCTURE MARA.
 DATA: END OF ITAB.       
  
  RANGES: ERSDA1 FOR MARA-ERSDA.

  ERSDA1-LOW = ERSDA_LOW.
  ERSDA1-HIGH = ERSDA_HIGH.
  ERSDA1-SIGN = 'I'.
  ERSDA1-OPTION = 'BT'.
  APPEND ERSDA1.
 
  SELECT * FROM MARA
             INTO TABLE ITAB
             WHERE MATNR IN MATNR1.

LOOP AT ITAB.
WRITE:/ ITAB-MATNR, ITAB-ERSDA.
ENDLOOP.

Mahesh

faisal_altaf2
Active Contributor
0 Kudos

Hi, Ali

You can use these Structures as given by Micky and TT RSDSSELOPT , VDDATE_RANGE,

But in Future if you need to use u201CFOR ALL ENTRIES INu201D than you again have to change this with no Structure type Because in this way you can send any type of Table.

Please Guide us in this way, Micky and TT.

Kind Regards,

Faisal

former_member217544
Active Contributor
0 Kudos

Hi Ali,

Check this table type: PLMT_AUDIT_RANGES_FOR_DATE.

Example code:


select-options: s_date for oijne-astdtt. in my screen.

data:  wa_data type PLMT_AUDIT_RANGES_FOR_DATE_WA.

wa_data-sign = ' I '. " (I or E based on req.)
wa_data-option = 'EQ'. (EQ or BT or Gt or GE or LE  etc. based on the req.)
wa_data-low = s_date-low .
wa_data-high = s_date-high.

Now you can pass the value wa_data as the function module input parameter.
Inside Function Module:
data: x_date type PLMT_AUDIT_RANGES_FOR_DATE.

append wa_data to x_date.

select nomtk into table int_fnomtk from oijne where astdtf in x_date.

Hope this wil help you.

Regards,

Swarna Munukoti.

Former Member
0 Kudos

Hi Ali,

You can use ranges,

Kindly go through the sample code below:

RANGES : r_afaber FOR anlp-afaber, " for depreciation area

r_peraf FOR anlp-peraf. " for depreciation period

&----


  • INITIALIZATION

&----


  • TO INITIALIZE ALL THE VARIABLES TO BE USED

  • IN THE PROGRAM

&----


INITIALIZATION.

r_afaber-sign = 'I'. " for inclusive

r_afaber-option = 'EQ'. " for equal operator

r_afaber-low = c_afaber_01. " depreciation area(low value)

APPEND r_afaber. " append values for depreciation area

r_afaber-sign = 'I'. " for inclusive

r_afaber-option = 'EQ'. " for equal operator

r_afaber-low = c_afaber_07. " depreciation area(low value)

APPEND r_afaber. " append values for depreciation area

r_peraf-sign = 'I'. " for inclusive

r_peraf-option = 'BT'. " for between operator

r_peraf-low = c_peraf_001. " depreciation period(low value)

r_peraf-high = c_peraf_012. " depreciation period(high value)

APPEND r_peraf. " append values for depreciation period

Hope it helps you

Regrds

Mansi

Former Member
0 Kudos

I want to explain my Case to be clear for every body,

Right now i have selection screen and complete code that generate a report.

The new idea is to run the report logic inside FM and remove selection-option not needed.

I do not like to change the logic too much,

Let say i have this selection screen

selection-screen begin of block b1 with frame title text-001.

select-options: s_date for oijne-astdtt,

s_soldto for oijnomi-soldto

selection-screen end of block b1.

Also I have this Query.

SELECT * FROM OIJNE WHERE DATE IN S_DATE and old in s_soldto.

Q1. How I can define imports parameter for S_DATE, and used them in Query instead of S_DATE.

Q2. In case of remove the selection option s_soldto, what i should put instead of .

0 Kudos

Hello,

You can define a range table as an import parameter for this:


I_R_DATE TYPE ACC_T_RA_DATE

ACC_T_RA_DATE --> Ranges Table for Date

Hope this helps.

BR,

Suhas

0 Kudos

HI, Ali.

Just Copy and Past all your Program. With Out Selection Screen Components like Parameters and

--> Select-options in the Source Code Tab of FM window.

--> Than copy past all the name of you select option in the u201CTablesu201D tab in Parameter Name Colum

--> And Past all the Parameters in the Import Tab.

--> At last you have to Create a Structure and Table Type if you want to get an internal Table from your FM.

--> For Structure and Table Type Creation you can use SE11.

Do this and tell me where you are facing problem,

Wating for you Reply,

Kind Regards,

Faisal

0 Kudos

hi Suhas Saha ,

Can u please be more clear about your suggestion.

Still i can not get u.

0 Kudos

HI Ali,

U can do like this also

declare s_date as from_date and to_date in import parameter of FM

and use like this

select * from onije where assdt between from_date and to_date.

it wil work.

Regards,

Azhar

Edited by: Azhar on Feb 2, 2009 5:14 PM

0 Kudos

>

> The new idea is to run the report logic inside FM and remove selection-option not needed.

>

> I do not like to change the logic too much,

>

> Let say i have this selection screen

>

> selection-screen begin of block b1 with frame title text-001.

>

> select-options: s_date for oijne-astdtt,

> s_soldto for oijnomi-soldto

>

> selection-screen end of block b1.

>

> Also I have this Query.

>

> SELECT * FROM OIJNE WHERE DATE IN S_DATE and old in s_soldto.

>

> Q1. How I can define imports parameter for S_DATE, and used them in Query instead of S_DATE.

> Q2. In case of remove the selection option s_soldto, what i should put instead of .

I assume you have to use the SELECT-OPTIONS of the report in the FM.

What i suggested was create an import param to the FM as a date range, so that you can have this as your input & use for the select as well.

Correct me if i am wrong in understanding your requirement !!!

BR,

Suhas

0 Kudos

Hi Faisal Altaf ,

I think your solution more suitable for my case.

In my old report i used subroutines, Where i should write those in FM, and where i should call them.

0 Kudos

Hi Faisal,

you said that

--> Select-options in the Source Code Tab of FM window.

Can you explain more about this step.

You help will be appreciated.

Regard,

Ali

0 Kudos

Hi,

*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES                                  ' Here in the Tables' Tab you can give the name of your select Option and use it in you code area as IN.
*"      PERNR_RANGE
*"  CHANGING
*"     REFERENCE(ITAB) TYPE  ZFSL_TEST_TT
*"----------------------------------------------------------------------

Please Reply if not clear.

Kind Regards,

Faisal

0 Kudos

Hello,

I think what i had suggested yesterday fits your requirement:

TABLES: bkpf.

DATA: it_bkpf TYPE STANDARD TABLE OF bkpf.

SELECT-OPTIONS:
s_bukrs FOR bkpf-bukrs,
s_budat FOR bkpf-budat.

START-OF-SELECTION.

* Get BKPF data
  CALL FUNCTION 'Z_GET_BKPF'
    EXPORTING
      i_r_bukrs     = s_bukrs
      i_r_date      = s_bukrs
    TABLES
      e_tab         = it_bkpf
    EXCEPTIONS
      no_data_found = 1
      OTHERS        = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

The code for the FM 'Z_GET_BKPF' is as follows:

FUNCTION Z_GET_BKPF .
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(I_R_BUKRS) TYPE  FAGL_RANGE_T_BUKRS
*"     REFERENCE(I_R_DATE) TYPE  ACC_T_RA_DATE
*"  TABLES
*"      E_TAB STRUCTURE  BKPF
*"  EXCEPTIONS
*"      NO_DATA_FOUND
*"----------------------------------------------------------------------

  SELECT *
  FROM bkpf
  INTO TABLE e_tab
  WHERE bukrs IN i_r_bukrs
  AND   budat IN i_r_date.

  IF sy-subrc NE 0.
    RAISE no_data_found.
  ENDIF.


ENDFUNCTION.

I think this will be of some help.

BR,

Suhas

0 Kudos

Hi Faisal,

Regarding the Name of Selection-Option , I put them in the Table tab parameter , But i face problem with the Type of those.

How i can get the Type for the name of Selection-Option.

Best Regard,

Ali

0 Kudos

Hi, Ali

Please don't give any type just leave this type field empty.

Please Reply if any else issue,

Kind Regards,

Faisal

0 Kudos

hi,

you can pass in tables parameter in FM.

create a range table for date and pass through tables parameter.

former_member222860
Active Contributor
0 Kudos

Hi Ali.

If you want to use the structure for the Range, here is piece of example

FUNCTION Z_DATE.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     REFERENCE(DATE) LIKE  ACC_S_RA_DATE STRUCTURE  ACC_S_RA_DATE
*"  TABLES
*"      RESULT STRUCTURE  MARA
*"----------------------------------------------------------------------

DATA: BEGIN OF ITAB OCCURS 0.
        INCLUDE STRUCTURE MARA.
DATA:  END OF ITAB.

 RANGES: ERSDA1 FOR MARA-ERSDA.

  ERSDA1-LOW = date-LOW.
  ERSDA1-HIGH = date-HIGH.
  ERSDA1-SIGN = date-SIGN.
  ERSDA1-OPTION = date-OPTION.
  APPEND ERSDA1.

  SELECT * FROM MARA
             INTO TABLE ITAB
             WHERE ERSDA IN ERSDA1.

LOOP AT ITAB.
MOVE ITAB TO RESULT.
APPEND RESULT.
ENDLOOP.

ENDFUNCTION.

Give the values for date-low and date-high in 'Char' format.

Check if it works for ur case.

thanks\

Mahesh

faisal_altaf2
Active Contributor
0 Kudos

Hi, Ali

Have a look at the Calling Program whic call a FM and Pass a Select-Option and Get a Internal Table from the Funtion with the name of the EMP.

Calling Program.

REPORT test_fm.
TABLES: pa0001.

DATA: it_pa0001 TYPE zfsl_test_tt WITH HEADER LINE.

SELECT-OPTIONS sopernr FOR pa0001-pernr.

CALL FUNCTION 'ZFSL_TEST'
  TABLES
    pernr_range = sopernr
  CHANGING
    itab        = it_pa0001[].

FM

FUNCTION zfsl_test.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      PERNR_RANGE
*"  CHANGING
*"     REFERENCE(ITAB) TYPE  ZFSL_TEST_TT
*"----------------------------------------------------------------------

DATA: it_pa0001 TYPE zfsl_test_tt WITH HEADER LINE.

SELECT pernr ename FROM pa0001
  INTO CORRESPONDING FIELDS OF TABLE it_pa0001
  WHERE endda = '99991231'
    AND pernr IN pernr_range.

itab = it_pa0001[].

ENDFUNCTION.

Hope above will solve out your problem,

Please Reply if any Issue,

Kind Regards,

Faisal

Former Member
0 Kudos

Hi Faisal,

My Idea in general is, I will use the same logic in the R3 to be used in WD by calling FM with some modification and change.

Do I have to remove the report event ex INITIALIZATION, START-OF-SELECTION, and AT-SELECTION SCREEN, etc.

Regard,

Ali

0 Kudos

Hello Ali,

How i can get the Type for the name of Selection-Option.

Did you try my solution? Is it not working for you?

Please go through it.

BR,

Suhas

Edited by: Suhas Saha on Feb 3, 2009 11:20 AM

0 Kudos

>

> Hi Faisal,

>

> My Idea in general is, I will use the same logic in the R3 to be used in WD by calling FM with some modification and change.

>

> Do I have to remove the report event ex INITIALIZATION, START-OF-SELECTION, and AT-SELECTION SCREEN, etc.

>

> Regard,

> Ali

Hi, Ali

I Think you have to remove all event ex INITIALIZATION, START-OF-SELECTION, and AT SELECTION SCREEN, etc

Kind Regards,

Faisal

Former Member
0 Kudos

Hi Suhas Saha

My FM is Remote Enable.

I face prolem with type it give me Generic type are not allowed in RFC

BR,

Ali

0 Kudos

Hello Ali,

That's it !!! Please mention all your clauses in your post. I was unaware about it :-((

Sorry for the misguiding post ... Thinking on an work-around !!!

Please check the code:

TABLES: bkpf.

DATA: it_bkpf TYPE STANDARD TABLE OF bkpf.

PARAMETERS: p_rfc TYPE char120.

SELECT-OPTIONS:
s_bukrs FOR bkpf-bukrs,
s_budat FOR bkpf-budat.

START-OF-SELECTION.

  CALL FUNCTION 'Z_GET_BKPF'
  DESTINATION p_rfc
    TABLES
      e_tab               = it_bkpf
      i_r_bukrs           = s_bukrs
      i_r_date            = s_budat
* EXCEPTIONS
*   NO_DATA_FOUND       = 1
*   OTHERS              = 2
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

The FM code:

FUNCTION Z_GET_BKPF .
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      E_TAB STRUCTURE  BKPF
*"      I_R_BUKRS TYPE  FAGL_RANGE_T_BUKRS
*"      I_R_DATE TYPE  ACC_T_RA_DATE
*"  EXCEPTIONS
*"      NO_DATA_FOUND
*"----------------------------------------------------------------------

  SELECT *
  FROM bkpf
  INTO TABLE e_tab
  WHERE bukrs IN i_r_bukrs
  AND   budat IN i_r_date.

  IF sy-subrc NE 0.
    RAISE no_data_found.
  ENDIF.

ENDFUNCTION.

Suhas

Edited by: Suhas Saha on Feb 3, 2009 11:41 AM

Former Member
0 Kudos

Hellow Suhas Saha ,

Sorry for every thing.

I need the logic that in R/3 to be used in WD.

I am planning to use Call FM-Remot Enable in WD to use the logic.

Right now I moving the logic from R/3 to FM.

But I face some problems in that.

So, I need to move the selection option, parameters .

0 Kudos

Hello Ali,

Can you check with this code:

FUNCTION Z_GET_BKPF .
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      E_TAB STRUCTURE  BKPF
*"      I_R_BUKRS STRUCTURE  FAGL_RANGE_BUKRS
*"      I_R_DATE STRUCTURE  ACC_S_RA_DATE
*"  EXCEPTIONS
*"      NO_DATA_FOUND
*"----------------------------------------------------------------------

  SELECT *
  FROM bkpf
  INTO TABLE e_tab
  WHERE bukrs IN i_r_bukrs
  AND   budat IN i_r_date.

  IF sy-subrc NE 0.
    RAISE no_data_found.
  ENDIF.


ENDFUNCTION.

Br,

Suhas

Former Member
0 Kudos

hello Suhas Saha

I get this message,

Reference parameter are not allowed with RFC.

BR,

Ali

0 Kudos

Hi,

For RFCs we need to check the check Box "Pass Value" present in Import and Export paramater tab for all the input and output parameters.

Regards,

Swarna Munukoti.

Former Member
0 Kudos

My Selectio Screen look like this:

*Date: ____________ to ___________ Requird

Location : __________to ___________ By Default (Blank) Optional -


> in WD Hardcoded as blank

Division: __________to ___________ By Default (Blank) Optional -


> in WD Hardcoded as blank

ShipName__________to ___________ By Default (Blank) Optional -


> in WD Hardcoded as blank

Agent:__________to ___________ By Default (Blank) Optional -


> in WD Hardcoded as blank

Offtaker:__________to ___________ By Default (Blank) Optional -


> in WD Hardcoded as blank

Inspector:__________to ___________ By Default (Blank) Optional -


> in WD Hardcoded as blank*

Ship with/without ETA As Check box (Checked)

Nomination item OOK As Check box (Checked)

Shi Name As radio button (default)

Agent As radio button

Inspector As radio button

Effective date As radio button

I need How to use the the structure of Selection Option in Import parameter and what type I should use?

How to deal with the range in the QUERY

Former Member
0 Kudos

Thnx all