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

Select options with function modules.

Former Member
0 Likes
3,527

Hello People,

I found few threads on this topic already, I tried solving with the help of those clues but in vain.

I want to create a function module which accepts a date range like in ACC_T_RA_DATE, and output a list of materials.

The list of materials correspond to the purchase orders that were created in the given date range.

Please kindly observe, I am not using a program to pass any value - I will be using only the function module throughout the process.

Please advice me on this.

Thanks in advance,

Disha.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,717

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

ACC_T_RA_DATE --> Ranges Table for Date

Or use structure VDDATE_RANGE/PLMT_AUDIT_RANGES_FOR_DATE for date range .

For output list of material create a Structure and Table Type .

For more details rfer to

It will work.

anya

11 REPLIES 11
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
2,717

Hi what is there so difficult in it ?

ACC_T_RA_DATE is a table type.

Declare a import parameter in your fm refereing to ACC_T_RA_DATE.

In you program

data:i_tab type ACC_T_RA_DATE,

la_date type ACC_S_RA_DATE.

la_date-sign = 'I'.

la_date-option = 'BT' "or EQ,LE etc.

la_date-low = '__/__/____'/

la_date-high = '__/__/____/.

append la_date to i_tab.

Now just pass i_tab to your importng parameter of the fm.

Read only

0 Likes
2,717

Hello Keshav,

Thanks for the quick reply. As I have already mentioned in my post, I am not using any program to export values into Function module. The entire thing should happen with the function module.

Disha.

Read only

Former Member
0 Likes
2,718

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

ACC_T_RA_DATE --> Ranges Table for Date

Or use structure VDDATE_RANGE/PLMT_AUDIT_RANGES_FOR_DATE for date range .

For output list of material create a Structure and Table Type .

For more details rfer to

It will work.

anya

Read only

0 Likes
2,717

Hi Anya,

Thanks for the reply, I did the same thing.

One import variable of type ACC_T_RA_DATE. And an other table which accepts the materials into it (of type ekpo) for output. I did an inner join on ekko and ekpo and in the where condition I have aedat from the date range.

I wonder if I am missing out something.

Disha.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,717

What is your exact requirement, FM should look like

FUNCTION z_mm_xxx.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     REFERENCE(RANGE_DATE) TYPE  ACC_T_RA_DATE
*"  EXPORTING
*"     REFERENCE(MATERIAL_LIST) TYPE  /SAPXCQM/EKPO_TAB
*"  EXCEPTIONS
*"      INVALID_DATE_RANGE
*"      NO_PURCHASE_ORDER
*"      NO_ITEM_FOUND
*"----------------------------------------------------------------------

  DATA: lv_ebeln LIKE ekko-ebeln,                           "#EC NEEDED
        lv_datum LIKE syst-datum.
  FIELD-SYMBOLS <fs> TYPE acc_s_ra_date.
* Init
  REFRESH material_list.
* Check date range
  LOOP AT range_date ASSIGNING <fs>.
    lv_datum = <fs>-low.
    CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
         EXPORTING
              date                      = lv_datum
         EXCEPTIONS
              plausibility_check_failed = 1.
    IF sy-subrc NE 0.
      RAISE invalid_date_range.
    ENDIF.
    IF <fs>-option EQ 'BT'
    OR <fs>-option EQ 'NB'.
      IF <fs>-high LT <fs>-low.                           "#EC PORTABLE
        RAISE invalid_date_range.
      ENDIF.
      lv_datum = <fs>-high.
      CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
           EXPORTING
                date                      = lv_datum
           EXCEPTIONS
                plausibility_check_failed = 1.
      IF sy-subrc NE 0.
        RAISE invalid_date_range.
      ENDIF.
    ENDIF.
  ENDLOOP.
* Check existence of PO
  SELECT SINGLE ebeln INTO lv_ebeln
    FROM ekko
    WHERE aedat IN range_date.
  IF sy-subrc NE 0.
    RAISE no_purchase_order.
  ENDIF.
* Read item
  SELECT * INTO CORRESPONDING FIELDS OF TABLE material_list
    FROM ekpo
    JOIN ekko ON ekko~ebeln EQ ekpo~ebeln
    WHERE ekko~aedat IN range_date.
  IF sy-subrc NE 0.
    RAISE no_item_found.
  ENDIF.
ENDFUNCTION.

Regards,

Raymond

Read only

Former Member
0 Likes
2,717

Hi Disha,

You can try with two import parameters instead one like start_date and end_date. In the select statement you can use between.

Hope this works.

Thanks,

Venkat

Read only

former_member201275
Active Contributor
0 Likes
2,717

I don't understand your problem.

Simply create to import parameters i.e. a from and to date, plus the output table for your materials.

Read only

Former Member
0 Likes
2,717

Hi Dishaa,

I think as per your requirement.. I have the same thinking that you create a fm with two import parameters which contains dates, i.e. From and To. and one export parameter as table from which you can get the list of materials you want from the table.

Regards,

Kunal.

Read only

0 Likes
2,717

Hey everybody,

Thanks for the post and the clues. It works.

I created a structure type zlinetype for my output table. And yup, its all fine - I dont understand why I faced a problem earlier.

FUNCTION ZMAT2.

*"----


""Local Interface:

*" IMPORTING

*" REFERENCE(START) TYPE EKKO-AEDAT

*" REFERENCE(END) TYPE EKKO-AEDAT

*" TABLES

*" T_MAT STRUCTURE ZLINETYPE

*"----


SELECT P~MATNR

K~AEDAT

INTO TABLE T_MAT

FROM EKPO AS P

INNER JOIN

EKKO AS K

ON PEBELN = KEBELN

WHERE

K~AEDAT GT START

AND

K~AEDAT LT END.

LOOP AT T_MAT.

WRITE : / T_MAT-MATNR,

/ T_MAT-AEDAT.

ENDLOOP.

ENDFUNCTION.

I have an other doubt. Is there way a way I can get an input help for my date range.

Thanks,

Disha.

Read only

0 Likes
2,717

WHY would you need input help on an FM parameter? Are you trying to use a function module as a report tool? Makes no sense...we call function modules from inside other programs!

If you need help on a date field, why not create a report with a selection screen and declare your input range with the appropriate DDIC reference?

Read only

0 Likes
2,717

Makes sense. Was just wondering why can we not ? Anyways Thanks people for your valuable suggestions.