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: 

Maintenance view generator, event 01

0 Kudos
1,249

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

3 REPLIES 3

Kiran_Valluru
Active Contributor
0 Kudos
88

Hi.,

Check this article : [Events TMG |http://www.google.co.in/url?sa=t&source=web&cd=2&ved=0CB8QFjAB&url=http%3A%2F%2Fwww.sdn.sap.com%2Firj%2Fscn%2Findex%3Frid%3D%2Flibrary%2Fuuid%2F80b077d7-5317-2e10-8db8-aaf6921ced4a%26overridelayout%3Dtrue&rct=j&q=dynamically%20enable%20disable%20fields%20in%20table%20maintenance%20generator&ei=zegBTtmHGsrYrQf7q-iFAw&usg=AFQjCNED1mF3CxkQnf1JvKVqHs1T912c0w&cad=rja]

what exactly you want to do.. If you want to fill a field based on the entered value then no need of Field Symbols and all.,

suppose if you enter ID as 1 and press Enter or Save in TMG , now for ID 1 if you want to populate Name Field Automatically.,

In the Event 05 .,

select name from names_table into lv_name where id = id_table-id.

id_table-name = lv_name.

hope this helps u.,

Thanks & Regards,

Kiran

raymond_giuseppi
Active Contributor
0 Kudos
88

You cannot assign fields of TOTAL which is not a transparent structure, you must explicitly define a record field with the correct structure (ref: [Internal Table TOTAL|http://help.sap.com/saphelp_nw04/helpdata/en/91/ca9fb9a9d111d1a5690000e82deaaa/content.htm])

For views or tables without text tables, the internal table has the structure of the view or table plus a processing and a selection flag.

Example

INCLUDE STRUCTURE <view name> or <table name>

INCLUDE STRUCTURE VIMTBFLAGS

For tables connected to a text table via the foreign key relationship TEXT, the structure of the table comprises the structure of the entity table and the text table, plus two processing flags and a selection flag.

Example

INCLUDE STRUCTURE <table name>

INCLUDE STRUCTURE <text table name>

INCLUDE STRUCTURE VIMTBFLAGS

Note

The structure of the table TOTAL is not transparent. You should define a record with this structure to access the table fields. After assigning the header line of the table TOTAL to the structure, the fields can be accessed via the structure. You can also use predefined table Total header line field symbols.

So use [A LOOP AT INTO or ASSIGNING|http://help.sap.com/abapdocu_70/en/ABAPLOOP_AT_ITAB_RESULT.htm].

(Some other events, like the event 05, don't use table TOTAL but current record (one record) is available defined by a TABLES: statement.)

Regards,

Raymond

0 Kudos
88

Thanks for the quick reply

In fact i got many problem finding that structure but finally got it: <vim_total_struc>

ASSIGN COMPONENT 'CRUSR' OF STRUCTURE <vim_total_struc> TO <crusr>.

is working perfect now