Good morning!
Does anybody know if a select-options match code can depend on another select-options match code? If yes ,please post an example.For example:
SELECT-OPTIONS: s_klart FOR klah-klart.
SELECT-OPTIONS: s_atinn FOR cabn-atinn NO INTERVALS NO-EXTENSION.
The match code of s_atinn need to depend on the match code of s_klart. Until now i`ve seen only dependency between select-option and a parameter.
Have a great day! Please see my code below :
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,
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
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
matnr TYPE mara-matnr,"clobjekte-objekt,"mara-matnr, Structură transfer: obiecte clasificate
werks TYPE marc-werks, " unitate logistica
mtart TYPE mara-mtart, " cont material
maktx TYPE makt-maktx, "Descriere material
matkl TYPE t023t-matkl,
END OF type_final.
TYPES:BEGIN OF type_marc,
matnr TYPE MARC-matnr,
werks TYPE marc-werks,
END OF type_marc.
TYPES:BEGIN OF type_mara,
matnr TYPE mara-matnr, "cod material
mtart TYPE mara-mtart, " cont material
matkl TYPE mara-matkl, " grup material
END OF type_mara.
TYPES:BEGIN OF type_t023t,
matkl TYPE t023t-matkl, " grup material
END OF type_t023t.
*Ranges
DATA:ra_matnr TYPE RANGE OF makt-matnr.
"DATA:ra_matnr TYPE RANGE OF mara-matnr.
*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_t023t TYPE type_t023t.
"DATA:wa_werks LIKE LINE OF ra_werks.
"DATA:wa_TY_MARC_MARA_MAKT TYPE TY_MARC_MARA_MAKT.
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_t023t TYPE STANDARD TABLE OF type_t023t.
"DATA:i_TY_MARC_MARA_MAKT TYPE STANDARD TABLE OF TY_MARC_MARA_MAKT.
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: gwa_atinn TYPE type_final, "atinn sau atnam?
gt_atinn TYPE TABLE OF type_final. "atinn sau atnam?
DATA: gt_return TYPE TABLE OF ddshretval,
gwa_return TYPE ddshretval.
DATA: gwa_dynpfields TYPE dynpread,
gt_dynpfields TYPE TABLE OF dynpread.
DATA: gv_klart TYPE klah-klart.
* ALV data declarations
data: it_sortcat type slis_sortinfo_alv occurs 1,
wa_sort like line of it_sortcat.
DATA: it_filter TYPE slis_t_filter_alv.
Data: ls_filter TYPE slis_filter_alv.
*selection screen
SELECT-OPTIONS: s_klart FOR klah-klart,"Tip clasa NO INTERVALS NO-EXTENSION
s_class FOR klah-class OBLIGATORY MATCHCODE OBJECT clas DEFAULT 'Z_MEDIU'."Nume clasa NO INTERVALS NO-EXTENSION
SELECT-OPTIONS: s_matkl FOR mara-matkl. "Grup Material
SELECT-OPTIONS: s_mtart 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.
SELECT matnr werks
FROM marc
INTO TABLE i_marc WHERE matnr IN s_matnr.
IF NOT i_marc[] IS INITIAL.
SELECT matnr
mtart
matkl
FROM mara INTO TABLE i_mara
FOR ALL ENTRIES IN i_marc
WHERE matnr = i_marc-matnr
AND mtart IN s_mtart
AND matkl IN s_matkl.
ENDIF.
IF NOT i_mara[] IS INITIAL.
SELECT matnr
maktx
FROM makt INTO TABLE i_makt1
FOR ALL ENTRIES IN i_mara
WHERE matnr = i_mara-matnr AND
spras = sy-langu.
ENDIF.
IF NOT i_mara[] IS INITIAL.
SELECT matkl
FROM t023t
INTO TABLE i_t023t
FOR ALL ENTRIES IN i_mara
WHERE matkl = i_mara-matkl AND
spras = sy-langu.
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.
"and klart IN s_klart.
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.
ENDIF.
IF i_final[] IS NOT INITIAL.
perform build_sortcat.
PERFORM build_field_catalouge.
Refresh it_filter.
ls_filter-fieldname = 'MTART'.
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 build_sortcat
*&----------------------------------------------------------*
* Build Sort catalog
*-----------------------------------------------------------*
FORM build_sortcat.
wa_sort-spos = 1.
wa_sort-fieldname = 'MATNR'.
wa_sort-SUBTOT = 'X'. "subtotals any totals column by this field
* gd_sortcat-tabname
APPEND wa_sort TO it_sortcat.
ENDFORM. " build_sortcat
*&---------------------------------------------------------------------*
*& 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 s_matnr[] IS INITIAL.
* IF wa_objects-objekt not IN s_matnr[].
* CONTINUE.
* ENDIF.
* 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_objects2 TYPE mara-matnr.
wa_final-matnr = 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 = '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.
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_sort = it_sortcat
it_filter = it_filter
TABLES
t_outtab = i_final[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " DISPLAY_DATA