Skip to Content
0
Jun 22, 2011 at 11:41 AM

Maintenance view generator, event 01

1150 Views

Hello,

I've create a transparent table zvalid_part and recently added audit fields.

Purpose of the event is to fill those fields automatically.

I've found several posts on the topic but none of them gives the whole code to achieve that

here's what i've tried but without success, i can set my audit fields as i don't know what to declare as data or field symbol and how to assign structure or field to field symbol.

Can someone help to get ride of runtime error ?

FORM set_audit_fields.

DATA: f_index LIKE sy-tabix. "Index to note the lines found

FIELD-SYMBOLS: <zlv_crusr> type zvalid_part-crusr,

<zlv_crdat> type zvalid_part-crdat,

<zlv_crtim> type zvalid_part-crtim,

<zlv_chusr> type zvalid_part-chusr,

<zlv_chdat> type zvalid_part-chdat,

<zlv_chtim> type zvalid_part-chtim.

LOOP AT total. IF <action> = neuer_eintrag OR <action> = aendern.

READ TABLE extract WITH KEY <vim_xtotal_key>.

IF sy-subrc EQ 0.

f_index = sy-tabix.

ELSE.

CLEAR f_index.

ENDIF.

ASSIGN COMPONENT 'CRUSR' OF STRUCTURE total TO <zlv_crusr>.

ASSIGN COMPONENT 'CRDAT' OF STRUCTURE total TO <zlv_crdat>.

ASSIGN COMPONENT 'CRTIM' OF STRUCTURE total TO <zlv_crtim>.

ASSIGN COMPONENT 'CHUSR' OF STRUCTURE total TO <zlv_chusr>.

ASSIGN COMPONENT 'CHDAT' OF STRUCTURE total TO <zlv_chdat>.

ASSIGN COMPONENT 'CHTIM' OF STRUCTURE total TO <zlv_chtim>.

IF <zlv_crusr> IS INITIAL.

<zlv_crusr> = sy-uname.

<zlv_crdat> = sy-datum.

<zlv_crtim> = sy-uzeit.

ENDIF.

<zlv_chusr> = sy-uname.

<zlv_chdat> = sy-datum.

<zlv_chtim> = sy-uzeit.

MODIFY total.

CHECK f_index GT 0.

extract = total.

MODIFY extract INDEX f_index.

ENDIF.

ENDLOOP.

sy-subrc = 0.

ENDFORM. "set_audit_fields