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: 

Table maintanance generator problem before saving(Event 01)

Former Member
0 Kudos

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.

5 REPLIES 5

former_member191761
Active Participant
0 Kudos

Hi Srinath,

Field 2 should also be a primary key. Please let me know if this helps.

Thanks

Sri

aarif_baig
Active Participant
0 Kudos

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.

Former Member
0 Kudos

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...

0 Kudos

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.

0 Kudos

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....