08-24-2012 10:50 PM
Hi Friends,
I have 3 z tables and each has one view created.
Tables
1.ZTT_RGA_DISPCODE -fields--Cost center,created on,createdby,changed on ,changedby
2.ZTT_RGA_RSN_CODE
-fields--Cost center,created on,createdby,changed on ,changedby
3.
ZTT_RGA_MTRL_CON
-fields--Cost center,created on,createdby,changed on ,changedby
Using event Create New entry ,i have a routine.
Issue:
When i am entrying a new entry in sm30 ,cost center does not exist,but the entry is available in the CSKS table.the Created on ,createdby should automatically populate..
Do i need to change any thing in the code below.
Please let me know any if you are not clear about my question.
FORM create_new.
ztt_rga_dispcode-created_on = sy-datum.
ztt_rga_dispcode-created_by = sy-uname.
ztt_rga_dispcode-changed_on = sy-datum.
ztt_rga_dispcode-changed_by = sy-uname.
MODIFY ztt_rga_dispcode.
ENDFORM. "CREATE_NEW
*&---------------------------------------------------------------------*
*& Form CONTENT_CHANGE
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM content_change.
BREAK-POINT.
ztt_rga_dispcode-changed_on = sy-datum.
ztt_rga_dispcode-changed_by = sy-uname.
MODIFY ztt_rga_dispcode.
ENDFORM. "CONTENT_CHANGE
*&---------------------------------------------------------------------*
*& Form CREATE_NEW1
*&---------------------------------------------------------------------*
* Event for Material number conversion:ZTT_RGA_MTRL_CON
*----------------------------------------------------------------------*
FORM CREATE_NEW1.
ZTT_RGA_MTRL_CON-created_on = sy-datum.
ZTT_RGA_MTRL_CON-created_by = sy-uname.
ZTT_RGA_MTRL_CON-changed_on = sy-datum.
ZTT_RGA_MTRL_CON-changed_by = sy-uname.
ENDFORM. "CREATE_NEW1
*&---------------------------------------------------------------------*
*& Form CREATE_NEW2
*&---------------------------------------------------------------------*
* Events for Reason code table:ZTT_RGA_RSN_CON
*----------------------------------------------------------------------*
FORM CREATE_NEW2.
data: gs_data TYPE ZTT_RGA_RSN_CODE.
ZTT_RGA_RSN_CODE-created_on = sy-datum.
ZTT_RGA_RSN_CODE-created_by = sy-uname.
ZTT_RGA_RSN_CODE-changed_on = sy-datum.
ZTT_RGA_RSN_CODE-changed_by = sy-uname.
data: lv_index TYPE sy-tabix VALUE '1'.
read TABLE extract INDEX sy-tabix.
IF sy-subrc is INITIAL.
gs_data-changed_on = sy-datum.
gs_data-changed_by = sy-uname.
modify ZTT_RGA_RSN_CODE from gs_data .
ENDIF.
08-27-2012 5:52 AM
08-27-2012 12:01 PM
Hi,
If the requirement is to populate changed date, changed by etc. then the same should happen both while creation and updation. If you write the code in event 'Creating new entry' then this would not happen. I would rather suggest to use the event 'Before Save data' to enter the audit field i.e changed date etc.
There is no need to use Modify statement.
Do write the code and let me know if the issue is solved. Thanks.
Regards,
Kumud
08-29-2012 6:21 PM
Hi Kumud,
Thanks for your reply,
I have used save entry and save changes events,the change on changed by created on created by are populating automatically
now the new requ.is
when ever the material id entered the material description should be populated automatically.
i have used the save entry for this.
data: lv_matnr type matnr,
lv_maktx TYPE maktx.
select maktx from makt into lv_maktx WHERE matnr = zvw_rga_rsn_code-matnr
and spras = sy-langu.
zvw_rga_rsn_code-maktx = lv_maktx.
zvw_rga_rsn_code-RCODE_DESC = lv_maktx.
ENDSELECT.
I have used this code,its nt wrking.Can you suggest.
08-29-2012 6:36 PM
08-30-2012 9:07 AM
Hi Vandana,
I assume material no. is a primary key! Now, when material no. is entered and you press enter, then has the description to be displayed or after you click on Save button? Before_save entry would not work here. As suggested by Jitendra, use Create_entry and check. Let me know if that works.
Regards,
Kumud