使用 ABAP 代码解析一个 class 的所有方法
生活随笔
收集整理的這篇文章主要介紹了
使用 ABAP 代码解析一个 class 的所有方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
效果如下:
使用 F4 value help 選定一個 ABAP class:
然后在第二個字段繼續使用 F4 help:
能提取出除了 CONSTRUCTOR 和 CLASS_CONSTRUCTOR 在內的其他方法。
源代碼:
REPORT ztest MESSAGE-ID rcdj_msg.TYPE-POOLS abap.DATA: ls_mtdkey TYPE seocmpkey,lt_parameter TYPE seos_parameters_r,ls_parameter TYPE seos_parameter_r,lt_ptab TYPE abap_parmbind_tab,ls_ptab_line TYPE abap_parmbind,new_table TYPE REF TO data,new_line TYPE REF TO data,wa_it_fldcatg TYPE lvc_s_fcat,lt_fldcatg TYPE lvc_t_fcat,lt_fldcatg_all TYPE lvc_t_fcat,lv_exc_ref TYPE REF TO cx_sy_dyn_call_error,lv_exc_text TYPE string,lv_dtelem TYPE dd03l-rollname,lv_meth TYPE string,lv_class TYPE string,lt_etab TYPE abap_excpbind_tab,ls_comp TYPE REF TO cl_abap_typedescr,lv_flname TYPE string,o_ref TYPE REF TO data,lv_methtyp TYPE vseomethod.FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,<l_line> TYPE any,<lt_table> TYPE STANDARD TABLE,<lt_line> TYPE any,<lt_field> TYPE any.TYPES: BEGIN OF lt_ref ,col_name TYPE string,col_val TYPE string,END OF lt_ref.DATA: lt_alv TYPE STANDARD TABLE OF lt_ref,lt_alv_tmp TYPE STANDARD TABLE OF lt_ref,ls_alv LIKE LINE OF lt_alv.DATA: BEGIN OF lt_index OCCURS 0,col_name TYPE string,col_index TYPE i,END OF lt_index. DATA ls_index LIKE LINE OF lt_index. DATA lt_index_tmp LIKE TABLE OF lt_index.DATA lt_string TYPE TABLE OF string. DATA: ls_string LIKE LINE OF lt_string.DATA: lo_obj TYPE REF TO object. DATA lv_count TYPE i. DATA lv_count_tmp TYPE i.DATA: gv_okcode TYPE sy-ucomm.DATA gref_alv_fuzz TYPE REF TO cl_gui_alv_grid. DATA gref_fuzz_cont TYPE REF TO cl_gui_custom_container.DATA: lv_line TYPE string,lt_line TYPE TABLE OF string.DATA gv_continue TYPE c.********************************************************************************SELECTION-SCREEN BEGIN OF BLOCK xyz WITH FRAME TITLE text-001. PARAMETERS: p_class TYPE seoclsname,p_method TYPE seomtdname,p_count TYPE i. SELECTION-SCREEN END OF BLOCK xyz.AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_class.PERFORM f4_class.AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_method.PERFORM f4_meth.AT SELECTION-SCREEN ON p_class.PERFORM val_class.AT SELECTION-SCREEN ON p_method.PERFORM val_meth.********************************************************************************START-OF-SELECTION.IF p_class IS INITIAL.MESSAGE s005.EXIT.ENDIF.IF p_method IS INITIAL.MESSAGE s006.EXIT.ENDIF.IF p_count IS INITIAL.MESSAGE s007.EXIT.ENDIF.lv_class = p_class.lv_meth = p_method.**** 1ST STEP .GET META DATAPERFORM get_meta_data.**** 2ND STEP. BUILD UP THE TEST DATA.PERFORM get_test_data.**** 3RD STEP. GENERATED TEST DATA TO BE PRESENTED FOR USER ENHANCEMENTPERFORM edit_test_data.****4TH STEP GENERATE TDC,5TH STEP. DYNAMIC METHOD CALL,6TH STEP. LOG/RESULT CREATIONPERFORM save_execute_api.*************************************************************************************************** FORMS*&---------------------------------------------------------------------* *& Form F4_CLASS *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM f4_class .CALL FUNCTION 'F4_DD_ALLTYPES'EXPORTINGobject = p_classsuppress_selection = 'X'display_only = ' 'only_types_for_clifs = 'X'IMPORTINGresult = p_class.ENDFORM. " F4_CLASS*&---------------------------------------------------------------------* *& Form F4_METH *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM f4_meth .DATA:clskey TYPE seoclskey,clstype TYPE seoclstype,components TYPE REF TO if_oo_clif_components_flat,method_flat TYPE seometflat. * cpdname_ TYPE seocpdname.DATA:lt_map TYPE TABLE OF dselc,ls_map TYPE dselc.TYPES: BEGIN OF typ_mtdkey_w_descr,mtdname TYPE seomtdname,descr TYPE seodescr.TYPES END OF typ_mtdkey_w_descr.DATA: mtdkeys TYPE STANDARD TABLE OF typ_mtdkey_w_descr,mtdkey TYPE typ_mtdkey_w_descr.DATA cl_inst TYPE REF TO cl_oo_class_components_flat.PERFORM dynp_val_read.IF p_class IS INITIAL.MESSAGE e005.ENDIF.clskey-clsname = p_class.CALL FUNCTION 'SEO_CLIF_GET'EXPORTINGcifkey = clskeyversion = seoc_version_inactivestate = '0'IMPORTINGclstype = clstypeEXCEPTIONSnot_existing = 1deleted = 2model_only = 3OTHERS = 4.IF sy-subrc <> 0.MESSAGE e003.ENDIF.IF clstype = seoc_clstype_class.* ec:with enhancement_componets mitgebenCREATE OBJECT cl_instEXPORTINGclskey = clskeywith_interface_components = seox_truewith_inherited_components = seox_truewith_enhancement_components = seox_true.components ?= cl_inst.ENDIF.REFRESH mtdkeys.LOOP AT components->methods INTO method_flat.IF method_flat-exposure NE '2'. "PUBLICCONTINUE.ENDIF.IF method_flat-cpdname = 'CONSTRUCTOR' ORmethod_flat-cpdname = 'CLASS_CONSTRUCTOR' ORmethod_flat-cpdname = 'DESTRUCTOR'.CONTINUE.ENDIF.mtdkey-mtdname = method_flat-cpdname.mtdkey-descr = method_flat-descript.APPEND mtdkey TO mtdkeys.ENDLOOP.REFRESH lt_map.ls_map-dyfldname = 'P_METHOD'.ls_map-fldname = 'MTDNAME'.INSERT ls_map INTO TABLE lt_map.CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'EXPORTINGdynpprog = sy-cprogdynpnr = sy-dynnrdynprofield = 'P_METHOD'retfield = 'MTDNAME'value_org = 'S'TABLESvalue_tab = mtdkeys "lt_test_namesdynpfld_mapping = lt_map.ENDFORM. " F4_METH*&---------------------------------------------------------------------* *& Form VAL_CLASS *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM val_class .DATA:clskey TYPE seoclskey,clstype TYPE seoclstype.CHECK NOT p_class IS INITIAL.clskey-clsname = p_class.CALL FUNCTION 'SEO_CLIF_GET'EXPORTINGcifkey = clskeyversion = seoc_version_inactivestate = '0'IMPORTINGclstype = clstypeEXCEPTIONSnot_existing = 1deleted = 2model_only = 3OTHERS = 4.IF sy-subrc <> 0.MESSAGE s003.EXIT.ENDIF.ENDFORM. " VAL_CLASS *&---------------------------------------------------------------------* *& Form VAL_METH *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM val_meth .DATA:clskey TYPE seoclskey,clstype TYPE seoclstype,components TYPE REF TO if_oo_clif_components_flat,method_flat TYPE seometflat.DATA cl_inst TYPE REF TO cl_oo_class_components_flat.CHECK NOT p_class IS INITIAL.CHECK NOT p_method IS INITIAL.clskey-clsname = p_class.* ec:with enhancement_componets mitgebenCREATE OBJECT cl_instEXPORTINGclskey = clskeywith_interface_components = seox_truewith_inherited_components = seox_truewith_enhancement_components = seox_true.components ?= cl_inst.READ TABLE components->methods INTO method_flatWITH KEY cpdname = p_method.IF sy-subrc NE 0.MESSAGE s004.EXIT.ENDIF.ENDFORM. " VAL_METH*&---------------------------------------------------------------------* *& Form DYNP_VAL_READ *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM dynp_val_read .DATA:lt_dynp TYPE TABLE OF dynpread,ls_dynp TYPE dynpread.ls_dynp-fieldname = 'P_CLASS'.INSERT ls_dynp INTO TABLE lt_dynp.CALL FUNCTION 'DYNP_VALUES_READ'EXPORTINGdyname = sy-cprogdynumb = sy-dynnrTABLESdynpfields = lt_dynp.READ TABLE lt_dynp INTO ls_dynp WITH KEY fieldname = 'P_CLASS'.IF sy-subrc = 0.p_class = ls_dynp-fieldvalue.ENDIF.ENDFORM. " DYNP_VAL_READ*&---------------------------------------------------------------------* *& Module STATUS_0100 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE status_0100 OUTPUT.SET PF-STATUS '100'.SET TITLEBAR '100'. ENDMODULE. " STATUS_0100 OUTPUT*&---------------------------------------------------------------------* *& Module GET_DATA OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE get_data OUTPUT.PERFORM display_data.ENDMODULE. " GET_DATA OUTPUT*&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE user_command_0100 INPUT.*Transport of changes from ALV grid -> itabCALL METHOD gref_alv_fuzz->check_changed_data.gv_okcode = sy-ucomm.CASE gv_okcode.WHEN 'ENTER'.gv_continue = 'X'.SET SCREEN 0.LEAVE SCREEN.WHEN 'CANC'.SET SCREEN 0.LEAVE SCREEN.ENDCASE.ENDMODULE. " USER_COMMAND_0100 INPUT*&---------------------------------------------------------------------* *& Form DISPLAY_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM display_data .TYPES : cellstyles TYPE lvc_t_styl.DATA:lt_fcat TYPE lvc_t_fcat,ls_layout TYPE lvc_s_layo,lt_toolbar_exclude TYPE ui_functions.IF gref_alv_fuzz IS INITIAL.** Create the container.CREATE OBJECT gref_fuzz_contEXPORTINGcontainer_name = 'CC_FUZZER'.** create alv grid control object and link to containerCREATE OBJECT gref_alv_fuzzEXPORTINGi_parent = gref_fuzz_contEXCEPTIONSerror_cntl_create = 1error_cntl_init = 2error_cntl_link = 3error_dp_create = 4.ENDIF.** exclude toolbar buttons.PERFORM alv_exclude_toolbar CHANGING lt_toolbar_exclude.ls_layout-edit = 'X'.ls_layout-language = 'E'.** set the table for displayCALL METHOD gref_alv_fuzz->set_table_for_first_displayEXPORTINGis_layout = ls_layoutit_toolbar_excluding = lt_toolbar_excludeCHANGINGit_outtab = <lt_table>it_fieldcatalog = lt_fldcatg[]EXCEPTIONSOTHERS = 1.ENDFORM. " DISPLAY_DATA*&---------------------------------------------------------------------* *& Form ALV_EXCLUDE_TOOLBAR *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * <--P_LT_TOOLBAR_EXCLUDE text *----------------------------------------------------------------------* FORM alv_exclude_toolbar CHANGING lt_toolbar_exclude TYPE ui_functions.DATA: * lt_toolbar_exclude TYPE ui_functions,ls_toolbar_exclude LIKE LINE OF lt_toolbar_exclude.** exclude unnecesary toolbar buttons.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.APPEND ls_toolbar_exclude TO lt_toolbar_exclude. * ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_filter. * APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_maintain_variant.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_help.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_current_variant.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_graph.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_info.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_subtot.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_sum.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_mb_sum.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_check.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_refresh.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_view_crystal.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_view_excel.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_expcrdata.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_expcrdesig.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_expcrtempl.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_call_abc.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_print.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_view_lotus.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_view_grid.APPEND ls_toolbar_exclude TO lt_toolbar_exclude.ls_toolbar_exclude = cl_gui_alv_grid=>mc_fc_find_more.APPEND ls_toolbar_exclude TO lt_toolbar_exclude. * lt_toolbar_exclude_out = lt_toolbar_exclude.ENDFORM. " ALV_EXCLUDE_TOOLBAR*&---------------------------------------------------------------------* *& Form GET_META_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM get_meta_data .* get parametersls_mtdkey-clsname = p_class.ls_mtdkey-cmpname = p_method.CALL FUNCTION 'SEO_METHOD_SIGNATURE_GET'EXPORTINGmtdkey = ls_mtdkeyIMPORTINGmethod = lv_methtypparameters = lt_parameter.IF lt_parameter IS INITIAL.MESSAGE e009.ENDIF.LOOP AT lt_parameter INTO ls_parameter. " WHERE pardecltyp = 0.CALL METHOD cl_abap_typedescr=>describe_by_nameEXPORTINGp_name = ls_parameter-typeRECEIVINGp_descr_ref = ls_compEXCEPTIONStype_not_found = 1OTHERS = 2.IF sy-subrc <> 0.MESSAGE e008 WITH ls_parameter-sconame.ENDIF. * IF ls_comp->kind NE 'E'. * MESSAGE e010 WITH ls_parameter-sconame. * ENDIF.CLEAR: wa_it_fldcatg.wa_it_fldcatg-fieldname = ls_parameter-sconame.wa_it_fldcatg-datatype = ls_parameter-type.wa_it_fldcatg-intlen = ls_comp->length.wa_it_fldcatg-coltext = ls_parameter-descript.wa_it_fldcatg-outputlen = '15'.APPEND wa_it_fldcatg TO lt_fldcatg_all.IF ls_parameter-pardecltyp = 0.APPEND wa_it_fldcatg TO lt_fldcatg.ENDIF.ENDLOOP.* create table dynamically using lt_fldcatgCALL METHOD cl_alv_table_create=>create_dynamic_tableEXPORTINGit_fieldcatalog = lt_fldcatg_allIMPORTINGep_table = new_table.ASSIGN new_table->* TO <lt_table>.CREATE DATA new_line LIKE LINE OF <lt_table>.ASSIGN new_line->* TO <lt_line>.ENDFORM. " GET_META_DATA*&---------------------------------------------------------------------* *& Form GET_TEST_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM get_test_data .LOOP AT lt_parameter INTO ls_parameter WHERE pardecltyp = 0.lv_dtelem = ls_parameter-type.**************************************************************************** KRITESH,SATYA * Get data using whereused list (use FM FUZZER_WHERE_USED). Please refer ZTEST_SUR_READ_STRUCT2 * Also inside the FM,sort randomly the list of whereused list tables * so that data would be different on each time this program is executed * Note: No of data entries should be P_COUNT.CALL FUNCTION 'TEST_SUR_READ_STRUCT2'EXPORTINGdtelem = lv_dtelemIMPORTINGiref = o_ref. *****************************************************************************ASSIGN o_ref->* TO <l_table>.LOOP AT <l_table> ASSIGNING <l_line>.ls_alv-col_val = <l_line>.ls_alv-col_name = ls_parameter-sconame.APPEND ls_alv TO lt_alv.ENDLOOP.**************************************************************************** KRITESH,SATYA * Get data using randomizer (use FM FUZZER_READ_STRUCT). Please refer ZTEST_SUR_READ_STRUCT * append to lt_alv as done above*****************************************************************************ENDLOOP.* lt_alv is a itab which holds data for all the parameters. * check that all parameters have minimum 1 number of data entry. * Also keep an index table to know where data of each parameter is starting.SORT lt_alv BY col_name.REFRESH lt_index.LOOP AT lt_parameter INTO ls_parameter WHERE pardecltyp = 0.lv_flname = ls_parameter-sconame.READ TABLE lt_alv INTO ls_alvWITH KEY col_name = lv_flname.IF sy-subrc = 0.ls_index-col_name = lv_flname.ls_index-col_index = sy-tabix.APPEND ls_index TO lt_index.ELSE." one of the parameter do not have any dataREFRESH lt_alv.MESSAGE e002 WITH lv_flname.EXIT.ENDIF.lt_alv_tmp[] = lt_alv[].DELETE lt_alv_tmp WHERE col_name NE lv_flname.DESCRIBE TABLE lt_alv_tmp LINES lv_count_tmp.IF lv_count = 0.lv_count = lv_count_tmp.ENDIF.IF lv_count_tmp LT lv_count.lv_count = lv_count_tmp.ENDIF.ENDLOOP.REFRESH lt_alv_tmp.ENDFORM. " GET_TEST_DATA *&---------------------------------------------------------------------* *& Form EDIT_TEST_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM edit_test_data .CHECK lt_alv IS NOT INITIAL.* Get data into proper table structure *************************************** * DO lv_count TIMES.DO 5 TIMES. " CHANGE THIS TO ABOVE STATEMENT !!!!! THIS IS ONLY FOR TESTING PURPOSE ***************************************LOOP AT lt_parameter INTO ls_parameter WHERE pardecltyp = 0.ASSIGN COMPONENT ls_parameter-sconame OF STRUCTURE <lt_line> TO <lt_field>.CHECK sy-subrc = 0.READ TABLE lt_index INTO ls_index WITH KEY col_name = ls_parameter-sconame.IF sy-subrc = 0.READ TABLE lt_alv INTO ls_alv INDEX ls_index-col_index.IF sy-subrc = 0 AND ls_alv-col_name = ls_parameter-sconame.<lt_field> = ls_alv-col_val.ENDIF.ls_index-col_index = ls_index-col_index + 1.MODIFY lt_index FROM ls_index TRANSPORTING col_index WHERE col_name = ls_parameter-sconame.ENDIF.ENDLOOP.APPEND <lt_line> TO <lt_table>.ENDDO.* GENERATED TEST DATA TO BE PRESENTED FOR USER ENHANCEMENT* Presentation of test data in editable ALV * lt_parameter-sconames would make the columns of the ALV * Use <lt_table>CALL SCREEN 100.CHECK gv_continue = 'X'.ENDFORM. " EDIT_TEST_DATA*&---------------------------------------------------------------------* *& Form SAVE_EXECUTE_API *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM save_execute_api .IF lv_methtyp-mtddecltyp = 0. " INSTANCE METHODCREATE OBJECT lo_obj TYPE (lv_class).CHECK sy-subrc = 0.ENDIF." break thomasjee.LOOP AT <lt_table> INTO <lt_line>.**** 4TH STEP GENERATE TDC ************************************************************************* GURMEET/MOHIT * Generation of TDC with contents <lt_table> so that A.UNITS can make use of it later * DATA: lv_varaints_modified TYPE abap_bool. * * TRY. * CALL METHOD cl_rcdj_create_tdc=>modify_tdc * EXPORTING * iv_class_name = p_class * iv_method_name = p_method * iv_tdc_name = '' * it_variants = <lt_table> * IMPORTING * ev_variants_modified = lv_varaints_modified. * CATCH cx_ecatt_apl . * ENDTRY. **************************************************************************LOOP AT lt_parameter INTO ls_parameter WHERE pardecltyp = 0.ASSIGN COMPONENT ls_parameter-sconame OF STRUCTURE <lt_line> TO <lt_field> CASTING TYPE (ls_parameter-type).IF sy-subrc = 0.GET REFERENCE OF <lt_field> INTO ls_ptab_line-value.ENDIF.ls_ptab_line-name = ls_parameter-sconame.IF ls_parameter-pardecltyp = 0.ls_ptab_line-kind = cl_abap_objectdescr=>exporting.ELSEIF ls_parameter-pardecltyp = 1.ls_ptab_line-kind = cl_abap_objectdescr=>importing.ENDIF.INSERT ls_ptab_line INTO TABLE lt_ptab.CLEAR ls_ptab_line.ENDLOOP.IF lt_ptab IS INITIAL.EXIT.ENDIF.**** 5TH STEP DYNAMIC METHOD CALL ************************************************************************* SURESHTRY.IF lv_methtyp-mtddecltyp = 0.CALL METHOD lo_obj->(lv_meth) " Instance Method callPARAMETER-TABLElt_ptabEXCEPTION-TABLElt_etab .ELSEIF lv_methtyp-mtddecltyp = 1.CALL METHOD (lv_class)=>(lv_meth) " Static Method CallPARAMETER-TABLElt_ptabEXCEPTION-TABLElt_etab .ENDIF.CATCH cx_sy_dyn_call_error INTO lv_exc_ref.lv_exc_text = lv_exc_ref->get_text( ).MESSAGE lv_exc_text TYPE 'I'.ENDTRY. ****************************************************************************** 6TH STEP LOG/RESULT CREATION ************************************************************************* SURESH/KANA * Proper presentation of results of each execution. * Try having an application log for the same**************************************************************************REFRESH lt_ptab.ENDLOOP.ENDFORM. " SAVE_EXECUTE_API總結
以上是生活随笔為你收集整理的使用 ABAP 代码解析一个 class 的所有方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 女子车位被女邻居霸停数月:一怒之下 直接
- 下一篇: 拒绝流氓应用 Win11安卓子系统重磅升