Skip to Content
author's profile photo Former Member
Former Member

Modify Database table

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Sep 01, 2006 at 04:52 PM

    I believe the UPDATE statement supports a WHERE clause.

    You really need to be careful when modifying a standard SAP table like JEST. Really you shouldn't be doing this.

    Regards,

    Rich HEilman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 01, 2006 at 07: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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.