Application Development and Automation 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: 
Read only

Saving the data in database at TMG level.?

Former Member
0 Likes
2,189

HI All,

I have requirement to create the entries and maintain at TMG level.

I have used to TMG event 05(Create new entry) to create new entry.

And i used TMG event 01(Before save to the database) to update the changes to database for existing entries.

Here i am facing with issue that data is not updating to the database. when i modify the existing the entries.

Please find below code i have written for the populating Profit center description and cost center description when user click on save button for the corresponding profit center and Cost center respectively.

Please help me if any of action i was missed in below code?

DATA : l_ktext       TYPE ktext,                                     " Profit center description
          l_kostl_ktext TYPE ktext,                                     " Cost center description
          l_index       TYPE sy-tabix.                                  " Record number
   break ibm_shga.
* Loop the internal table TOTAL to get the Changed records
   LOOP AT total.
     IF <action> = 'U'.                                                 " Action = 'U'
       CLEAR zps_av.
       MOVE total TO zps_av.
       READ TABLE extract WITH KEY total.
       IF sy-subrc EQ 0.
         l_index = sy-tabix.
       ELSE.
         CLEAR l_index.
       ENDIF.
*     Get the Profit center description
       SELECT ltext                                                     " Get the Profit center description
              FROM cepct
              INTO l_ktext UP TO 1 ROWS
              WHERE prctr = zps_av-prctr
               AND  spras = sy-langu.
       ENDSELECT.
       IF sy-subrc EQ 0.
         zps_av-prctr_desc = l_ktext.
       ENDIF.
*     Get the Cost center description
       SELECT ktext                                                     " Cost center description
              FROM cskt
              INTO l_kostl_ktext UP TO 1 ROWS
              WHERE kostl = zps_av-kostl
                AND spras = sy-langu.
         IF sy-subrc EQ 0.
           zps_av-kostl_desc = l_kostl_ktext.
         ENDIF.
       ENDSELECT.
       MOVE zps_av TO total.
       MODIFY total.
       CHECK l_index GT 0.
       extract = total.
       MODIFY extract INDEX l_index.
     ENDIF.
   ENDLOOP.
   sy-subrc = 0.
ENDFORM.                                                               "POPULATE_DESC

HI All,

I have requirement to create the entries and maintain at TMG level.

I have used to TMG event 05(Create new entry) to create new entry.

And i used TMG event 01(Before save to the database) to update the changes to database for existing entries.

Here i am facing with issue that data is not updating to the database. when i modify the existing the entries.

Please find below code i have written for the populating Profit center description and cost center description when user click on save button for the corresponding profit center and Cost center respectively.

Please help me if any of action i was missed in below code?

DATA : l_ktext       TYPE ktext,                                     " Profit center description
          l_kostl_ktext TYPE ktext,                                     " Cost center description
          l_index       TYPE sy-tabix.                                  " Record number
   break ibm_shga.
* Loop the internal table TOTAL to get the Changed records
   LOOP AT total.
     IF <action> = 'U'.                                                 " Action = 'U'
       CLEAR zps_av.
       MOVE total TO zps_av.
       READ TABLE extract WITH KEY total.
       IF sy-subrc EQ 0.
         l_index = sy-tabix.
       ELSE.
         CLEAR l_index.
       ENDIF.
*     Get the Profit center description
       SELECT ltext                                                     " Get the Profit center description
              FROM cepct
              INTO l_ktext UP TO 1 ROWS
              WHERE prctr = zps_av-prctr
               AND  spras = sy-langu.
       ENDSELECT.
       IF sy-subrc EQ 0.
         zps_av-prctr_desc = l_ktext.
       ENDIF.
*     Get the Cost center description
       SELECT ktext                                                     " Cost center description
              FROM cskt
              INTO l_kostl_ktext UP TO 1 ROWS
              WHERE kostl = zps_av-kostl
                AND spras = sy-langu.
         IF sy-subrc EQ 0.
           zps_av-kostl_desc = l_kostl_ktext.
         ENDIF.
       ENDSELECT.
       MOVE zps_av TO total.
       MODIFY total.
       CHECK l_index GT 0.
       extract = total.
       MODIFY extract INDEX l_index.
     ENDIF.
   ENDLOOP.
   sy-subrc = 0.
ENDFORM.                                                               "POPULATE_DESC

4 REPLIES 4
Read only

former_member226419
Contributor
0 Likes
1,237

Hi Siva,

I am not getting the exact Req. Your req is to create the new entries in ztable for MATNR and PRCTR  with the help of TMG events mentioned below and also you want to  modify the existing entries and SAVE the same in ztable. But you are not able to do the same in case of modifying the entries in ztable but able to do in case of creating the new ones.

Have I understood correct?

BR

Sumeet

Read only

0 Likes
1,237

Hi Sumeet,

Thanks for the reply,

Your understand is correct.

I am not able to update the changes to data base to the existing entry using TMG events.

i had used TMG event 01 for the this .

Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,237

Hi Siva

In  order to update the description you have to update EXTRACT internal table then it will refelct.

Try changing EXTRACT table in debugging and check

Nabheet

Read only

0 Likes
1,237


In order to modify records in the maintenance screen of the TMG u have to write on chain request on the field which you are going to change. Then it will modify the record.

  Find the below example code for the same.mentioned fields are going to get changed)

CHAIN.
FIELD <table name>-<field name> .
FIELD <table name>-<field name> .
FIELD <table name>-<field name> .
FIELD <table name>-<field name> .
FIELD <table name>-<field name> .
MODULE <module_name> ON CHAIN-REQUEST.
ENDCHAIN
.

inside the module u can wirte ur code if u want to update any fields.

Message was edited by: Manoj Reddy