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

How i can improve performance for this code

Former Member
0 Likes
693

Hi Friends-

Is there any other way i can write this below code to improve performance ?

DATA : ls_idoc_data TYPE edidd,

ls_e1p1000 TYPE e1p1000,

ls_e1p0000 TYPE e1p0000,

ls_e1p0006 TYPE e1p0006 .

constants: C_01(2) TYPE C Value '01',

C_02(2) TYPE C Value '02',

C_03(2) TYPE C Value '03',

C_04(2) TYPE C Value '04',

C_1(1) TYPE C Value '1',

C_5(1) TYPE C Value '5'.

LOOP AT idoc_data INTO ls_idoc_data WHERE segnam = 'E1P1000'.

ls_e1p1000 = ls_idoc_data-sdata.

IF ls_e1p1000-otype = 'C' .

DELETE idoc_data.

ENDIF.

ENDLOOP.

LOOP AT idoc_data INTO ls_idoc_data WHERE segnam = 'E1P0000'.

ls_e1p0000 = ls_idoc_data-sdata.

IF ( ( ls_e1p0000-massn NE C_01 ) or ( ls_e1p0000-massn NE C_02 )

or ( ls_e1p0000-massn NE C_03 ) or ( ls_e1p0000-massn NE C_04 ) )

and ( ls_e1p0000-massg NE C_01 ).

DELETE idoc_data.

endif.

ENDLOOP.

LOOP AT idoc_data INTO ls_idoc_data WHERE segnam = 'E1P0006'.

ls_e1p0006 = ls_idoc_data-sdata.

IF ( ls_e1p0006-subty NE C_1 ) or ( ls_e1p0006-subty NE C_5 ).

DELETE idoc_data.

endif.

ENDLOOP.

Regards

Gauri

6 REPLIES 6
Read only

Former Member
0 Likes
674

Hi,

You can put all the conditions in asingle LOOP by using ELSEIF condition.

Check this.

DATA : ls_idoc_data TYPE edidd,
ls_e1p1000 TYPE e1p1000,
ls_e1p0000 TYPE e1p0000,
ls_e1p0006 TYPE e1p0006 .

constants: C_01(2) TYPE C Value '01',
C_02(2) TYPE C Value '02',
C_03(2) TYPE C Value '03',
C_04(2) TYPE C Value '04',
C_1(1) TYPE C Value '1',
C_5(1) TYPE C Value '5'.

LOOP AT idoc_data INTO ls_idoc_data WHERE segnam = 'E1P1000'.
ls_e1p1000 = ls_idoc_data-sdata.
IF ls_e1p1000-otype = 'C' .

DELETE idoc_data.

ELSEIF ( ( ls_e1p0000-massn NE C_01 ) or ( ls_e1p0000-massn NE C_02 )
or ( ls_e1p0000-massn NE C_03 ) or ( ls_e1p0000-massn NE C_04 ) )
and ( ls_e1p0000-massg NE C_01 ).


DELETE idoc_data.

ELSEIF ( ls_e1p0006-subty NE C_1 ) or ( ls_e1p0006-subty NE C_5 ).

DELETE idoc_data.
ENDIF.

ENDLOOP.

Read only

Former Member
0 Likes
674

HI,

check the code

Delete idoc_data where ( segnam = 'E1P1000' and otype = 'C' ) or

(subty NE C_1 or subty NE C_5 ) or

( ( massn NE C_01 ) or ( massn NE C_02 ) or

(massn NE C_03 ) or ( massn NE C_04 ) )and

( massg NE C_01 ).

Read only

JozsefSzikszai
Active Contributor
0 Likes
674

pseudo code (probably you need to correct the delete), but much simplier:

FIELD-SYMBOLS : <ls_idoc_data> TYPE ls_idoc_data.

LOOP AT idoc_data ASSIGING <ls_idoc_data>. " WHERE segnam = 'E1P1000'.
CASE <ls_idoc_data>-segnam.
WHEN 'E1P1000'.
IF <ls_e1p1000-otype> = 'C'.
DELETE idoc_data.
ELSE.
ls_e1p1000 = ls_idoc_data-sdata.
ENDIF.
WHEN 'E1P0000'.
IF ( ( ls_e1p0000-massn NE C_01 ) or ( ls_e1p0000-massn NE C_02 )
or ( ls_e1p0000-massn NE C_03 ) or ( ls_e1p0000-massn NE C_04 ) )
and ( ls_e1p0000-massg NE C_01 ).
DELETE idoc_data.
ELSE.
ls_e1p0000 = ls_idoc_data-sdata.
ENDIF.
WHEN 'E1P0006'.
IF ( ls_e1p0006-subty NE C_1 ) or ( ls_e1p0006-subty NE C_5 ).
DELETE idoc_data.
ELSE.
ls_e1p0006 = ls_idoc_data-sdata.
ENDIF.
ENDCASE.
ENDLOOP.

Read only

Former Member
0 Likes
674

Hi Meeta,

Instead of looping with a condition on Segment Name, you can loop in to the table with out any condition and use case statements for segment name.


LOOP AT ITAB into W_ITAB.

CASE SEGNAME.

WHEN 'E1P1000'.
" Take necessary action
WHEN 'E1P0000'
" Take necessary action
ENDLOOP.

Best Regards,

Ram.

Read only

Former Member
0 Likes
674

Hi Friends

how i can pull values from table PA0001 in between this code

as its classes and interface it not allow me few keywords .

is there any other proper way to read this DB table Pa0001

am doing write now like this ,

**Validation for IT 0001 .

data : begin of It ,

pernr type persno ,

bukrs type bukrs,

werks type werks,

end of it.

When 'E1P0001'.

ls_e1p0001 = ls_idoc_data-sdata.

select pernr bukrs werks from pa0001 into it where bukrs = ls_e1p0001-bukrs

and werks = ls_e1p0001-werks.

if sy-subrc NE C_0.

DELETE idoc_data.

endif.

endselect.

Regards

Meeta

Read only

0 Likes
674

Hi,

just do a select for all entries from table PA0001

where bukrs = idoc_data-bukrs and werks = idoc_data-werks.

then in the loop at idoc_data , do a read binary to get record from PA0001.

Thanks and Regards,

Dev.