2006 Jun 22 2:55 AM
Hello experts,
Yesterday, I created a code inside a maintenance view event(02-After saving the data in the database). It worked fine. But as I tested it today, it didn't work att all. Below is my code:
MOVE sy-uname TO zts0001-zcreated_by.
MOVE sy-datum TO zts0001-zchanged_date.
So my idea here is that after saving the modifed record, it would move the latest time and username on those 2 fields in my z table. But now it seems not to be working. I didnt change anything.
Again, thank you guys and take care!
Message was edited by: viraylab
2006 Jun 22 3:02 AM
Hello experts,
Yesterday, I created a code inside a maintenance view event(02-After saving the data in the database). It worked fine. But as I tested it today, it didn't work att all. Below is my code:
MOVE sy-uname TO zts0001-zcreated_by.
MOVE sy-datum TO zts0001-zchanged_date.
So my idea here is that after saving the modifed record, it would move the latest time and username on those 2 fields in my z table. But now it seems not to be working. I didnt change anything.
Again, thank you guys and take care!
Message was edited by: viraylab
2006 Jun 22 3:02 AM
2006 Jun 22 3:05 AM
Hi Rich,
No, I didnt re-generate it since the code is still intact. Anyway, for more clarity, i'll post the entire code below. This is for event 02. The idea here is to get the records where its date is equal to sy-datum then update those records in table 2.
FORM get_name_and_date.
TABLES: zshipto_email,
zts_stpgeoloc.
MOVE sy-uname TO zts0001-zcreated_by.
MOVE sy-datum TO zts0001-zchanged_date.
TYPES: BEGIN OF t_zts0001,
kunnr LIKE zts0001-kunnr,
cdseq LIKE zts0001-cdseq,
zaddress LIKE zts0001-zaddress,
END OF t_zts0001.
TYPES: BEGIN OF t_zts_stpgeoloc,
kunnr LIKE zts_stpgeoloc-kunnr,
cdseq LIKE zts_stpgeoloc-cdseq,
zaddress LIKE zts_stpgeoloc-zaddress,
END OF t_zts_stpgeoloc.
TYPES: BEGIN OF t_address_status,
kunnr LIKE zts0001-kunnr,
cdseq LIKE zts0001-cdseq,
old_address LIKE zts0001-zaddress,
new_address LIKE zts0001-zaddress,
END OF t_address_status.
DATA: it_zts0001 TYPE STANDARD TABLE OF t_zts0001,
it_zts_stpgeoloc TYPE SORTED TABLE OF t_zts_stpgeoloc
WITH UNIQUE KEY kunnr cdseq WITH HEADER LINE,
it_address_status TYPE STANDARD TABLE OF t_address_status
WITH HEADER LINE.
DATA: it_zshipto_email TYPE STANDARD TABLE OF zshipto_email
WITH HEADER LINE.
DATA: maildata TYPE sodocchgi1,
mailtxt TYPE TABLE OF solisti1 WITH HEADER LINE,
mailrec TYPE TABLE OF somlrec90 WITH HEADER LINE.
DATA: lv_contents TYPE string.
FIELD-SYMBOLS: <fs_zts0001> TYPE t_zts0001.
SELECT kunnr cdseq zaddress FROM zts0001
INTO TABLE it_zts0001
WHERE zchanged_date = sy-datum.
SELECT kunnr cdseq zaddress FROM zts_stpgeoloc
INTO TABLE it_zts_stpgeoloc
FOR ALL ENTRIES IN it_zts0001
WHERE kunnr = it_zts0001-kunnr
AND cdseq = it_zts0001-cdseq.
LOOP AT it_zts0001 ASSIGNING <fs_zts0001>.
READ TABLE it_zts_stpgeoloc WITH KEY kunnr = <fs_zts0001>-kunnr
cdseq = <fs_zts0001>-cdseq.
IF sy-subrc = 0.
IF it_zts_stpgeoloc-zaddress <> <fs_zts0001>-zaddress.
MOVE <fs_zts0001>-kunnr TO it_address_status-kunnr.
MOVE <fs_zts0001>-cdseq TO it_address_status-cdseq.
MOVE it_zts_stpgeoloc-zaddress TO it_address_status-old_address.
MOVE <fs_zts0001>-zaddress TO it_address_status-new_address.
APPEND it_address_status.
UPDATE zts_stpgeoloc SET zaddress = <fs_zts0001>-zaddress
WHERE kunnr = <fs_zts0001>-kunnr
AND cdseq = <fs_zts0001>-cdseq.
ENDIF.
ENDIF.
ENDLOOP.
IF NOT it_address_status[] IS INITIAL.
SELECT * FROM zshipto_email
INTO TABLE it_zshipto_email
WHERE zevent = '2'.
IF sy-dbcnt > 0.
maildata-obj_name = 'Record Changed in table ZTS0001'.
maildata-obj_descr = 'Record Changed in table ZTS0001'.
maildata-obj_langu = sy-langu.
LOOP AT it_zshipto_email.
mailtxt-line = 'FYI: Record changed in table ZTS0001'.
APPEND mailtxt.
LOOP AT it_address_status.
CONCATENATE: 'Address of dealer' it_address_status-kunnr
'code' it_address_status-cdseq 'was changed'
'from' it_address_status-old_address 'to'
it_address_status-new_address 'in table'
'ZTS0001 and ZTS_STPGEOLOC' INTO lv_contents
SEPARATED BY space.
mailtxt-line = lv_contents.
APPEND mailtxt.
CLEAR lv_contents.
ENDLOOP.
mailtxt-line = 'NOTE: Do not reply to this message.'.
APPEND mailtxt.
mailrec-receiver = it_zshipto_email-zemail.
mailrec-rec_type = 'U'.
APPEND mailrec.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = maildata
document_type = 'RAW'
put_in_outbox = 'X'
commit_work = 'X'
TABLES
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR: maildata, mailtxt, mailrec.
REFRESH: mailtxt, mailrec.
ENDLOOP.
ENDIF.
ENDIF.
ENDFORM.
2006 Jun 22 3:08 AM
Viray,
Try putting a break point in the include at some statement. Then see whether the control is going there when you save the entries in the table/view.
Check whether the code is there assigned for that event or not. As Rich said, if you had re-generated table maintenance, then the code assigned to the event will be deleted.
Thanks,