Skip to Content

updating the database using z bapi without deleting existing data

hi every body,

i am using a zbapi in that i am updating a table which is having 40 fields but i am modifying the only four fields but it is deleting the remaining field entries

i am now attaching the code what i have used

ZMPETS_SHIPHDR-SHIPDOCNO = wf_shipdocno.

ZMPETS_SHIPHDR-VENACCEPTIND = VENACCEPTIND.

ZMPETS_SHIPHDR-LASTCHANGEDT = SY-DATUM.

ZMPETS_SHIPHDR-LASTCHANGEBY = SY-UNAME.

ZMPETS_SHIPHDR-LOEKZ = ' '.

CALL FUNCTION 'Z_MPETS_SAVE_SHIPHDR'

EXPORTING

zmpets_shiphdr_save = ZMPETS_SHIPHDR.

*COMMITING THE UPDATION.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

IMPORTING

RETURN = RETURN.

  • UPDATING THE SHIPMENT ACTIVITY TABLE.

ZMPETS_SHIPACTIV-PETSDOCNUMBER = wf_shipdocno.

ZMPETS_SHIPACTIV-LOEKZ = ' '.

ZMPETS_SHIPACTIV-ACTIVITY = '20'.

CALL FUNCTION 'Z_MPETS_SAVE_SHIPACTIV'

EXPORTING

zmpets_shipactiv_save = ZMPETS_SHIPACTIV.

in the upper function module the code

is

modify zmpets_shipactiv from zmpets_shipactiv_save.

we have to use this compulsory as it is client's standard

*COMMITING THE UPDATION.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

IMPORTING

RETURN = RETURN.

kindly give me reply

i will reward the points for a best reply

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 28, 2006 at 12:09 PM

    Welcome to SDN!

    You will need to pass all 40 fields into your BAPI structure (ZMPETS_SHIPACTIV). The problem is that when you use the modify from statement, the BAPI updates the DB as-is from the BAPI structure, and since you are passing it only 4 values, it defaults the others to space.

    Do this:

    SELECT * FROM ZMPETS_SHIPACTIV WHERE <specify key fields here>

    and then

    ZMPETS_SHIPACTIV-PETSDOCNUMBER = wf_shipdocno.

    ZMPETS_SHIPACTIV-LOEKZ = ' '.

    ZMPETS_SHIPACTIV-ACTIVITY = '20'.

    CALL FUNCTION 'Z_MPETS_SAVE_SHIPACTIV'

    EXPORTING

    zmpets_shipactiv_save = ZMPETS_SHIPACTIV.

    This should work.

    Hope this helps.

    Sudha

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 28, 2006 at 12:22 PM

    Hi,

    pass all the key fields along with the non

    key fields you want to modify by filling BAPI

    structure .

    CALL FUNCTION 'Z_MPETS_SAVE_SHIPACTIV'

    EXPORTING

    zmpets_shipactiv_save = ZMPETS_SHIPACTIV.

    Regards

    Amole

    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.