Application Development 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: 

Reg : Modifing a database Ztable

mallikarjun_vaja
Participant
0 Kudos

Hi,

I have a ztable with 10fields and 11th field is date field. I also have a work area with these fields.

For every record in the Ztable...all the 10 fields have data but 11th filed does not have data(its empty).

Now I want to insert/modify/update database table ztable in such a way that:

IF the date field is empty..just update that date field only with SY-datum.

else leave it.

How do you do that?

Can you give me a sample code?

Thanks,

Arjun

1 ACCEPTED SOLUTION

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

You can modify the exisitng ztable's data as follows

update ztable set date = value where date is initial.

5 REPLIES 5

former_member404244
Active Contributor
0 Kudos

Hi,

do like this..

Loop at itab into watab.

if watab-date is initial.

watab-date = SY-DATUM.

ENDIF.

MODIFY ITAB FROM WATAB transporting date.

ENDLOOP.

Now go for update statement with ztable

update ztable from table itab.

Regards,

Nagaraj

JozsefSzikszai
Active Contributor
0 Kudos

hi Arjun,

something like

SELECT *

INTO gt_ztable

FROM ztable

WHERE date EQ '00000000'.

LOOP AT gt_ztable INTO gw_ztable.

gw_ztable-date = sy-datum.

MODIFY gt_ztable from gw_ztable TRANSPORTING date.

ENDLOOP.

UPDATE ztable FROM TABLE gt_ztable.

IF sy-subrc EQ 0.

COMMIT WORK.

ELSE.

ROLLBACK WORK.

ENDIF.

hope this helps

ec

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

You can modify the exisitng ztable's data as follows

update ztable set date = value where date is initial.

0 Kudos

hi Jayanti,

thats perfect answer.

my problem is solved.

I have given you points.

thanks again

bye

Arjun

Former Member
0 Kudos

Hi,

How this Ztable is getting updated?

if its thru Zprogram: then u can write thru codeand Modify Ztable.

If its thru maintenance view, then u need to write the code in Maintenance prgm.

Regards

Kannaiah