Skip to Content
0
Former Member
Dec 21, 2006 at 09:39 AM

performance Issue in ABAP part as suggested by SE30 for the below coding

44 Views

Dear Abapers,

The below coding was done by my seniors and having performance issue i.e in SE30 the abap part is consuming 98% of time.

Pl. help us to solve this situation.

With best regards,

S. Arunachalam.

the code is:

REPORT ZOBJLIST LINE-SIZE 320 NO STANDARD PAGE HEADING. "280 to 320

TABLES: MARA, MAKT, A916, KONP, MVKE, ZSAI_PARAM.

  • Input parameters *****************************************************

DATA IT_MARA LIKE MARA OCCURS 0 WITH HEADER LINE.

DATA T_CLASS LIKE SCLASS OCCURS 0 WITH HEADER LINE.

DATA T_CLOBJDAT LIKE CLOBJDAT OCCURS 0 WITH HEADER LINE.

DATA FLG_COLOR TYPE C.

DATA WRK_CLASS LIKE KLAH-CLASS.

DATA WRK_PERCENT TYPE I. " Progress percentage

DATA WRK_LINES LIKE SY-TABIX. " To store the no. of lines in int.table

DATA WRK_PROGRESSTEXT(72) . " Progress indicator text

DATA : BEGIN OF IT_MATNR OCCURS 0,

MATNR LIKE MARA-MATNR,

MAKTX LIKE MAKT-MAKTX,

BISMT LIKE MARA-BISMT, "Thanikai-17.05.2002

END OF IT_MATNR.

DATA : BEGIN OF IT_HEADER OCCURS 0,

MATNR LIKE MARA-MATNR,

MAKTX LIKE MAKT-MAKTX,

CLART LIKE SCLASS-KLART,

CLASS LIKE SCLASS-CLASS,

BISMT LIKE MARA-BISMT, "Thanikai-17.05.2002

SCMNG(4) TYPE I, "Thanikai-03.10.2002

END OF IT_HEADER.

DATA : BEGIN OF IT_DETAILS OCCURS 0,

MATNR LIKE MARA-MATNR,

ZAEHL LIKE CLOBJDAT-ZAEHL,

ATNAM LIKE CLOBJDAT-ATNAM,

AUSP1 LIKE CLOBJDAT-AUSP1,

END OF IT_DETAILS.

DATA : BEGIN OF IT_DETAILS1 OCCURS 0,

MATNR LIKE MARA-MATNR,

ATNAM LIKE CLOBJDAT-ATNAM,

ZAEHL LIKE CLOBJDAT-ZAEHL,

END OF IT_DETAILS1.

DATA: IT_DETAILS2 LIKE IT_DETAILS1 OCCURS 0 WITH HEADER LINE.

DATA TMP_MATNR LIKE AUSP-OBJEK.

DATA WRK_FIELD(25).

DATA WRK_TABNAME(40). " Name of the int.table from wrk_fldname

DATA WRK_FIELDNAME(40). " Name of the fld name from wrk_fldname

DATA WRK_FLDNAME(40).

DATA T_CLOBJDAT_LINES LIKE SY-TABIX.

DATA WRK_LINES1 LIKE SY-TABIX.

DATA WRK_FIRST_TIME.

DATA TMP_STR.

DATA WRK_AUSP1 LIKE CLOBJDAT-AUSP1.

DATA: WRK_KBETR LIKE KONP-KBETR. "Thanikai-03.10.2002

************************************************************************

SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.

*PARAMETERS:

SELECT-OPTIONS:

P_MATKL FOR MARA-MATKL DEFAULT 'DIAL' OBLIGATORY NO INTERVALS.

SELECT-OPTIONS : S_MATNR FOR MARA-MATNR MATCHCODE OBJECT MAT1.

SELECTION-SCREEN END OF BLOCK B3.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.

PARAMETERS: P_CLASS LIKE KLAH-CLASS,

P_KLART LIKE KLAH-KLART DEFAULT '001' OBLIGATORY.

SELECTION-SCREEN END OF BLOCK B2.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS : REQ RADIOBUTTON GROUP RGRP ,

NREQ RADIOBUTTON GROUP RGRP .

SELECTION-SCREEN END OF BLOCK B1.

AT SELECTION-SCREEN.

IF NOT P_CLASS IS INITIAL.

WRK_CLASS = P_CLASS.

ELSE.

WRK_CLASS = SPACE.

ENDIF.

************************************************************************

TOP-OF-PAGE.

IF SY-BATCH NE 'X'.

PERFORM PRINT_TOP.

ENDIF.

START-OF-SELECTION.

SET PF-STATUS '9000'.

SELECT * INTO TABLE IT_MARA

FROM MARA CLIENT SPECIFIED

WHERE MANDT = SY-MANDT

AND MATKL IN P_MATKL

AND MATNR IN S_MATNR.

DESCRIBE TABLE IT_MARA LINES WRK_LINES.

MOVE 'Selecting Material Description' TO WRK_PROGRESSTEXT.

PERFORM SAPGUI USING WRK_PERCENT WRK_PROGRESSTEXT.

LOOP AT IT_MARA.

SELECT SINGLE * FROM MAKT CLIENT SPECIFIED

WHERE MANDT = SY-MANDT

AND MATNR = IT_MARA-MATNR

AND SPRAS = 'E'.

IF SY-SUBRC = 0.

IT_MATNR-MATNR = IT_MARA-MATNR.

IT_MATNR-MAKTX = MAKT-MAKTX.

IT_MATNR-BISMT = IT_MARA-BISMT. "Thanikai-17.05.2002

ENDIF.

APPEND IT_MATNR.

CLEAR IT_MATNR.

ENDLOOP.

CLEAR WRK_LINES.

DESCRIBE TABLE IT_MATNR LINES WRK_LINES.

MOVE 'Selecting Class / characteristics for the Material'

TO WRK_PROGRESSTEXT.

PERFORM SAPGUI USING WRK_PERCENT WRK_PROGRESSTEXT.

LOOP AT IT_MATNR.

CLEAR: TMP_MATNR, T_CLASS, T_CLOBJDAT. "Thanikai-26.08.2002

REFRESH: T_CLASS, T_CLOBJDAT. "Thanikai-26.08.2002

TMP_MATNR = IT_MATNR-MATNR.

CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'

EXPORTING

CLASS = WRK_CLASS

CLASSTEXT = 'X'

CLASSTYPE = '001'

  • CLINT = ' '

FEATURES = 'X'

LANGUAGE = SY-LANGU

OBJECT = TMP_MATNR

OBJECTTABLE = 'MARA'

KEY_DATE = SY-DATUM

INITIAL_CHARACT = 'X'

NO_VALUE_DESCRIPT = 'X'

CHANGE_SERVICE_CLF = 'X'

  • INHERITED_CHAR = ' '

TABLES

T_CLASS = T_CLASS

T_OBJECTDATA = T_CLOBJDAT

EXCEPTIONS

NO_CLASSIFICATION = 1

NO_CLASSTYPES = 2

INVALID_CLASS_TYPE = 3

OTHERS = 4.

IF SY-SUBRC = 0.

READ TABLE T_CLASS INDEX 1.

IT_HEADER-MATNR = IT_MATNR-MATNR.

IT_HEADER-MAKTX = IT_MATNR-MAKTX.

IT_HEADER-BISMT = IT_MATNR-BISMT."Thanikai-17.05.2002

IT_HEADER-CLART = T_CLASS-KLART.

IT_HEADER-CLASS = T_CLASS-CLASS.

PERFORM PKG_DLVY_UNIT.

APPEND IT_HEADER.

CLEAR: IT_HEADER.

  • Code Start by Thanikai on 16.08.2002

LOOP AT T_CLOBJDAT.

IT_DETAILS-MATNR = IT_MATNR-MATNR.

IT_DETAILS-ZAEHL = T_CLOBJDAT-ZAEHL.

IT_DETAILS-ATNAM = T_CLOBJDAT-ATNAM.

IT_DETAILS-AUSP1 = T_CLOBJDAT-AUSP1.

APPEND IT_DETAILS.

ENDLOOP.

CLEAR: IT_DETAILS.

LOOP AT T_CLOBJDAT.

IT_DETAILS1-MATNR = IT_MATNR-MATNR.

IT_DETAILS1-ATNAM = T_CLOBJDAT-ATNAM.

IT_DETAILS1-ZAEHL = T_CLOBJDAT-ZAEHL.

APPEND IT_DETAILS1.

ENDLOOP.

CLEAR: IT_DETAILS1.

DESCRIBE TABLE IT_DETAILS1 LINES T_CLOBJDAT_LINES.

IF WRK_FIRST_TIME NE 'X'.

WRK_LINES1 = T_CLOBJDAT_LINES.

WRK_FIRST_TIME = 'X'.

IT_DETAILS2[] = IT_DETAILS1[].

ELSE.

IF T_CLOBJDAT_LINES GT WRK_LINES1.

WRK_LINES1 = T_CLOBJDAT_LINES.

IT_DETAILS2[] = IT_DETAILS1[].

ENDIF.

ENDIF.

CLEAR: T_CLOBJDAT_LINES.

CLEAR: IT_DETAILS1. REFRESH: IT_DETAILS1.

ENDIF.

  • Code end by Thanikai on 16.08.2002

ENDLOOP.

CLEAR: WRK_LINES1, WRK_FIRST_TIME.

  • Print Details *********************************

PERFORM PRINT_DETAILS.

************************************************************************

AT USER-COMMAND.

GET CURSOR FIELD WRK_FIELD.

SPLIT WRK_FIELD AT '-' INTO WRK_TABNAME WRK_FLDNAME.

IF NOT WRK_FLDNAME IS INITIAL.

CASE SY-UCOMM.

WHEN 'SORA'.

IF SY-LSIND > 0.

SY-LSIND = SY-LSIND - 1. "To print in the same window

ENDIF.

PERFORM PRINT_REPORT_ASCENDING.

WHEN 'SORD'.

IF SY-LSIND > 0.

SY-LSIND = SY-LSIND - 1. "To print in the same window

ENDIF.

PERFORM PRINT_REPORT_DESCENDING.

ENDCASE.

ELSE.

MESSAGE S000(38) WITH 'Selete Material Number / Description'.

ENDIF.

&----


*& Form SAPGUI

&----


  • text

----


  • -->P_WRK_PERCENT text *

  • -->P_WRK_PROGRESSTEXT text *

----


FORM SAPGUI USING P_WRK_PERCENT

P_WRK_PROGRESSTEXT.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

PERCENTAGE = WRK_PERCENT

TEXT = WRK_PROGRESSTEXT

EXCEPTIONS

OTHERS = 1.

ENDFORM. " SAPGUI

&----


*& Form PRINT_REPORT_ASCENDING

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM PRINT_REPORT_ASCENDING.

IF WRK_TABNAME = 'IT_HEADER'.

SORT IT_HEADER BY (WRK_FLDNAME).

PERFORM PRINT_TOP.

PERFORM PRINT_DETAILS.

ENDIF.

ENDFORM. " PRINT_REPORT_ASCENDING

&----


*& Form PRINT_DETAILS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


  • WRK_AUSP1 width chged below from (7)to(9) by Nagaraj/MKRK 24.11.05

FORM PRINT_DETAILS.

SORT IT_HEADER BY MATNR.

IF SY-BATCH EQ 'X'.

PERFORM PRINT_TOP.

ENDIF.

IF REQ = 'X'.

LOOP AT IT_HEADER.

IF FLG_COLOR = 'X'.

FORMAT COLOR COL_NORMAL INTENSIFIED ON.

CLEAR FLG_COLOR.

ELSE.

FORMAT COLOR COL_NORMAL INTENSIFIED OFF.

FLG_COLOR = 'X'.

ENDIF.

WRITE :/ SY-VLINE NO-GAP,

(18) IT_HEADER-MATNR COLOR COL_KEY NO-GAP,

SY-VLINE NO-GAP,

(40) IT_HEADER-MAKTX NO-GAP,

SY-VLINE NO-GAP,

(18) IT_HEADER-BISMT NO-GAP, "Thanikai-17.05.2002

SY-VLINE NO-GAP.

  • Code started by Thanikai on 16.08.2002

LOOP AT IT_DETAILS2.

CLEAR: TMP_STR, WRK_AUSP1.

IF IT_DETAILS2-ATNAM EQ 'CALIBRE'.

LOOP AT IT_DETAILS WHERE MATNR = IT_HEADER-MATNR

AND ATNAM = IT_DETAILS2-ATNAM

AND ZAEHL = IT_DETAILS2-ZAEHL.

TMP_STR = 'X'.

WRK_AUSP1 = IT_DETAILS-AUSP1.

EXIT.

ENDLOOP.

IF TMP_STR EQ 'X'.

WRITE : (9)WRK_AUSP1 NO-GAP, SY-VLINE NO-GAP.

ELSE.

WRITE : ' ', SY-VLINE NO-GAP.

ENDIF.

ELSE.

LOOP AT IT_DETAILS WHERE MATNR = IT_HEADER-MATNR

AND ATNAM = IT_DETAILS2-ATNAM.

TMP_STR = 'X'.

WRK_AUSP1 = IT_DETAILS-AUSP1.

EXIT.

ENDLOOP.

IF TMP_STR EQ 'X'.

WRITE : (9)WRK_AUSP1 NO-GAP, SY-VLINE NO-GAP.

ELSE.

WRITE : ' ', SY-VLINE NO-GAP.

ENDIF.

ENDIF.

ENDLOOP.

WRITE : (8) IT_HEADER-SCMNG NO-GAP, SY-VLINE NO-GAP.

IF SY-LINNO > 25.

IF SY-BATCH EQ 'X'.

NEW-PAGE.

PERFORM PRINT_TOP.

ENDIF.

ENDIF.

  • Code end by Thanikai on 16.08.2002..

ENDLOOP.

ELSEIF NREQ = 'X'.

LOOP AT IT_HEADER.

IF FLG_COLOR = 'X'.

FORMAT COLOR COL_NORMAL INTENSIFIED ON.

CLEAR FLG_COLOR.

ELSE.

FORMAT COLOR COL_NORMAL INTENSIFIED OFF.

FLG_COLOR = 'X'.

ENDIF.

WRITE :/ SY-VLINE NO-GAP,

(18) IT_HEADER-MATNR COLOR COL_KEY NO-GAP,

SY-VLINE NO-GAP,

(18) IT_HEADER-BISMT NO-GAP, "Thanikai-17.05.2002

SY-VLINE NO-GAP.

  • Code started by Thanikai on 16.08.2002

LOOP AT IT_DETAILS2.

CLEAR: TMP_STR, WRK_AUSP1.

IF IT_DETAILS2-ATNAM EQ 'CALIBRE'.

LOOP AT IT_DETAILS WHERE MATNR = IT_HEADER-MATNR

AND ATNAM = IT_DETAILS2-ATNAM

AND ZAEHL = IT_DETAILS2-ZAEHL.

TMP_STR = 'X'.

WRK_AUSP1 = IT_DETAILS-AUSP1.

EXIT.

ENDLOOP.

IF TMP_STR EQ 'X'.

WRITE : (9)WRK_AUSP1 NO-GAP, SY-VLINE NO-GAP.

ELSE.

WRITE : ' ', SY-VLINE NO-GAP.

ENDIF.

ELSE.

LOOP AT IT_DETAILS WHERE MATNR = IT_HEADER-MATNR

AND ATNAM = IT_DETAILS2-ATNAM.

TMP_STR = 'X'.

WRK_AUSP1 = IT_DETAILS-AUSP1.

EXIT.

ENDLOOP.

IF TMP_STR EQ 'X'.

WRITE : (9)WRK_AUSP1 NO-GAP, SY-VLINE NO-GAP.

ELSE.

WRITE : ' ', SY-VLINE NO-GAP.

ENDIF.

ENDIF.

ENDLOOP.

WRITE : (8) IT_HEADER-SCMNG NO-GAP, SY-VLINE NO-GAP.

IF SY-LINNO > 25.

IF SY-BATCH EQ 'X'.

NEW-PAGE.

PERFORM PRINT_TOP.

ENDIF.

ENDIF.

  • Code end by Thanikai on 16.08.2002

ENDLOOP.

ENDIF.

ULINE.

ENDFORM. " PRINT_DETAILS

&----


*& Form PRINT_REPORT_DESCENDING

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM PRINT_REPORT_DESCENDING.

IF WRK_TABNAME = 'IT_HEADER'.

SORT IT_HEADER BY (WRK_FLDNAME) DESCENDING.

PERFORM PRINT_TOP.

PERFORM PRINT_DETAILS.

ENDIF.

ENDFORM. " PRINT_REPORT_DESCENDING

&----


*& Form PRINT_TOP

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


  • IT_DETAILS2-ATNAM width chged below from 7 to 9. Nagaraj/MKRK 24.11.05

FORM PRINT_TOP.

FORMAT COLOR COL_HEADING INTENSIFIED OFF.

ULINE.

IF REQ = 'X'.

READ TABLE IT_HEADER INDEX 1.

WRITE :/ SY-VLINE NO-GAP,(17) 'Material No' ,SY-VLINE NO-GAP.

SET LEFT SCROLL-BOUNDARY.

WRITE :(39) ' Material Description', SY-VLINE NO-GAP,

(17) ' Old Matl. Number', SY-VLINE NO-GAP. "Thanikai-17.05.2002

  • Comments made by Thanikai on 16.08.2002

  • LOOP AT IT_DETAILS WHERE MATNR = IT_HEADER-MATNR.

LOOP AT IT_DETAILS2.

  • WRITE : (9) IT_DETAILS1-ATNAM NO-GAP,SY-VLINE NO-GAP.

WRITE : (9) IT_DETAILS2-ATNAM NO-GAP,SY-VLINE NO-GAP.

ENDLOOP.

WRITE : (8) 'Pkg.Unit' NO-GAP, SY-VLINE NO-GAP.

ELSEIF NREQ = 'X'.

READ TABLE IT_HEADER INDEX 1.

WRITE :/ SY-VLINE NO-GAP, (17) 'Material No' ,SY-VLINE NO-GAP,

(17) ' Old Matl. Number', SY-VLINE NO-GAP. "Thanikai-17.05.2002

  • Comments made by Thanikai on 16.08.2002

  • LOOP AT IT_DETAILS WHERE MATNR = IT_HEADER-MATNR.

LOOP AT IT_DETAILS2.

  • WRITE : (9) IT_DETAILS-ATNAM NO-GAP,SY-VLINE NO-GAP.

WRITE : (9) IT_DETAILS2-ATNAM NO-GAP,SY-VLINE NO-GAP.

ENDLOOP.

WRITE : (8) 'Pkg.Unit' NO-GAP, SY-VLINE NO-GAP.

ENDIF.

ULINE.

FORMAT RESET.

ENDFORM. " PRINT_TOP

&----


*& Form PKG_DLVY_UNIT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM PKG_DLVY_UNIT.

SELECT SINGLE KONP~KBETR INTO WRK_KBETR

FROM ( A916 INNER JOIN KONP

ON KONP~MANDT = SY-MANDT

AND KONPKNUMH = A916KNUMH

AND KONP~KOPOS = '01' ) CLIENT SPECIFIED

WHERE A916~MANDT = SY-MANDT

AND A916~KAPPL = 'V'

AND A916~KSCHL = 'PR00'

AND A916~VKORG = 'WTCH'

AND A916~VTWEG = '01'

AND A916~SPART = '01'

AND A916~MATNR = IT_MATNR-MATNR

AND A916~DATBI >= SY-DATUM

AND A916~DATAB <= SY-DATUM.

IF SY-SUBRC EQ 0.

SELECT SINGLE * FROM ZSAI_PARAM CLIENT SPECIFIED

WHERE MANDT = SY-MANDT

AND PMFID = 'ZPKG_PRICE'

AND PMVL1 = '01'.

IF SY-SUBRC EQ 0.

IF WRK_KBETR BETWEEN 1 AND ZSAI_PARAM-PMVL2.

SELECT SINGLE * FROM MVKE CLIENT SPECIFIED

WHERE MANDT = SY-MANDT

AND MATNR = IT_MATNR-MATNR

AND VKORG = 'WTCH'

AND VTWEG = '01'.

IF SY-SUBRC EQ 0.

IF MVKE-SCMNG GE 1.

IT_HEADER-SCMNG = MVKE-SCMNG.

ELSE.

  • In the absence of delivery unit for a material,

  • delivery unit is considered as one.

IT_HEADER-SCMNG = 1.

ENDIF.

ELSE.

IT_HEADER-SCMNG = 1.

ENDIF.

ELSE.

  • If the price for a material is either below 1 or above 2499, then

  • the delivery unit is considered as one.

IT_HEADER-SCMNG = 1.

ENDIF.

ELSE.

IT_HEADER-SCMNG = 1.

ENDIF.

ELSE.

  • In the absence of price for a material, delivery unit is

  • considered as one.

IT_HEADER-SCMNG = 1.

ENDIF.

CLEAR: WRK_KBETR.

ENDFORM. " PKG_DLVY_UNIT