Standard function module inside a loop.

Hi Experts,
I am trying to improve performance program that has a standard abap function module inside a loop. I am some what lost on what to do here. Here below is what the code looks like as of now. I have read that i need to try and not use the function module at all be it is a very complicated function module. Any suggestions will be appreciated.
DATA: tl_retorno TYPE bapireturn1 OCCURS 0 WITH HEADER LINE. "Retorno
   DATA: wl_bukrs   LIKE acct_det_bf-comp_code,     "Empresa
         wl_process LIKE acct_det_bf-process,       "Chave
         wl_symko   LIKE hrpp_acct_det-symb_acct,   "Conta Simbólica
         wl_momag   LIKE hrpp_acct_det-eg_acct_det, "Agrupamento
         wl_razao   LIKE acct_det_bf-gl_account.    "Conta Razão
*-->                  <--*
   SORT tg_rubcr BY bukrs lgart.
   LOOP AT tg_rubcr.
     CLEAR: wl_bukrs, wl_process, wl_symko, wl_momag, wl_razao.
     wl_bukrs   = tg_rubcr-bukrs.
     wl_process = tg_rubcr-process.
     wl_symko   = tg_rubcr-symko.
     CLEAR tg_aux.
     IF tg_rubcr-u_momag IS INITIAL. "A rubrica necessita de agrupamento?
       CLEAR wl_momag.
* Busca Contas Razão sem Agrupamento de Empregados
       CALL FUNCTION 'HRPP_FI_ACCT_DET_HR'
         EXPORTING
           companycode              = wl_bukrs
           process                  = wl_process
           symb_acct                = wl_symko
           eg_acct_det              = wl_momag
           add_modif                = ' '
         IMPORTING
           gl_account_debit         = wl_razao
*         GL_ACCOUNT_CREDIT        =
*         POSTING_KEY_DEBIT        =
*         POSTING_KEY_CREDIT       =
*         ACCOUNT_TYPE             =
         TABLES
           return_tab               = tl_retorno.
       tg_rubcr-razao = wl_razao.
       tg_aux = tg_rubcr.
       APPEND tg_aux.
     ELSE.  "Não necessita de agrupamento de empregado?
       LOOP AT tg_t52em. "Para todos os agrupamentos
         CLEAR tg_aux.
         CLEAR tl_retorno.
         REFRESH tl_retorno.
         CLEAR wl_momag.
         wl_momag  = tg_t52em-momag.
* Busca Contas Razão com Agrupamento de Empregados
         CALL FUNCTION 'HRPP_FI_ACCT_DET_HR'
           EXPORTING
             companycode              = wl_bukrs
             process                  = wl_process
             symb_acct                = wl_symko
             eg_acct_det              = wl_momag
             add_modif                = ' '
           IMPORTING
             gl_account_debit         = wl_razao
*           GL_ACCOUNT_CREDIT        =
*           POSTING_KEY_DEBIT        =
*           POSTING_KEY_CREDIT       =
*           ACCOUNT_TYPE             =
           TABLES
             return_tab               = tl_retorno.
         tg_rubcr-razao = wl_razao.
         tg_aux = tg_rubcr.
         tg_aux-momag = tg_t52em-momag.
         APPEND tg_aux.
       ENDLOOP.
     ENDIF.
   ENDLOOP.
* Limpa tabela com rubricas e move todo o conteúdo da auxiliar
   REFRESH tg_rubcr.
   CLEAR tg_rubcr.
   tg_rubcr[] = tg_aux[].
ENDFORM.                    " busca_conta_razao

Hi Patrick,
If you do not want to use the function module then the other option that you can use is do selects from the tables that the FM 'HRPP_FI_ACCT_DET_HR' is using to get the importing "parameter  gl_account_debit         = wl_razao"  outside the loop.
So steps will be:
Debug FM 'HRPP_FI_ACCT_DET_HR'  to find out how it getting importing data using exporting parameters.
Then before the loop is called do a select for all entries on table tg_rubcr. And id muliple tables are used Read statements to populate a final table with gl_account_debit         = wl_razao value.
Then use the final table to get this value inside the loop.
Please let me know if you need more details.

Similar Messages

  • *Can we call a Standard Function Module inside a Zfunction module ?*

    Can anyone please help me know whether we can call a Standard Function Module inside a Zfunction module ?
    I tried the same (No syntax error) BUT when i activate the zFunction Module it throws the error:-
    +'' REPORT/PROGRAM statement missing, or program type is INCLUDE. " +

    Yes, I got the Answer -
    We Can we call a Standard Function Module inside a Zfunction module.
    But we need to make sure that the Function Groups are activated.
    FUNCTION ZFM_TEST_NESTED_FM.
    ""Local Interface:
    *"  EXPORTING
    *"     REFERENCE(EX_CONVERT_UPPER_CASE) TYPE  STRING
    CALL FUNCTION 'TERM_TRANSLATE_TO_UPPER_CASE'
      EXPORTING
      LANGU                     = SY-LANGU
        TEXT                         = 'gaurav'
    IMPORTING
        TEXT_UC                   = EX_CONVERT_UPPER_CASE
    EXCEPTIONS
       NO_LOCALE_AVAILABLE       = 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.
    ENDFUNCTION.

  • Standard Function Modules required

    I am look for a standard Function Module / RFC / BAPI for the below
    Get the list of table (for a given search criteria like if I give m* it should return me list of
              tables starting with m)
    Get details of the table (its field details)
    Regards,
    Samson.

    Select TABNAME fron dd02l into Itab where Tabname like M*
    Select FIELDNAME ROLLNAME DOMNAME DATATYPE from dd03l into itab2 fro all entries in Itab where tabname = itab-tabname.
    Or:
    Select TABNAME fron dd02l into Itab where Tabname like M*
    Loo at Itab.
    Pass table name in each loop pass to FM: GET_FIELDTAB or DDIF_FIELDINFO_GET
    GET_FIELDTAB    -
    >If you pass table it will give you related fields.
    Endloop.
    Regards,
    Gurpreet

  • How to capture error message from standard function module

    Dear friends
    when i  execute standard function module in finance , i am getting error message , pls check the below screen shot,
    how to capture the below error message so that i have display in my webdynpro component
    Thanks
    Vijaya

    Hello Vijaya,
    Incase of BAPI's they have a return table parameter T_RETURN. Just read that return table to get the error message.
    Incase of normal function modules, there will be exceptions raised for the message used inside the function module. Just read the sy-subrc after the FM and based on the sy-subrc value find the respective exception raised.
    May be you can try like this, whenever the message is raised it will be stored in the system variable.
    CALL FM.
    check for the system variables.
    sy-msgid = Message ID of the latest message raised.
    sy-msgno = message number of the latest message raised.
    sy-msgty = message type of the latest message raised.
    sy-msgv1 = variable1 of the latest message raised.
    sy-msgv2 = variable2 of the latest message raised.
    sy-msgv3 = variable3 of the latest message raised.
    sy-msgv4 = variable4 of the latest message raised.
    Regards,
    TP

  • Where the documentation is provided for the Standard Function module ?

    If there is no documentation provided for the standard function module in SE37 what is the best way to understand the functionality of the function module?Is there any where we can find the documentation?
    Please dont say the From coding part its too vast to understand
    Ex: HRCM_ORGSTRC_INFO_TABLE_GET
    Paint for me ..
    Regards
    sas
    Edited by: Julius Bussche on Mar 18, 2009 1:17 PM

    O Really thanks amit !!
    Are you able to understand the below code and please provide your valuable inputs what we are understanding is the same.
    PERFORM read_infotypes.
    *-- ********************************************************** NMP
    *-- IF scb frozen then write to itab-scb field.  nmp 11/2001.
    *-- ********************************************************** NMP
    *--Begin of Change by vneld - 01/17/2007
    *  IF PA0001-ZZBERN NE SPACE.
    *    FROZEN = PA0001-ZZBERN.
    *  ENDIF.
    *  ITAB-SCB = FROZEN.
    *-- ********************************************************** NMP
    *--end of Change by  vneld- 01/17/2007
      PERFORM get_date USING '92'
                       CHANGING w_hiredate.
      PERFORM get_date USING '93'
                       CHANGING w_rehire.
      PERFORM get_date USING '94'
                       CHANGING w_termdate.
      IF NOT ( w_rehire IS INITIAL ).
        w_hiredate = w_rehire.
        itab-code = 'R'.
      ELSE.
        itab-code = 'H'.
      ENDIF.
      IF p0001-persg = '3'.
        itab-code = 'T'.
      ENDIF.
    *Change by Mdukes
    ** We need HIRE,Rehire & term  within 13 month`s window
    ** But if someone Hire in IT ,change dept and then terminated .
    ** We need to exclude that person from the list  .
    ** We need to change his Org.Unit by END_DATE 12/31/9999 from Pa0001.
      CLEAR:result_tab.REFRESH:result_tab.
      CALL FUNCTION 'HRCM_ORGSTRC_INFO_TABLE_GET'
        EXPORTING
          PLVAR          = '01'
          ROOT_OTYPE     = 'O'
          ROOT_OBJID     = P0001-ORGEH
          BEGDA          = SY-DATUM
          ENDDA          = P0001-ENDDA
          PATH_ID        = EVPATH
          PATH_DEPTH     = 10
        TABLES
          ORG_INFO_TABLE = result_tab
        EXCEPTIONS
          PATH_ERROR     = 1
          ROOT_ERROR     = 2
          OTHERS         = 3.
    *  CALL FUNCTION 'RH_STRUC_GET'
    *    EXPORTING = 'O'
    *      act_objid       = PA0001-ORGEH
    *      act_wegid       =  EVPATH
    *      act_plvar       =  TYPE
    *      act_tflag       = space
    *      act_vflag       = space
    *      authority_check = space
    *    TABLES
    *      result_tab      = result_tab
    *    EXCEPTIONS
    *      no_plvar_found  = 1
    *      no_entry_found  = 2
    *      OTHERS          = 3.
    * reading the Org.Unit based on employee Org.unit (Evaluation Path 'O-O'.
    * After that making sure the latest Pa0001 org.unit is part of selection org.unit
    * If yes, set the flag to = 1 . Otherwise ignore the rec .
    * We want only IT folks hire/rehire/term within 13 monthu2019s window
    * if somebody change the dept and get term within 13 monthu2019s .it
    * Should show up in hire but not in term report .
      CLEAR:REC.
      lOOP AT result_tab.
        read table PCHOBJID with key low = result_tab-OBJID.
        if sy-subrc = 0 .
          Rec = 1.
          EXIT.
        Endif.
      ENDLOOP.
      if rec  = 1.
    *--begin of change by vneld- 01/17/07
        CHECK ( ( w_hiredate >= w_13th_mnth_date AND w_hiredate <= sy-datum )
          OR
              ( w_termdate >= w_13th_mnth_date AND w_termdate <= sy-datum ) ).
    *--end of change by vneld- 01/17/07
    **---check for hires or terms in the calendar year.
    **---No future terms
    *  CHECK ( ( W_HIREDATE(4) = SY-DATUM(4) ) OR
    *  ( W_TERMDATE(4) = SY-DATUM(4) AND W_TERMDATE <= SY-DATUM ) ).
        CONCATENATE p0002-vorna p0002-nachn INTO itab-name SEPARATED BY ' '.
    *--Begin of change by vneld 03/29/2007
    *--get supervisor name
        data : lname(20),
               fname(20).
        clear: lname,
               fname.
        Select vorna nachn from pa0002 into (fname ,lname)
               where pernr =  p0001-zzsuper_no.
        endselect.
        CONCATENATE lname fname INTO itab-supv SEPARATED BY ' '.
    *  itab-supv = p0001-zzsuper_text.
    *--End of change by vneld 03/29/2007
    *----get employee group text
        CLEAR t501t.
        SELECT SINGLE * FROM t501t WHERE sprsl = 'EN' AND
                                         persg = p0001-persg.
        IF sy-subrc EQ 0.
          itab-group = t501t-ptext.
        ENDIF.
        PERFORM get_dept.
        PERFORM get_position.
        PERFORM append_fields.
      endif.
    ENDFORM.                    " PROCESS_EMPLOYEE
    Edited by: saslove sap on Mar 19, 2009 7:45 AM

  • IF statement in Standard function module PRICING

    Hi,
    In standard function module PRICING
    I found one if statement like this.
    if  xkomv-kntyp na '1$' .
    Plz tell me the meaning of thai '1$' value.
    Regards,
    Upender Verma.

    Hi,
         NA means Contains Not Any ..
         if xkomv-kntyp na '1$'  means .. xkomv-kntyp does not contain '1' or '$'.
         Read help on comparision operator 'NA'
    Regards,
    Srini.

  • Implicit enhancement to a standard function module.

    Hi everybody.
    I used an Implicit Enhancement to a Standard function module Customized_Message, at the starting of function module.
    Code:
    ENHANCEMENT 1  ZFK01_ENHANCEMENT4.    "active version
    If sy-tcode = 'FK01' and sy-CPROG = 'SAPMF02K' AND I_MSGNR = '230' AND i_arbgb = 'F2' AND I_DTYPE = 'I'.
      EXIT.
    ENDIF.
    ENDENHANCEMENT.
    The above is working fine, to the condition what i had given above code.
    But my question is, can i use a implicit enchancement to a Standard function module(Customized_message).

    Yes, but you should also be aware that 'F2' is a configurable message class in the IMG.  You should attempt to solve your issue in that manner first.

  • Error in the SAP standard function module 'RSDRI_INFOPROV_READ'.

    Hello Experts,
    We upgraded from 3.5 to 7,0 support pack 17 .
    After upgrade we are getting error
      with return code 11 'Others´'.
    While debugging the standard function module we found that the standard method s_r_infoprov->read is being executed with the return code = 8 (inherited_error).
    Any suggestions?
    Regards,
    Vivek

    Not sure if the parameters provided were correct,you may wish to do a sanity check
    Input Parameters:
    1. I_INFOPROV - This will hold the Name of the Info Cube from where we need the pull the data.
    2. I_T_SFC - This parameter is in the format of Internal Table which holds the Character Info Objects we need to pull from the Source Cube.
    3. I_T_SFK - This parameter is also in the format of Internal Table which holds the Key Figure Info Objects which we need to pull from the Source Cube.
    4. I_T_RANGE - This is also in the format of Internal Table which holds the Selection criteria for which we need to pull from the Source Cube u2013 For example the Company Code u2013 001 and Fiscal Year Period u2013 001/2006.
    5. I_T_REQUID u2013 Selection of cube data based on Request Id.
    6. I_SAVE_IN_TABLE u2013 In case you need to save the data in DB table
    7. I_REFERENCE_DATE u2013 This holds the current date.
    8. I_AUTHORITY_CHECK u2013 This will hold the value u2018Ru2019, which is meant for READ.
    9. I_DEBUG u2013 This is for Debugging mode and holds the default value u2018Yu2019.
    Output Parameters:
    1. E_T_DATA u2013 This Output Parameter is of internal table format, in which we can mention the output fields (For all the fields mentioned in the Input Parameter, this output parameter will hold the values).
    2. E_END_OF_DATA u2013 Once the FM is executed successfully, this output parameter will hold the value u2018Xu2019, means extraction completed successfully.
    Hope it Helps
    Chetan
    @CP..

  • BDC program or standard function module to change data in PFCG TCode.

    Gurus,
    I have programatically change the validity date of SAP security role (TCode PFCG). Are there any standard function module available for this ? If not then does PFCG supports update vida BDC programming ?
    Regards,
    Rajesh.

    Cross-posting. Thread locked.
    Please read [the rules|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement].
    PS: Please clean up / follow up on all your hundreds of unresolved questions.

  • Is it necessary to use the standard function modules always?

    Hi All,
       Suppose i can retrieve the BUSINEES PARTNER ID from the table BUT000 with the help of 'BP_GUID' field through a select query statement. 
    Now is it necessary to use a standard function module to retrieve the same data. what about the performance? which is the better solution. to implement our own code or to use the function module available.
    Please someone clarify me about this issue.
    Regards,
    Sharry.

    If you'd ask the question in general it's obvious that there is no good answer as it always would depend on the circumstance. However, as you've posted your question in the performance tuning forum, let's look at your question in this context first. I think it's fairly safe to say, that in almost 100% of the cases a standard function module will not be as fast as any well implemented and custom tailored code. If in doubt, just try reading the code of the function module you want to read; most likely you will find lots of unnecessary fluff in there, often they read data that you don't even need.
    And as far as buffering is concerned, that can also be an issue. E.g. let's say you do a massive read of distinct business partners and you only need the data once for each partner. Obviously buffering is silly in this case and it might even slow down your program, because the implemented buffering is not necessarily well implemented. I've come across a few cases, where the buffer tables where standard tables with no efficient read access (so no sorted table or hash table) and once tons of data were buffered, it actually took a moment to look up if the record already was buffered (just to find it wasn't there yet).
    Now most of the times this slowdown is not an issue as the lookup is still fast compared to the (usually) prevalent database accesses with their slower IO timing. But another factor to consider is memory consumption and why buffer data in memory (and waste it), if you can't use the buffer anyway? So when I do use standard function modules, I usually try to see what they retain in global memory, to better understand if I need to call some initialization/clearing/refresh function...
    Note also that often you need to process lots of data, but don't find a standard function module for "mass access", so you need to read your object one by one. Obviously that's another good candidate for implementing your own queries, where you can process the data in packages.
    So what might be the reason to use a standard function module? Well, often it's required because the logic is so complex that it would take you too much time to implement it (not to mention that we often simply don't know all the logic that's coded in there). Another advantage is that you might get independent of the data model. E.g. for IDoc interfaces SAP switched in some release the tables where the data is stored. So if you had coded your own queries to get IDoc data, they wouldn't have worked after this particular release upgrade. The standard function on the other hand, checks both the old and new tables, so by using it you would have been fine.
    The one major caveat I'd give though is to always check whether the function module is released or at least documented to some degree. I.e. if it's not released, SAP won't support it and does not guarantee that the interface or logic stays the same. In my experience lots of functions I do want to use are not released (or documented), but I will still use them because they seem to be the best alternative in certain scenarios.
    Cheers, harald

  • Do we have standard function module or program to activate transformation?

    Hi Gurus,
    Do we have any standard function module or program to activate transformation in BI system? If yes please let me know or let me know how to proceed with to create custom program to activate transformation.
    Thanks,
    Manoj

    Hi Sven,
      Thanks for your help.
    Even I am facing the same problem, we didnt want to open the production system to activate the transformation also it take time to transport them every time from development
    can you please explain how to use these methods, what parameters to pass
    do you have a sample code, it will be of great help.
    use this methods
    cl_rstran_trfn=>factory
    cl_rsds_rsds=>if_rso_tlogo_general~get_instance
    l_rsds->if_rso_tlogo_maintain~is_active
    l_rsds->if_rso_tlogo_maintain~activate

  • Any standard function module to read data from a cube

    Hi,
    I want to read data from a cube say XYZ, into an internal table. Is there any standard function module to do this? If so can anyone plz tell me what change should i make in the function module for my requirement.
    Regards
    BW Fresher.

    Hi R,
    Try function module 'RSDRI_INFOPROV_READ'
    ABAP Report RSDRI_INFOPROV_READ_DEMO contains an example of how the function module can be used.
    Udo

  • Standard Function modules to update customer partner

    Hi,
    Can anyone please suggest standard function modules to update customer partner functions?
    Was looking at Customer_insert, customer_update, CUSTOMER_UPDATE_SALES_AREA.
    I will have only the partner data in the customser sales view to get updated. I dont need the company data.
    Awaiting some insightful inputs please.
    Thanks,
    Satheesh

    FM and TABLES
    http://72.14.235.104/search?q=cache:71IXBMWcX_8J:reflexcontracts.co.uk/SAP_R3_QUICK_REF.xlsupdatetable+tse05&hl=en&ct=clnk&cd=1&gl=in
    FUNCTION MODULES
    http://www.erpgenie.com/abap/functions.htm
    http://www.sapdevelopment.co.uk/fmodules/fmssap.htm
    http://www.erpgenie.com/abap/index.htm
    http://www.geocities.com/victorav15/sapr3/abapfun.html
    Rewards if useful.........
    Minal

  • Standard Function Module for OB52

    Hi,
      Is there any standard function module or BAPI for OB52 transaction.
      PLease let me know.
    Regards,
    Raghu

    Hi,
    OB52 is basically a transaction variant of SM30 for maintaining the view V_T001B.
    So there will not be any BAPI available to maintain the same.
    Regards,
    Ankur Parab

  • Standard function modules

    how to work with standard function modules

    To work with standard function modules,
    First Check the function module in se37  and also read the function module documentation if available
    execute the function module.
    u will get a screen.
    You need to give some inputs in the output of the function module. say object-id as a input 4400000456.
    Also check the import and export parameters which gets updated once u execute the function modules after feeding inputs to the function module.
    actually in the example, 4400000456.
    once u give the input. the corresponding internal tables related to that object-id get automatically thru the fM.
    then u can retrieve the related information from the internal tables of function modules.
    say Get the number of days for a particular month
    in this function module my input is month  and year.
    this will return no of days for that particular month.
       CALL FUNCTION 'NUMBER_OF_DAYS_PER_MONTH_GET'
         EXPORTING
           par_month = p_bumon
           par_year  = p_bdatj
         IMPORTING
           par_days  = lv_days.
    Similary u can work with other function module , which is necessary for your requirement
    Thanks

Maybe you are looking for

  • WQHD IPS Monitor support

    I currently am operating on a 2010 Mac Pro with a ATI Radeon HD 5770 video card (two minidisplay port, and a single dual-link DVI) .  The machine has been upgraded to 10.8.X, and has 16GB or RAM.  My 30" Apple display is on its last legs.  I cannot c

  • Weird Problem Exporting HD to DVD (only when camera moving)

    i just edited an HD footage then i exported it as self contained animated movie. then i compressed it with compressor as DVD Best Quality 90 min. after i burned it with DVD studio Pro, i played it back from the dvd, and the image is acceptable with t

  • Will changing the suffix on the file type make the file readable on devices

    I read on the forums that you can just change the .mov to .mp4 to get devices to recognize the file. It that correct or does the file actually need to be converted? I am trying to get a Quicktime movie to play on an Android phone.

  • DW CS3 Crashing when /select tag closed

    Hi all, Could someone please take a brief look at the code below and tell me why Dreamweaver CS3 keeps crashing every time I try to close the </select> tag? Quick rundown: I'm populating a detail page from my SQL database. If an option (for example "

  • Access Database for Mac-Replacement

    What is the application for mac that is the most similar to Microsoft Access? I used to use it in my PC days, and it was so much easier to use than free mac solutions I've tried such as NeoOffice Database. I was hoping to find an app in the <100 rang