Application Development 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: 

urgent help in performance

Former Member
0 Kudos
96

hi experts:

Here is my last code how here I can avoid from select <b>single</b> and from end <b>select</b> for the first select when i cehck it in se30 it take 20 sec total.

Regards

INCLUDE yhr_ex_hours_emp_data.

INCLUDE yhr_ex_hours_emp_sel.

START-OF-SELECTION.

GET peras.

PERFORM get_new_data.

END-OF-SELECTION.

INCLUDE yhr_ex_hours_emp_get_data.

PERFORM create_field_cat.

form get_new_data .

wa_person_tab-pernr = pernr-pernr.

rp_provide_from_last t_0001 ' ' sy-datum sy-datum. "pa0001

  • pn-begda pn-endda.

wa_person_tab-stell = t_0001-stell.

wa_person_tab-werks = t_0001-werks.

wa_person_tab-persg = t_0001-persg.

wa_person_tab-persk = t_0001-persk.

  • wa_person_tab-orgeh = t_0001-orgeh.

rp_provide_from_last t_0002 ' ' sy-datum sy-datum. "pa0002

wa_person_tab-lastname = t_0002-nachn.

wa_person_tab-firstname = t_0002-vorna.

wa_person_tab-perid = t_0002-perid.

  • LOOP AT t_0315 into wa_t0315.

rp_provide_from_last t_0315 ' ' sy-datum sy-datum. "pa0315

wa_person_tab-lifnr = t_0315-lifnr.

wa_person_tab-kostl = t_0315-kostl.

wa_person_tab-yytariff_code = t_0315-yytariff_code.

wa_person_tab-yytariff_total = t_0315-yytariff_total.

wa_person_tab-yywaers = t_0315-yywaers.

APPEND wa_person_tab TO person_tab.

CLEAR wa_person_tab.

DELETE person_tab WHERE ( persg <> '6' AND persg <> '7' AND persg <> '8' ).

MOVE person_tab[] TO person_tab2[].

IF person_tab[] IS NOT INITIAL.

SELECT pernr stdaz begda plans " Employee Numbers & Hours

FROM pa2010

INTO (wa_person_tab-pernr, wa_person_tab-hours,

wa_person_tab-begda, wa_person_tab-orgeh)

FOR ALL ENTRIES IN person_tab

WHERE pernr = person_tab-pernr

AND lgart = '9EXT' " Wage Type (salary)

AND begda GE pn-begda

AND begda LE pn-endda.

IF sy-subrc = 0.

APPEND wa_person_tab TO person_tab.

CLEAR wa_person_tab.

ENDIF.

<b> ENDSELECT.</b>

ELSE.

MESSAGE i023.

EXIT.

ENDIF.

*__________________Copy Constant of Table To other Row____________

LOOP AT person_tab INTO wa_person_tab.

READ TABLE person_tab2 INTO wa_person_tab2

WITH KEY pernr = wa_person_tab-pernr.

IF sy-subrc = 0.

MOVE: wa_person_tab2-stell TO wa_person_tab-stell,

wa_person_tab2-persg TO wa_person_tab-persg,

wa_person_tab2-lastname TO wa_person_tab-lastname,

wa_person_tab2-werks TO wa_person_tab-werks,

wa_person_tab2-persk TO wa_person_tab-persk,

wa_person_tab2-firstname TO wa_person_tab-firstname,

wa_person_tab2-perid TO wa_person_tab-perid,

wa_person_tab2-lifnr TO wa_person_tab-lifnr,

wa_person_tab2-kostl TO wa_person_tab-kostl,

wa_person_tab2-yytariff_code TO wa_person_tab-yytariff_code,

wa_person_tab2-yytariff_total TO wa_person_tab-yytariff_total,

wa_person_tab2-yywaers TO wa_person_tab-yywaers,

wa_person_tab2-kostl TO wa_person_tab-kostl.

MODIFY person_tab FROM wa_person_tab

TRANSPORTING stell persg lastname werks persk firstname perid lifnr

kostl yytariff_code yytariff_total yywaers kostl.

ENDIF.

ENDLOOP.

DELETE person_tab WHERE hours = 0.

IF pnppernr IS INITIAL.

LOOP AT person_tab INTO wa_person_tab.

AT END OF pernr.

SUM.

MOVE: wa_person_tab-stdaz TO wa_hour_tab_total-stdaz,

wa_person_tab-pernr TO wa_hour_tab_total-pernr.

APPEND wa_hour_tab_total TO hour_tab_total.

ENDAT.

ENDLOOP.

SORT person_tab BY pernr.

LOOP AT person_tab INTO wa_person_tab.

READ TABLE hour_tab_total INTO wa_hour_tab_total

WITH KEY pernr = wa_person_tab-pernr BINARY SEARCH.

IF sy-subrc = 0.

MOVE wa_hour_tab_total-stdaz TO wa_person_tab-hours.

MODIFY person_tab FROM wa_person_tab TRANSPORTING hours.

ENDIF.

ENDLOOP.

SORT person_tab ASCENDING.

DELETE ADJACENT DUPLICATES FROM person_tab COMPARING pernr.

ENDIF.

*__________________Org. Unit Text_________________________________

LOOP AT person_tab INTO wa_person_tab.

SELECT orgtx "org.unit text

FROM t527x

INTO wa_person_tab-orgtx

WHERE orgeh = wa_person_tab-orgeh

AND sprsl = 'B'.

IF sy-subrc = 0 .

MODIFY person_tab FROM wa_person_tab TRANSPORTING orgtx.

ENDIF.

ENDSELECT.

ENDLOOP.

*__________________lifner text_________________________________

LOOP AT person_tab INTO wa_person_tab.

SELECT name1 "lifnr text

FROM lfa1

INTO wa_person_tab-lfa_txt

WHERE lifnr = wa_person_tab-lifnr.

IF sy-subrc = 0 .

MODIFY person_tab FROM wa_person_tab TRANSPORTING lfa_txt.

ENDIF.

ENDSELECT.

ENDLOOP.

*--


Area & Sub.Area From 1008--


LOOP AT person_tab INTO wa_person_tab.

SELECT SINGLE persa btrtl

FROM hrp1008

INTO (wa_person_tab-persa ,wa_person_tab-btrtl )

WHERE objid = wa_person_tab-orgeh

AND plvar = '01'

AND otype = 'O'.

IF sy-subrc = 0.

MODIFY person_tab FROM wa_person_tab TRANSPORTING persa btrtl.

CLEAR wa_person_tab.

ENDIF.

  • ENDSELECT.

ENDLOOP.

*--


Area & Sub.Area Text From 1008--


LOOP AT person_tab INTO wa_person_tab.

SELECT SINGLE name1 "Area.text

FROM t500p

INTO wa_person_tab-name1

WHERE persa = wa_person_tab-persa

AND molga = 'IL'.

IF sy-subrc = 0.

MODIFY person_tab FROM wa_person_tab TRANSPORTING name1.

CLEAR wa_person_tab.

ENDIF.

  • ENDSELECT.

ENDLOOP.

LOOP AT person_tab INTO wa_person_tab.

SELECT SINGLE btext "Sub.area text

FROM t001p

INTO wa_person_tab-btext

WHERE btrtl = wa_person_tab-btrtl

AND molga = 'IL'.

IF sy-subrc = 0.

MODIFY person_tab FROM wa_person_tab TRANSPORTING btext.

CLEAR wa_person_tab.

ENDIF.

  • ENDSELECT.

ENDLOOP.

LOOP AT person_tab INTO wa_person_tab.

SELECT SINGLE ptext "group text

FROM t501t

INTO wa_person_tab-emp_group_txt

WHERE persg = wa_person_tab-persg

AND sprsl = 'B'.

IF sy-subrc = 0.

MODIFY person_tab FROM wa_person_tab TRANSPORTING emp_group_txt.

CLEAR wa_person_tab.

ENDIF.

  • ENDSELECT.

ENDLOOP.

LOOP AT person_tab INTO wa_person_tab.

SELECT SINGLE ptext "sub.group text

FROM t503t

INTO wa_person_tab-emp_sub_group_txt

WHERE persk = wa_person_tab-persk

AND sprsl = 'B'.

IF sy-subrc = 0.

MODIFY person_tab FROM wa_person_tab TRANSPORTING emp_sub_group_txt.

CLEAR wa_person_tab.

ENDIF.

  • ENDSELECT.

ENDLOOP.

*LOOP AT person_tab INTO wa_person_tab.

*

  • SELECT plans

  • FROM pa0001

  • INTO wa_person_tab-orgeh

  • WHERE pernr = wa_person_tab-pernr

  • AND orgeh <> '9999'.

*

  • IF sy-subrc = 0.

  • MODIFY person_tab FROM wa_person_tab TRANSPORTING orgeh.

  • ENDIF.

  • ENDSELECT.

*

  • ENDLOOP.

*--


empty data error (from person tab)--


IF person_tab[] IS INITIAL.

MESSAGE i023.

EXIT.

ENDIF.

SORT person_tab BY orgeh.

  • DELETE person_tab WHERE orgeh = 0.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
58

hi

1. sort internal table before using binary search.

<b>SORT hourt_tab_total by pernr.</b>

READ TABLE hour_tab_total INTO wa_hour_tab_total

WITH KEY pernr = wa_person_tab-pernr BINARY SEARCH.

2. use for all entries instead of select inside the loop. and avoid select-endselect for the below code:

LOOP AT person_tab INTO wa_person_tab.

SELECT name1 "lifnr text

FROM lfa1

INTO wa_person_tab-lfa_txt

WHERE lifnr = wa_person_tab-lifnr.

IF sy-subrc = 0 .

MODIFY person_tab FROM wa_person_tab TRANSPORTING lfa_txt.

ENDIF.

ENDSELECT.

3. there are selects inside the LOOP. try to avoid it

for ex:

LOOP AT person_tab INTO wa_person_tab.

SELECT SINGLE name1 "Area.text

FROM t500p

INTO wa_person_tab-name1

WHERE persa = wa_person_tab-persa

AND molga = 'IL'.

regards,

madhu

1 REPLY 1

Former Member
0 Kudos
59

hi

1. sort internal table before using binary search.

<b>SORT hourt_tab_total by pernr.</b>

READ TABLE hour_tab_total INTO wa_hour_tab_total

WITH KEY pernr = wa_person_tab-pernr BINARY SEARCH.

2. use for all entries instead of select inside the loop. and avoid select-endselect for the below code:

LOOP AT person_tab INTO wa_person_tab.

SELECT name1 "lifnr text

FROM lfa1

INTO wa_person_tab-lfa_txt

WHERE lifnr = wa_person_tab-lifnr.

IF sy-subrc = 0 .

MODIFY person_tab FROM wa_person_tab TRANSPORTING lfa_txt.

ENDIF.

ENDSELECT.

3. there are selects inside the LOOP. try to avoid it

for ex:

LOOP AT person_tab INTO wa_person_tab.

SELECT SINGLE name1 "Area.text

FROM t500p

INTO wa_person_tab-name1

WHERE persa = wa_person_tab-persa

AND molga = 'IL'.

regards,

madhu