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

Transform from basic to object

Former Member
0 Likes
799

Hi Experts,

Is there anyway to turn this kind of basic abap code into abap object one?

READTABLE Internal INTO area WITH KEY
ytest = source_fields_rule-gl_account
BINARYSEARCH.

IF area-flag = 'N'.
           CLEAR RESULT.
ENDIF.


IF area-flag = 'Y'.


           IF area-tpr ISINITIAL.
               RESULT = SOURCE_FIELDS_RULE-value.
            
ELSE.
               RESULT = area-tpr.

            ENDIF.
ENDIF.

Thanks.

Amine

1 ACCEPTED SOLUTION
Read only

Clemenss
Active Contributor
0 Likes
769

Hi amine,

for oo programming please refer to google. You will find tons of learning material. What is you oo expertise/training level?

In your case, you can use a functional method importing source_fields_rule returning RESULT.

But your code is buggy as it is:

READTABLE ... BINARYSEARCH and no check for SY-SUBRC will cause unpredictable errors if no matching record is found.

Regards

Clemens

6 REPLIES 6
Read only

UweFetzer_se38
Active Contributor
0 Likes
769

Hi Amine,

I don't understand your question. Is there a syntax check error in ABAP OO context?

Read only

0 Likes
769

Hi Uwe,

No there is no errors, but i would like to change it in an objects style not the basic abap....

I don't know if it's more clear

Amine

Read only

0 Likes
769

There is no "object style" ABAP. This code block will look exactly the same in ABAO OO (needs some "optimization" though, see Clemens' comment, but this is another story).

Read only

0 Likes
769

I taked account of Clemens remark.

Do you see any other optimization that i can add to my code?

Thanks.

Amine

Read only

Clemenss
Active Contributor
0 Likes
770

Hi amine,

for oo programming please refer to google. You will find tons of learning material. What is you oo expertise/training level?

In your case, you can use a functional method importing source_fields_rule returning RESULT.

But your code is buggy as it is:

READTABLE ... BINARYSEARCH and no check for SY-SUBRC will cause unpredictable errors if no matching record is found.

Regards

Clemens

Read only

Former Member
0 Likes
769

Thanks for the advice Clemens.

Amine