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

Performance problem in smartform(abap)

Former Member
0 Likes
503

HI floks

i did some development in new smartform its working fine but i have issue in data base performance is 76% . but i utilize similar below code with various conditions in various 12 places . is it possible to reduce performance this type of code . check it and mail me how can i do it . if possible can suggest me fast .how much % is best for this type of performance issues.

DATA : BEGIN OF ITVBRPC OCCURS 0,

LV_POSNR LIKE VBRP-POSNR,

END OF ITVBRPC.

DATA : BEGIN OF ITKONVC OCCURS 0,

LV_KNUMH LIKE KONV-KNUMH,

LV_KSCHL LIKE KONV-KSCHL,

END OF ITKONVC.

DATA: BEGIN OF ITKONHC OCCURS 0,

LV_KNUMH LIKE KONH-KNUMH,

LV_KSCHL LIKE KONH-KSCHL,

LV_KZUST LIKE KONH-KZUST,

END OF ITKONHC.

DATA: BEGIN OF ITKONVC1 OCCURS 0,

LV_KWERT LIKE KONV-KWERT,

END OF ITKONVC1.

DATA : BEGIN OF ITCALCC OCCURS 0,

LV_KWERT LIKE KONV-KWERT,

END OF ITCALCC.

DATA: COUNTC(3) TYPE n,

TOTALC LIKE KONV-KWERT.

SELECT POSNR FROM VBRP INTO ITVBRPC

WHERE VBELN = INV_HEADER-VBELN AND ARKTX = WA_INVDATA-ARKTX .

APPEND ITVBRPC.

ENDSELECT.

LOOP AT ITVBRPC.

SELECT KNUMH KSCHL FROM KONV INTO ITKONVC WHERE KNUMV =

LV_VBRK-KNUMV AND KPOSN = ITVBRPC-LV_POSNR AND KSCHL = 'ZLAC'.

APPEND ITKONVC.

ENDSELECT.

ENDLOOP.

SORT ITKONVC BY LV_KNUMH.

DELETE ADJACENT DUPLICATES FROM ITKONVC.

LOOP AT ITKONVC.

SELECT KNUMH KSCHL KZUST FROM KONH INTO ITKONHC WHERE KNUMH = ITKONVC-LV_KNUMH AND KSCHL = 'ZLAC' AND KZUST = 'Z02'.

APPEND ITKONHC.

ENDSELECT.

ENDLOOP.

LOOP AT ITKONHC.

SELECT KWERT FROM KONV INTO ITKONVC1 WHERE KNUMH = ITKONHC-LV_KNUMH AND

KSCHL = ITKONHC-LV_KSCHL AND KNUMV = LV_VBRK-KNUMV.

MOVE ITKONVC1-LV_KWERT TO ITCALCC-LV_KWERT.

APPEND ITCALCC.

ENDSELECT.

endloop.

LOOP AT ITCALCC.

COUNTC = COUNTC + 1.

TOTALC = TOTALC + ITCALCC-LV_KWERT.

ENDLOOP.

MOVE ITKONHC-LV_KSCHL TO LV_CKSCHL.

MOVE TOTALC TO LV_CKWERT.

it's urgent ..........

thanks .

bbbbye

suresh

3 REPLIES 3
Read only

Former Member
0 Likes
462

Hi

U can use for all entries instead of to insert the select statament into loop:

SELECT POSNR FROM VBRP INTO TABLE ITVBRPC
            WHERE VBELN = INV_HEADER-VBELN 
              AND ARKTX = WA_INVDATA-ARKTX .

IF SY-SUBRC = 0.
  SELECT KNUMH KSCHL FROM KONV INTO TABLE ITKONVC
    FOR ALL ENTRIES IN  ITVBRPC 
         WHERE KNUMV = LV_VBRK-KNUMV 
           AND KPOSN = ITVBRPC-LV_POSNR 
           AND KSCHL = 'ZLAC'.
  
  SELECT KNUMH KSCHL KZUST FROM KONH INTO TABLE ITKONHC
          FOR ALL ENTRIES ITKONVC
                WHERE KNUMH = ITKONVC-LV_KNUMH 
                  AND KSCHL = 'ZLAC' AND KZUST = 'Z02'.
  IF SY-SUBRC = 0.
   SELECT KWERT FROM KONV INTO TABLE ITCALCC 
          FOR ALL ENTRIES ITKONHC
                  WHERE KNUMV = LV_VBRK-KNUMV
                    AND KSCHL = ITKONHC-LV_KSCHL 
                    AND KNUMH = ITKONHC-LV_KNUMH. 

   ENDIF.
 ENDIF.

Max

Read only

0 Likes
462

I think you'll find that if you follow Max's example, the database percentage will actually go up!

But this is because his code is more efficient on the non-database portion of the program. It will eliminate a lot of network traffic between the database and the application

My point is that looking at the database percentage doesn't really tell you much. A program that retrieves a lot of data but doesn't manipulate it will naturally have a high database percentage. One that doesn't get much data but processes heavily what it does get will have a lower database percentage.

The important things to keep in mind are to use an index (which you are already doing) and avoid nested loops (which doesn't apply here).

Rob

Read only

Former Member
0 Likes
462

u can use INTO TABLE instead of INTO & ENDSELECTION.

u can use FOR ALL ENTRIES instead of LOOPS & NESTED LOOPS.

REGDS

KIRAN