Hi all, currently i have this situation where i want to check the meta data of a certain table with a particular column. I m able to check the datatype, length and primary key with the help of DNTAB structure. But i also need to check whether the particular column is a mandatory field. From the DNTAB structure i cannot find the mandatory field. So i was wondering is there a solution to this?
Below is the code i have:
DATA: BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE dntab.
DATA: END OF itab.
TYPES: BEGIN OF itab1,
FIELDNAME(14) TYPE C,
DATATYPE TYPE DD03L-DATATYPE,
PRIMARYKEY TYPE DD03L-KEYFLAG,
DATALENGTH TYPE DD03L-LENG,
*SNULL TYPE DD03L-MANDATORY,*
END OF itab1.
DATA: g_itab1 TYPE STANDARD TABLE OF itab1 WITH HEADER LINE.
DATA: wa_itab1 TYPE itab1.
REFRESH itab.
CALL FUNCTION 'NAMETAB_GET' "Fetches the fields
EXPORTING
langu = sy-langu
tabname = P_TABLE
TABLES
nametab = itab
EXCEPTIONS
no_texts_found = 1.
LOOP AT itab .
ls_alv_cat-fieldname = itab-fieldname.
ls_alv_cat-ref_table = P_TABLE.
ls_alv_cat-ref_field = itab-fieldname.
ls_alv_cat-seltext = itab-fieldtext.
ls_alv_cat-reptext = itab-fieldtext.
wa_itab1-FIELDNAME = itab-FIELDNAME.
wa_itab1-DATATYPE = itab-DATATYPE.
wa_itab1-PRIMARYKEY = itab-KEYFLAG.
wa_itab1-DATALENGTH = itab-DDLEN.
APPEND ls_alv_cat TO i_alv_cat.
APPEND wa_itab1 TO g_itab1.
fcount = fcount + 1.
ENDLOOP.
SNULL is the one i define for mandatory check. but when i put in this line of code : wa_itab1-SNULL = itab-MANDATORY.
it gave me an error saying that itab does not have this component MANDATORY.