cancel
Showing results for 
Search instead for 
Did you mean: 

improve performance of a BI routine

Former Member
0 Kudos
84

Hi Colleagues,

As I am rather beginner on ABAP development. Could you provide some advise in order to improve the abap coding below ?

Thanks

    loop at RESULT_PACKAGE assigning <result_fields>.

*  Populate <result_fields>-/BIC/ZGLACCOUN
    IF <result_fields>-GL_ACCOUNT = '2121010299' AND
       <result_fields>-/BIC/ZGLACCOUN IS INITIAL.
       SELECT SINGLE GL_ACCOUNT FROM /BI0/PMATL_GROUP INTO
       <result_fields>-/BIC/ZGLACCOUN
       WHERE MATL_GROUP EQ <result_fields>-MATL_GROUP AND
                OBJVERS EQ 'A'.
    ELSEIF <result_fields>-GL_ACCOUNT = '2120010099' AND
       <result_fields>-/BIC/ZGLACCOUN IS INITIAL.
       SELECT SINGLE GL_ACCOUNT FROM /BI0/PMATL_GROUP INTO
       <result_fields>-/BIC/ZGLACCOUN
       WHERE MATL_GROUP EQ <result_fields>-MATL_GROUP AND
                OBJVERS EQ 'A'.
    ELSE.
      <result_fields>-/BIC/ZGLACCOUN = <result_fields>-GL_ACCOUNT.
    ENDIF.

** populate : <result_fields>-GR_RE_IND
  SELECT SINGLE GR_RE_IND FROM /BIC/AZPUR_O0100 INTO
  <result_fields>-GR_RE_IND
   WHERE DOC_NUM    EQ <result_fields>-DOC_NUM
   AND   DOC_ITEM   EQ <result_fields>-DOC_ITEM.

** populate : >> 0VENDOR
    IF <result_fields>-vendor IS INITIAL.
*..   Loop to find vendor in DSO 0FIGL_002 via *
*..   Company code, fiscal variant, fiscal period, accounting document *
      LOOP AT gtab-figl_o02 INTO gwa-figl_o02
        WHERE comp_code  = <result_fields>-comp_code AND
              fiscvarnt  = <result_fields>-fiscvarnt AND
              fiscper    = <result_fields>-fiscper   AND
              ac_doc_no  = <result_fields>-ac_doc_no .
*..     If vendor found then get out
        IF gwa-figl_o02-vendor IS NOT INITIAL .
          <result_fields>-VENDOR = gwa-figl_o02-vendor  .
          EXIT .
        ENDIF .

      ENDLOOP .
    ENDIF.

** populate : >> 0PMNTTRMS.
    IF <result_fields>-pmnttrms IS INITIAL.
*..   Loop to find vendor in DSO 0FIGL_002 via *
*..   Company code, fiscal variant, fiscal period, accounting document *
      LOOP AT gtab-figl_o02 INTO gwa-figl_o02
        WHERE comp_code  = <result_fields>-comp_code AND
              fiscvarnt  = <result_fields>-fiscvarnt AND
              fiscper    = <result_fields>-fiscper   AND
              ac_doc_no  = <result_fields>-ac_doc_no .

*..     If vendor found then get out
        IF gwa-figl_o02-pmnttrms IS NOT INITIAL .
          <result_fields>-pmnttrms = gwa-figl_o02-pmnttrms  .
          EXIT .
        ENDIF .

      ENDLOOP .
    ENDIF.
    endloop. 

Edited by: kishan P on Sep 19, 2010 8:11 AM

Edited by: Matt on Sep 19, 2010 8:00 AM - modifed subject

Accepted Solutions (1)

Accepted Solutions (1)

matt
Active Contributor
0 Kudos

Please use a more meaningful subject in future

If the master data of MATL_GROUP (for example) is not too big, select into an internal table and READ from that instead of doing these SELECT SINGLEs. If it is large, then you should still build an internal table, READ from that first, if you don't find it, then do a select and insert into the internal table. These are standard buffering techiques. Apply to ALL the database reads.

Where possible, use HASHED or SORTED internal tables. E.g. gtab-figl_o02 should be SORTED table with a (possibly unique) key of comp_code, fiscvarnt, fiscper, ac_doc_no.

From an ease of maintenance perspective - modularise the program.

From a BI perspective - my understanding is that it is not a good idea to use the standard InfoObjects (0....). Rather create your own, using the standard as a template. And you REALLY don't need to begin your own infoobjects with a "Z".

Finally, go through this thread But you did do that already, didn't you?

Answers (0)