Application Development 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: 

updating the ztable from import parameters

prabhanjan_reddy
Participant
0 Kudos

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

1 ACCEPTED SOLUTION

prasoon_sahay
Participant
0 Kudos

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

6 REPLIES 6

prasoon_sahay
Participant
0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

thanks wid your answer i have made upation in my programm and now its working correctly

paul_bakker2
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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