While working on the ABAP CDS Development, It is a common practice that uses the Where-used-list of CDS views so that if we are making any change in a CDS then we can expect how many CDS views might get impacted. So thought of building ABAP program where we can do more things than Where-used-list like getting the object-flow upwards and object-flow downwards. So we had built an ABAP program that would give the object flow of a given the CDS view, which pretty similar to the SAP BW Dataflow diagram feature.
I took I_SALESORDERITEMCUBE for displaying the CDS(s) which were used with option Object Flow down
*&---------------------------------------------------------------------*
*& Report YCDS_OBJECTFLOW
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT YCDS_OBJECTFLOW.
PARAMETERS: P_UP RADIOBUTTON GROUP G1,
P_DOWN RADIOBUTTON GROUP G1.
PARAMETERS: P_TAB TYPE DDLNAME.
TYPES: BEGIN OF TY_OUTPUT,
DDLSOURCENAME TYPE DDSTRUCOBJNAME,
DDTEXT TYPE DDTEXT,
VIEWNAME TYPE VIEWNAME,
TABNAME TYPE TABNAME,
END OF TY_OUTPUT.
TYPES: BEGIN OF TY_DISP,
DDLSOURCENAME TYPE DDSTRUCOBJNAME,
DDTEXT TYPE DDTEXT,
DATACATEGORY(20) TYPE C,
QUERY(20) TYPE C,
END OF TY_DISP.
DATA: IT_OUTPUT TYPE STANDARD TABLE OF TY_OUTPUT.
DATA: WA_OUTPUT TYPE TY_OUTPUT.
DATA: IT_OUTPUT_DOWN TYPE STANDARD TABLE OF TY_OUTPUT.
DATA: WA_OUTPUT_DOWN TYPE TY_OUTPUT.
DATA: wa_layout TYPE slis_layout_alv.
DATA: gt_fldcat TYPE slis_t_fieldcat_alv.
DATA: V_TAB TYPE DDLNAME.
DATA: V_NAME TYPE OBJECTNAME.
DATA: IT_DISP TYPE STANDARD TABLE OF TY_DISP.
DATA: WA_DISP TYPE TY_DISP.
DATA: IT_DDHEADANNO TYPE STANDARD TABLE OF DDHEADANNO.
DATA: WA_DDHEADANNO TYPE DDHEADANNO.
DATA: IT_DD02T TYPE STANDARD TABLE OF DD02T.
DATA: WA_DD02T TYPE DD02T.
IF P_UP IS NOT INITIAL.
*********************UPWARD FLOW***********************************
SELECT SINGLE SQLVIEWNAME INTO V_NAME
FROM CDSSQLVIEW
WHERE DDLSOURCENAME = P_TAB.
IF SY-SUBRC = 0.
V_TAB = V_NAME.
ELSE.
V_TAB = P_TAB.
ENDIF.
SELECT DDLSOURCENAME
DDTEXT
VIEWNAME
TABNAME
FROM CDSSQLVIEW as a INNER JOIN DD26I as b
ON a~SQLVIEWNAME = b~VIEWNAME
INNER JOIN DDDDLSRCT as c
ON a~DDLSOURCENAME = c~DDLNAME
INTO TABLE IT_OUTPUT
WHERE TABNAME = V_TAB AND
DDLANGUAGE = 'E'.
IF IT_OUTPUT[] IS NOT INITIAL.
SELECT STRUCOBJN
NAME
POSITION
VALUE
FROM DDHEADANNO
INTO TABLE IT_DDHEADANNO
FOR ALL ENTRIES IN IT_OUTPUT
WHERE STRUCOBJN = IT_OUTPUT-DDLSOURCENAME AND
( NAME = 'ANALYTICS.QUERY' OR
NAME = 'ANALYTICS.DATACATEGORY' ).
SORT IT_DDHEADANNO BY STRUCOBJN.
ENDIF.
PERFORM PREPARE_DISPLAY.
REFRESH gt_fldcat[].
PERFORM field_catalogue TABLES gt_fldcat USING:
'1' 'DDLSOURCENAME' 'IT_DISP' '20' text-001 'X',
'2' 'DDTEXT' 'IT_DISP' '60' text-002 '',
'3' 'DATACATEGORY' 'IT_DISP' '20' text-003 '',
'4' 'QUERY' 'IT_DISP' '20' text-004 ''.
PERFORM DISPLAY_OUTPUT.
*****************END OF UPWARD FLOW***********************************
ELSEIF P_DOWN IS NOT INITIAL.
SELECT DDLSOURCENAME
DDTEXT
VIEWNAME
TABNAME
FROM CDSSQLVIEW as a INNER JOIN DD26I as b
ON a~SQLVIEWNAME = b~VIEWNAME
INNER JOIN DDDDLSRCT as c
ON a~DDLSOURCENAME = c~DDLNAME
INTO TABLE IT_OUTPUT_DOWN
WHERE DDLSOURCENAME = P_TAB AND
DDLANGUAGE = 'E'..
REFRESH IT_OUTPUT[].
LOOP AT IT_OUTPUT_DOWN INTO WA_OUTPUT_DOWN.
CLEAR WA_OUTPUT.
SELECT SINGLE DDLSOURCENAME
DDTEXT
VIEWNAME
TABNAME
FROM CDSSQLVIEW as a INNER JOIN DD26I as b
ON a~SQLVIEWNAME = b~VIEWNAME
INNER JOIN DDDDLSRCT as c
ON a~DDLSOURCENAME = c~DDLNAME
INTO WA_OUTPUT
WHERE VIEWNAME = WA_OUTPUT_DOWN-TABNAME AND
DDLANGUAGE = 'E'.
IF SY-SUBRC = 0.
APPEND WA_OUTPUT TO IT_OUTPUT.
ELSE.
CLEAR WA_OUTPUT.
SELECT SINGLE TABNAME
DDLANGUAGE
AS4LOCAL
AS4VERS
DDTEXT
FROM DD02T
INTO WA_DD02T
WHERE TABNAME = WA_OUTPUT_DOWN-TABNAME AND
DDLANGUAGE = 'E' AND
AS4LOCAL = 'A'.
IF SY-SUBRC = 0.
WA_OUTPUT-DDLSOURCENAME = WA_DD02T-TABNAME.
WA_OUTPUT-DDTEXT = WA_DD02T-DDTEXT.
APPEND WA_OUTPUT TO IT_OUTPUT.
ENDIF.
ENDIF.
ENDLOOP.
PERFORM PREPARE_DISPLAY.
REFRESH gt_fldcat[].
PERFORM field_catalogue TABLES gt_fldcat USING:
'1' 'DDLSOURCENAME' 'IT_DISP' '20' text-005 'X',
'2' 'DDTEXT' 'IT_DISP' '60' text-002 '',
'3' 'DATACATEGORY' 'IT_DISP' '20' text-003 '',
'4' 'QUERY' 'IT_DISP' '20' text-004 ''.
PERFORM DISPLAY_OUTPUT.
ENDIF.
FORM field_catalogue TABLES p_gt_fldcat LIKE gt_fldcat
USING p_column
p_field
p_table
p_length
p_text
p_hot.
* Local work area for field cat
DATA: lwa_fieldcat TYPE slis_fieldcat_alv.
* Clearing workarea
CLEAR: lwa_fieldcat.
* Fill I_fieldcat
lwa_fieldcat-col_pos = p_column.
lwa_fieldcat-fieldname = p_field.
lwa_fieldcat-tabname = p_table.
lwa_fieldcat-outputlen = p_length.
lwa_fieldcat-seltext_l = p_text.
lwa_fieldcat-emphasize = p_hot.
APPEND lwa_fieldcat TO p_gt_fldcat.
ENDFORM. " field_catalogue
FORM user_command USING
p_ucomm LIKE sy-ucomm
p_rs_selfield TYPE slis_selfield.
DATA: V_DUMMY TYPE DDLNAME.
IF p_rs_selfield-SEL_TAB_FIELD = 'IT_DISP-DDLSOURCENAME'.
*********************UPWARD FLOW***********************************
IF P_UP IS NOT INITIAL.
SELECT SINGLE SQLVIEWNAME INTO V_NAME
FROM CDSSQLVIEW
WHERE DDLSOURCENAME = P_RS_SELFIELD-VALUE.
IF SY-SUBRC = 0.
V_TAB = V_NAME.
ELSE.
V_TAB = P_RS_SELFIELD-VALUE.
ENDIF.
SELECT DDLSOURCENAME
DDTEXT
VIEWNAME
TABNAME
FROM CDSSQLVIEW as a INNER JOIN DD26I as b
ON a~SQLVIEWNAME = b~VIEWNAME
INNER JOIN DDDDLSRCT as c
ON a~DDLSOURCENAME = c~DDLNAME
INTO TABLE IT_OUTPUT
WHERE TABNAME = V_TAB AND
DDLANGUAGE = 'E'.
IF IT_OUTPUT[] IS NOT INITIAL.
SELECT STRUCOBJN
NAME
POSITION
VALUE
FROM DDHEADANNO
INTO TABLE IT_DDHEADANNO
FOR ALL ENTRIES IN IT_OUTPUT
WHERE STRUCOBJN = IT_OUTPUT-DDLSOURCENAME AND
( NAME = 'ANALYTICS.QUERY' OR
NAME = 'ANALYTICS.DATACATEGORY' ).
SORT IT_DDHEADANNO BY STRUCOBJN.
ENDIF.
PERFORM PREPARE_DISPLAY.
REFRESH gt_fldcat[].
PERFORM field_catalogue TABLES gt_fldcat USING:
'1' 'DDLSOURCENAME' 'IT_DISP' '20' text-001 'X',
'2' 'DDTEXT' 'IT_DISP' '60' text-002 '',
'3' 'DATACATEGORY' 'IT_DISP' '20' text-003 '',
'4' 'QUERY' 'IT_DISP' '20' text-004 ''.
PERFORM DISPLAY_OUTPUT.
****************END OF UPWARD FLOW***********************************
ELSEIF P_DOWN IS NOT INITIAL.
SELECT DDLSOURCENAME
DDTEXT
VIEWNAME
TABNAME
FROM CDSSQLVIEW as a INNER JOIN DD26I as b
ON a~SQLVIEWNAME = b~VIEWNAME
INNER JOIN DDDDLSRCT as c
ON a~DDLSOURCENAME = c~DDLNAME
INTO TABLE IT_OUTPUT_DOWN
WHERE DDLSOURCENAME = P_RS_SELFIELD-VALUE AND
DDLANGUAGE = 'E'.
REFRESH IT_OUTPUT[].
LOOP AT IT_OUTPUT_DOWN INTO WA_OUTPUT_DOWN.
CLEAR WA_OUTPUT.
SELECT SINGLE DDLSOURCENAME
DDTEXT
VIEWNAME
TABNAME
FROM CDSSQLVIEW as a INNER JOIN DD26I as b
ON a~SQLVIEWNAME = b~VIEWNAME
INNER JOIN DDDDLSRCT as c
ON a~DDLSOURCENAME = c~DDLNAME
INTO WA_OUTPUT
WHERE VIEWNAME = WA_OUTPUT_DOWN-TABNAME AND
DDLANGUAGE = 'E'.
IF SY-SUBRC = 0.
APPEND WA_OUTPUT TO IT_OUTPUT.
ELSE.
CLEAR WA_OUTPUT.
SELECT SINGLE TABNAME
DDLANGUAGE
AS4LOCAL
AS4VERS
DDTEXT
FROM DD02T
INTO WA_DD02T
WHERE TABNAME = WA_OUTPUT_DOWN-TABNAME AND
DDLANGUAGE = 'E' AND
AS4LOCAL = 'A'.
IF SY-SUBRC = 0.
WA_OUTPUT-DDLSOURCENAME = WA_DD02T-TABNAME.
WA_OUTPUT-DDTEXT = WA_DD02T-DDTEXT.
APPEND WA_OUTPUT TO IT_OUTPUT.
ENDIF.
ENDIF.
ENDLOOP.
PERFORM PREPARE_DISPLAY.
REFRESH gt_fldcat[].
PERFORM field_catalogue TABLES gt_fldcat USING:
'1' 'DDLSOURCENAME' 'IT_DISP' '20' text-005 'X',
'2' 'DDTEXT' 'IT_DISP' '60' text-002 '',
'3' 'DATACATEGORY' 'IT_DISP' '20' text-003 '',
'4' 'QUERY' 'IT_DISP' '20' text-004 ''.
PERFORM DISPLAY_OUTPUT.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DISPLAY_OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_OUTPUT .
IF IT_OUTPUT[] IS INITIAL.
MESSAGE 'NO MORE Drilldown' TYPE 'I'.
ELSE.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = gt_fldcat[]
IS_LAYOUT = wa_layout
TABLES
T_OUTTAB = IT_DISP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form PREPARE_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PREPARE_DISPLAY .
REFRESH IT_DISP[].
LOOP AT IT_OUTPUT INTO WA_OUTPUT.
WA_DISP-DDLSOURCENAME = WA_OUTPUT-DDLSOURCENAME.
WA_DISP-DDTEXT = WA_OUTPUT-DDTEXT.
CLEAR WA_DDHEADANNO.
READ TABLE IT_DDHEADANNO INTO WA_DDHEADANNO WITH
KEY STRUCOBJN = WA_OUTPUT-DDLSOURCENAME
NAME = 'ANALYTICS.DATACATEGORY'
BINARY SEARCH.
WA_DISP-DATACATEGORY = WA_DDHEADANNO-VALUE.
CLEAR WA_DDHEADANNO.
READ TABLE IT_DDHEADANNO INTO WA_DDHEADANNO WITH
KEY STRUCOBJN = WA_OUTPUT-DDLSOURCENAME
NAME = 'ANALYTICS.QUERY'
BINARY SEARCH.
WA_DISP-QUERY = WA_DDHEADANNO-VALUE.
APPEND WA_DISP TO IT_DISP.
ENDLOOP.
ENDFORM.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 |