2012 Nov 09 4:26 PM
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
2012 Nov 09 4:48 PM
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
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
2012 Nov 09 4:48 PM
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
2012 Nov 13 2:34 PM
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
2012 Nov 09 5:23 PM
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
2012 Nov 13 2:35 PM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |