Sunteți pe pagina 1din 5

GetStarted

Solutions

Partner

Support

About

Community

Training

Community

Developer

Blogs

UpdateOrderuserstatus
uponSaveofNotification
orOrder
May31,2016

| 86Views |
JogeswaraRaoK
morebythisauthor

PLMEnterpriseAssetManagement(EAM)/PlantMaintenance(PM)
Solution

share
0

share
0

tweet

Follow

Update Order userstatus upon Save of Notification or Order :


ObviouslywearetalkingaboutlinkedNotificationOrderScenario.

DearFriends,
TomyapproximationIgavearound150enhancementsolutions sofar
whileansweringthequeries.AmongtheseIfeltlikedocumentingfew(7

sofar)becauseoftheircomplexandinterestingnature.Ifeltthatthe
presentonetooisofsimilarnatureandforumwillbebenefitedifitis
presentedintheformofatechnicalblog.

share
0

1
like

Actions

Sohereitis:.
Itisaboutarecentcallforhelp,wherethememberwasseekingsolutionfor
herrequirementwhichwasexpressedas:WhenparticularTaskisopenin
theNotification,howtoupdatetheuserstatusinIW31/32onServiceOrder
.PleaseSuggest..

Ifeltthisisanotheropportunitytocontributefewlinesofenhancement
codetotheforum.Igavethesolutionie.,theuserexitandthecode.
ThecodereadstheSystemstatusoftheNotification,ifitfindsOSTS
(outstandingtask)thenitsetsaspecificuserstatus(sayABCD)tothe
Order,obviouslyduringSave(ofOrderastherequirementsounded).

The member then clarifies like: No no, I do not want during Order
Save, It to happen while Notification Save. Then I gave that solution
too,otheruserexit,andcorrespondingcodeobviously.

Soherewearegoingtoseeboththesolutionsfor
1.Updating Order Userstatus during Order Save if Notification has
outstanding

tasks.

(userexit

IWO10009,

F/exit

EXIT_SAPLCOIH_009)

2.Updating the Order Userstatus during Notification Save if


Notification has outstanding tasks. (userexit QQMA0014, F/exit
EXIT_SAPMIWO0_020)

Beforeweseetheindividualsolutioncodesforbothofthese,letsfirst
lookatthelogic.
ThestartpointistoknowwhetheranyoutstandingTaskisthere
in the Notification. This means Notification system status will
haveOSTSvalue.
To know this we need to use function module STATUS_READ.
The input to this fm is Notification OBJNRvalue which we get
fromQMELorVIQMELtable.
But the output from the above fm will be in code (not in text
formatOSTS).Weneedtoknowthiscodeforourcoding.This
isknownfromtableTJ02T when we input value OSTS in the
field TXT04 and E in field SPRAS. We get the value as
I0158.(Thiscommonforyou,meandforallothers)

So in the code we need to tell to update the Order status to


ABCDiftheNotificationuserstatuscodeisI0158.
WeneedtousefunctionmoduleSTATUS_CHANGE_EXTERN
toupdatetheOrderuserstatus.
ThisfmworksOBJNRvalueofOrderasinputwhichis
Readily available as a field in the Import structure
(caufvd_imp)oftheuserexitifitiscase1above
NeedtogetitfromtableAUFKifitiscase2..
But this fm too needs code only not the text of user status
(ABCD)tosetitinOrder.Sohowdowegetit?
We get it from table TJ30T by inputting the Status profile of
OrderinfieldSTSMA,valueABCDinfieldTXT04andvalueE
infieldSPRAS.LetsassumewegotthisasE0004.
Nowwearereadyforcoding.

Ifitisthecase1,ie., Updating Order Userstatus during Order Save if


Notification has outstanding tasks, we need to put the following code in
includeZXWOCU07.

Andthecodeis:
DATA:i_statLIKEjstatOCCURS0WITHHEADERLINE,
l_objnrTYPEj_objnr.
SELECTSINGLEobjnrFROMviqmelINTOl_objnrWHEREqmnum=caufvd_impqmnum.
CALLFUNCTIONSTATUS_READ
EXPORTING
objnr=l_objnr
only_active=X
TABLES
status=i_stat.
LOOPATi_stat.
IFi_statstat=I0158.
CALLFUNCTIONSTATUS_CHANGE_EXTERN
EXPORTING
objnr=caufvd_impobjnr
user_status=E0004

set_inact=.
ENDIF.
ENDLOOP.

Ifitiscase2:UpdatingtheOrderUserstatusduringNotificationSaveif
Notificationhasoutstandingtasks,weneedtousethecodebelowinthe
includeZXQQMU20.
Thecodeis:
DATA:i_statLIKEjstatOCCURS0WITHHEADERLINE,
l_objnrTYPEj_objnr.
SELECTSINGLEobjnrFROMaufkINTOl_objnrWHEREaufnr=i_viqmelaufnr.
CALLFUNCTIONSTATUS_READ
EXPORTING
objnr=i_viqmelobjnr
only_active=X
TABLES
status=i_stat.
LOOPATi_stat.
IFi_statstat=I0158.
CALLFUNCTIONSTATUS_CHANGE_EXTERN
EXPORTING
objnr=l_objnr
user_status=E0004
set_inact=.
ENDIF.
ENDLOOP.

Note:
Thoughalreadymentionedinthelogicpointsabove,Iwanttoremind
abouttheE0004codeusedinthecodesabove.youhavetogetthis
valuefromtableTJ30TbyinputtingyourOrderstatusprofile in field

STSMA,theuserstatustobesetinOrderinfieldTXT04andEin
fieldSPRAS.
BoththecodesItestedbeforepostingtothatdiscussion.Ifyouare
going to use, test well for its satisfactory working in the Dev
servers.

..Andthuswearriveattheendofthispost..
ThankyouandRegards

KJogeswaraRao

AlertModerator

Bethefirsttoleaveacomment
AddComment

Share & Follow

Privacy

TermsofUse

LegalDisclosure

Copyright

Trademark

Sitemap

Newsletter

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