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

Is there a better solution ?

Former Member
0 Likes
607

Hey,

i have following code:

LOOP AT itab 1.

LOOP AT itab2.

CHECK itab1-object EQ itab2-object.

CHECK itab1-name NE itab2-name.

CHECK itab1-name(10) NE 'BCDE_BUKRS'.

CHECK itab1-name(10) NE 'BCDE_KRED_'.

CHECK itab1-name(10) NE 'BCDE_BLART'.

CHECK itab1-name(10) NE 'BCDE_DOKUA'.

CHECK itab1-name(10) NE 'BCDE_DEBI_'.

CHECK itab1-name(10) NE 'BCDE_SAKTO'.

Append something.

ENDLOOP.

ENDLOOP.

Is it better and possible to use case instead of check?

Or is it better to use if´s ?

Any idea?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
575

I think.. it's better to use if..

If ( itab1-object EQ itab2-object ) and ( itab1-name NE itab2-name ) and ( itab1-name(10) NE 'BCDE_BUKRS' ) and ( itab1-name(10) NE 'BCDE_KRED_' ) and ( itab1-name(10) NE'BCDE_BLART' ) and ( itab1-name(10) NE 'BCDE_DOKUA' ) and ( itab1-name(10) NE 'BCDE_DEBI_' ) and ( itab1-name(10) NE 'BCDE_SAKTO').

append something.

endif.

But using check it's okay also..

Hey,

i have following code:

LOOP AT itab 1.

LOOP AT itab2.

CHECK itab1-object EQ itab2-object.

CHECK itab1-name NE itab2-name.

CHECK itab1-name(10) NE 'BCDE_BUKRS'.

CHECK itab1-name(10) NE 'BCDE_KRED_'.

CHECK itab1-name(10) NE 'BCDE_BLART'.

CHECK itab1-name(10) NE 'BCDE_DOKUA'.

CHECK itab1-name(10) NE 'BCDE_DEBI_'.

CHECK itab1-name(10) NE 'BCDE_SAKTO'.

Append something.

ENDLOOP.

ENDLOOP.

Is it better and possible to use case instead of check?

Or is it better to use if´s ?

Any idea?

3 REPLIES 3
Read only

Former Member
0 Likes
576

I think.. it's better to use if..

If ( itab1-object EQ itab2-object ) and ( itab1-name NE itab2-name ) and ( itab1-name(10) NE 'BCDE_BUKRS' ) and ( itab1-name(10) NE 'BCDE_KRED_' ) and ( itab1-name(10) NE'BCDE_BLART' ) and ( itab1-name(10) NE 'BCDE_DOKUA' ) and ( itab1-name(10) NE 'BCDE_DEBI_' ) and ( itab1-name(10) NE 'BCDE_SAKTO').

append something.

endif.

But using check it's okay also..

Read only

Former Member
0 Likes
575
loop at itab2 
where itab1-object EQ itab2-object
and    itab1-name NE itab2-name
and    ...
and    itab1-name(10) NE 'BCDE_SAKTO'.

endloop.
Read only

Former Member
0 Likes
575

Hello Sascha,

If the nested loops are inevitable please do the following to improve performance

data : local1(10) type C value 'BCDE_BUKRS' ,

local2(10) type C value 'BCDE_KRED_' ,

local3(10) type C value 'BCDE_BLART' ,

local4(10) type C value 'BCDE_DOKUA' ,

local5(10) type C value 'BCDE_DEBI_' ,

local6(10) type C value 'BCDE_SAKTO'.,

LOOP AT itab1 where

itab1-name(10) NE local1 and

itab1-name(10) NE local2 and

itab1-name(10) NE local3 and

itab1-name(10) NE local4 and

itab1-name(10) NE local5 and

itab1-name(10) NE local6 .

loop at itab2 where

itab1-object = itab2-object and

itab1-name <> itab2-name .

append *.

endloop.

endloop.

Please check and revert..reward if helpful

Regards

Byju