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: 

Delete is not working Properly

Former Member
0 Kudos

Dear All,

I have created a z-report by copying MB51. and added material group (mara-matkl). but its not working. I have a final table 'list'. and i have another internal table it_mara. so in it_mara i have 7 entries as per material group. I need to delete entries of matnr from 'list' (final internal table) where material number is matching with it_mara table.

Kindly Advice.

Thanks and Regards

Jai

15 REPLIES 15

former_member186746
Active Contributor
0 Kudos

Hi,

What was the reason for copying it?

You did check the online documentation of MB51 and scrolled down to the example explaing what to do when you want to add an extra field?

Kind regards, Rob Dielemans

0 Kudos

Hi Rob,

Actually that was our requirement to create MB51 for general items.so that we can prevent some users to use MB51 directly.

Thanks and Regards

Jai

0 Kudos

Hi,

Loop at it_mara table and delete from final table where matnr = ls_mara-matnr.

That should do it.. If the requirement is something different, please elaborate on the issue.

Ninad

0 Kudos

Hi Mr. joshi,

I have already tried the same but its not working.

I am having it_mara as below.

So, I need to delete entries of ''list''(Final Internal Table) where these material number are not existing.

I need to show the data for these material number only.

Thanks and Reagrds

Jai

0 Kudos

Hi,

Can you post your code of the loop?

Ninad

0 Kudos

Since the matnr field of IT_MARA table has leading 0's, the matnr field of final table should also have leading 0's. otherwise the delete statement may fail.

please check using debugger.

Ninad

Former Member
0 Kudos

Use this.

loop at it_mara into wa_mara.

delete i_list where matnr = wa_mara-matnr.

endloop.

Regards,

Saddam.

0 Kudos

Hi Saddam,

I have already tried this.

But its not working.

Thanks and Regards

Jai

0 Kudos

Hi Jayaprakash,

Can you share the content of i_list and check if MATNR is having leading zeroes in i_list.

Thanks

0 Kudos

Hi,

This is the code that i have written.

LOOP AT it_mara INTO wa_mara.

       READ TABLE it_mara INTO wa_mara WITH KEY matnr = list-matnr BINARY SEARCH.

*    If sy-subrc = 0.

       list-matkl = wa_mara-matkl.

       DELETE list WHERE matnr NE wa_mara-matnr.

       ENDLOOP.


Thanks and Reagrds

Jai

0 Kudos

Hi Jai,

This wont work.

Try the below code

loop at list into ls_list.

  read table it_mara transporting no fields with key matnr = list-matnr.

  if sy-subrc NE 0.

    delete list from ls_list.

  endif.

endloop.

0 Kudos

Hi Mr. Joshi,

Actually "list" is a structure, so this is not working as well.

Thanks and Regards

Jai

0 Kudos

Hi,

This is the declaration part.

DATA: BEGIN OF list OCCURS 0.

         INCLUDE STRUCTURE itab.

DATA: maktx LIKE makt-maktx,

* MAA EhP4 -Start ------------------------------------------"MAA EhP4

*     the fields for the multi account assignment           "MAA EhP4

       ekkn_zekkn             TYPE  dzekkn,                  "MAA EhP4

       ekpo_meins             TYPE  ekpo-meins,              "MAA EhP4

       pstyp                  TYPE  ekpo-pstyp,              "MAA2

       knttp                  TYPE  knttp,                   "MAA EhP4

       vrtkz                  TYPE  ekpo-vrtkz,              "MAA EhP4

       twrkz                  TYPE  ekpo-twrkz,              "MAA EhP4

       ekpo_weunb             TYPE  ekpo-weunb,              "MAA EhP4

       mb51_share             TYPE  ekbe_ma-share_f,         "MAA EhP4

       mb51_share_menge       TYPE  mb51_share_menge,        "MAA EhP4

       mb51_share_bpmng       TYPE  mb51_share_bpmng,        "MAA EhP4

       mb51_share_dmbtr       TYPE  mb51_share_dmbtr,        "MAA EhP4

* MAA EhP4 -End --------------------------------------------"MAA EhP4

       name1 LIKE t001w-name1,

       btext LIKE t156t-btext,

       pspid LIKE prps-posid,

       vornr TYPE vornr,                                     "215929

       color_line(03)       TYPE c,                          "n555

       color TYPE slis_t_specialcol_alv,

       longnum TYPE /sappspro/longnum.

DATA: END OF list.


TYPES : stype_list_maa       LIKE  LINE OF list,

         stab_list_maa        TYPE  STANDARD TABLE OF stype_list_maa.


Thanks and Regards

Jai

0 Kudos

Hi,

'occours 0' indicates that list is an internal table with a header line,

raymond_giuseppi
Active Contributor
0 Kudos

Use the standard report,

  • Implicit enhancement in LINE structure (look for ENHANCEMENT 1  MGV_LAMA_RM07DOCS, eg. g add MARA_MATKL to LIST)
  • Enhancement Spot ES_RM07DOCS,
    • RM07DOCS_04 Initialization (fill your mara itab ?)
    • RM07DOCS_07 Add fields to ALV (e.g. perform bu_fc using 'LIST' 'MARA_MATKL' 'MARA' 'MATKL' c_no_out.))
    • RM07DOCS_06 Update your own fields in LINE during LOOP AT ITAB, there you could also delete some records

(Of course if you actually want a copy of standard, and expect to have left before next update, you can change the code at the same location)

Regards,

Raymond