09-01-2006 5:36 PM
Hi All
I know my code will not work since Modify doesn,t support where,but my problem is like that..can u suggest how can i get the same result
I ahve to modify the TAble "JEST' there are 3 cases
i have a internal table T_OBJLIST having a single field
objid.
Actually JEST has 4 Fields OBJNR,STAT,INCTV,CHGNR
DATA : E_JEST type JEST .
Loop at T_OBJLIST.
clear e_jest.
MOVE : T_OBJLIST-OBJID TO E_JEST-OBJNR ,
C_E0001 TO E_JEST-STAT ,
SPACE TO E_JEST-INACT .
CASE1-MODIFY only INACT if it is X and OBJID in JEST & STATUS is E0001 do,nt change CCHGNR of Jest.
But below query changes CHGNR also.
MODIFY JEST FROM E_JEST WHERE OBJNR EQ T_OBJLIST-OBJID
AND STAT EQ E0001
AND INACT EQ C_X .
IF SY-SUBRC EQ 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK..
ENDIF.
Case2-Modify only when Objid is Same but STSUS is not E0001
MODIFY JEST FROM E_JEST WHERE OBJNR eq T_OBJLIST-OBJID
AND STAT NE C_E0001 .
Case 3- Modify when OBJID not found in JEST
MOVE : C_001 TO E_JEST-CHGNR .
MODIFY JEST FROM E_JEST WHERE OBJNR NE E_JEST-OBJNR .
Thanks
SAurabh Tiwari
09-01-2006 5:52 PM
09-01-2006 8:35 PM
I do agree with Rich it is not advisable to update SAP standard tables but here is the logic if you have to ...
Loop at T_objlist.
select * into ijest from jest where objnr = objid.
if sy-subrc = 0.
if ijest-stat = 'E00001'.
ejest-objnr = ijest-objid.
ejest-stat = ijest-stat.
ejest-chgnr = ijest-chgnr.
check ijest-inctv = 'X'.
ejest-inact = space.
endif.
else.
ejest-objnr = ijest-objid.
ejest-stat = ijest-stat.
ejest-chgnr = C_001
ejest-inctv = space.
endif.
modify jest from ejest.
commit work.
endloop.