If clicking on First Radio Button,
Table name should be pass in parameter
The Fields Should display related to table
- Table Name
- Field Name
- Data Element
- Value Table
If clicking on Second Radio Button,
Structure name should be pass in parameter
The Fields Should display related to table
- Table Name
- Field Name
- Data Element
- Value Table
If clicking on Third Radio Button,
Two Parameters should be there, the first parameter should given table/structure name, second parameter should be field name related to first parameter field (table/structure), Then Fields Should display related to table
- Table Name
- Field Name
- Data Element
- Value Table
Validations:
- Passing Of Wrong parameter data, should throw an message
- Leaving Blank & execute, should throw an message
ABAP Concepts Need To use:
- RTTS
- ALV
Building Of Report
Note:
I Used 8 Includes:
First INCLUDE: Z_DATA.
(Defining Parameters, Data & Field Symbol)
PARAMETERS: p_rb1 RADIOBUTTON GROUP rg DEFAULT 'X' USER-COMMAND rbg,
p_rb2 RADIOBUTTON GROUP rg,
p_rb3 RADIOBUTTON GROUP rg.
PARAMETERS: p_var3 TYPE dd03l-tabname MODIF ID rb1,
p_var4 TYPE dd02l-tabname MODIF ID rb2.
TYPES: BEGIN OF ty_dd03l,
tabname TYPE dd03l-tabname,
fieldname TYPE dd03l-fieldname,
rollname TYPE dd03l-rollname, "Data element
entitytab TYPE dd04l-entitytab, "Value table
END OF ty_dd03l,
BEGIN OF ty_dd04l,
rolname TYPE dd04l-rollname,
entitytab TYPE dd04l-entitytab,
END OF ty_dd04l.
DATA: gt_dd03l TYPE STANDARD TABLE OF ty_dd03l,
gt_dd04l TYPE STANDARD TABLE OF ty_dd04l.
DATA: lo_temp_table TYPE REF TO cl_abap_tabledescr,
lo_ty_struct TYPE REF TO cl_abap_structdescr,
lo_ref_final_table TYPE REF TO data.
FIELD-SYMBOLS: <fs_table> TYPE ANY TABLE.
Second INCLUDE: ZRB_OPE.
(Radio Button Logic (AT SELECTION-SCREEN OUTPUT))
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF p_rb1 IS NOT INITIAL.
IF screen-group1 EQ 'RB2'.
screen-active = 0.
IF screen-group1 EQ 'RB1'.
screen-active = 1.
ENDIF.
ENDIF.
ELSEIF p_rb2 IS NOT INITIAL.
IF screen-group1 EQ 'RB2'.
screen-active = 0.
IF screen-group1 EQ 'RB1'.
screen-active = 1.
ENDIF.
ENDIF.
ELSEIF p_rb3 IS NOT INITIAL.
IF screen-group1 EQ 'RB1'.
screen-active = 1.
IF screen-group1 EQ 'RB2'.
screen-active = 1.
ENDIF.
ENDIF.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
Third INCLUDE: ZDATA_RTTS_OPE.
(RTTS - Defining Operation of Data (START-OF-SELECTION))
START-OF-SELECTION.
lo_temp_table =
CAST cl_abap_tabledescr(
cl_abap_tabledescr=>describe_by_data( p_data = gt_dd03l )
).
lo_ty_struct ?= lo_temp_table->get_table_line_type( ).
DATA(p_table_comp) = lo_ty_struct->get_components( ).
CREATE DATA lo_ref_final_table TYPE HANDLE lo_temp_table.
ASSIGN lo_ref_final_table->* TO <fs_table>.
Fourth INCLUDE: ZCL_DEF_RB_TOPE.
(Assigning Class Definition)
CLASS cl_main DEFINITION.
PUBLIC SECTION.
METHODS: lm_table,
lm_structure,
lm_field.
ENDCLASS.
Fifth INCLUDE: ZCL_IMP_TB..
(Radio Button 01 - Table Operation)
CLASS cl_main IMPLEMENTATION.
METHOD lm_table.
IF p_rb1 = abap_true.
IF p_var3 IS INITIAL.
MESSAGE ID 'zso_msg' TYPE 'I' NUMBER '001'.
ELSE.
SELECT * FROM dd02l INTO TABLE @DATA(gt_temp2) WHERE tabname = @p_var3 AND tabclass = 'TRANSP'.
IF sy-subrc = 0.
SELECT dd03l~tabname,
dd03l~fieldname,
dd03l~rollname,
dd04l~entitytab
INTO TABLE @<fs_table>
FROM dd03l INNER JOIN dd04l
ON dd03l~rollname = dd04l~rollname
WHERE tabname = @p_var3.
LOOP AT gt_dd03l ASSIGNING FIELD-SYMBOL(<fs_abc3>).
IF <fs_abc3>-entitytab IS INITIAL.
<fs_abc3>-entitytab = 'N/A'.
ENDIF.
ENDLOOP.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = DATA(lo_alv)
CHANGING
t_table = <fs_table>.
CATCH cx_salv_msg INTO DATA(lo_exception).
DATA(lv_msg) = lo_exception->get_text( ).
ENDTRY.
lo_alv->display( ).
ELSE.
MESSAGE 'Input is not valid' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
Sixth INCLUDE: ZCL_IMP_STR.
(Radio Button 02 - Structure Operation)
METHOD lm_structure.
IF p_rb2 = abap_true.
IF p_var3 IS INITIAL.
MESSAGE 'Structure Name Is Required' TYPE 'S' DISPLAY LIKE 'E'.
ELSE.
SELECT * FROM dd02l INTO TABLE @DATA(gt_temp2) WHERE tabname = @p_var3 AND tabclass = 'INTTAB'.
IF sy-subrc = 0.
SELECT dd03l~tabname,dd03l~fieldname,dd03l~rollname,dd04l~entitytab
INTO TABLE @gt_dd03l
FROM dd03l INNER JOIN dd04l
ON dd03l~rollname = dd04l~rollname
WHERE tabname = @p_var3.
LOOP AT gt_dd03l ASSIGNING FIELD-SYMBOL(<fs_abc1>).
IF <fs_abc1>-entitytab IS INITIAL.
<fs_abc1>-entitytab = 'N/A'.
ENDIF.
ENDLOOP.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = DATA(lo_alv)
CHANGING
t_table = gt_dd03l.
CATCH cx_salv_msg INTO DATA(lo_exception).
DATA(lv_msg) = lo_exception->get_text( ).
ENDTRY.
lo_alv->display( ).
ELSE.
MESSAGE 'Input is not valid' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
Seventh INCLUDE: ZCL_IMP_TB_ST_FD.
(Radio Button 03 - Table/Structure + Field Operation)
METHOD lm_field.
IF p_rb3 = abap_true.
IF p_var3 IS INITIAL.
MESSAGE 'Table/Strucure Name is required' TYPE 'S' DISPLAY LIKE 'E'.
ELSEIF p_var4 IS INITIAL.
MESSAGE 'Field is required related to Table/Strucure' TYPE 'S' DISPLAY LIKE 'E'.
ELSE.
SELECT * FROM dd03l INTO TABLE @DATA(gt_data) WHERE tabname = @p_var3 AND fieldname = @p_var4.
IF sy-subrc = 0.
SELECT dd03l~tabname,dd03l~fieldname,dd03l~rollname,dd04l~entitytab
INTO TABLE @gt_dd03l
FROM dd03l INNER JOIN dd04l
ON dd03l~rollname = dd04l~rollname
WHERE tabname = @p_var3 AND fieldname = @p_var4.
LOOP AT gt_dd03l ASSIGNING FIELD-SYMBOL(<fs_abc2>).
IF <fs_abc2>-entitytab IS INITIAL.
<fs_abc2>-entitytab = 'N/A'.
ENDIF.
ENDLOOP.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = DATA(lo_alv)
CHANGING
t_table = gt_dd03l.
CATCH cx_salv_msg INTO DATA(lo_exception).
DATA(lv_msg) = lo_exception->get_text( ).
ENDTRY.
lo_alv->display( ).
ELSE.
MESSAGE 'Input is not valid' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
ENDCLASS.
Eigth INCLUDE: ZCL_OP.
(Class Implementation Result O/P Data (START-OF-SELECTION))
START-OF-SELECTION.
DATA(lo_rttc) = NEW cl_main( ).
lo_rttc->lm_table( ).
lo_rttc->lm_structure( ).
lo_rttc->lm_field( ).
Thank You :)
Top comments (0)