Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

save data

Hi,

Following Codeing using to table control data save ztable.

module update_database input.

IF ok_code = 'SAVE'.

DATA : itab2_save LIKE ZPSRP OCCURS 10 WITH HEADER LINE,

itab2_db LIKE ZPSRP OCCURS 10 WITH HEADER LINE.

CLEAR : itab2_save , itab2_db.

REFRESH : itab2_save , itab2_db.

LOOP AT itab2.

MOVE-CORRESPONDING itab2 TO itab2_save.

MOVE sy-mandt TO itab2_save-mandt.

APPEND itab2_save.

ENDLOOP.

IF LIPS-vbeln IS NOT INITIAL.

SELECT * FROM ZPSRP

INTO CORRESPONDING FIELDS OF TABLE itab2_db

WHERE vbeln = LIPS-vbeln.

ELSEIF likp-vbeln IS NOT INITIAL.

SELECT * FROM ZPSRP

INTO CORRESPONDING FIELDS OF TABLE itab2_db

WHERE vbeln = likp-vbeln.

ENDIF.

IF sy-subrc = 0.

*if itab2_db[] = itab2_save[].

LOOP AT itab2_db.

DELETE ZPSRP FROM itab2_db.

ENDLOOP.

*Loop AT Itab2.

  • MODIFY ZPSRP FROM TABLE itab2_save.

INSERT ZPSRP FROM TABLE itab2_save.

  • COMMIT WORK.

REFRESH: itab2. "_save.

*ENDLOOP.

  • endif.

ELSE.

LOOP AT itab2_save.

MODIFY itab2_save.

ENDLOOP.

  • LOOP AT ITAB2_SAVE.

  • MODIFY ZPSRP FROM TABLE itab2_save.

INSERT ZPSRP FROM TABLE itab2_save.

  • COMMIT WORK.

  • ENDLOOP.

ENDIF.

REFRESH : itab2_save, itab2.

  • CLEAR :itab2 , flag , vbeln , vstel.

  • CLEAR: likp-vbeln,

  • likp-vstel.

*

  • CLEAR: vbrp-vbeln,

  • vbrp-vstel.

*

  • CLEAR : TOT_BAG,

  • TOT_WEG.

ENDIF.

endmodule. " update_database INPUT

ITAB2 and ZPSRP is same fields.

Prb Is : 1. multiple record not save .

EG:

Vbeln posnr QTY1 weight

-1000 10 50 100

-1000 10 60 110

the above record not save in same time

*error is:*INSERT ZPSRP FROM TABLE itab2_save.

Kindly Advise me.

By,

Jeevan

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question