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

How to pass select-option filed to Function Module Exporting Parameter

Former Member
0 Likes
1,863

Hi,

How to pass select-option filed to Function Module Exporting Parameter.

Thanks

1 ACCEPTED SOLUTION
Read only

former_member156446
Active Contributor
0 Likes
1,459

Hi there..

*" VALUE(BUKRS) LIKE BSID-BUKRS DEFAULT ' '.

datA: lv_bukrs type bsid-bukrs.

loop at so_bukrs into wa_bukrs.

lv_bukrs = wa_bukrs-low.

endloop.

call FM,,,,,,,,,,,,


bukrs = lv_bukrs.

12 REPLIES 12
Read only

former_member156446
Active Contributor
0 Likes
1,459

Hi there

you can do that if there is not type conflict with both of them

any variable you send to FM need to be the same type of the variable used in FM source code.

loop at so_option.

move....

endloop.

Read only

Former Member
0 Likes
1,459

Just few Minutes back the same(Almost) problem has been answered:

Read only

0 Likes
1,459

Amit,

i am using the FM CUSTOMER_DUE_DATE_ANALYSIS.

"*"Lokale Schnittstelle:

*" IMPORTING

*" VALUE(BUKRS) LIKE BSID-BUKRS DEFAULT ' '.

But in my program Bukrs as select-option filed.Now ia want to pass the select-option field Bukrs to the above fm filed BUKRS.

So,here how sholud we pass the Select-option value to that fm.

Thanks

Read only

former_member156446
Active Contributor
0 Likes
1,460

Hi there..

*" VALUE(BUKRS) LIKE BSID-BUKRS DEFAULT ' '.

datA: lv_bukrs type bsid-bukrs.

loop at so_bukrs into wa_bukrs.

lv_bukrs = wa_bukrs-low.

endloop.

call FM,,,,,,,,,,,,


bukrs = lv_bukrs.

Read only

0 Likes
1,459

Hi,

 DATA: BEGIN OF ITAB5_WRK OCCURS 0,
        KUNNR     TYPE KNKK-KUNNR,  "CUSTOMER #
        SBGRP     TYPE KNKK-SBGRP,  "CREDIT REP
        KLIMK     TYPE KNKK-KLIMK,  "CREDIT LIMIT
        NAME1     TYPE KNA1-NAME1,  "CUSTOMER NAME
        SKFOR     TYPE KNKK-SKFOR,  "TOTAL A/R
        AMT1      TYPE KNKK-SKFOR,  "CURRENT
        AMT2      TYPE KNKK-SKFOR,                          "01-30
        AMT3      TYPE KNKK-SKFOR,                          "31-60
        AMT4      TYPE KNKK-SKFOR,                          "61-90
        AMT5      TYPE KNKK-SKFOR,                          "91-120
        AMT6      TYPE KNKK-SKFOR,                          "OVR 120
        BZIRK     TYPE KNVV-BZIRK,

      END OF ITAB5_WRK.




SELECT-OPTIONS P_COMP     FOR  T001-BUKRS


  SELECT KUNNR SBGRP  FROM KNKK
         INTO TABLE ITAB5_WRK
         WHERE SBGRP IN P_REP
           AND KUNNR GE '0001000000'
           AND SKFOR NE 0.


  LOOP AT ITAB5_WRK.
    DELETE ADJACENT DUPLICATES FROM ITAB5_WRK COMPARING KUNNR.
  ENDLOOP.

  PERFORM GET_CREDIT_LIMITS.
*=======================================================================
  IF P_DIST NE SPACE.


    LOOP AT ITAB5_WRK.

      SELECT SINGLE * FROM KNVV WHERE KUNNR EQ ITAB5_WRK-KUNNR
                                  AND VKORG EQ P_COMP
                                  AND VTWEG EQ '20'
                                  AND SPART EQ '10'
                                  AND BZIRK IN P_DIST.

      IF SY-SUBRC EQ 0.
        MOVE KNVV-BZIRK TO ITAB5_WRK-BZIRK.
        MODIFY ITAB5_WRK.
      ELSE.
        DELETE ITAB5_WRK.
      ENDIF.

    ENDLOOP.


  ENDIF.

*==============================================================
  LOOP AT ITAB5_WRK.

    MOVE: 'F/S'            TO WRK-KKBER,
           ITAB5_WRK-KUNNR TO WRK-KUNNR.

    PERFORM AGING.

    ADD: W_SNFAE  TO ITAB5_WRK-AMT1,
         W_SFAE1  TO ITAB5_WRK-AMT2,
         W_SFAE2  TO ITAB5_WRK-AMT3,
         W_SFAE3  TO ITAB5_WRK-AMT4,
         W_SFAE4  TO ITAB5_WRK-AMT5,
         W_SFAE5  TO ITAB5_WRK-AMT6,
         W_SFAEL  TO ITAB5_WRK-SKFOR,
         W_SNFAE  TO ITAB5_WRK-SKFOR.

    MOVE: 'SPEC'            TO WRK-KKBER,
           ITAB5_WRK-KUNNR TO WRK-KUNNR.

    *PERFORM AGING.*

    ADD: W_SNFAE  TO ITAB5_WRK-AMT1,
         W_SFAE1  TO ITAB5_WRK-AMT2,
         W_SFAE2  TO ITAB5_WRK-AMT3,
         W_SFAE3  TO ITAB5_WRK-AMT4,
         W_SFAE4  TO ITAB5_WRK-AMT5,
         W_SFAE5  TO ITAB5_WRK-AMT6,
         W_SFAEL  TO ITAB5_WRK-SKFOR,
         W_SNFAE  TO ITAB5_WRK-SKFOR.


    MODIFY ITAB5_WRK.


  ENDLOOP.


FORM AGING.

  *CALL FUNCTION 'CUSTOMER_DUE_DATE_ANALYSIS'*  
  EXPORTING
      BUKRS             = P_COMP            
      KKBER             = WRK-KKBER
      KUNNR             = WRK-KUNNR
      RASID             = 'FEND'
      KLIMP             = 'X'
    IMPORTING
      SFAE1             = W_SFAE1
      SFAE2             = W_SFAE2
      SFAE3             = W_SFAE3
      SFAE4             = W_SFAE4
      SFAE5             = W_SFAE5
      SFAE6             = W_SFAE6
      SFAEL             = W_SFAEL
      SNFA1             = W_SNFA1
      SNFA2             = W_SNFA2
      SNFA3             = W_SNFA3
      SNFA4             = W_SNFA4
      SNFA5             = W_SNFA5
      SNFA6             = W_SNFA6
      SNFAE             = W_SNFAE
    EXCEPTIONS
      NO-AGING_SCHEDULE = 1
      NO_TABLE_INPUT    = 2.



  CASE SY-SUBRC.
    WHEN 1.
      MESSAGE E999 WITH 'PLEASE ENTER AGING SCHEDULE'.
    WHEN 2.
      MESSAGE E999 WITH 'DO NOTHING ??'.
  ENDCASE.

ENDFORM.                    "AGING 

Thanks

Read only

0 Likes
1,459

Hi there..

FORM AGING.

data: lv_burks type BSID-BUKRS.

loop at P_COMP.
lv_bukrs = p_comp-low .   "" this works if you give only one CC.

clear: p_comp.
endloop.

  *CALL FUNCTION 'CUSTOMER_DUE_DATE_ANALYSIS'*  
  EXPORTING
      BUKRS             = lv_bukrs

Read only

0 Likes
1,459
lv_bukrs = wa_bukrs-low.
 
endloop.
 
call FM,,,,,,,,,,,,

I'm not sure if this will serve your purpose since you have select-options instead of parameter.

What if the user gave input like:

1000 To 2000 ?

it will calculate due date analysis(From FM) only for 1000 (wa_bukrs-low)

You have to use Ranges for select-options,and get all Company code which falls between 1000(wa_bukrs-low) to 2000(wa_bukrs-high).

Amit.

Read only

0 Likes
1,459

Amit,

Yes, that the Problem here i am facing

if the user gave input :

1000 To 2000 .How sholud we pass the filed value to that Function Module.

Thanks

Read only

0 Likes
1,459

SELECT-OPTIONS / RANGES are still just tables.

Pass it as a table to the FM. Just make sure you have the layout defined the same way in the FM.

As an example..

In the FM IMPORT Tab


Parm Name      TYPE     Reference Type
I_GRPNAME      TYPE     ZPS_R_GRPNAME_T

now ZPS_R_GRPNAME_T is a Table Type of ROW TYPE ZPS_R_GRPNAME.


ZPS_R_GRPNAME is a Structure defined as
SIGN          SCPR_SIGN
OPTION        OPTION
LOW           GRPNAME (Char 15)
HIGH          GRPNAME (Char 15)

We use this to read plants with in a division and the EXPORT tab contains

the same basic info for the PLANT/Branch Range.

So you can pass a Range to and from an FM.

This is the FM Source


FUNCTION ZSD_GET_BRANCH_GROUP.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     REFERENCE(I_GRPNAME) TYPE  ZPS_R_GRPNAME_T
*"     REFERENCE(FLAG_READ_DESC) TYPE  FLAG_X OPTIONAL
*"  EXPORTING
*"     REFERENCE(E_BRANCH_RANGE) TYPE  ZPS_R_BRANCH_T
*"  TABLES
*"      IT_BRANCH_DESC STRUCTURE  ZPS_BRANCH_DESC OPTIONAL
*"----------------------------------------------------------------------

data:
 it_zpca like standard table of zpca with header line,
 c_region type khinr value 'JWHCO'.

* Valid branches
data:
  wa_werks like zpca-branch,
  it_werks like standard table of wa_werks.

data:
  wa_branch_range like zps_r_branch,
  wa_branch_desc  like zps_branch_desc.


* Init
  check not i_grpname[] is initial.
  clear e_branch_range. refresh e_branch_range.

* Read All Branches for Division from ZPCA
  select *
    into table it_zpca
    from zpca
   where region   eq c_region and
         division in i_grpname.

  check not it_zpca[] is initial.

  loop at it_zpca.

    wa_branch_range-sign    = 'I'.
    wa_branch_range-option  = 'EQ'.
    wa_branch_range-low     = it_zpca-branch.
    append wa_branch_range to e_branch_range.
    clear wa_branch_range.

  endloop.
  sort e_branch_range.
  delete adjacent duplicates from e_branch_range.

* Get Descriptions
  if flag_read_desc ne space.

    loop at it_zpca.

       wa_branch_desc-werks  = it_zpca-branch.
       wa_branch_desc-bukrs  = it_zpca-cmpy.
       wa_branch_desc-brtext = it_zpca-brtext.
       wa_branch_desc-brtextextd = it_zpca-brtextextd.

       append wa_branch_desc to it_branch_desc. clear wa_branch_desc.

    endloop.
    sort it_branch_desc.

  endif.

ENDFUNCTION.

Edited by: Paul Chapman on Dec 5, 2008 2:41 PM

Read only

0 Likes
1,459

Hi,

That means i need to copy the fm CUSTOMER_DUE_DATE_ANALYSIS into Zfm and make changes?

Thanks

Read only

0 Likes
1,459

Okay,Do one thing :

Just fetch the master data from T001 based on selection sceen values like 1000 to 2000.

select * from t001 into table i_t001 where bukrs in i_bukrs.

and by looping on i_t001 table read your final internal table with key bukrs and code looks like:

loop at <final itab>.
*CALL FUNCTION 'CUSTOMER_DUE_DATE_ANALYSIS'*  
  EXPORTING
      BUKRS             = <finalitab-bukrs>
endloop.

That means i need to copy the fm CUSTOMER_DUE_DATE_ANALYSIS into Zfm and make changes?

No, Not at all.

Read only

0 Likes
1,459

Hi there..

If you can investigate on the root cause of the issue.. its because any of the internal table does not have a BUKRS field.. investigate in such a way where you can find a link between Customer and company code.. join those table and get bukrs... loop that table pass then to the FM or BAPI..

*CALL FUNCTION 'CUSTOMER_DUE_DATE_ANALYSIS'*  
  EXPORTING
      BUKRS             = P_COMP            
      KKBER             = WRK-KKBER
      KUNNR             = WRK-KUNNR
      RASID             = 'FEND'
      KLIMP             = 'X'
    IMPORTING
      SFAE1             = W_SFAE1
      SFAE2             = W_SFAE2
      SFAE3             = W_SFAE3
      SFAE4             = W_SFAE4
      SFAE5             = W_SFAE5
      SFAE6             = W_SFAE6
      SFAEL             = W_SFAEL
      SNFA1             = W_SNFA1
      SNFA2             = W_SNFA2
      SNFA3             = W_SNFA3
      SNFA4             = W_SNFA4
      SNFA5             = W_SNFA5
      SNFA6             = W_SNFA6
      SNFAE             = W_SNFAE
    EXCEPTIONS
      NO-AGING_SCHEDULE = 1
      NO_TABLE_INPUT    = 2.