Verräts du uns auch wie du die Ausgabe machsts (ALV, WRITE, etc...).hmaxi96 hat geschrieben:Nun ist meine Frage, wie blende ich die 19 anderen Spalten aus die ich nicht selektiert habe?
Code: Alles auswählen.
* Voraussetztung die Spalten sind sinnvoll benammt: zb. LGORT_0001; LGORT_00002; LGORT_8000;....
LOOP AT fieldcat.
IF fieldcat-fieldname(5) = 'LGORT'. "es handelt sich um einen Lagerortfeld
IF fieldcat-fieldname+6(4) NOT IN sel_opt_lgort. "Lagerort ist nicht in SelOpt enthalten
fieldcat-no_out = 'X'. "User will den Lagerort nicht sehen, also ausblenden
ENDIF.
ENDIF.
ENDLOOP.
Die Verrenkung macht er gerade, da es dynamisch nicht lösbar war, wird es jetzt mit statischen Strukturen gelöst.ralf.wenzel hat geschrieben:Durch die Selektionsoption kannst du standardmäßig nur Zeilen ausblenden. Spalten auszublenden heißt, ziemliche Verrenkungen zu machen.
Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report ZTEST_HM_MATERIALUEBERSICHT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTEST_HM_MATERIALUEBERSICHT.
TABLES: MAKT, MARA, MARC, EINA, EINE, MARD, T001L.
TYPES: BEGIN OF gty_complete,
maktx TYPE maktx,
bismt TYPE bismt,
matnr TYPE matnr,
werks TYPE werks_d,
lifnr TYPE elifn,
name1 TYPE name1,
infnr TYPE infnr,
ekorg TYPE ekorg,
baur TYPE atnam,
baug TYPE atnam,
hilfe TYPE char1,
*LGORTE
lgort001 TYPE labst,"7000
lgort002 TYPE labst,"8000
lgort003 TYPE labst,"8001
lgort004 TYPE labst,"8002
lgort005 TYPE labst,"8020
lgort006 TYPE labst,"8021
lgort007 TYPE labst,"8040
lgort008 TYPE labst,"8041
lgort009 TYPE labst,"8060
lgort010 TYPE labst,"8061
lgort011 TYPE labst,"8062
lgort012 TYPE labst,"8064
lgort013 TYPE labst,"8100
lgort014 TYPE labst,
lgort015 TYPE labst,
lgort016 TYPE labst,
lgort017 TYPE labst,
lgort018 TYPE labst,
lgort019 TYPE labst,
lgort020 TYPE labst,
lbkum TYPE lbkum,
cellcolor TYPE lvc_t_scol,
END OF gty_complete.
DATA: gt_complete TYPE TABLE OF gty_complete,
gs_complete TYPE gty_complete.
Data : ls_cellcolor TYPE lvc_s_scol. "For cell color
TYPES: BEGIN OF gty_tab,
stelle(3) TYPE n,
lgort TYPE lgort_d,
END OF gty_tab.
DATA: gt_tab TYPE TABLE OF gty_tab,
gs_tab TYPE gty_tab.
DATA: gt_mard TYPE TABLE OF mard,
gs_mard TYPE mard.
DATA: gt_mara TYPE TABLE OF mara,
gs_mara TYPE mara.
DATA: gt_makt TYPE TABLE OF makt,
gs_makt TYPE makt.
DATA: gt_marc TYPE TABLE OF gty_complete,
gs_marc TYPE gty_complete.
DATA: gt_eina TYPE TABLE OF eina,
gs_eina TYPE eina.
DATA: gt_eine TYPE TABLE OF eine,
gs_eine TYPE eine.
DATA: gt_lfa1 TYPE TABLE OF lfa1,
gs_lfa1 TYPE lfa1.
DATA: gt_mbew TYPE TABLE OF mbew,
gs_mbew TYPE mbew.
PARAMETERS: p_werks TYPE marc-werks.
SELECT-OPTIONS: s_matnr FOR marc-matnr,
s_lgort FOR t001l-lgort.
PERFORM marc.
PERFORM alv.
FORM marc.
SELECT matnr werks FROM marc INTO CORRESPONDING FIELDS OF TABLE gt_marc WHERE matnr IN s_matnr.
LOOP AT gt_marc INTO gs_complete.
PERFORM mara USING gs_complete-matnr.
PERFORM makt USING gs_complete-matnr.
PERFORM eine USING gs_complete-werks.
PERFORM eina USING gs_complete-matnr gs_complete-infnr.
PERFORM lfa1 USING gs_complete-lifnr.
PERFORM klassifizierung USING gs_complete-matnr.
PERFORM lgorte USING gs_complete-matnr gs_complete-werks.
PERFORM gesamtbestand USING gs_complete-matnr gs_complete-werks.
APPEND gs_complete TO gt_complete.
ENDLOOP.
ENDFORM.
FORM makt USING im_matvar.
SELECT SINGLE spras maktx matnr FROM makt INTO CORRESPONDING FIELDS OF gs_makt WHERE matnr = im_matvar AND spras = sy-langu.
MOVE gs_makt-maktx TO gs_complete-maktx.
CLEAR gs_makt.
ENDFORM.
FORM eine USING im_werkvar.
SELECT SINGLE * FROM eine INTO CORRESPONDING FIELDS OF gs_eine WHERE werks = im_werkvar.
MOVE gs_eine-infnr TO gs_complete-infnr.
MOVE gs_eine-ekorg TO gs_complete-ekorg.
CLEAR gs_eine.
ENDFORM.
FORM mara USING im_matvar.
SELECT SINGLE matnr bismt FROM mara INTO CORRESPONDING FIELDS OF gs_mara WHERE matnr = im_matvar.
MOVE gs_mara-bismt TO gs_complete-bismt.
CLEAR gs_mara.
ENDFORM.
FORM eina USING im_matvar im_infvar.
SELECT SINGLE matnr infnr lifnr FROM eina INTO CORRESPONDING FIELDS OF gs_eina WHERE matnr = im_matvar AND infnr = im_infvar.
MOVE gs_eina-lifnr TO gs_complete-lifnr.
CLEAR gs_eina.
ENDFORM.
FORM lfa1 USING im_lifvar.
SELECT SINGLE name1 FROM lfa1 INTO CORRESPONDING FIELDS OF gs_lfa1 WHERE lifnr = im_lifvar.
MOVE gs_lfa1-name1 TO gs_complete-name1.
CLEAR gs_lfa1.
ENDFORM.
FORM lgorte USING im_matvar im_werkvar.
FIELD-SYMBOLS: <fs> TYPE any.
DATA: lv_field TYPE string.
DATA: lv_line TYPE i.
SELECT * FROM mard INTO CORRESPONDING FIELDS OF TABLE gt_mard WHERE matnr = im_matvar AND werks = im_werkvar.
"MOVE gs_mard-labst TO gs_complete-lgort1.
LOOP AT gt_mard INTO gs_mard.
READ TABLE gt_tab INTO gs_tab WITH KEY lgort = gs_mard-lgort.
CLEAR lv_field.
IF sy-subrc = 0.
ELSE.
DESCRIBE TABLE gt_tab LINES lv_line.
gs_tab-stelle = lv_line + 1.
gs_tab-lgort = gs_mard-lgort.
APPEND gs_tab TO gt_tab.
ENDIF.
lv_field = 'LGORT' && gs_tab-stelle.
ASSIGN COMPONENT lv_field OF STRUCTURE gs_complete TO <fs>.
IF sy-subrc = 0.
<fs> = gs_mard-labst.
ENDIF.
CLEAR lv_field.
CLEAR gs_mard.
ENDLOOP.
ENDFORM.
FORM gesamtbestand USING im_matvar im_werkvar.
SELECT SINGLE * FROM mbew INTO CORRESPONDING FIELDS OF gs_mbew WHERE matnr = im_matvar AND bwkey = im_werkvar.
MOVE gs_mbew-lbkum TO gs_complete-lbkum.
ENDFORM.
FORM klassifizierung USING im_matnr.
DATA: lv_object TYPE char50.
* Klassen
DATA: BEGIN OF tclass OCCURS 0.
INCLUDE STRUCTURE sclass.
DATA: END OF tclass.
* Merkmalswerte zu einem Objekt
DATA: BEGIN OF tobjectdata OCCURS 0.
INCLUDE STRUCTURE clobjdat.
DATA: END OF tobjectdata.
* Objekte zu einer Klasse
DATA: BEGIN OF tobjects OCCURS 0.
INCLUDE STRUCTURE clobjekte.
DATA: END OF tobjects.
lv_object = im_matnr.
CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
EXPORTING
CLASS = 'M_0218'
CLASSTEXT = 'X'
CLASSTYPE = '001'
* CLINT = 0
* FEATURES = 'X'
LANGUAGE = SY-LANGU
OBJECT = lv_object
* OBJECTTABLE = ' '
KEY_DATE = SY-DATUM
* INITIAL_CHARACT = 'X'
* NO_VALUE_DESCRIPT =
* CHANGE_SERVICE_CLF = 'X'
* INHERITED_CHAR = ' '
* CHANGE_NUMBER = ' '
TABLES
T_CLASS = tclass
T_OBJECTDATA = tobjectdata
* I_SEL_CHARACTERISTIC =
* T_NO_AUTH_CHARACT =
EXCEPTIONS
NO_CLASSIFICATION = 1
NO_CLASSTYPES = 2
INVALID_CLASS_TYPE = 3
OTHERS = 4.
IF sy-subrc = 0.
READ TABLE tobjectdata
WITH KEY atnam = 'M_266_BAUREIHE_P'.
IF sy-subrc = 0.
IF tobjectdata-AUSP1 NE '?'.
gs_complete-baur = tobjectdata-AUSP1.
ENDIF.
ENDIF.
READ TABLE tobjectdata
WITH KEY atnam = 'M_268_BAUGRUPPE_P'.
IF sy-subrc = 0.
IF tobjectdata-AUSP1 NE '?'.
gs_complete-baug = tobjectdata-AUSP1.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
READ TABLE gt_complete INTO gs_complete INDEX rs_selfield-tabindex.
CASE rs_selfield-fieldname.
WHEN 'MATNR'.
SET PARAMETER ID 'MAT' FIELD gs_complete-matnr.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
ENDCASE.
CASE rs_selfield-fieldname.
WHEN 'INFNR'.
SET PARAMETER ID 'MAT' FIELD gs_complete-matnr.
SET PARAMETER ID 'LIF' FIELD gs_complete-lifnr.
SET PARAMETER ID 'EKO' FIELD gs_complete-ekorg.
SET PARAMETER ID 'INF' FIELD gs_complete-infnr.
SET PARAMETER ID 'WRK' FIELD gs_complete-werks.
CALL TRANSACTION 'ME1M'.
ENDCASE.
ENDCASE.
ENDFORM. "alv_user_command
FORM alv.
DATA: lt_fcat TYPE lvc_t_fcat,
ls_layout TYPE lvc_s_layo.
ls_layout-ctab_fname = 'CELLCOLOR'."For cell coloring
PERFORM fieldcat_merge CHANGING lt_fcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
I_CALLBACK_PROGRAM = sy-cprog
* I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
IS_LAYOUT_LVC = ls_layout
IT_FIELDCAT_LVC = lt_fcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS_LVC =
* IT_SORT_LVC =
* IT_FILTER_LVC =
* IT_HYPERLINK =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT_LVC =
* IS_REPREP_ID_LVC =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO_LVC =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = gt_complete
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
FORM fieldcat_merge CHANGING ch_fcat TYPE lvc_t_fcat.
DATA: lo_structdescr TYPE REF TO cl_abap_structdescr.
DATA: lo_elemdescr TYPE REF TO cl_abap_elemdescr.
DATA: ls_dummy TYPE gty_complete.
DATA: lt_fields TYPE ddfields.
DATA: lt_comp TYPE abap_component_tab.
DATA: lt_comp_final TYPE abap_component_tab.
DATA: ls_dfies TYPE dfies.
FIELD-SYMBOLS: <line> TYPE lvc_s_fcat,
<comp> TYPE LINE OF abap_component_tab,
<field> TYPE dfies.
* ~~~~~~~~~~~~~~~~~~~~~~~~~~-{ DO }-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
"Erstellen der Strukturbeschreibung
lo_structdescr ?= cl_abap_structdescr=>describe_by_data( ls_dummy ).
IF lo_structdescr IS BOUND.
lt_fields = cl_salv_data_descr=>read_structdescr( lo_structdescr ).
CLEAR ch_fcat[].
LOOP AT lt_fields ASSIGNING <field>.
APPEND INITIAL LINE TO ch_fcat ASSIGNING <line>.
<line>-fieldname = <field>-fieldname. "<comp>-name. "Feldname 'UNAME' etc.
<line>-rollname = <field>-rollname.
<line>-domname = <field>-domname.
<line>-tabname = <field>-tabname.
<line>-coltext = <field>-reptext.
<line>-scrtext_l = <field>-scrtext_l.
<line>-scrtext_s = <field>-scrtext_s.
<line>-scrtext_m = <field>-scrtext_m.
<line>-rollname = <field>-domname.
* <line>-convexit = <field>-convexit.
* <line>-checktable = <field>-checktable.
* <line>-ref_table = <field>-reftable.
* <line>-ref_field = <FIELD>-reffield.
<line>-col_opt = 'X'.
* <line>-outputlen = <field>-outputlen.
IF <line>-fieldname = 'MATNR'.
<line>-hotspot = 'X'.
ENDIF.
IF <line>-fieldname = 'INFNR'.
<line>-hotspot = 'X'.
ENDIF.
IF <line>-fieldname = 'BAUR'.
<line>-coltext = 'Baureihe'.
ENDIF.
IF <line>-fieldname = 'BAUG'.
<line>-coltext = 'Baugruppe'.
ENDIF.
* <line>-valexi = <field>-valexi.
* <line>-mac = <field>-mac.
<line>-ref_field = <field>-reffield.
<line>-ref_table = <field>-reftable.
ENDLOOP.
ENDIF.
* ~~~~~~~~~~~~~~~~~~~~~~~~~~-{ EN
ENDFORM. "fieldcat_merge
Ich kann in dem Programm nichts erkennen, wo du eine Datei hochlädst.hmaxi96 hat geschrieben:Danke für eure Hilfe!
Wollte grade eine Textdatei hochladen, aber "Die Dateierweiterung ist nicht erlaubt."
So, wie ich dein Programm verstehe, willst du eine Liste der Werke haben, in der spaltenweise die Bestände der einzelnen Lagerorte stehen, richtig?hmaxi96 hat geschrieben:Ich wollte hier im Forum eine Textdatei mit dem Quelltext hochladen aber die hat nicht geklappt...
Ich möchte einfach nur wenn nur 1 Lgort in der Select-Option ausgewählt ist dass auch nur das angezeigt wird.
Denn ich kann nicht IF <line>-fieldname = 'LGORT' IS INITIAL. machen, da ich 20 Felder habe und diese den Wert 0,000 beinhalten.
Wenn ich IF <line>-fieldname = 'LGORT' = '0.000'. mache geht das natürlich nicht weil in jeder Spalte min. 1 mal 0,000 steht.
In fieldcat_merge für alle entsprechenden Spalten <line>-no_out auf 'X' setzen.hmaxi96 hat geschrieben:Genau dass will ich ja schon die ganze Zeit machen.
Ich weiß nicht wie ich den NO_OUT machen soll...
Das mit dem hochladen hat sich schon erledigt, wollte den Quelltext per .txt hier im Forum hochladen, dies ging nicht deshalb habe ich ihn so reingeschrieben.
Folgende Benutzer bedankten sich beim Autor a-dead-trousers für den Beitrag:
hmaxi96