09-10-2014 12:02 AM
Hi Experts,
I have created one custom table with 5 fields
Field1 = Approval no ( Key Field and Editable )-->Auto Populated
Field 2 = Vesrion No ( Non Key filed and Output Only)
Filed 3= description( Editable Filed)
Filed 4 = Created by(Auto poplated)
Filed 5 = Created_date(Autopopulate).
I have Create TMG for the table and am able to populate field4 field5 using create_entries event01.
My table having 3 records let us assume.
Field1 field2 field3 field4 field5
10001 01 test xxxx 12/09/14
10001 02 test xxxx 12/09/14
When i try to create same entry 10001 how to maintain vesrion(Field2) number(Auto Populated). ?
I am trying to create using before save event how to compare TOTAL and EXTRACT tables?
Please find the code which I wrote its not working...
Please correct the below code.
LOOP AT total.
wa_data1 = <vim_total_struc>.
lv_index1 = sy-tabix.
READ TABLE extract with KEY total.
IF sy-subrc eq 0.
lv_index2 = sy-tabix.
wa_data2 = <vim_extract_struc>.
if wa_data1-version is INITIAL.
wa_data1-version = 1.
else.
wa_data1-version = wa_data1-version + 1.
endif.
wa_data2-version = wa_data1-version.
<vim_extract_struc> = wa_data2.
<vim_total_struc> = wa_data1.
MODIFY extract INDEX lv_index2.
MODIFY total index lv_index1.
ENDIF.
09-10-2014 4:39 AM
Hi Srinath,
Field 2 should also be a primary key. Please let me know if this helps.
Thanks
Sri
09-10-2014 5:24 AM
Hi Srinath,
It is not working because you have only field1 as primary key and you are inputting same value again if you make feild2 also as primary key it will work.
Thanks.
09-10-2014 10:54 AM
HI Srilakshmi,
Thanks for your reply....What am trying to Say Field should be populated automatically...based on previous version...Primary key not a problem...
let me explain with example...
The table having 2 entries.....
No Version desc user name date
1001 01 text sy-uname sy-datum
1001 02 text1 sy-uname sy-udatum
when the user tries to enter 1001 no the system should be update the version number as 03 that is my requirement... the user will not enter version number that is greyed out ....
Please help how to modify extract and modify...
09-10-2014 11:06 AM
Hi Srilakshmi,
For this requirement, use the events of tables, please go through the below link,
http://wiki.scn.sap.com/wiki/display/ABAPch/EVENTS+IN+TABLE+MAINTENANCE
After select the event 05, write the below code,
IF TABLENAME-NO = '1001'.
TABLENAME-VERSION = '03'.
ELSE.
TABLENAME-VERSION = '01'.
ENDIF.
Regards,
John.
09-10-2014 11:38 AM
Hi John,
Suppose if they want to maintain version for 100 time we can't write if statements 100 times right...
We should use Extract and modify tables...
I do not know how to use extract and modify statements....