Dann eben Tabelle DD04L lesen und die Domäne des Datenelements vor FuBa-Aufruf ermitteln.diamondo hat geschrieben:Ich will aber ein Datenelement einlesen und den Inhalt seiner Domäne(Wertebereich) ausgeben.
Lg
Code: Alles auswählen.
FuBa: SWU_GET_VALUES_TO_FIELDNAME Holt Festwerte zu einem Tabellen-/Strukturfeld
FuBa: SWU_GET_DOMNAME_TO_ROLLNAME Holt Domaine zu einem Datenelement
FuBa: SWU_GET_TABLE_TO_DOMNAME Holt Tabelle zu einer Domaine
FuBa: SWU_GET_ROLLNAME_TO_FIELDNAME Holt Datenelement zu einem Tabellen-/Strukturfeld
diamondo hat geschrieben:ibo hat geschrieben:Hi
"CS_STRUCT Changing Type ANY " das kannst du in FUBA-Schnittstelle.
Ibo
Also gehört CS_STRUCT zu meiner eigenen FuBa als Import parameter fürs Datenelement?
Code: Alles auswählen.
FUNCTION ZZ_LIES_WERTE.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" EXPORTING
*" REFERENCE(EX_WERTE) TYPE ANY
*" CHANGING
*" REFERENCE(IM_DATA) TYPE ANY
*" REFERENCE(IM_TAB) TYPE ANY
*" EXCEPTIONS
*" DATA_NICHT_GEFUNDEN
*"----------------------------------------------------------------------
DATA: lr_struct TYPE REF TO cl_abap_structdescr.
DATA lv_tab_name TYPE ddobjname.
FIELD-SYMBOLS <ls_component> TYPE any.
DATA MYTAB TYPE STANDARD TABLE OF DFIES.
DATA wa TYPE DFIES.
* Get the structure of CS_STRUCT
lr_struct ?= cl_abap_typedescr=>describe_by_data( IM_DATA ).
lv_tab_name = lr_struct->absolute_name+6.
LOOP AT lr_struct->components ASSIGNING <ls_component>.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = lv_tab_name
fieldname = <ls_component>-IM_DATA
langu = sy-langu
TABLES
dfies_tab = MYTAB
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
IF sy-subrc <> 0 OR MYTAB IS INITIAL.
CONTINUE.
ENDIF.
READ TABLE MYTAB INTO ls_dfies INDEX 1.
DATA: fv_wa TYPE dd07v,
fv_tab_a TYPE STANDARD TABLE OF dd07v,
fv_tab_n TYPE STANDARD TABLE OF dd07v.
CALL FUNCTION 'DD_DOMA_GET'
EXPORTING
domain_name = ls_dfies-domname
langu = sy-langu
withtext = 'X'
TABLES
dd07v_tab_a = fv_tab_a
dd07v_tab_n = fv_tab_n
EXCEPTIONS
illegal_value = 1
op_failure = 2
OTHERS = 3.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
" hier kriegst du alles Festwerte,
" die existieren in dieser Tabelle lt_dd07v.
"
ENDLOOP.
Code: Alles auswählen.
lr_struct ?= cl_abap_typedescr=>describe_by_data( IM_DATA ).
lv_tab_name = lr_struct->absolute_name+6.
Code: Alles auswählen.
fieldname = <ls_component>-IM_DATA
Code: Alles auswählen.
FUNCTION swu_get_values_to_fieldname.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(LANGUAGE) LIKE SY-LANGU DEFAULT SY-LANGU
*" VALUE(FIELD)
*" VALUE(VALUE) OPTIONAL
*" EXPORTING
*" VALUE(EX_G07TAB) TYPE DD07V
*" TABLES
*" G07TAB STRUCTURE DD07V OPTIONAL
*" EXCEPTIONS
*" FIELD_NOT_FOUND
*" VALUES_NOT_FOUND
*"----------------------------------------------------------------------
* begin of local data definition
DATA: rollname LIKE dd03l-rollname,
domname LIKE dd04l-domname,
l_value TYPE domvalue_l.
* end of local data definition
* casting
l_value = value.
** get rollname
* CALL FUNCTION 'SWU_GET_ROLLNAME_TO_FIELDNAME'
* EXPORTING
* field = field
* IMPORTING
* rollname = rollname
* EXCEPTIONS
* field_not_found = 01.
* IF sy-subrc NE 0.
* RAISE field_not_found.
* ENDIF.
*
** get domaine
* CALL FUNCTION 'SWU_GET_DOMNAME_TO_ROLLNAME'
* EXPORTING
* rollname = rollname
* IMPORTING
* domname = domname
* EXCEPTIONS
* rollname_not_found = 01.
* IF sy-subrc NE 0.
* RAISE field_not_found.
* ENDIF.
* --- OSS note 1374211 ---
* CALL FUNCTION 'SWU_GET_DOMNAME_TO_FIELDNAME'
* EXPORTING
* FIELD = field
* IMPORTING
* DOMNAME = domname
* EXCEPTIONS
* OTHERS = 01.
*
* IF SY-SUBRC <> 0.
* RAISE field_not_found.
* ENDIF.
*
** get values
* CALL FUNCTION 'SWU_GET_TABLE_TO_DOMNAME'
* EXPORTING
* domname = domname
* language = language
* TABLES
* g07tab = g07tab
* EXCEPTIONS
* internal_error = 01.
* IF sy-subrc NE 0.
* RAISE values_not_found.
* ENDIF.
* --- note 1961034 use buffered access ---
data lh_elem type ref to CL_ABAP_ELEMDESCR.
data lh_type type ref to CL_ABAP_TYPEDESCR.
data lt_values type DDFIXVALUES.
data ls_values type DDFIXVALUE.
data l_DFIES type DFIES.
data l_DD07V type DD07V.
call method CL_ABAP_TYPEDESCR=>describe_by_name
exporting
P_NAME = field
receiving
P_DESCR_REF = lh_type
exceptions
others = 1.
IF sy-subrc NE 0.
RAISE field_not_found.
ENDIF.
if lh_type is bound and
lh_type->KIND = CL_ABAP_TYPEDESCR=>KIND_ELEM .
lh_elem ?= lh_type.
call method lh_elem->GET_DDIC_FIXED_VALUES
exporting
P_LANGU = language
receiving
P_FIXED_VALUES = lt_values
exceptions
others = 1.
IF sy-subrc NE 0 or lt_values[] is initial.
RAISE values_not_found.
ENDIF.
call method lh_elem->GET_DDIC_FIELD
exporting
P_LANGU = language
receiving
P_FLDDESCR = l_DFIES
exceptions
others = 0.
l_DD07V-DOMNAME = l_DFIES-domname.
l_DD07V-VALPOS = '0000'.
l_DD07V-DDLANGUAGE = language.
loop at lt_values into ls_values.
add 1 to l_DD07V-VALPOS .
l_DD07V-DOMVALUE_L = ls_values-low.
l_DD07V-DOMVALUE_H = ls_values-high.
l_DD07V-DDTEXT = ls_values-ddtext.
append l_DD07V to g07tab.
endloop.
else.
RAISE field_not_found.
endif.
* --- end of note 1961034 ---
* get line
IF value IS SUPPLIED.
DELETE g07tab WHERE domvalue_l NE l_value.
READ TABLE g07tab INDEX 1 INTO ex_g07tab.
ENDIF.
ENDFUNCTION.