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

write this short code in better way

Former Member
0 Likes
429

HI,

There is a way to write this short code in better way ?

what is disturb is the number 2 and maybe the exit.

Best Regards

lv_extract_tabix = lines( lt_dupl ).
    IF lv_extract_tabix GE 2.
      EXIT.
    ENDIF.

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
410

Hello Michael

Without knowing the requirements it is somewhat difficult to rewrite the coding. I assume you want to check whether the itab has at least a given number of entries.


CONSTANTS:
  gc_min_lines        TYPE i  value '2'.

...
  READ TABLE lt_dupl TRANSPORTING NO FIELDS INDEX gc_min_lines.
  CHECK ( syst-subrc = 0 ).  

Regards

Uwe

HI,

There is a way to write this short code in better way ?

what is disturb is the number 2 and maybe the exit.

Best Regards

lv_extract_tabix = lines( lt_dupl ).
    IF lv_extract_tabix GE 2.
      EXIT.
    ENDIF.

2 REPLIES 2
Read only

GuyF
Active Participant
0 Likes
410

Hi,

The only way to make this code shorter is to write:

lv_extract_tabix = lines( lt_dupl ).
CHECK lv_extract_tabix EQ 1.

But I don't really see a problem with the code you wrote.

Guy.

Read only

uwe_schieferstein
Active Contributor
0 Likes
411

Hello Michael

Without knowing the requirements it is somewhat difficult to rewrite the coding. I assume you want to check whether the itab has at least a given number of entries.


CONSTANTS:
  gc_min_lines        TYPE i  value '2'.

...
  READ TABLE lt_dupl TRANSPORTING NO FIELDS INDEX gc_min_lines.
  CHECK ( syst-subrc = 0 ).  

Regards

Uwe