08-20-2009 1:01 AM
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
08-20-2009 5: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
08-20-2009 1: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.
08-20-2009 4: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
08-20-2009 5: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
08-20-2009 5: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
08-20-2009 9:54 PM
Hello vikred, everybody,
As you suggested I'm doing like this:
data: wa_transptabl type z_transptabl, it_transptabl like standard table of wa_transptabl.
select FLD1 FLD2 FLD3
into table it_transptabl
from R3TABLE
where FLD1 ne ''.
loop at it_interloc into wa_interloc.
wa_interloc-ZINTIND = '0007'.
****************************************************
I want to insert current field into "z_transptabl" transparent table <--- how?
****************************************************
endloop.
Thanks,
Bernardo
08-21-2009 5:35 AM
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.
08-20-2009 6: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>
08-20-2009 6: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>