‎2009 Apr 22 5:51 AM
Hi,
I have all datas in my itab.there are multiple mblnr in single date .but in my 'Z' table i am getting one mblnr.why multiple mblnrs are not inserted.
LOOP AT ITAB.
IT_ZTPLSTOCK-MATNR = ITAB-MATNR_I.
IT_ZTPLSTOCK-WERKS = ITAB-WERKS_I.
IT_ZTPLSTOCK-MJAHR = ITAB-MJAHR.
IT_ZTPLSTOCK-BUDAT = ITAB-BUDAT.
IF ITAB-BWART_I = '101'.
IT_ZTPLSTOCK-MENGE1 = ITAB-MENGE_I.
IT_ZTPLSTOCK-MEINS1 = ITAB-MEINS_I.
IT_ZTPLSTOCK-DMBTR1 = ITAB-DMBTR_I.
IT_ZTPLSTOCK-BWART = ITAB-BWART_I.
IT_ZTPLSTOCK-MBLNR = ITAB-MBLNR.
ELSEIF ITAB-BWART_I = '102'.
IT_ZTPLSTOCK-MENGE1 = ITAB-MENGE_I.
IT_ZTPLSTOCK-MEINS1 = ITAB-MEINS_I.
IT_ZTPLSTOCK-DMBTR1 = ITAB-DMBTR_I.
IT_ZTPLSTOCK-BWART = ITAB-BWART_I.
IT_ZTPLSTOCK-MBLNR = ITAB-MBLNR.
ELSEIF ITAB-BWART_I = '201'.
IT_ZTPLSTOCK-MENGE2 = ITAB-MENGE_I.
IT_ZTPLSTOCK-MEINS2 = ITAB-MEINS_I.
IT_ZTPLSTOCK-DMBTR2 = ITAB-DMBTR_I.
IT_ZTPLSTOCK-BWART = ITAB-BWART_I.
IT_ZTPLSTOCK-MBLNR = ITAB-MBLNR.
ELSEIF ITAB-BWART_I = '202'.
IT_ZTPLSTOCK-MENGE2 = ITAB-MENGE_I.
IT_ZTPLSTOCK-MEINS2 = ITAB-MEINS_I.
IT_ZTPLSTOCK-DMBTR2 = ITAB-DMBTR_I.
IT_ZTPLSTOCK-BWART = ITAB-BWART_I.
IT_ZTPLSTOCK-MBLNR = ITAB-MBLNR.
APPEND IT_ZTPLSTOCK.
CLEAR IT_ZTPLSTOCK.
ENDLOOP.
LOOP AT IT_ztplstock.
MOVE-CORRESPONDING IT_ztplstock TO ZTPLSTOCK.
INSERT ZTPLSTOCK.
ENDLOOP.suggest some ideas.
with regards,
Bathri
‎2009 Apr 22 6:03 AM
HI,
Please note that the key in DB table is unique. Hense your key should define a line item uniquely.
Looking at the key fields of your table, I feel it is incomplete.
You can have several documents of same material, plant and date combination.
I think you should add document number i.e MBLNR to the key combination in your Z-Table.
Hope this helps,
RJ
‎2009 Apr 22 5:55 AM
Hi Bathri,
is that you MBLNR is the key field..if so..the INSERT will insert only one MBLNR.
try to do the modify..
like belwo
data IT_ztplstock_final type table of ZTPLSTOCK.
LOOP AT IT_ztplstock.
MOVE-CORRESPONDING IT_ztplstock TO IT_ztplstock_final
MODIFY ZTPLSTOCK from IT_ztplstock_final.
ENDLOOP.it works
Thanks!!
‎2009 Apr 22 5:57 AM
hi,
mblnr is not a key field,key fields are budat,matnr,mjahr and werks.
‎2009 Apr 22 5:55 AM
hi,
it dependce on what are the key fields u r using in u r ztable.check with manually entering the values in u r ztable if it accepting then u r program will wrok .
‎2009 Apr 22 5:56 AM
mblnr is the key field of the table.
Use: Accepting Duplicate keys
LOOP AT IT_ztplstock.
MOVE-CORRESPONDING IT_ztplstock TO ZTPLSTOCK.
INSERT ZTPLSTOCK Accepting Duplicate keys.
ENDLOOP.Regards,
Gurpreet
‎2009 Apr 22 5:56 AM
Dear insted of writting this you could have done this
LOOP AT IT_ztplstock.
MOVE-CORRESPONDING IT_ztplstock TO ZTPLSTOCK.
INSERT ZTPLSTOCK.
ENDLOOP.try to do this
INSERT ZTPLSTOCK FROM TABLE IT_ztplstock.and check your internal table at that time .
rgds ankit
‎2009 Apr 22 5:58 AM
and for creating a composite key you can also do insert serial number so that it would act as a primary key
‎2009 Apr 22 6:03 AM
HI,
Please note that the key in DB table is unique. Hense your key should define a line item uniquely.
Looking at the key fields of your table, I feel it is incomplete.
You can have several documents of same material, plant and date combination.
I think you should add document number i.e MBLNR to the key combination in your Z-Table.
Hope this helps,
RJ
‎2009 Apr 22 6:28 AM
hi,
thanks i put mblnr as key field its working fine.
regards,
Bathri..
‎2009 Apr 22 6:28 AM
LOOP AT IT_ztplstock.
MOVE-CORRESPONDING IT_ztplstock TO ZTPLSTOCK.
INSERT ZTPLSTOCK.
ENDLOOP.
instead of this u can use like the below one
LOOP AT IT_ztplstock.
MOVE-CORRESPONDING IT_ztplstock TO ZTPLSTOCK.
modify ztplstock from it_ztplstock with key mblnr
ENDLOOP.