Thank you for your answers until now. I have managed to make changes to my report but i still have some issues. When i put a value in s_grpmat it brings me all the columns in the grid except maktx. Also another thing that i would like to do is to be able to see all the materials even if i don`t put a value in s_matnr or in s_grpmat .Now is showing me only one material when i don`t put nothing in s_matnr and nothing in s_grpmat.
Thank you for your help!
TABLES:klah,
mara,
cabn,
makt,
marc,
t001w,
t023t,
t134t.
TYPE-POOLS:abap,
slis.
*Types declarations
TYPES:BEGIN OF type_class1,
class TYPE klah-class, "Nume clasa
klart TYPE klah-klart," Tip clasa
END OF type_class1.
TYPES:BEGIN OF type_makt,
matnr TYPE makt-matnr,"cod material
maktx TYPE makt-maktx, "descriere material
"werks type t001w-werks,
END OF type_makt.
TYPES:BEGIN OF type_ksml, "caracteristici clasa
imerk TYPE ksml-imerk,"caracteristica interna
clint TYPE ksml-clint,"numar intern clasa
klart TYPE ksml-klart, "tip clasa
END OF type_ksml.
TYPES:BEGIN OF type_charclass,
atnam TYPE atnam, "Nume caracteristica
objek1_internal TYPE objnum, "chei obiectului de clasificat
objek1 TYPE objnum,"chei obiectului de clasificat
objek1_text TYPE clobjtxt, "Descriere obiect
klart TYPE klah-klart, "tip clasa
END OF type_charclass.
TYPES:BEGIN OF type_status,
klart TYPE tclut-klart,"tip clasa
status TYPE tclut-status, "stare clasa
stext TYPE tclut-stext, "text pentru intrare de tabel
END OF type_status.
TYPES:BEGIN OF type_obtab,
klart TYPE tcla-klart,"tip clasa
obtab TYPE tabelle, "Nume tabel bază de date pt.obiect
END OF type_obtab.
TYPES:BEGIN OF type_final,
matnr TYPE clobjekte-objekt,"marc-matnr," Structură transfer: obiecte clasificate
class TYPE klah-class," nume clasa
klart TYPE klah-klart, "tip clasa
status TYPE sclass-statu, "sclass-Structură de referinţă: Date clasă,statu-Stare clasificare
maktx TYPE makt-maktx, "Descriere material
atnam TYPE clobjdat-atnam, " clobjdat-Structură referinţă: Date clasificare obiect- atnam-nume caracteristica
atwrt TYPE clobjdat-ausp1, "ausp1- Valoare caracteristică
atbez TYPE clobjdat-smbez, "smbez -Descriere caracteristică
stext TYPE tclut-stext, "stext - Text pt.o intrare de tabel
werks TYPE t001w-werks, " unitate logistica
matkl TYPE mara-matkl, " grup material
mtart TYPE mara-mtart, " cont material
END OF type_final.
TYPES:BEGIN OF type_t001w,
werks TYPE t001w-werks,
"matnr TYPE MARC-matnr,
END OF type_t001w.
TYPES:BEGIN OF type_marc,
werks TYPE marc-werks,
matnr TYPE MARC-matnr,
END OF type_marc.
TYPES:BEGIN OF type_mara,
matnr TYPE mara-matnr, "cod material
matkl TYPE mara-matkl, " grup material
mtart TYPE mara-mtart, " cont material
END OF type_mara.
*Ranges
DATA:ra_matnr TYPE RANGE OF makt-matnr.
DATA:ra_werks TYPE RANGE OF marc-werks.
*zone de lucru
DATA:wa_final TYPE type_final.
DATA:wa_class1 TYPE type_class1.
DATA:wa_makt1 TYPE type_makt.
DATA:wa_ksml TYPE type_ksml.
DATA:wa_charclass TYPE type_charclass.
DATA:wa_tcla1 TYPE type_obtab.
DATA:wa_status TYPE type_status.
DATA:wa_fieldcat TYPE slis_fieldcat_alv.
DATA:wa_layout TYPE slis_layout_alv.
DATA:wa_matnr LIKE LINE OF ra_matnr.
DATA:wa_marc TYPE type_marc.
DATA:wa_werks LIKE LINE OF ra_werks.
DATA:wa_t001w TYPE type_t001W.
DATA:wa_mara TYPE type_mara.
*Tabele interne
DATA:i_final TYPE TABLE OF type_final.
DATA:i_class1 TYPE STANDARD TABLE OF type_class1.
DATA:i_makt1 TYPE STANDARD TABLE OF type_makt.
DATA:i_ksml TYPE STANDARD TABLE OF type_ksml.
DATA:i_ksml_te TYPE STANDARD TABLE OF type_ksml.
DATA:i_tcla1 TYPE STANDARD TABLE OF type_obtab.
DATA:i_charclass TYPE STANDARD TABLE OF type_charclass.
DATA:i_status TYPE STANDARD TABLE OF type_status.
DATA:i_fieldcat TYPE TABLE OF slis_fieldcat_alv.
DATA:i_marc TYPE STANDARD TABLE OF type_marc.
DATA:i_t001w TYPE STANDARD TABLE OF type_t001W.
DATA:i_mara TYPE STANDARD TABLE OF type_mara.
*Variabile
DATA:wf_initial_char TYPE rmclm-basisd. "rmclm-structura , basisd-Date de bază sistem de clasificare
DATA: g_werks type marc-werks.
DATA: it_filter TYPE slis_t_filter_alv.
Data: ls_filter TYPE slis_filter_alv.
*selection screen
SELECT-OPTIONS: s_klart FOR klah-klart NO INTERVALS NO-EXTENSION DEFAULT '001',"Tip clasa
s_class FOR klah-class NO INTERVALS NO-EXTENSION OBLIGATORY MATCHCODE OBJECT clas DEFAULT 'Z_MEDIU'."Nume clasa
SELECT-OPTIONS: s_grpmat FOR t023t-matkl NO INTERVALS NO-EXTENSION. "Grup Material
"SELECT-OPTIONS: s_cntmat FOR t134t-mtart NO INTERVALS NO-EXTENSION DEFAULT '3010'. "Grup Material
SELECT-OPTIONS: s_matnr FOR mara-matnr NO INTERVALS NO-EXTENSION. "Numar Material
SELECT-OPTIONS: s_atinn FOR cabn-atinn NO INTERVALS NO-EXTENSION. "Caracteristici
"SELECT-OPTIONS: s_werks FOR t001w-werks NO INTERVALS NO-EXTENSION DEFAULT '3000'. "Unitate logistica
SELECTION-SCREEN SKIP 1.
START-OF-SELECTION.
*IF s_matnr[] IS INITIAL AND s_werks[] IS INITIAL AND s_grpmat[] IS INITIAL AND s_cntmat[] IS INITIAL.
SELECT matnr maktx FROM makt INTO TABLE i_makt1
WHERE matnr IN s_matnr AND
spras = sy-langu. "and
"maktg IN s_maktx .
SELECT werks matnr FROM marc into table i_marc "
where matnr IN s_matnr. "AND
*IF i_makt1 IS INITIAL.
* SELECT werks matnr
* INTO TABLE i_marc
* FROM marc FOR ALL ENTRIES IN i_makt1
* WHERE matnr EQ i_makt1-matnr.
* "AND werks IN s_werks.
*ENDIF.
"IF s_matnr[] IS INITIAL AND s_grpmat[] IS INITIAL.
SELECT matnr matkl mtart FROM mara INTO TABLE i_mara "
WHERE matnr IN s_matnr AND
matkl IN s_grpmat AND
mtart = '3010'."s_cntmat.
"ENDIF.
"IF s_klart[] IS INITIAL.
* SELECT matnr matkl mtart FROM mara INTO TABLE i_mara "
* WHERE "matnr IN s_matnr AND
* "matkl IN s_grpmat AND
* mtart = '3010'."s_cntmat.
"ENDIF.
*IF s_cntmat[] IS INITIAL.
*
*MESSAGE 'Nu sunt date pentru selectia efectuata' TYPE 'E'.
* EXIT.
* ENDIF.
* Loop AT i_mara INTO WA_mara.
* ENDLOOP.
" ENDIF.
* IF i_makt1[] IS INITIAL.
* MESSAGE 'Nu s-au gasit inregistrari2!' TYPE 'E'.
* EXIT.
* ELSE.
* LOOP AT i_makt1 INTO wa_makt1.
* wa_matnr-sign = 'I'.
* wa_matnr-option = 'EQ'.
* wa_matnr-low = wa_makt1-matnr.
* APPEND wa_matnr TO ra_matnr.
* ENDLOOP.
* ENDIF.
* IF i_marc[] IS INITIAL.
* MESSAGE 'Nu s-au gasit inregistrari1!' TYPE 'E'.
* EXIT.
* ELSE.
* LOOP AT i_marc INTO wa_marc.
* wa_werks-sign = 'I'.
* wa_werks-option = 'EQ'.
* wa_werks-low = wa_marc-werks.
* APPEND wa_werks TO ra_werks.
* ENDLOOP.
* ENDIF.
SELECT class klart FROM klah INTO TABLE i_class1
WHERE class IN s_class
AND klart IN s_klart.
IF i_class1[] IS INITIAL.
MESSAGE 'Nu sunt date pentru selectia efectuata' TYPE 'E'.
EXIT.
ENDIF.
IF s_atinn[] IS NOT INITIAL. "s_atinn -caracteristica din select-options
IF i_class1[] IS NOT INITIAL.
SELECT imerk clint klart " imerk(are element de data atinn) -caracteristica interna , clint-numar intern clasa , klart-tip clasa
INTO TABLE i_ksml
FROM ksml FOR ALL ENTRIES IN i_class1
WHERE klart = i_class1-klart
AND imerk IN s_atinn "s_atinn = cabn-atinn
AND lkenz = space.
ENDIF.
IF i_ksml[] IS NOT INITIAL.
SORT i_ksml BY imerk ASCENDING.
i_ksml_te[] = i_ksml[].
LOOP AT i_ksml_te INTO wa_ksml.
AT NEW imerk.
PERFORM get_classes USING wa_ksml-imerk
wa_ksml-klart
wa_ksml-clint.
"wa_marc-werks.
ENDAT.
ENDLOOP.
IF i_charclass[] IS INITIAL.
MESSAGE 'Nu sunt date pentru selectia efectuata' TYPE 'E'.
EXIT.
ENDIF.
ENDIF.
ENDIF.
IF i_class1[] IS NOT INITIAL.
SELECT klart
status
stext
INTO TABLE i_status
FROM tclut
FOR ALL ENTRIES IN i_class1
WHERE klart = i_class1-klart
AND spras = sy-langu.
SELECT klart obtab
INTO TABLE i_tcla1
FROM tcla
FOR ALL ENTRIES IN i_class1
WHERE klart = i_class1-klart.
ENDIF.
IF s_atinn[] IS NOT INITIAL.
*Process the classes retrieved for the characteristics entered
LOOP AT i_charclass INTO wa_charclass.
PERFORM get_objects USING wa_charclass-objek1
wa_charclass-klart.
"wa_charclass-werks.
ENDLOOP.
ELSE.
*Process for all the classes entered
LOOP AT i_class1 INTO wa_class1.
PERFORM get_objects USING wa_class1-class
wa_class1-klart.
ENDLOOP.
* LOOP AT i_marc into wa_marc.
*
* Perform get_objects using wa_marc-werks.
*
* ENDLOOP.
ENDIF.
IF i_final[] IS NOT INITIAL.
PERFORM build_field_catalouge.
Refresh it_filter.
ls_filter-fieldname = 'MATKL'.
ls_filter-tabname = 'i_final[]'.
ls_filter-sign0 = 'I'.
ls_filter-optio = 'NE'.
ls_filter-valuf_int = ' '.
APPEND ls_filter TO It_filter.
PERFORM display_data.
** perform validate_screen.
**perform get_mat_stock_data.
* ELSE.
* MESSAGE 'No records found' TYPE 'E'.
* EXIT.
*
ENDIF.
*&---------------------------------------------------------------------*
*& Form GET_CLASSES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_<FS_KSML>_IMERK text
*----------------------------------------------------------------------*
FORM get_classes USING p_imerk TYPE ksml-imerk
p_klart TYPE ksml-klart
p_clint TYPE ksml-clint.
"p_werks TYPE marc-werks.
DATA:i_classes TYPE tt_ctwul_output.
DATA:wa_classes TYPE ctwul_output.
DATA:wa_ksmltemp TYPE type_ksml.
DATA:wf_atnam TYPE atnam.
DATA:wf_werks TYPE werks.
CLEAR i_classes[].
WRITE p_imerk TO wf_atnam USING EDIT MASK '==ATINN'.
"WRITE p_werks TO wf_werks USING EDIT MASK '==WERKS'.
PERFORM get_characteristics TABLES i_classes
USING wf_atnam
p_klart.
"p_werks.
CHECK sy-subrc = 0.
LOOP AT i_classes INTO wa_classes WHERE objek1 IN s_class. "and objek1 in s_werks.
READ TABLE i_ksml WITH KEY clint = wa_classes-objek1_internal
klart = wa_classes-klart
TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
MOVE : wa_classes-objek1 TO wa_charclass-objek1,
wa_classes-objek1_internal TO wa_charclass-objek1_internal,
wa_classes-klart TO wa_charclass-klart,
wa_classes-objek1_text TO wa_charclass-objek1_text.
wa_charclass-atnam = wf_atnam.
APPEND wa_charclass TO i_charclass.
CLEAR wa_charclass.
ENDIF.
ENDLOOP.
ENDFORM. " GET_CLASSES
*&---------------------------------------------------------------------*
*& Form GET_CHARACTERISTICS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_I_CLASSES text
* -->P_WF_ATNAM text
* -->P_P_KLART text
*----------------------------------------------------------------------*
FORM get_characteristics TABLES p_classes TYPE tt_ctwul_output
USING p_atnam TYPE atnam
p_klart TYPE klah-klart.
"p_werks TYPE marc-werks.
CALL FUNCTION 'CTWUL_CHARACT_USAGE'
EXPORTING
charact_name = p_atnam
class_type = p_klart
classes = 'X'
IMPORTING
et_classes = p_classes[]
EXCEPTIONS
charact_not_found = 1
value_conversion = 2
no_authority = 3
OTHERS = 4.
ENDFORM. " GET_CHARACTERISTICS
*&---------------------------------------------------------------------*
*& Form GET_OBJECTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_WA_CLASS1_CLASS text
* -->P_WA_CLASS1_KLART text
*----------------------------------------------------------------------*
FORM get_objects USING p_wf_class TYPE any
p_klart TYPE klah-klart.
"p_werks type marc-werks.
"p_wf_werks TYPE any.
DATA:i_objclass TYPE TABLE OF sclass.
DATA:i_objectdata TYPE TABLE OF clobjdat.
DATA:i_objects TYPE TABLE OF clobjekte.
DATA:i_objects2 TYPE TABLE OF clobjekte.
DATA:wa_objclass TYPE sclass.
DATA:wa_objects TYPE clobjekte.
DATA:wa_object_data TYPE clobjdat.
DATA:wa_objects2 TYPE clobjekte.
DATA:wf_class TYPE klah-class.
DATA:wf_node_l TYPE i.
DATA:wf_node_h TYPE i.
DATA:wf_obtab TYPE tcla-obtab.
DATA:wf_werks TYPE marc-werks.
"DATA:wf_node_2 TYPE i.
"DATA:wf_node_h TYPE i.
"wf_werks = p_wf_werks.
wf_class = p_wf_class.
READ TABLE i_tcla1 INTO wa_tcla1 WITH KEY klart = wa_class1-klart.
IF sy-subrc = 0.
wf_obtab = wa_tcla1-obtab.
ENDIF.
CALL FUNCTION 'CLAF_OBJECTS_OF_CLASS'
EXPORTING
class = wf_class
classes = abap_true
classtext = abap_true
classtype = p_klart
language = sy-langu
key_date = sy-datum
objecttable = wf_obtab
initial_charact = wf_initial_char
TABLES
t_class = i_objclass
t_objectdata = i_objectdata
t_objects = i_objects
EXCEPTIONS
no_classification = 1
invalid_class_type = 2
OTHERS = 3.
IF sy-subrc = 0.
LOOP AT i_objects INTO wa_objects.
IF sy-tabix EQ 1.
wf_node_l = sy-tabix.
wf_node_h = wa_objects-anzaus.
ELSE.
wf_node_l = wf_node_h + 1.
wf_node_h = wf_node_h + wa_objects-anzaus.
ENDIF.
* IF ra_matnr[] IS NOT INITIAL.
* IF wa_objects-objekt NOT IN ra_matnr[].
* CONTINUE.
* ENDIF.
* ENDIF.
READ TABLE i_objclass INTO wa_objclass
WITH KEY class = wf_class.
IF sy-subrc NE 0.
CLEAR wa_objclass.
ENDIF.
IF s_atinn[] IS NOT INITIAL.
LOOP AT i_objectdata INTO wa_object_data FROM wf_node_l TO wf_node_h
WHERE atnam EQ wa_charclass-atnam.
PERFORM build_data USING wa_object_data
wa_objects
wa_objclass
p_klart
wf_class.
ENDLOOP.
ELSE.
LOOP AT i_objectdata INTO wa_object_data FROM wf_node_l TO wf_node_h.
PERFORM build_data USING wa_object_data
wa_objects
wa_objclass
p_klart
wf_class.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM.
" GET_OBJECTS
*&---------------------------------------------------------------------*
*& Form BUILD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_WA_OBJECTDATA text
* -->P_WA_OBJECTS text
* -->P_P_KLART text
* -->P_WF_CLASS text
*----------------------------------------------------------------------*
FORM build_data USING p_wa_objectdata TYPE clobjdat
p_wa_objects TYPE clobjekte
p_wa_class TYPE sclass
p_p_klart TYPE klah-klart
p_wf_class TYPE klah-class.
"p_wa_objects TYPE marc-matnr.
wa_final-matnr = p_wa_objects-objekt. "p_wa_objects-objekt.
wa_final-klart = p_p_klart.
wa_final-class = p_wf_class.
wa_final-status = p_wa_class-statu.
"wa_final-werks = p_wa_objects2-objekt. "p_wa_objects-objekt."
"wa_final-werks = wa_marc-werks."p_p_werks.
"wa_final-mtart = wa_mara-mtart.
IF wa_makt1-matnr <> p_wa_objects-objekt.
READ TABLE i_makt1 INTO wa_makt1
WITH KEY matnr = p_wa_objects-objekt BINARY SEARCH
TRANSPORTING maktx.
IF sy-subrc <> 0.
CLEAR wa_makt1.
ENDIF.
ENDIF.
IF wa_marc-werks <> p_wa_objects-objekt. "p_wa_objects-objekt.
READ TABLE i_marc INTO wa_marc
WITH KEY matnr = p_wa_objects-objekt BINARY SEARCH "p_wa_object2-objekt BINARY SEARCH
TRANSPORTING WERKS.
IF sy-subrc <> 0.
CLEAR wa_marc.
ENDIF.
ENDIF.
IF wa_mara-matkl <> p_wa_objects-objekt. "p_wa_object2-objekt.
READ TABLE i_mara INTO wa_mara
WITH KEY matnr = p_wa_objects-objekt BINARY SEARCH "p_wa_object2-objekt BINARY SEARCH
TRANSPORTING matnr matkl mtart.
IF sy-subrc <> 0.
CLEAR wa_mara.
ENDIF.
ENDIF.
wa_final-mtart = wa_mara-mtart.
wa_final-matkl = wa_mara-matkl.
wa_final-werks = wa_marc-werks.
wa_final-maktx = wa_makt1-maktx.
wa_final-atnam = p_wa_objectdata-atnam.
wa_final-atwrt = p_wa_objectdata-ausp1.
wa_final-atbez = p_wa_objectdata-smbez.
IF p_wa_class-statu <> wa_status-status.
READ TABLE i_status INTO wa_status
WITH KEY status = p_wa_class-statu.
IF sy-subrc <> 0.
CLEAR wa_status.
ENDIF.
ENDIF.
wa_final-stext = wa_status-stext.
APPEND wa_final TO i_final.
ENDFORM. " BUILD_DATA
*&---------------------------------------------------------------------*
*& Form BUILD_FIELD_CATALOUGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM build_field_catalouge .
wa_layout-colwidth_optimize = abap_true.
wa_layout-zebra = abap_true.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-seltext_m = 'Unitate logistica'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'KLART'.
wa_fieldcat-seltext_m = 'Tip clasa'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MTART'.
wa_fieldcat-seltext_m = 'Cont Material'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MAKTX'.
wa_fieldcat-seltext_m = 'Descriere'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
* wa_fieldcat-fieldname = 'CLASS'.
* wa_fieldcat-seltext_m = 'Nume clasa'.
* APPEND wa_fieldcat TO i_fieldcat.
* CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-seltext_m = 'Cod Material'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATKL'.
wa_fieldcat-seltext_m = 'Grupa Material'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ATNAM'.
wa_fieldcat-seltext_m = 'Nume caracteristica'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ATWRT'.
wa_fieldcat-seltext_m = 'Valoare caracteristica'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
* wa_fieldcat-fieldname = 'STATUS'.
* wa_fieldcat-seltext_m = 'Status'.
* APPEND wa_fieldcat TO i_fieldcat.
* CLEAR wa_fieldcat.
*
* wa_fieldcat-fieldname = 'STEXT'.
* wa_fieldcat-seltext_m = 'Stare'.
* APPEND wa_fieldcat TO i_fieldcat.
* CLEAR wa_fieldcat.
ENDFORM. " BUILD_FIELD_CATALOUGE
*&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_data .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_grid_title = 'Clasificarea materialelor si caracteristicile lor'
is_layout = wa_layout
it_fieldcat = i_fieldcat[]
it_filter = it_filter
TABLES
t_outtab = i_final[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " DISPLAY_DATA
Thank you for your answers until now. I have managed to make changes to my report but i still have some issues. When i put a value in s_grpmat it brings me all the columns in the grid except maktx. Also another thing that i would like to do is to be able to see all the materials even if i don`t put a value in s_matnr or in s_grpmat .Now is showing me only one material when i don`t put nothing in s_matnr and nothing in s_grpmat.
Thank you for your help!
capture.png (26.2 kB)
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.
Zuletzt geändert von
dragospirnut1 am 12.07.2017 14:27, insgesamt 2-mal geändert.