Sunteți pe pagina 1din 2

4/19/2015

Collectionofourbesttableexpressions|SCN

GettingStarted Newsletters

Hi,Guest

LogOn

JoinUs

Store

SearchtheCommunity

Products

Services&Support

AboutSCN

Downloads

Industries

Training&Education

Partnership

DeveloperCenter

Activity

LinesofBusiness

UniversityAlliances

Events&Webinars

Innovation

Browse

Communications

Actions

ABAPDevelopment

Collectionofourbesttableexpressions
PostedbyBerndDittrichinABAPDevelopmentonApr17,20153:58:47PM
Share

Tweet

Like

ThispostisourlittlecollectionofusefulltableexpressionsusedinSAPTransportationManagementcontext.The
examplesaredoaminspecific,butmaybeothercanusetheprinciplesaswell.
Specialthanksto HorstKellerforhelpingusgettingstarted!

Asimpleonetogetstarted:

Extractthelatesttimestampfromatable

01. lr_tor_a_checkin>arrival=REDUCE/scmtms/actual_date(INITres=lr_tor_a_checkin>arrival
02. FOR<fs_exec>INlt_d_execinfo
03. NEXTres=nmax(val1=res
04. val2=<fs_exec>actual_date)).
Nowforsomethingabitmorcomplex...

ExtractEaliestandlatesttimestampoutofatablewithmultipletimestampfieldsin
it

01.
02.
03.
04.
05.
06.
07.
08.
09.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.

TYPES:BEGINOFty_min_max_times,
min_timeTYPE/scmtms/timestamp,
max_timeTYPE/scmtms/timestamp,
ENDOFty_min_max_times.
CONSTANTS:lc_maxTYPEtimestampVALUE'29993112000000'.
ls_min_max_times=REDUCEty_min_max_times(
INITres=VALUEty_min_max_times(min_time=lc_max
max_time=0)
FOR<fs_stop>INit_stop
USINGKEYparent_key
WHERE(parent_key=is_rootkey)
NEXT
resmax_time=nmax(val1=resmax_time
val2=<fs_stop>appointment_end
val3=<fs_stop>aggr_assgn_end_l
val4=<fs_stop>aggr_assgn_end_c
val5=<fs_stop>req_end
val6=<fs_stop>plan_trans_time)
resmin_time=nmin(val1=resmin_time
val2=CONDtimestamp(WHEN<fs_stop>appointment_startISNOTINITIALTHEN<fs_stop>appointment_startELSElc_max)
val3=CONDtimestamp(WHEN<fs_stop>req_startISNOTINITIALTHEN<fs_stop>req_startELSElc_max)
val4=CONDtimestamp(WHEN<fs_stop>plan_trans_timeISNOTINITIALTHEN<fs_stop>plan_trans_timeELSElc_max)
val5=CONDtimestamp(WHEN<fs_stop>aggr_assgn_start_lISNOTINITIALTHEN<fs_stop>aggr_assgn_start_lELSElc_max)
)).

Theunderlyingdiscussioncanbefound here.
Now,somethingmorethanjusttimestamps...

Extracttheshortestdurationtogetherwithanothervaluewhichshouldcomefrom
thelinewiththeshortestduration

01.
02.
03.
04.
05.
06.
07.
08.
09.
10.

DATA(ls_min_dur)=REDUCEty_min_dur(INITresult=VALUEty_min_dur(min_dur=
99999)

FOR<ls_lddd>INmt_lddd

USINGKEYloc_frWHERE(loc_fr=iv_loc_key)

NEXT

http://scn.sap.com/community/abap/blog/2015/04/17/collectionofourbesttableexpressions

1/2

4/19/2015
11.
12.
13.
14.
15.
16.
17.

119Views

Collectionofourbesttableexpressions|SCN
resultloc_fr=<ls_lddd>loc_fr

resultmin_dur
=nmin(val1=resultmin_durval2=<ls_lddd>duration)

resultloc_to=COND#(WHENresultmin_dur=<ls_lddd>duration
THEN<ls_lddd>loc_toELSEresultloc_to)).

AverageUserRating
(0ratings)

Share

Tweet

Like

0Comments
Therearenocommentsonthispost

SiteIndex
Privacy

ContactUs
TermsofUse

SAPHelpPortal
LegalDisclosure

Copyright

http://scn.sap.com/community/abap/blog/2015/04/17/collectionofourbesttableexpressions

FollowSCN

2/2

S-ar putea să vă placă și