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

Table change not working

Former Member
0 Likes
1,054

Hi Experts

I tried the following coding, but its not working, pls suggest me what could be the reason.

DATA message_wa TYPE vbap.

message_wa-vbeln = '1'.

message_wa-posnr = '10'.

message_wa-ERDAT = '04.07.2006'.

MODIFY vbap FROM message_wa.

Regards

Rajaram

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
948

Hi,

try like this.........

DATA wa_vbap TYPE vbap.

wa_vbap-vbeln    = '0000000001'.
wa_vbap-posnr   = '000010'.
wa_vbap-erdat   = '20060704'.
MODIFY vbap FROM wa_vbap.
IF sy-subrc is initial.
message 'Record updated' type 'S'.
endif.

Cheers,

jose.

7 REPLIES 7
Read only

Former Member
0 Likes
949

Hi,

try like this.........

DATA wa_vbap TYPE vbap.

wa_vbap-vbeln    = '0000000001'.
wa_vbap-posnr   = '000010'.
wa_vbap-erdat   = '20060704'.
MODIFY vbap FROM wa_vbap.
IF sy-subrc is initial.
message 'Record updated' type 'S'.
endif.

Cheers,

jose.

Read only

0 Likes
948

Hi Jose

Thank you very much, Now Its working fine yar, can we change all the fields in table including primary key as following this procedure.

pls advise me.

Read only

0 Likes
948

Hi,

All fields except key fields(key is used to identify a reccord right)...............

u can insert a record with a new key.......

Cheers,

jose.

Read only

0 Likes
948

Ok thank you,

how to insert/delete a new record, pls provide me code.

Regards

Rajaram

Read only

0 Likes
948

Hi,

DELETE FROM vbap WHERE vbeln = '0000000001' AND posnr = '000010'.

OR

DATA wa_vbap TYPE vbap.
wa_vbap-vbeln = '0000000001'.
wa_vbap-posnr = '000010'.
DELETE vbap FROM wa_vbap.

OR

DATA it_vbap TYPE STANDARD TABLE OF vbap WITH HEADER LINE.
it_vbap-vbeln = '0000000001'.
it_vbap-posnr = '000010'.
APPEND it_vbap.
it_vbap-vbeln = '0000000001'.
it_vbap-posnr = '000020'.
APPEND it_vbap.
DELETE vbap FROM TABLE it_vbap.

Read only

Former Member
0 Likes
948

Hi Rajaram,

Please check this sample code to change the values in VBAP.

&----


*& Report ZFORMS_TEST *

*& *

&----


*& *

*& *

&----


REPORT ZFORMS_TEST .

DATA message_wa TYPE vbap.

data : begin of it_vbap occurs 0.

include structure VBAP.

data : end of it_vbap.

parameters : p_vbeln like vbap-vbeln.

start-of-selection.

clear it_vbap.

select * from vbap

into table it_vbap where vbeln = p_vbeln

and posnr = '10'.

clear it_vbap.

read table it_vbap index 1.

move '20060202' to it_vbap-erdat.

modify it_vbap index 1.

CALL FUNCTION 'DB_UPDATE_TABLE'

EXPORTING

TABLENAME = 'VBAP'

  • IMPORTING

  • SQLCODE =

TABLES

INTTAB = it_vbap

EXCEPTIONS

DB_ERROR = 1

NOT_FOUND = 2

WRONG_PARAM = 3

INTERNAL_ERROR = 4

OTHERS = 5

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

else.

write : 'Database updated successfully'.

ENDIF.

Please reward points if useful.

Read only

Former Member
0 Likes
948

Hi Raja

For normal ztable, you can use

delete db from table itab.

Here itab should be a internal table and contain the data to be deleted.

or

delete from db where condition.

update db from table itab.

Regards

Pavan