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: 

to use the function.modu 'MRM_INVHEAD_MANY_READ' in a subroutine

Former Member
0 Kudos

i want to write this function within a subroutine. i don't know how to pass the parameter for I_TAB_IVTYP etc. Can u show me the coding that has uses the subroutine that has something like this.

perform ........

LOOP AT I_TAB_RBKPV_A INTO WA_TAB_RBKPV_A.

WRITE: / WA_TAB_RBKPV_A-BELNR .

ENDLOOP.

form .........

CALL FUNCTION 'MRM_INVHEAD_MANY_READ'

EXPORTING

T_IVTYP = I_TAB_IVTYP

TABLES

T_BLART = S_BLART

T_XBLNR = S_XBLNR

T_BKTXT = S_BKTXT

T_USNAM = S_USNAM

  • T_ERFNAM =

T_GJAHR = S_GJAHR

T_LIFNR = S_LIFNR

T_BUKRS = S_BUKRS

T_BELNR = S_BELNR

T_BLDAT = S_BLDAT

T_BUDAT = S_BUDAT

  • T_REPART =

  • T_RBSTAT = L_RG_RBSTAT

T_RBKPV = I_TAB_RBKPV_A

  • EXCEPTIONS

  • ENTRY_NOT_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.

endform.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Did the answer in this thread not answer your questio?

Regards,

Rich Heilman

8 REPLIES 8

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Did the answer in this thread not answer your questio?

Regards,

Rich Heilman

0 Kudos

when i tried using the given example it thrown an run time error.

0 Kudos

Just see how he defined the parameters .

0 Kudos

What was the error?

Regards,

Rich Heilman

0 Kudos

the field t_ivtyp no defined. that u no error while activating, this occurs only during execution.

0 Kudos

Ok, go back to that example. We must make a change, then it will work. That parameter is defined in the function module as "Pass by Value", this means that you cannot pass by reference here. So we need to get around it if we want to call it in a subroutine. Here is the changes that you will to make(in BOLD), then the example will work. Make sure to award points to the other thread and mark it as solved as well as this thread. Thanks.



*&---------------------------------------------------------------------*
*&      Form  read_invhead
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_LT_IVTYP  text
*      -->P_LT_BLART  text
*      -->P_LT_XBLNR  text
*      -->P_LT_BKTXT  text
*      -->P_LT_USNAM  text
*      -->P_LT_GJAHR  text
*      -->P_LT_LIFNR  text
*      -->P_LT_BUKRS  text
*      -->P_LT_BELNR  text
*      -->P_LT_BLDAT  text
*      -->P_LT_BUDAT  text
*      -->P_LT_RBKPV  text
*----------------------------------------------------------------------*
form read_invhead tables lt_ivtyp type  mrm_tab_ivtyp
                         lt_blart type  mrm_tab_soblart
                         lt_xblnr type  mrm_tab_soxblnr
                         lt_bktxt type  mrm_tab_sobktxt
                         lt_usnam type  mrm_tab_sousnam
                         lt_gjahr type  mrm_tab_sogjahr
                         lt_lifnr type  mrm_tab_solifnr
                         lt_bukrs type  mrm_tab_sobukrs
                         lt_belnr type  mrm_tab_sobelnr
                         lt_bldat type  mrm_tab_sobldat
                         lt_budat type  mrm_tab_sobudat
                         lt_rbkpv type  mrm_tab_rbkpv.

<b>  data: i_ivtyp type mrm_tab_ivtyp.</b>
  data: lt_rbstat type mrm_tab_sorbstat,
        lwa_rbstat like line of lt_rbstat.

  lwa_rbstat-sign = 'I'.
  lwa_rbstat-option = 'EQ'.
  lwa_rbstat-low = '2'.
  append lwa_rbstat to lt_rbstat.

<b>  i_ivtyp[] = lt_ivtyp[].</b>

  call function 'MRM_INVHEAD_MANY_READ'
    exporting
<b>      t_ivtyp               = i_ivtyp</b>
    tables
     t_blart               = lt_blart
     t_xblnr               = lt_xblnr
     t_bktxt               = lt_bktxt
     t_usnam               = lt_usnam
*   T_ERFNAM              =
     t_gjahr               = lt_gjahr
     t_lifnr               = lt_lifnr
     t_bukrs               = lt_bukrs
     t_belnr               = lt_belnr
     t_bldat               = lt_bldat
     t_budat               = lt_budat
*   T_REPART              =
      t_rbstat              = lt_rbstat
      t_rbkpv               = lt_rbkpv
   exceptions
     entry_not_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.

endform.                    " read_invhead

REgards,

Rich Heilman

Former Member
0 Kudos

Hi Anitha,

You can go to SE37 & give the FM name & go to display.then press 'where used list' button,you can see the programs where this FM is used & how the parameters are passed.Do it accordingly in your code.

0 Kudos

The values that can be passed are.....



          Online                              
1         ERS                                 
2         ERS zero document                   
3         Batch run                           
4         EDI                                 
5         Cancellation                        
6         Invoicing plan                      
7         Transfer prices                     
8	  Revaluation
9	  WEB invoice
B	  BAPI invoice
A	  Invoice from Parking function
C	  Account maintenance

                    

Regards,

Rich Heilman