2006 Dec 22 10:31 AM
I want to retrieve data from different sap standard tables
and want to upload to one custom table ,can anybody suggest me
how to do.if possible sample code please.
Is it possible through BAPI if yes kind send one sample
2006 Dec 22 10:33 AM
hi Jyoti,
For that you donot need any BAPI write a report program on your own .. first collect the data from all the tables to a final internal table and use Modify statement to update that data on to your custom table ..
Regards,
Santosh
2006 Dec 22 10:40 AM
simply read data from diff tables based on join in ur internal table and then use tht IT to update ur custom table via 2 methods -
1) use modify if both the custom table and ur IT has same structure
2) else do a loop at ut Inernal table and then use
keyword Update.
no need of BAPi..
reward if helpfull
Message was edited by:
siddhi daftary
2006 Dec 22 10:39 AM
simply read data from diff tables based on join in ur internal table and then use tht IT to update ur custom table via 2 methods -
1) use modify if both the custom table and ur IT has same structure
2) else do a loop at ut Inernal table and then use
keyword Update.
no need of BAPi..
reward if helpfull
Message was edited by:
siddhi daftary
2006 Dec 22 10:53 AM
Try this,
REPORT zkb_test3.
DATA: i_scarr TYPE TABLE OF scarr,
w_scarr TYPE scarr,
i_spfli TYPE TABLE OF spfli,
w_spfli TYPE spfli.
TYPES: BEGIN OF t_custom_table,
carrid TYPE spfli-carrid,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
countryfr TYPE spfli-countryfr,
cityfrom TYPE spfli-cityfrom,
airpfrom TYPE spfli-airpfrom,
countryto TYPE spfli-countryto,
cityto TYPE spfli-cityto,
airpto TYPE spfli-airpto,
END OF t_custom_table.
DATA: i_cust_tab TYPE TABLE OF t_custom_table,
w_cust_tab TYPE t_custom_table.
START-OF-SELECTION.
SELECT * FROM scarr
INTO TABLE i_scarr
UP TO 5 ROWS.
SELECT * FROM spfli INTO TABLE i_spfli
FOR ALL ENTRIES IN i_scarr
WHERE carrid = i_scarr-carrid.
SORT i_scarr BY carrid ASCENDING.
SORT i_spfli BY carrid ASCENDING.
CLEAR: w_spfli, w_scarr, w_cust_tab.
LOOP AT i_spfli INTO w_spfli.
IF w_spfli-carrid NE w_scarr-carrid.
READ TABLE i_scarr INTO w_scarr
WITH KEY carrid = w_spfli-carrid.
ENDIF.
w_cust_tab-carrid = w_spfli-carrid.
w_cust_tab-carrname = w_scarr-carrname.
w_cust_tab-connid = w_spfli-connid.
w_cust_tab-countryfr = w_spfli-countryfr.
w_cust_tab-cityfrom = w_spfli-cityfrom.
w_cust_tab-airpfrom = w_spfli-airpfrom.
w_cust_tab-countryto = w_spfli-countryto.
w_cust_tab-cityto = w_spfli-cityto.
w_cust_tab-airpto = w_spfli-airpto.
APPEND w_cust_tab TO i_cust_tab.
ENDLOOP.
IF NOT i_cust_tab IS INITIAL.
* Insert / Upadte i_cust_tab to <database table>
* Note the <database table> must be same as i_cust_tab
ENDIF.
Regards
Kathirvel
2006 Dec 22 11:59 AM
1) <b>create a view for the the fields that you have in custom table and specify the join condition.</b>
suppose if u want field1 from table 1 and field2 from table2.
then create view with fields f1 and f2 and specify the join condition.
(even u can do the above as:- select f1 of t1 with one select , f2 of t2 with second select ; and then add these two fields to internal table.)
if u create view then only one select is required and hence performance is improved
2)<b> select data from view into ur internal table.</b>
3)<b> update the custom table from ur internal table</b>