Code: Alles auswählen.
PROGRAM ylo_stuli_expl.
CONSTANTS: alv_struc LIKE dd02l-tabname VALUE 'STPO'.
* Ausgabe Struktur
DATA:it_data TYPE stpo OCCURS 0 WITH HEADER LINE.
DATA:ls_data TYPE stpo.
DATA: ok_code LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'GRID_CONT1',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
is_variant TYPE disvariant.
*--- Field catalog table
DATA gt_fieldcat TYPE lvc_t_fcat WITH HEADER LINE.
*--- Layout structure
DATA gs_layout TYPE lvc_s_layo .
*---------------------------------------------------------------------*
* MAIN *
*---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK qsel
WITH FRAME TITLE text-s02.
PARAMETERS:
* Material
pm_matnr LIKE mara-matnr MEMORY ID mat OBLIGATORY,
* Sprache
pm_zspra LIKE stxh-tdspras DEFAULT 'DE',
* Alternative
pm_stlal LIKE mast-stlal DEFAULT ' ',
* Stuecklistenanwendung
pm_capid LIKE tc04-capid MEMORY ID pid DEFAULT 'FERT',
* Datum gültig am
pm_datuv LIKE stko-datuv OBLIGATORY DEFAULT sy-datum,
* Einsatzmenge
pm_emeng LIKE stko-bmeng NO-DISPLAY,
* Kennz. Materialkurztext lesen
pm_mktls LIKE csdata-xfeld DEFAULT 'X' NO-DISPLAY,
* Kennz. Mehrstufige Auflösung
pm_mehrs LIKE csdata-xfeld DEFAULT 'X' NO-DISPLAY,
* Fertigung
pm_sanfr LIKE stpo-sanfe DEFAULT 'X' NO-DISPLAY,
* Stücklistenverwendung
pm_stlan LIKE stzu-stlan DEFAULT '3',
* Kennz. Vorr. Stücklistenverw.
pm_svwvo LIKE csdata-xfeld DEFAULT 'X' NO-DISPLAY,
* Max. Auflösungsstufe
pm_stpst LIKE stpox-stufe DEFAULT ' ',
* Werk
pm_werks LIKE marc-werks DEFAULT '0001',
* Kennz. Vorr. Fertig.-version
pm_vrsvo LIKE csdata-xfeld DEFAULT 'X' NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK qsel.
PERFORM read_bom.
CALL SCREEN 100.
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'AUSW' WITH text-tit.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
*----Preparing field catalog.
PERFORM prepare_field_catalog TABLES gt_fieldcat .
*----Preparing layout structure
PERFORM prepare_layout CHANGING gs_layout .
is_variant-report = sy-repid.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
is_variant = is_variant
i_save = 'X'
is_layout = gs_layout
CHANGING
it_outtab = it_data[]
it_fieldcatalog = gt_fieldcat[].
* CALL METHOD grid1->set_toolbar_interactive.
* CALL METHOD grid1->refresh_table_display.
ENDIF.
ENDMODULE. "PBO OUTPUT
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
MODULE pai INPUT.
* to react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN OTHERS.
* do nothing
ENDCASE.
CLEAR ok_code.
ENDMODULE. "PAI INPUT
*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM exit_program.
* CALL METHOD G_CUSTOM_CONTAINER->FREE.
* CALL METHOD CL_GUI_CFW=>FLUSH.
LEAVE TO SCREEN 0.
ENDFORM. "EXIT_PROGRAM
*&--------------------------------------------------------------------*
*& Form prepare_field_catalog
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->PT_FIELDCATtext
*---------------------------------------------------------------------*
FORM prepare_field_catalog TABLES pt_fieldcat TYPE lvc_t_fcat .
DATA ls_fcat TYPE lvc_s_fcat .
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = alv_struc
CHANGING
ct_fieldcat = pt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
READ TABLE pt_fieldcat INTO ls_fcat WITH KEY fieldname = 'VGPZL'.
ls_fcat-REPTEXT = 'Auflösungsstufe'.
ls_fcat-coltext = 'Stufe'.
ls_fcat-scrtext_l = 'Stufe'.
ls_fcat-scrtext_m = 'Stufe'.
ls_fcat-scrtext_s = 'Stufe'.
* INSERT ls_fcat INTO pt_fieldcat INDEX 1.
MODIFY pt_fieldcat FROM ls_fcat INDEX sy-tabix.
* LOOP AT pt_fieldcat INTO ls_fcat .
*
*
* CASE ls_fcat-fieldname .
* WHEN 'VGPZL' .
* ls_fcat-coltext = 'Stufe' .
* ls_fcat-scrtext_l = 'Stufe'.
* ls_fcat-scrtext_m = 'Stufe'.
* ls_fcat-scrtext_s = 'Stufe'.
*
* MODIFY pt_fieldcat FROM ls_fcat .
*
*
* ENDCASE .
* ENDLOOP .
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
ENDFORM . "prepare_field_catalog
*&--------------------------------------------------------------------*
*& Form prepare_layout
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->PS_LAYOUT text
*---------------------------------------------------------------------*
FORM prepare_layout CHANGING ps_layout TYPE lvc_s_layo.
ps_layout-zebra = 'X' .
ps_layout-cwidth_opt ='X'.
ps_layout-numc_total = ' '.
ps_layout-no_merging = 'X'.
ps_layout-no_rowmark = ' '.
* ps_layout-sel_mode = 'A'.
* ps_layout-grid_title = 'Bom Explode' .
* ps_layout-smalltitle = 'X' .
ENDFORM. " prepare_layout
*&--------------------------------------------------------------------*
*& Form Read_BOM
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM read_bom.
*---------------------------------------------------------------------*
* interne Tabellen für Matstüli *
*---------------------------------------------------------------------*
* Einstiegsmaterial
DATA: BEGIN OF selpool.
INCLUDE STRUCTURE cstmat.
DATA: END OF selpool.
* Positionentabelle
DATA: BEGIN OF zstb OCCURS 1000.
INCLUDE STRUCTURE stpox.
DATA: END OF zstb.
* Materialkatalog
DATA: BEGIN OF matcat OCCURS 50.
INCLUDE STRUCTURE cscmat.
DATA: END OF matcat.
* Langtexttabelle
DATA: dstst_flg LIKE csdata-xfeld.
CLEAR: zstb,it_data,matcat.
REFRESH: zstb,it_data,matcat.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
capid = pm_capid
datuv = pm_datuv
emeng = pm_emeng
mktls = pm_mktls
mehrs = pm_mehrs
mtnrv = pm_matnr
sanfr = pm_sanfr
stlan = pm_stlan
svwvo = pm_svwvo
stpst = pm_stpst
werks = pm_werks
vrsvo = pm_vrsvo
stlal = pm_stlal
* ehndl = '1'
* mmory = '1'
IMPORTING
topmat = selpool
dstst = dstst_flg
TABLES
stb = zstb
matcat = matcat
EXCEPTIONS
material_not_found = 4
no_plant_data = 8
no_bom_found = 12
no_suitable_bom_found = 16
alt_not_found = 24
missing_authorization = 28.
IF sy-subrc NE 0.
MESSAGE s904(v3).
EXIT.
* Keine Stückliste gefunden, bitte Eingabedaten prüfen!
ENDIF.
LOOP AT zstb.
SELECT SINGLE * FROM stpo INTO ls_data
WHERE stlnr = zstb-stlnr AND
stlkn = zstb-stlkn AND
stpoz = zstb-stpoz AND
stvkn = zstb-stvkn.
* Stufenzähler
ls_data-vgpzl = zstb-stufe.
APPEND ls_data TO it_data.
ENDLOOP.
ENDFORM. "Read_BOM