Skip to Content
avatar image
Former Member

Update Transparent Tables

Hello,

1) I've created a transparent table

2) Transparent table is loaded by running a SELECT including tables (e.g.: R/3's VTTK, VTPA)

3) Updates must be done on transparent table data, so I need to loop at table, make field updates according some specific criteria

4) A CURSOR fetches data into another structure / CURSOR must be based on transparent table

I would like to know how to complete step n°3), I mean, loop at transparent table, update fields record by record, etc.. Are used table types fine?

Hope you could help. Thanks!

Bernardo

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

6 Answers

  • Best Answer
    Aug 20, 2009 at 04:50 AM

    Hi,

    you dont have to loop at the transperant table. Instead loop at the internal table. Just use the UPDATE and SET statement to update the database table with conditions.

    
    " After the select statement and when  the internal table is filled
    
    loop at itab.
    UPDATE ZTABLE SET field1 = itab-field1 
    where field2 = 'ABC'.                   " Any condition based on which the table has to be updated
    endloop.
    
    

    Regards,

    Vik

    Add comment
    10|10000 characters needed characters exceeded

    • Bernardo,

      Assuming FLD1, FLD2 & FLD3 are the keys of the transparent table z_transptabl, try it like this:

      loop at it_interloc into wa_interloc.
       wa_interloc-ZINTIND = '0007'.
       update z_transptabl 
            set ZINTIND = wa_interloc-ZINTIND
            where FLD1  = wa_interloc-FLD1
            and   FLD2  = wa_interloc-FLD2
            and   FLD3  = wa_interloc-FLD3.
       if sy-subrc ne 0.
      * your error handling goes here...
       endif.
      endloop.

      Hope this helps.

      Cheers,

      Sougata.

  • Aug 20, 2009 at 12:54 AM

    You can't loop through the transparent table data.

    Data needs to be extracted into an internal table.

    Then update the internal table.

    Finally MODIFY or UPDATE the transparent table using internal table.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 20, 2009 at 03:49 AM

    hi,

    Tampering with standard sap tables,

    it not at all advisable.

    The data in this table comes from transactions,

    and these transactions validate the data,

    only after that it dumps the business data in such tables.

    This is the reason why VTTK, VTPA table does not

    have table maintenance, and sap has not

    provided any maintenance for it.

    For such requirements,

    one way is to create a Z program,

    which has a selection screen

    asking for the primary key selection

    (Inspection Lot Number in your case)

    Then after that, using SQL, it updates

    the field of that row.

    Still such things are not advisable.

    Its necessasry to have the confirmation

    and signature of functional consultant,

    which touching standard sap tables.

    -Thanks & Regards

    Saurabh Goel

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 20, 2009 at 04:49 AM

    we do not loop in transparent tables.

    fetch them to a internal table. use select for this.

    and then loop at this internal table and modify the internal table as needed.

    then modify the transparent table from this internal table.

    MODIFY ztest FROM TABLE gt_test.

    here ztest is transparent table and gt_test is internal table

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 20, 2009 at 05:36 AM

    Hi,

    how can u loop the sap transparent table?

    u cant , u should fetch the dat afrom transaparent table to a internal table , then loop the internal table and then get the required data in the internal table and then modify the sap transapranet table from the internal table.

    still modifying the trnsparent table is not advisable programatically,as it keeps the data from the transaction.

    u decide what is the requirement exactly , and wht u want to do>

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 20, 2009 at 05:39 AM

    Hi,

    how can u loop the sap transparent table?

    u cant , u should fetch the dat afrom transaparent table to a internal table , then loop the internal table and then get the required data in the internal table and then modify the sap transapranet table from the internal table.

    still modifying the trnsparent table is not advisable programatically,as it keeps the data from the transaction.

    u decide what is the requirement exactly , and wht u want to do>

    Add comment
    10|10000 characters needed characters exceeded