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

most performant Abap syntax

Former Member
0 Likes
773

Hello experts,

What is the most performant Abap syntax for this requirment:

If loading time (TVST-LAZBS) = A

   then Loading time will be the value contained in T630L-LOADTG

ElseIF Loading time (TVST-LAZBS) = B

then Loading time will be the value contained inTVST-LOADTG

EndIF

EndIF.

Thanks.

Amine

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
726

Amine,

Are you looking for more performance efficient code for this logic? It actually depends on where this is being called, is this in a User Exit?

Please check below sample code for a general syntax.

Select single * from TVST into ls_TVST where VSTEL = <Shippingpt>.

if sy-subrc = 0.

if ls_TVST-LAZBS = 'A'.

   Select single * from T630L into ls_T630L where

                                                    VSTEL = ls_TVST-VSTEL and

                                                    ROUTE = <Route_dtls> and

                                                    LADGR = <loding_grp>.

     if sy-subrc = 0.

        Loading time = ls_t60l-LOADTG

     endif.

elseif ls_TVST-LAZBS = 'B'.

   Loading time = ls_TVST-LOADTG

else.

   Loading time = space. " No Loading time determined.

endif.

endif.

Thanks!

VM

Amine,

Are you looking for more performance efficient code for this logic? It actually depends on where this is being called, is this in a User Exit?

Please check below sample code for a general syntax.

Select single * from TVST into ls_TVST where VSTEL = <Shippingpt>.

if sy-subrc = 0.

if ls_TVST-LAZBS = 'A'.

   Select single * from T630L into ls_T630L where

                                                    VSTEL = ls_TVST-VSTEL and

                                                    ROUTE = <Route_dtls> and

                                                    LADGR = <loding_grp>.

     if sy-subrc = 0.

        Loading time = ls_t60l-LOADTG

     endif.

elseif ls_TVST-LAZBS = 'B'.

   Loading time = ls_TVST-LOADTG

else.

   Loading time = space. " No Loading time determined.

endif.

endif.

Thanks!

VM

4 REPLIES 4
Read only

Former Member
0 Likes
727

Amine,

Are you looking for more performance efficient code for this logic? It actually depends on where this is being called, is this in a User Exit?

Please check below sample code for a general syntax.

Select single * from TVST into ls_TVST where VSTEL = <Shippingpt>.

if sy-subrc = 0.

if ls_TVST-LAZBS = 'A'.

   Select single * from T630L into ls_T630L where

                                                    VSTEL = ls_TVST-VSTEL and

                                                    ROUTE = <Route_dtls> and

                                                    LADGR = <loding_grp>.

     if sy-subrc = 0.

        Loading time = ls_t60l-LOADTG

     endif.

elseif ls_TVST-LAZBS = 'B'.

   Loading time = ls_TVST-LOADTG

else.

   Loading time = space. " No Loading time determined.

endif.

endif.

Thanks!

VM

Read only

0 Likes
726

Hi Venkat.

Thanks for your answer.

I am now looking for the more efficient data model. I don't know yet where I am going to use this code.

May be in BW level..

Thanks.

Amine

Read only

amy_king
Active Contributor
0 Likes
726

Hi Amine,

Venkat's suggestion should perform just fine. Table T630L has only a few fields so SELECT * is fine, though if it had many fields, you would want to select only the fields you actually needed:

SELECT SINGLE loadtg

    FROM t630l

    INTO loading_time

    WHERE...

I wonder though if you're placing this IF/ELSEIF block within a loop and that's why you're asking about performance? If so, you'll want to avoid performing the SELECT ... FROM T630L for each iteration of the loop. To do this, before entering the loop, read all needed data from T630L into an internal table. Within the loop, you can then read the relevant record from the internal table instead of performing a SELECT.

Cheers,

Amy

Read only

Former Member
0 Likes
726

Many thanks for the advice Amy.

Cheers

Amine