Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

save data

Former Member
0 Likes
738

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

6 REPLIES 6
Read only

Former Member
0 Likes
706

hello

'use modify instead of insert...

tell me wat error it shows

Read only

0 Likes
706

Hi,

Modify Comment Using stored value are 0

By,

Jeevan

Read only

0 Likes
706

modify do both update and insert according to the condition

can u tell me wat error it shows when you run the program.

Read only

BH2408
Active Contributor
0 Likes
706

Hi ,

Try for the Modify

MODIFY tablename FROM TABLE iinternal table .

Regards,

Bharani

Read only

Former Member
0 Likes
706

Hi,

Modify Comment Using stored value are 0

By,

Jeevan

Read only

Former Member
0 Likes
706

ANS