03-15-2011 11:29 AM
tables : zbomtable.
types : begin of ty_bom,
reinr type zbomtable-zreinr,
slno type slno,
materialdesc type zbomtable-materialdesc,
plant type zbomtable-plant,
itemno type zbomtable-itemno,
end of ty_bom.
data : it_bom type standard table of ty_bom.
data : wa_bom type ty_bom.
wa_bom-reinr = p_reinr.
wa_bom-slno = p_slno.
wa_bom-materialdesc = p_materialdesc.
wa_bom-plant = p_plant1.
wa_bom-itemno = p_itemno.
append wa_bom to it_bom.
insert bomtable from table it_bom.
append it_bom to bomstructure.
endfunction.
this is logicc i have used and its not working to update the table from external sources
i need correct and if any one know correct one please reply to this postt
regards prabhanjan
03-15-2011 11:35 AM
Remove below line:
insert bomtable from table it_bom.
append it_bom to bomstructure.
Add below line:
Modify zbomtable from table it_bom.
if sy-subrc eq 0.
commit work.
endif.
Edited by: Prasoon Sahay on Mar 15, 2011 5:07 PM
03-15-2011 11:35 AM
Remove below line:
insert bomtable from table it_bom.
append it_bom to bomstructure.
Add below line:
Modify zbomtable from table it_bom.
if sy-subrc eq 0.
commit work.
endif.
Edited by: Prasoon Sahay on Mar 15, 2011 5:07 PM
03-16-2011 4:42 AM
thak you for u r suggestion
but i have small doubt
as i am getting that values in into internal table but
that values are not appedned into strucutre
and tbale has not been updated
as i seen from debugging mode
as i am very new to this abap environment
and oplease help me in this one
regards prabhanjan
03-16-2011 4:44 PM
Hello Prabhanjan,
The code for the function module below has been tested and works. Try copying it into your system. You may have to change some of the import parameter definitions and definition for ty_bom. One thing I noticed with your code is that you are inserting to bomtable and not zbomtable.
Kind Regards,
Rae Ellen Woytowiez
FUNCTION z_bom_add.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(P_REINR) TYPE CHAR01
*" REFERENCE(P_SLNO) TYPE NUM10
*" REFERENCE(P_MATERIALDESC) TYPE MAKTX
*" REFERENCE(P_PLANT) TYPE WERKS_D
*" REFERENCE(P_ITEMNO) TYPE CHAR18
*"----------------------------------------------------------------------
TABLES : zbomtable.
TYPES : BEGIN OF ty_bom,
mandt TYPE mandt,
reinr TYPE char01,
slno TYPE num10,
materialdesc TYPE maktx,
plant TYPE werks_d,
itemno TYPE char18,
END OF ty_bom.
DATA : it_bom TYPE STANDARD TABLE OF ty_bom.
DATA : wa_bom TYPE ty_bom.
wa_bom-mandt = sy-mandt.
wa_bom-reinr = p_reinr.
wa_bom-slno = p_slno.
wa_bom-materialdesc = p_materialdesc.
wa_bom-plant = p_plant.
wa_bom-itemno = p_itemno.
APPEND wa_bom TO it_bom.
MODIFY zbomtable FROM TABLE it_bom.
ENDFUNCTION.
Edited by: Rae Ellen Woytowiez on Mar 16, 2011 5:48 PM
Edited by: Rae Ellen Woytowiez on Mar 16, 2011 6:14 PM
03-17-2011 1:12 PM
thanks wid your answer i have made upation in my programm and now its working correctly
03-17-2011 6:16 AM
Hi,
I am assuming you are trying to add a new line to database table, and to an internal table.
There is no need for the 'type' declarations, as you can use the database table's structure.
This code will do it :
-
data: wa_bom like zbomtable, "work area
lt_bom type standard table of zbomtable. "internal table
populate a new line
clear wa_bom.
wa_bom-reinr = p_reinr.
wa_bom-slno = p_slno.
wa_bom-materialdesc = p_materialdesc.
wa_bom-plant = p_plant1.
wa_bom-itemno = p_itemno.
add the new line to the DB table (or change it if it already exists)
modify zbomtable from wa_bom.
add the new line to the internal table
append wa_bom to lt_bom.
good luck
Paul Bakker
03-17-2011 6:45 AM
Hi Prabhanjan,
Before updating the entry to the data base table, try to select the data read the data table with all the parameters that you are trying to update. Some thing like below.
tables : zbomtable.
types : begin of ty_bom,
reinr type zbomtable-zreinr,
slno type slno,
materialdesc type zbomtable-materialdesc,
plant type zbomtable-plant,
itemno type zbomtable-itemno,
end of ty_bom.
data : it_bom type standard table of ty_bom.
data : wa_bom type ty_bom.
data: it_temp type standard table of zbomtable.
Select all the records into a table
select * from zbomtable into it_temp where reinr = p_reinr and
slno = p_slno and
materialdesc = p_materialdesc and
bom-plant = p_plant1 and
itemno = p_itemno.
wa_bom-reinr = p_reinr.
wa_bom-slno = p_slno.
wa_bom-materialdesc = p_materialdesc.
wa_bom-plant = p_plant1.
wa_bom-itemno = p_itemno.
append wa_bom to it_bom.
***Check if there is no record existing in the data base table with your entries. If yes, insert the record.
This will help us to make sure that there is no duplicate entry is being passed.
if it_temp[ ] is initial.
insert bomtable from table it_bom.
endif.
append it_bom to bomstructure.
endfunction.
Thanks,
Guru