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: 

how to compare matnr based on '*' how tocalculate subtotals via coding

0 Kudos

hi gurus.,

My requirement is i hv to group all sub-partnumbers in one single part number ..

for Example: BHRM2960 (8 chars) is my main Part number

for this Sub-part numbers come like this ..

BHRM2960-010

BHRM2960-020

BHRM2960-030

.. i want to group all the sub-partnumbers under main part number ..

i.e., like this 'BHRM2960*' .. how can i achieve this ..also i have to calculate total of all the sub-part numbers based on header part number through code .. how can i achieve this.. plz help me ..its urgent ..

Thanks in advance

8 REPLIES 8

Former Member
0 Kudos

for example your internal table contains fields like...........

main, sub, amount, maintot, subtot................

sort itab by main sub.

loop at itab.

  • to calculate main total...............

at end of main.

sum.

itab-maintot = amount.

endat.

  • to calculate sub total..............

at end of sub.

sum.

itab-sudtot = amount.

endat.

endloop.

reward if useful..................

Former Member
0 Kudos

Hi,

use function module

data : it_stb2    like stpox occurs 0 with header line,
       it_spma2x like it_spma2 occurs 0 with header line,
       it_matcat  like cscmat occurs 0 with header line,

call function 'CS_BOM_EXPL_MAT_V2'
    exporting
      capid                 = 'PP01'
      datuv                 = sy-datum
      mktls                 = 'X'
      mehrs                 = 'X'
      mmory                 = '1'
      mtnrv                 = it_spma2-matnr
      werks                 = werks
    tables
      stb                   = it_stb2
      matcat                = it_matcat
    exceptions
      alt_not_found         = 1
      call_invalid          = 2
      material_not_found    = 3
      missing_authorization = 4
      no_bom_found          = 5
      no_plant_data         = 6
      no_suitable_bom_found = 7
      others                = 8.

Regards,

V.Balaji

Reward if Usefull...

0 Kudos

hi Gurus.,

my requirement not yet reached.. first i hv to group all sub-part numbers under their respective Part number Group ...Then i hv to sum up based on Part number .. how can i achieve this... its urgent...

0 Kudos

ex:

data: begin of itab occurs 0,

main

sub

end of itab.

data: begin of itab1 occurs 0,

main

sub type string,

subtot type i,

end of itab1.

sort itab by main.

loop at itab.

concatenate itab1-sub itab-sub

into itab1-sub

separated by '*'.

itab1-subtot = itab1-subtot + 1.

at end of main.

move: itab-main to itab1-main.

append itab1.

clear itab1.

endat.

endloop.

Former Member
0 Kudos

Hi ,

If you are using ,ALV grid or List display function module then then it will be very easy for you to do these type of requirement.

In function module 'REUSE_ALV_GRID/LIST_DISPLAY' , you have to fill some parameters and you can avail the facility of sorting fields , subtotals and grouping etc.

Former Member
0 Kudos

Hi,

Look at the transaction 'CS12'. You will get a solution from this.

Thanks and Regards,

Suman

asik_shameem
Active Contributor
0 Kudos

Hi,

loop the sub-partner table with condition WHERE number CP 'BHRM2960*'.

LOOP AT it_sub WHERE partn CP 'BHRM2960*'.
  ....

ENDLOOP.

0 Kudos

i requirement reached