REPORT bom.
TABLES : vbap, stpo, mast, tc04, makt ,stpox .
TYPE-POOLS: slis.
DATA: fieldcat
TYPE slis_t_fieldcat_alv,
fieldcat_ln LIKE
LINE OF fieldcat,
event_exit
TYPE slis_t_event_exit,
event_exit_ln LIKE
LINE OF event_exit,
sortcat
TYPE slis_t_sortinfo_alv,
sortcat_ln LIKE
LINE OF sortcat,
eventcat
TYPE slis_t_event,
eventcat_ln LIKE
LINE OF eventcat.
DATA: gt_list_top_of_page TYPE slis_t_listheader.
DATA: gc_formname_top_of_page TYPE slis_formname
VALUE ‘ALV_TOP_OF_PAGE’.
DATA : ps_layout TYPE slis_layout_alv.
DATA: bom_itab LIKE
TABLE OF stpox
WITH HEADER
LINE.
*DATA: itab LIKE TABLE OF zst_pp_0001 WITH HEADER LINE.
DATA:BEGIN
OF tp OCCURS
0,
box TYPE char1,
matnr
LIKE mast-matnr,
stlnr LIKE mast-stlnr,
stlal
LIKE mast-stlal,
END
OF tp.
DATA:
BEGIN OF tpidnrk
OCCURS 0,
matnr
LIKE mast-matnr,
stlal LIKE mast-stlal,
END OF tpidnrk.
DATA : BEGIN
OF itab OCCURS
0, “定#一##表(明#)
matnr
LIKE mast-matnr,
matnp LIKE mast-matnr,
stlnr
LIKE mast-stlnr,
maktx LIKE makt-maktx,
maktx2
LIKE makt-maktx,
idnrp LIKE stpo-idnrk,
stlkn
LIKE stpo-stlkn,
idnrk LIKE stpo-idnrk,
menge
LIKE stpo-menge,
meins LIKE stpo-meins,
z_index(
3) TYPE
c,
END
OF itab.
DATA : i_mat
LIKE TABLE
OF tp WITH
HEADER LINE.
DATA : no
TYPE i.
DATA: wa_stlal LIKE mast-stlal.
SELECTION-
SCREEN : BEGIN
OF BLOCK b1
WITH FRAME
TITLE t1.
SELECT-OPTIONS: s_matnr
FOR vbap-matnr MEMORY
ID 4.
PARAMETERS : p_werks LIKE aufk-werks
OBLIGATORY
MEMORY ID
1.
PARAMETERS : p_capid
LIKE tc04-capid DEFAULT
‘PP01’.
SELECTION-SCREEN :
END OF
BLOCK b1.
INITIALIZATION.
t1 =
‘選擇條件’.
START-OF-SELECTION.
SELECT matnr stlnr stlal
FROM mast
INTO (tp-matnr,tp-stlnr,tp-stlal)
WHERE matnr
IN s_matnr
AND werks
EQ p_werks.
APPEND tp.
CLEAR tp.
ENDSELECT.
LOOP AT tp.
PERFORM cs_bom_expl_mat_v2 USING tp-matnr
p_capid
p_werks
tp-stlal.
no = 0.
LOOP AT bom_itab
WHERE stufe = 1.
no = no +
1.
itab-z_index = no.
itab-matnr = tp-matnr.
SELECT SINGLE maktx
INTO itab-maktx
FROM makt
WHERE matnr = tp-matnr.
MOVE-CORRESPONDING bom_itab
TO itab.
tpidnrk-matnr = itab-idnrk.
tpidnrk-stlal = tp-stlal.
SELECT
SINGLE maktx INTO itab-maktx2
FROM makt
WHERE matnr = itab-idnrk.
* AND spras = ‘1’.
* SELECT SINGLE zeinr bismt
* INTO (itab-zeinr,itab-bismt)
* FROM mara
* WHERE matnr = itab-idnrk.
IF itab-matnr+
0(1) <>
‘0’.
itab-matnp = itab-matnr.
ELSEIF itab-matnr+
0(1) =
‘0’.
itab-matnp = itab-matnr+1(
10) .
ENDIF.
itab-idnrp = itab-idnrk.
APPEND itab.
APPEND tpidnrk.
CLEAR tpidnrk.
CLEAR itab.
CLEAR bom_itab.
ENDLOOP.
ENDLOOP.
END-
OF-SELECTION.
LOOP
AT tpidnrk .
SELECT
SINGLE * FROM mast
WHERE matnr EQ tpidnrk-matnr.
IF sy-subrc = 0.
PERFORM cs_bom_expl_mat_v2 USING tpidnrk-matnr
p_capid
p_werks
tpidnrk-stlal.
no = 0.
DELETE tpidnrk.
LOOP
AT bom_itab WHERE stufe =
1.
no =
no + 1.
itab-z_index =
no.
itab-matnr = tpidnrk-matnr.
SELECT
SINGLE maktx INTO itab-maktx
FROM makt
WHERE matnr = tpidnrk-matnr.
MOVE-CORRESPONDING bom_itab TO itab.
tpidnrk-matnr = itab-idnrk.
SELECT SINGLE maktx
INTO itab-maktx2
FROM makt
WHERE matnr = itab-idnrk.
* AND spras = ‘1’.
* SELECT SINGLE zeinr bismt
* INTO (itab-zeinr,itab-bismt)
* FROM mara
* WHERE matnr = itab-idnrk.
IF itab-matnr+0(
1) <> ‘0’.
itab-matnp = itab-matnr.
ELSEIF itab-matnr+0(
1) = ‘0’.
itab-matnp = itab-matnr+
1(10) .
ENDIF.
itab-idnrp = itab-idnrk.
APPEND itab.
APPEND tpidnrk.
CLEAR tpidnrk.
CLEAR itab.
CLEAR bom_itab.
ENDLOOP.
ENDIF.
* APPEND tpidnrk.
ENDLOOP.
REFRESH gt_list_top_of_page[].
PERFORM e04_comment_build .
CLEAR fieldcat.
REFRESH fieldcat.
PERFORM build_fieldcat.
PERFORM build_eventcat.
PERFORM alv_display.
*&——————————————————————–*
*& Form e04_comment_build
*&——————————————————————–*
* text
*———————————————————————*
FORM e04_comment_build.
DATA : list_line
LIKE LINE
OF gt_list_top_of_page.
list_line-typ = ‘H’.
list_line-
key = ”.
list_line-info =
‘物料清單(BOM)明細’.
APPEND list_line
TO gt_list_top_of_page.
CLEAR list_line.
list_line-typ =
‘S’.
list_line-key =
‘工厂’.
list_line-info = p_werks.
APPEND list_line
TO gt_list_top_of_page.
CLEAR list_line.
list_line-typ =
‘H’.
list_line-key =
”.
list_line-info = ”.
APPEND list_line TO gt_list_top_of_page.
ENDFORM. ” e04_comment_build
*&——————————————————————–*
*& Form build_eventcat
*&——————————————————————–*
* text
*———————————————————————*
FORM build_eventcat.
DATA : ls_event TYPE slis_alv_event.
CALL FUNCTION
‘REUSE_ALV_EVENTS_GET’
EXPORTING
i_list_type =
0
IMPORTING
et_events = eventcat.
READ TABLE eventcat
WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc =
0.
MOVE gc_formname_top_of_page
TO ls_event-form.
APPEND ls_event TO eventcat.
ENDIF.
ENDFORM.
” build_eventcat
*&—————————————————-
*& Form alv_display
* text
*—————————————————–
* –〉 p1 text
* 〈 — p2 text
*—————————————————–
FORM alv_display.
CALL
FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = ‘ZWT_PP05’
* I_CALLBACK_USER_COMMAND = ‘COMMAND_EXECUTE’
is_layout = ps_layout
it_fieldcat = fieldcat
i_save = ‘A’
it_events = eventcat
TABLES
t_outtab = itab
EXCEPTIONS
program_error =
1
OTHERS =
2.
ENDFORM.
” alv_display
*&——————————————————————–*
*& Form alv_top_of_page
*&——————————————————————–*
* text
*———————————————————————*
FORM alv_top_of_page.
CALL
FUNCTION ‘REUSE_ALV_COMMENTARY_WRITE’
EXPORTING
it_list_commentary = gt_list_top_of_page.
ENDFORM.
“alv_top_of_page
*—————————————————–
* FORM build_fieldcat
*—————————————————–
* ……..
*—————————————————–
FORM build_fieldcat.
DATA : col_pos
TYPE i
VALUE 0.
ps_layout-get_selinfos =
‘X’.
ps_layout-colwidth_optimize = ‘X’.
ps_layout-detail_popup =
‘X’.
*PS_LAYOUT-BOX_FIELDNAME = ‘FLAG’.
ps_layout-no_keyfix =
”.
*PS_LAYOUT-KEY_HOTSPOT = ‘X’.
ps_layout-colwidth_optimize =
‘X’.
ADD
1 TO col_pos.
* fieldcat_ln-ref_tabname = ‘ITAB8’.
fieldcat_ln-tabname = ‘ITAB’.
fieldcat_ln-ref_fieldname =
‘Z_INDEX’.
fieldcat_ln-fieldname = ‘Z_INDEX’.
fieldcat_ln-
key = ‘X’.
fieldcat_ln-seltext_s =
‘序號’.
fieldcat_ln-seltext_l = ‘序號’.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic =
‘序號’.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln
TO fieldcat.
CLEAR fieldcat_ln.
ADD 1
TO col_pos.
* fieldcat_ln-ref_tabname = ‘ITAB8’.
fieldcat_ln-tabname =
‘ITAB’.
fieldcat_ln-ref_fieldname = ‘MATNR’.
fieldcat_ln-fieldname =
‘MATNR’.
fieldcat_ln-key =
‘X’.
fieldcat_ln-seltext_s = ‘產品編號’.
fieldcat_ln-seltext_l =
‘產品編號’.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic = ‘產品編號’.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln TO fieldcat.
CLEAR fieldcat_ln.
ADD
1 TO col_pos.
* fieldcat_ln-ref_tabname = ‘ITAB8’.
fieldcat_ln-tabname = ‘ITAB’.
fieldcat_ln-ref_fieldname =
‘MAKTX’.
fieldcat_ln-fieldname = ‘MAKTX’.
fieldcat_ln-
key = ‘X’.
fieldcat_ln-seltext_s =
‘產品描述’.
fieldcat_ln-seltext_l = ‘產品描述’.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic =
‘產品描述’.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln
TO fieldcat.
CLEAR fieldcat_ln.
ADD 1
TO col_pos.
* fieldcat_ln-ref_tabname = ‘ITAB8’.
fieldcat_ln-tabname =
‘ITAB’.
fieldcat_ln-ref_fieldname = ‘IDNRP’.
fieldcat_ln-fieldname =
‘IDNRP’.
fieldcat_ln-key =
‘X’.
fieldcat_ln-seltext_s = ‘BOM物料編號’.
fieldcat_ln-seltext_l =
‘BOM物料編號’.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic = ‘BOM物料編號’.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln TO fieldcat.
CLEAR fieldcat_ln.
ADD
1 TO col_pos.
* fieldcat_ln-ref_tabname = ‘ITAB8’.
fieldcat_ln-tabname = ‘ITAB’.
fieldcat_ln-ref_fieldname =
‘MAKTX2’.
fieldcat_ln-fieldname = ‘MAKTX2’.
fieldcat_ln-
key = ‘X’.
fieldcat_ln-seltext_s =
‘BOM物料描述’.
fieldcat_ln-seltext_l = ‘BOM物料描述’.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic =
‘BOM物料描述’.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln
TO fieldcat.
CLEAR fieldcat_ln.
ADD 1
TO col_pos.
* fieldcat_ln-ref_tabname = ‘ITAB8’.
fieldcat_ln-tabname =
‘ITAB’.
fieldcat_ln-ref_fieldname = ‘MEINS’.
fieldcat_ln-fieldname =
‘MEINS’.
fieldcat_ln-key =
‘X’.
fieldcat_ln-seltext_s = ‘單位’.
fieldcat_ln-seltext_l =
‘單位’.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic = ‘單位’.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln TO fieldcat.
CLEAR fieldcat_ln.
ADD
1 TO col_pos.
* fieldcat_ln-ref_tabname = ‘ITAB8’.
fieldcat_ln-tabname = ‘ITAB’.
fieldcat_ln-ref_fieldname =
‘MENGE’.
fieldcat_ln-fieldname = ‘MENGE’.
fieldcat_ln-
key = ‘X’.
fieldcat_ln-seltext_s =
‘數量’.
fieldcat_ln-seltext_l = ‘數量’.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic =
‘數量’.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln
TO fieldcat.
CLEAR fieldcat_ln.
ENDFORM. “build_fieldcat
*—————————————————–
* FORM BUILD_FIELDCAT_SUB
*—————————————————–
* ……..
*—————————————————–
* –〉 VALUE(P_COL_POS)
* –〉 VALUE(P_FIELDNAME)
* –〉 VALUE(P_SELTEXT)
*—————————————————–
FORM build_fieldcat_sub
USING value(p_col_pos)
value(p_fieldname)
value(p_seltext).
* ADD 1 TO COL_POS.
* fieldcat_ln-ref_tabname = ‘ZST_PP_0001’.
fieldcat_ln-tabname =
‘ITAB’.
fieldcat_ln-ref_fieldname = p_fieldname.
fieldcat_ln-fieldname = p_fieldname.
* FIELDCAT_LN-KEY = ‘X’.
fieldcat_ln-seltext_s = p_seltext.
fieldcat_ln-seltext_l = p_seltext.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic =
p_seltext.
fieldcat_ln-col_pos = p_col_pos.
APPEND fieldcat_ln TO fieldcat.
CLEAR fieldcat_ln.
ENDFORM.
” BUILD_FIELDCAT_SUB
*—————————————————–
* FORM CS_BOM_EXPL_MAT_V2
* ……..
* –〉 MATNR
* –〉 CAPID
* –〉 WERKS
*—————————————————–
FORM cs_bom_expl_mat_v2 USING matnr
LIKE afpo-matnr
capid LIKE tc04-capid
werks
LIKE ekpo-werks
stlal LIKE mast-stlal.
CALL FUNCTION
‘CS_BOM_EXPL_MAT_V2’
EXPORTING
aumng =
0
capid = capid
datuv = sy-datum
mehrs = ‘X’
mtnrv = matnr
stlal = stlal
stlan =
‘1’
werks = werks
TABLES
stb = bom_itab
* 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
conversion_error = 8
OTHERS = 9
.
ENDFORM. “CS_BOM_EXPL_MAT_V2 .
TABLES : vbap, stpo, mast, tc04, makt ,stpox .
TYPE-POOLS: slis.
DATA: fieldcat
TYPE slis_t_fieldcat_alv,
fieldcat_ln LIKE
LINE OF fieldcat,
event_exit
TYPE slis_t_event_exit,
event_exit_ln LIKE
LINE OF event_exit,
sortcat
TYPE slis_t_sortinfo_alv,
sortcat_ln LIKE
LINE OF sortcat,
eventcat
TYPE slis_t_event,
eventcat_ln LIKE
LINE OF eventcat.
DATA: gt_list_top_of_page TYPE slis_t_listheader.
DATA: gc_formname_top_of_page TYPE slis_formname
VALUE ‘ALV_TOP_OF_PAGE’.
DATA : ps_layout TYPE slis_layout_alv.
DATA: bom_itab LIKE
TABLE OF stpox
WITH HEADER
LINE.
*DATA: itab LIKE TABLE OF zst_pp_0001 WITH HEADER LINE.
DATA:BEGIN
OF tp OCCURS
0,
box TYPE char1,
matnr
LIKE mast-matnr,
stlnr LIKE mast-stlnr,
stlal
LIKE mast-stlal,
END
OF tp.
DATA:
BEGIN OF tpidnrk
OCCURS 0,
matnr
LIKE mast-matnr,
stlal LIKE mast-stlal,
END OF tpidnrk.
DATA : BEGIN
OF itab OCCURS
0, “定#一##表(明#)
matnr
LIKE mast-matnr,
matnp LIKE mast-matnr,
stlnr
LIKE mast-stlnr,
maktx LIKE makt-maktx,
maktx2
LIKE makt-maktx,
idnrp LIKE stpo-idnrk,
stlkn
LIKE stpo-stlkn,
idnrk LIKE stpo-idnrk,
menge
LIKE stpo-menge,
meins LIKE stpo-meins,
z_index(
3) TYPE
c,
END
OF itab.
DATA : i_mat
LIKE TABLE
OF tp WITH
HEADER LINE.
DATA : no
TYPE i.
DATA: wa_stlal LIKE mast-stlal.
SELECTION-
SCREEN : BEGIN
OF BLOCK b1
WITH FRAME
TITLE t1.
SELECT-OPTIONS: s_matnr
FOR vbap-matnr MEMORY
ID 4.
PARAMETERS : p_werks LIKE aufk-werks
OBLIGATORY
MEMORY ID
1.
PARAMETERS : p_capid
LIKE tc04-capid DEFAULT
‘PP01’.
SELECTION-SCREEN :
END OF
BLOCK b1.
INITIALIZATION.
t1 =
‘選擇條件’.
START-OF-SELECTION.
SELECT matnr stlnr stlal
FROM mast
INTO (tp-matnr,tp-stlnr,tp-stlal)
WHERE matnr
IN s_matnr
AND werks
EQ p_werks.
APPEND tp.
CLEAR tp.
ENDSELECT.
LOOP AT tp.
PERFORM cs_bom_expl_mat_v2 USING tp-matnr
p_capid
p_werks
tp-stlal.
no = 0.
LOOP AT bom_itab
WHERE stufe = 1.
no = no +
1.
itab-z_index = no.
itab-matnr = tp-matnr.
SELECT SINGLE maktx
INTO itab-maktx
FROM makt
WHERE matnr = tp-matnr.
MOVE-CORRESPONDING bom_itab
TO itab.
tpidnrk-matnr = itab-idnrk.
tpidnrk-stlal = tp-stlal.
SELECT
SINGLE maktx INTO itab-maktx2
FROM makt
WHERE matnr = itab-idnrk.
* AND spras = ‘1’.
* SELECT SINGLE zeinr bismt
* INTO (itab-zeinr,itab-bismt)
* FROM mara
* WHERE matnr = itab-idnrk.
IF itab-matnr+
0(1) <>
‘0’.
itab-matnp = itab-matnr.
ELSEIF itab-matnr+
0(1) =
‘0’.
itab-matnp = itab-matnr+1(
10) .
ENDIF.
itab-idnrp = itab-idnrk.
APPEND itab.
APPEND tpidnrk.
CLEAR tpidnrk.
CLEAR itab.
CLEAR bom_itab.
ENDLOOP.
ENDLOOP.
END-
OF-SELECTION.
LOOP
AT tpidnrk .
SELECT
SINGLE * FROM mast
WHERE matnr EQ tpidnrk-matnr.
IF sy-subrc = 0.
PERFORM cs_bom_expl_mat_v2 USING tpidnrk-matnr
p_capid
p_werks
tpidnrk-stlal.
no = 0.
DELETE tpidnrk.
LOOP
AT bom_itab WHERE stufe =
1.
no =
no + 1.
itab-z_index =
no.
itab-matnr = tpidnrk-matnr.
SELECT
SINGLE maktx INTO itab-maktx
FROM makt
WHERE matnr = tpidnrk-matnr.
MOVE-CORRESPONDING bom_itab TO itab.
tpidnrk-matnr = itab-idnrk.
SELECT SINGLE maktx
INTO itab-maktx2
FROM makt
WHERE matnr = itab-idnrk.
* AND spras = ‘1’.
* SELECT SINGLE zeinr bismt
* INTO (itab-zeinr,itab-bismt)
* FROM mara
* WHERE matnr = itab-idnrk.
IF itab-matnr+0(
1) <> ‘0’.
itab-matnp = itab-matnr.
ELSEIF itab-matnr+0(
1) = ‘0’.
itab-matnp = itab-matnr+
1(10) .
ENDIF.
itab-idnrp = itab-idnrk.
APPEND itab.
APPEND tpidnrk.
CLEAR tpidnrk.
CLEAR itab.
CLEAR bom_itab.
ENDLOOP.
ENDIF.
* APPEND tpidnrk.
ENDLOOP.
REFRESH gt_list_top_of_page[].
PERFORM e04_comment_build .
CLEAR fieldcat.
REFRESH fieldcat.
PERFORM build_fieldcat.
PERFORM build_eventcat.
PERFORM alv_display.
*&——————————————————————–*
*& Form e04_comment_build
*&——————————————————————–*
* text
*———————————————————————*
FORM e04_comment_build.
DATA : list_line
LIKE LINE
OF gt_list_top_of_page.
list_line-typ = ‘H’.
list_line-
key = ”.
list_line-info =
‘物料清單(BOM)明細’.
APPEND list_line
TO gt_list_top_of_page.
CLEAR list_line.
list_line-typ =
‘S’.
list_line-key =
‘工厂’.
list_line-info = p_werks.
APPEND list_line
TO gt_list_top_of_page.
CLEAR list_line.
list_line-typ =
‘H’.
list_line-key =
”.
list_line-info = ”.
APPEND list_line TO gt_list_top_of_page.
ENDFORM. ” e04_comment_build
*&——————————————————————–*
*& Form build_eventcat
*&——————————————————————–*
* text
*———————————————————————*
FORM build_eventcat.
DATA : ls_event TYPE slis_alv_event.
CALL FUNCTION
‘REUSE_ALV_EVENTS_GET’
EXPORTING
i_list_type =
0
IMPORTING
et_events = eventcat.
READ TABLE eventcat
WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc =
0.
MOVE gc_formname_top_of_page
TO ls_event-form.
APPEND ls_event TO eventcat.
ENDIF.
ENDFORM.
” build_eventcat
*&—————————————————-
*& Form alv_display
* text
*—————————————————–
* –〉 p1 text
* 〈 — p2 text
*—————————————————–
FORM alv_display.
CALL
FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = ‘ZWT_PP05’
* I_CALLBACK_USER_COMMAND = ‘COMMAND_EXECUTE’
is_layout = ps_layout
it_fieldcat = fieldcat
i_save = ‘A’
it_events = eventcat
TABLES
t_outtab = itab
EXCEPTIONS
program_error =
1
OTHERS =
2.
ENDFORM.
” alv_display
*&——————————————————————–*
*& Form alv_top_of_page
*&——————————————————————–*
* text
*———————————————————————*
FORM alv_top_of_page.
CALL
FUNCTION ‘REUSE_ALV_COMMENTARY_WRITE’
EXPORTING
it_list_commentary = gt_list_top_of_page.
ENDFORM.
“alv_top_of_page
*—————————————————–
* FORM build_fieldcat
*—————————————————–
* ……..
*—————————————————–
FORM build_fieldcat.
DATA : col_pos
TYPE i
VALUE 0.
ps_layout-get_selinfos =
‘X’.
ps_layout-colwidth_optimize = ‘X’.
ps_layout-detail_popup =
‘X’.
*PS_LAYOUT-BOX_FIELDNAME = ‘FLAG’.
ps_layout-no_keyfix =
”.
*PS_LAYOUT-KEY_HOTSPOT = ‘X’.
ps_layout-colwidth_optimize =
‘X’.
ADD
1 TO col_pos.
* fieldcat_ln-ref_tabname = ‘ITAB8’.
fieldcat_ln-tabname = ‘ITAB’.
fieldcat_ln-ref_fieldname =
‘Z_INDEX’.
fieldcat_ln-fieldname = ‘Z_INDEX’.
fieldcat_ln-
key = ‘X’.
fieldcat_ln-seltext_s =
‘序號’.
fieldcat_ln-seltext_l = ‘序號’.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic =
‘序號’.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln
TO fieldcat.
CLEAR fieldcat_ln.
ADD 1
TO col_pos.
* fieldcat_ln-ref_tabname = ‘ITAB8’.
fieldcat_ln-tabname =
‘ITAB’.
fieldcat_ln-ref_fieldname = ‘MATNR’.
fieldcat_ln-fieldname =
‘MATNR’.
fieldcat_ln-key =
‘X’.
fieldcat_ln-seltext_s = ‘產品編號’.
fieldcat_ln-seltext_l =
‘產品編號’.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic = ‘產品編號’.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln TO fieldcat.
CLEAR fieldcat_ln.
ADD
1 TO col_pos.
* fieldcat_ln-ref_tabname = ‘ITAB8’.
fieldcat_ln-tabname = ‘ITAB’.
fieldcat_ln-ref_fieldname =
‘MAKTX’.
fieldcat_ln-fieldname = ‘MAKTX’.
fieldcat_ln-
key = ‘X’.
fieldcat_ln-seltext_s =
‘產品描述’.
fieldcat_ln-seltext_l = ‘產品描述’.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic =
‘產品描述’.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln
TO fieldcat.
CLEAR fieldcat_ln.
ADD 1
TO col_pos.
* fieldcat_ln-ref_tabname = ‘ITAB8’.
fieldcat_ln-tabname =
‘ITAB’.
fieldcat_ln-ref_fieldname = ‘IDNRP’.
fieldcat_ln-fieldname =
‘IDNRP’.
fieldcat_ln-key =
‘X’.
fieldcat_ln-seltext_s = ‘BOM物料編號’.
fieldcat_ln-seltext_l =
‘BOM物料編號’.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic = ‘BOM物料編號’.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln TO fieldcat.
CLEAR fieldcat_ln.
ADD
1 TO col_pos.
* fieldcat_ln-ref_tabname = ‘ITAB8’.
fieldcat_ln-tabname = ‘ITAB’.
fieldcat_ln-ref_fieldname =
‘MAKTX2’.
fieldcat_ln-fieldname = ‘MAKTX2’.
fieldcat_ln-
key = ‘X’.
fieldcat_ln-seltext_s =
‘BOM物料描述’.
fieldcat_ln-seltext_l = ‘BOM物料描述’.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic =
‘BOM物料描述’.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln
TO fieldcat.
CLEAR fieldcat_ln.
ADD 1
TO col_pos.
* fieldcat_ln-ref_tabname = ‘ITAB8’.
fieldcat_ln-tabname =
‘ITAB’.
fieldcat_ln-ref_fieldname = ‘MEINS’.
fieldcat_ln-fieldname =
‘MEINS’.
fieldcat_ln-key =
‘X’.
fieldcat_ln-seltext_s = ‘單位’.
fieldcat_ln-seltext_l =
‘單位’.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic = ‘單位’.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln TO fieldcat.
CLEAR fieldcat_ln.
ADD
1 TO col_pos.
* fieldcat_ln-ref_tabname = ‘ITAB8’.
fieldcat_ln-tabname = ‘ITAB’.
fieldcat_ln-ref_fieldname =
‘MENGE’.
fieldcat_ln-fieldname = ‘MENGE’.
fieldcat_ln-
key = ‘X’.
fieldcat_ln-seltext_s =
‘數量’.
fieldcat_ln-seltext_l = ‘數量’.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic =
‘數量’.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln
TO fieldcat.
CLEAR fieldcat_ln.
ENDFORM. “build_fieldcat
*—————————————————–
* FORM BUILD_FIELDCAT_SUB
*—————————————————–
* ……..
*—————————————————–
* –〉 VALUE(P_COL_POS)
* –〉 VALUE(P_FIELDNAME)
* –〉 VALUE(P_SELTEXT)
*—————————————————–
FORM build_fieldcat_sub
USING value(p_col_pos)
value(p_fieldname)
value(p_seltext).
* ADD 1 TO COL_POS.
* fieldcat_ln-ref_tabname = ‘ZST_PP_0001’.
fieldcat_ln-tabname =
‘ITAB’.
fieldcat_ln-ref_fieldname = p_fieldname.
fieldcat_ln-fieldname = p_fieldname.
* FIELDCAT_LN-KEY = ‘X’.
fieldcat_ln-seltext_s = p_seltext.
fieldcat_ln-seltext_l = p_seltext.
fieldcat_ln-seltext_m = fieldcat_ln-reptext_ddic =
p_seltext.
fieldcat_ln-col_pos = p_col_pos.
APPEND fieldcat_ln TO fieldcat.
CLEAR fieldcat_ln.
ENDFORM.
” BUILD_FIELDCAT_SUB
*—————————————————–
* FORM CS_BOM_EXPL_MAT_V2
* ……..
* –〉 MATNR
* –〉 CAPID
* –〉 WERKS
*—————————————————–
FORM cs_bom_expl_mat_v2 USING matnr
LIKE afpo-matnr
capid LIKE tc04-capid
werks
LIKE ekpo-werks
stlal LIKE mast-stlal.
CALL FUNCTION
‘CS_BOM_EXPL_MAT_V2’
EXPORTING
aumng =
0
capid = capid
datuv = sy-datum
mehrs = ‘X’
mtnrv = matnr
stlal = stlal
stlan =
‘1’
werks = werks
TABLES
stb = bom_itab
* 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
conversion_error = 8
OTHERS = 9
.
ENDFORM. “CS_BOM_EXPL_MAT_V2
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/18237.html