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

Standard function module inside a loop.

Former Member
0 Likes
3,097

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




1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,633

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:

  1. Debug FM 'HRPP_FI_ACCT_DET_HR'  to find out how it getting importing data using exporting parameters.
  2. 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.
  3. Then use the final table to get this value inside the loop.

Please let me know if you need more details.

4 REPLIES 4
Read only

Former Member
0 Likes
1,634

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:

  1. Debug FM 'HRPP_FI_ACCT_DET_HR'  to find out how it getting importing data using exporting parameters.
  2. 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.
  3. Then use the final table to get this value inside the loop.

Please let me know if you need more details.

Read only

0 Likes
1,633

Hi Sandip,

Thank you for replying, it was helpful, but could you please detail the three points for me a little more.

Thanks

Read only

0 Likes
1,633

Put a break point in FM 'HRPP_FI_ACCT_DET_HR'  to find the exporting parameters.

Then open a new SE37 session give your inputs and start debugging.

Properly check all the selects and internal tables that are populated inside the FM to get to the point where the importing parameter gl_account_debit         = wl_razao is filled in.

Idea here is to write the pseudo code of the FM outside the loop before the loop is called and fill an internal table with fields and values that you are passing to this FM and there should be a field that will contain the impoting parameter value also.

Once inside the loop do a read table for the internal table with key from table fields of looping table and match them from the value in the internal table prepared.

Regards,

Sandip

Read only

former_member202771
Contributor
0 Likes
1,633

Hi Patrick,

CALL FUNCTION - STARTING NEW TASK

Check this concept of PARALLEL PROCESSING.


thanks,

Anil