TYPES: BEGIN OF ty_header,
matnr TYPE vbeln,
matkl TYPE kunag,
werks TYPE werks_d,
stlal type stalt,
stktx TYPE stktx,
bmeng type basmn,
bmein type basme,
datuv type datuv,
andat type andat,
annam type annam,
aedat type aedat,
aenam type aenam,
END OF ty_header.
TYPES: BEGIN OF ty_item,
posnr TYPE sposn,
postp TYPE postp,
idnrk TYPE idnrk,
menge TYPE kmpmg,
meins type kmpme,
potx1 type potx1,
potx2 type potx2,
sanin type sanin,
erskz type erskz,
END OF ty_item.
DATA: w_header TYPE ty_header.
DATA: t_header TYPE STANDARD TABLE OF ty_header.
DATA: w_item TYPE ty_item.
DATA: t_item TYPE STANDARD TABLE OF ty_item.
DATA : gs_top like cstmat.
DATA : gt_stb like table of stpox.
DATA : gv_matnr type matnr,
gv_werks type werks_d.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
Select-options : s_matnr for gv_matnr,
s_werks for gv_werks.
Parameters : p_stlal type stlal default ='1',
p_stlan type stlan default = '4'.
SELECTION-SCREEN BEGIN OF BLOCK B1.
START-OF-SELECTION.
Loop at s_matnr.
PERFORM Validation tables i_stpov
using s_matnr-low
s_werks-low.
Endloop.
PERFORM build_fieldcat.
PERFORM display_alv.
Form Validation tables itab
using matnr
werks.
call function 'CS_WHERE_USED_MAT'
exporting
datub = sy-datum
datuv = sy-datum
matnr = matnr
postp = ' '
stlan = ' '
werks = werks
stltp = ' '
importing
topmat = selpool "Not Currently Used
tables
wultb = itab
* equicat = eqpcat "Not Currently Used
* kndcat = kndcat "Not Currently Used
* matcat = matcat "Not Currently Used
* stdcat = stdcat "Not Currently Used
* tplcat = tplcat "Not Currently Used
* prjcat = prjcat "Not Currently Used
exceptions
material_not_found = 02.
If ne 02.
PERFORM get_data using s_matnr-low.
Endif.
Endform.
Form get_data using matnr.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
AUMNG = 'X'
CAPID = 'PP01'
CUOBJ = 000000000000000
DATUV = sy-datum
EMENG = '2.000'
MBWLS = 'X'
MKTLS = 'X'
MEHRS = 'X'
MMORY = 1
MTNRV = matnr
STLAL = 1
STLAN = 1
STPST = 0
SVWVO = 'X'
WERKS = '5501'
VRSVO = 'X'
IMPORTING
TOPMAT = gs_top
DSTST =
TABLES
stb = gt_stb
* MATCAT = gt_matca
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
CONVERSION_ERROR = 8
OTHERS = 9
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
MOVE CORRESPONDING gs_top to t_header.
MOVE CORRESPONDING gt_stb to t_item.
Endform.
FORM build_fieldcat .
w_keyinfo-header01 = 'VBELN'.
w_keyinfo-item01 = 'VBELN'.
*&---------------------------------------------------------------------*
w_fcat-col_pos = 1.
w_fcat-fieldname = 'MATNR'.
w_fcat-seltext_m = 'Material Number'.
w_fcat-tabname = 'W_header'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 1.
w_fcat-fieldname = 'MATKL'.
w_fcat-seltext_m = 'Material Group'.
w_fcat-tabname = 'W_header'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 1.
w_fcat-fieldname = 'WERKS'.
w_fcat-seltext_m = 'Plant'.
w_fcat-tabname = 'W_header'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 1.
w_fcat-fieldname = 'STLAL'.
w_fcat-seltext_m = 'Alternative BOM'.
w_fcat-tabname = 'W_header'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 1.
w_fcat-fieldname = 'BMENG'.
w_fcat-seltext_m = 'Base quantity'.
w_fcat-tabname = 'W_header'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 1.
w_fcat-fieldname = 'DATUV'.
w_fcat-seltext_m = 'Valid from date'.
w_fcat-tabname = 'W_header'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 1.
w_fcat-fieldname = 'ANDAT'.
w_fcat-seltext_m = 'Created on'.
w_fcat-tabname = 'W_header'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 1.
w_fcat-fieldname = 'ANNAM'.
w_fcat-seltext_m = 'Created by'.
w_fcat-tabname = 'W_header'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 1.
w_fcat-fieldname = 'AEDAT'.
w_fcat-seltext_m = 'Changed on'.
w_fcat-tabname = 'W_header'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 1.
w_fcat-fieldname = 'AENAM'.
w_fcat-seltext_m = 'Changed by'.
w_fcat-tabname = 'W_header'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 2.
w_fcat-fieldname = 'POSTP'.
w_fcat-seltext_m = 'Item Category (Bill of Material)'.
w_fcat-tabname = 'w_item'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 3.
w_fcat-fieldname = 'IDNRK'.
w_fcat-seltext_m = 'BOM component'.
w_fcat-tabname = 'w_item'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 4.
w_fcat-fieldname = 'MENGE'.
w_fcat-seltext_l = 'Component quantity'.
w_fcat-tabname = 'w_item'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 5.
w_fcat-fieldname = 'MEINS'.
w_fcat-seltext_m = 'Component unit of measure'.
w_fcat-tabname = 'w_item'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 6.
w_fcat-fieldname = 'POTX1'.
w_fcat-seltext_m = 'BOM Item Text (Line 1)'.
w_fcat-tabname = 'w_item'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 7.
w_fcat-fieldname = 'POTX2'.
w_fcat-seltext_m = 'BOM item text (line 2)'.
w_fcat-tabname = 'w_item'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 8.
w_fcat-fieldname = 'SANIN'.
w_fcat-seltext_m = 'Indicator: item relevant to plant maintenance'.
w_fcat-tabname = 'w_item'.
APPEND w_fcat TO t_fcat.
w_fcat-col_pos = 9.
w_fcat-fieldname = 'ERSKZ'.
w_fcat-seltext_m = 'Indicator: spare part'.
w_fcat-tabname = 'w_item'.
APPEND w_fcat TO t_fcat.
ENDFORM. " BUILD_FIELDCAT
FORM display_alv .
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
it_fieldcat = t_fcat
i_tabname_header = c_vbrk
i_tabname_item = c_vbrp
is_keyinfo = w_keyinfo
TABLES
t_outtab_header = t_header
t_outtab_item = t_item.
ENDFORM.
No comments:
Post a Comment