Application Development and Automation 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: 
Read only

nedd help BOM Material

Former Member
0 Likes
748

Hi All,

I am checking the BOM material for Material in plant . The material contains the diff level bom item. In my progarm I am taking the leve upto 20. Then the loop executing 20 times even if there is no level. B ut I want know the dynanic where the level is endfor each material ?

Transaction : cs15.

regards,

Aja

Just check the program RCS15001 - this is main program inside of CS15 Transaction.

I am not understanding properly ,but code looks good.

may i know where you are getting issue..

Thanks

Seshu

6 REPLIES 6
Read only

Former Member
0 Likes
715

There is no limitation , BOM will have number of levels

Thanks

Seshu

Read only

0 Likes
715

Hi Seshu,

I am wrting like this .please chekc my code. I am checking the mterial upto 20 levels even though there is no furhger level. If there is no further we need to exit from that mterial.

Here is the code:

FORM GET_MATERIAL_BOM USING P_P_MATNR

P_P_BEGRU.

DATA :LIT_BOM_DATA LIKE IT_BOM_DATA OCCURS 0 WITH HEADER LINE.

DATA :LIT_BOM_DATA2 LIKE IT_BOM_DATA OCCURS 0 WITH HEADER LINE.

W_DATUB = SY-DATUM.

W_DATUV = SY-DATUM.

W_LEV_INIT = 1.

W_LVL = 20.

IF W_LVL GT 0.

CALL FUNCTION 'CS_WHERE_USED_MAT'

EXPORTING

DATUB = W_DATUB

DATUV = W_DATUV

MATNR = P_P_MATNR

WERKS = P_P_BEGRU

  • STLTP = 'M'

TABLES

WULTB = IT_WULTB

EQUICAT = IT_EQUICAT

KNDCAT = IT_KNDCAT

MATCAT = IT_MATCAT

STDCAT = IT_STDCAT

TPLCAT = IT_TPLCAT

EXCEPTIONS

CALL_INVALID = 1

MATERIAL_NOT_FOUND = 2

NO_WHERE_USED_REC_FOUND = 3

NO_WHERE_USED_REC_SELECTED = 4

NO_WHERE_USED_REC_VALID = 5

OTHERS = 6.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT IT_WULTB.

W_COUNTER = SY-TABIX.

W_TABIX = SY-TABIX.

  • level

IT_BOM_DATA-LEL = W_LEV_INIT.

  • Item

IT_BOM_DATA-MATNR = IT_WULTB-MATNR.

APPEND IT_BOM_DATA.

  • clear bom_data.

IT_WULTB-SORT_NO = W_COUNTER.

MODIFY IT_WULTB INDEX W_TABIX.

ENDLOOP.

W_LVL = W_LVL - 1.

DO W_LVL TIMES.

LOOP AT IT_WULTB.

CLEAR IT_WULTB_MID[].

CALL FUNCTION 'CS_WHERE_USED_MAT'

EXPORTING

DATUB = W_DATUB

DATUV = W_DATUV

MATNR = IT_WULTB-MATNR

WERKS = P_P_BEGRU

  • STLTP = 'M'

TABLES

WULTB = IT_WULTB_MID

EQUICAT = IT_EQUICAT

KNDCAT = IT_KNDCAT

MATCAT = IT_MATCAT

STDCAT = IT_STDCAT

TPLCAT = IT_TPLCAT

EXCEPTIONS

CALL_INVALID = 1

MATERIAL_NOT_FOUND = 2

NO_WHERE_USED_REC_FOUND = 3

NO_WHERE_USED_REC_SELECTED = 4

NO_WHERE_USED_REC_VALID = 5

OTHERS = 6.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT IT_WULTB_MID. "#EC CI_NESTED

MOVE-CORRESPONDING IT_WULTB_MID TO IT_W_WULTB.

W_COUNTER = SY-TABIX.

APPEND IT_W_WULTB.

CLEAR IT_W_WULTB.

ENDLOOP.

  • append lines of it_wultb_mid to it_W_WULTB.

REFRESH IT_WULTB_MID.

CLEAR IT_WULTB_MID.

ENDLOOP.

W_LEV_INIT = W_LEV_INIT + 1 .

CLEAR IT_WULTB.

REFRESH IT_WULTB.

LOOP AT IT_W_WULTB.

  • level

IT_BOM_DATA-LEL = W_LEV_INIT.

  • Item

IT_BOM_DATA-MATNR = IT_W_WULTB-MATNR.

APPEND IT_BOM_DATA.

  • Move to midlayer internal table

IT_WULTB = IT_W_WULTB.

APPEND IT_WULTB.

ENDLOOP.

CLEAR IT_W_WULTB.

REFRESH IT_W_WULTB.

CLEAR IT_WULTB_MID[].

ENDDO.

ENDIF.

SORT IT_BOM_DATA DESCENDING BY LEL MATNR.

DELETE ADJACENT DUPLICATES FROM IT_BOM_DATA COMPARING LEL MATNR.

LIT_BOM_DATA[] = IT_BOM_DATA[].

LIT_BOM_DATA2[] = IT_BOM_DATA[].

REFRESH IT_BOM_DATA.

READ TABLE LIT_BOM_DATA2 INDEX 1.

IF SY-SUBRC = 0.

LOOP AT LIT_BOM_DATA WHERE LEL = LIT_BOM_DATA2-LEL.

IT_BOM_DATA = LIT_BOM_DATA.

APPEND IT_BOM_DATA.

CLEAR IT_BOM_DATA.

ENDLOOP.

ENDIF.

CLEAR LIT_BOM_DATA.

REFRESH LIT_BOM_DATA.

CLEAR LIT_BOM_DATA2.

REFRESH LIT_BOM_DATA2.

Please helpe me in this.

regards,

AJay Reddy

Read only

0 Likes
715

Just check the program RCS15001 - this is main program inside of CS15 Transaction.

I am not understanding properly ,but code looks good.

may i know where you are getting issue..

Thanks

Seshu

Read only

0 Likes
715

Hi Seshu,

Every time the material is checking upto 20 levels . I am using 'DO' in that LOOP,

How can i increase the performence for above code. Already I did my analysis . Still it is taking time, Please help me in this performnece issue.

regards,

Ajay reddy

Read only

0 Likes
715

Hello Ajay,

Nice to know that you got the results but still it has performance issue.

only way you can reduce - some of the product may not have 20 levels ,so try to keep the exit command to come out from the do loop

if there are no levels . We are using Standard FM's to get levels ,so we can't decrease the time.

Thanks

Seshu

Read only

0 Likes
715

What's the FM you mentioned that can get the levels of a material BOM?