Signature of a function module | Exception class |
FUNCTION zjg_fm1_1. *"------------------------------------------------------------ *" IMPORTING *" REFERENCE(IV_GUID) *" TYPE GUID_16 *" DEFAULT '1234567812345678' *" REFERENCE(IF_FLAG) TYPE CHAR_01 *" TABLES *" RETURN STRUCTURE BAPIRET2 *" EXCEPTIONS *" NOT_FOUND *" SOME_ERROR *"------------------------------------------------------------ |
|
Function Group | Interface |
in top include
|
|
class zjg_cl_new definition public create private final.
public section.
interfaces zjg_if_new.
class-methods: s_get_instance
returning
value(rr_instance) type ref to zjg_if_new.
private section.
data sr_instance type ref to zjg_cl_new.
endclass.
class zjg_cl_new implementation.
method s_get_instance.
if sr_instance is not bound.
sr_instance = new zjg_cl_new( ).
endif.
rr_instance = sr_instance.
endmethod.
method zjg_if_new~send_message_for_contract.
...do something
endmethod.
endclass.
Class zjg_cl_new definition public create private final.
public section.
interfaces zjg_if_new.
class-methods: s_get_instance returning value(rr_instance) type ref to zjg_if_new.
endclass.
class zjg_cl_new implementation.
method s_get_instance.
rr_instance = sr_instance.
endmethod.
method zjg_if_new~send_message_for_contract.
...do something
endmethod.
endclass.
Function Module | Signature |
zjg_fm1_set_buffer | FUNCTION zjg_fm1_set_buffer. |
zjg_fm1_1. | FUNCTION zjg_fm1_1. *" IMPORTING *" REFERENCE(IV_GUID) TYPE GUID_16 DEFAULT '1234567812345678' *" REFERENCE(IV_FLAG) TYPE CHAR_01 *" TABLES *" RETURN STRUCTURE BAPIRET2 *" EXCEPTIONS *" NOT_FOUND *" SOME_ERROR |
zjg_fm2 | FUNCTION zjg_fm2. *" IMPORTING *" REFERENCE(IV_GUID) TYPE GUID_16 *" EXPORTING *" REFERENCE(RV_SUCCESS_FLAG) TYPE CHAR_01 |
Local interface Method definition | Local class Method implementation | Adaptions to the newly created class |
LIF_DOC | LCL_DOC | ZJG_CL_NEW |
CLASS lcl_doc DEFINITION. PUBLIC SECTION. INTERFACES lif_doc. ENDCLASS. | CLASS ZJG_CL_NEW definition. private section. methods constructor. data mr_doc type ref to lif_doc. | |
TYPES tt_bapiret2 TYPE STANDARD TABLE OF bapiret2 WITH DEFAULT KEY. | ||
class zjg_cl_new implementation. method constructor. mr_doc = new lcl_doc( ). endmethod. | ||
METHODS zjg_fm1_set_buffer. | METHOD lif_doc~zjg_fm1_set_buffer . CALL FUNCTION 'ZJG_FM1_SET_BUFFER'. ENDMETHOD. | |
METHODS zjg_fm1_1 IMPORTING iv_guid TYPE guid_16 iv_flag TYPE char_01 CHANGING return TYPE tt_bapiret2 EXCEPTIONS not_found some_error . | METHOD lif_doc~zjg_fm1_1 . CALL FUNCTION 'ZJG_FM1_1' EXPORTING iv_guid = iv_guid iv_flag = if_flag TABLES return = return EXCEPTIONS not_found = 1 some_error = 2. Case sy-subrc. When 0. When 1. Raise not_found. When 2. Raise some_error. When others. Endcase. ENDMETHOD. | |
METHOD lif_doc~zjg_fm2 . CALL FUNCTION 'ZJG_FM2' EXPORTING iv_guid = iv_guid IMPORTING rv_success_flag = rv_success. ENDMETHOD. |
Old Function Module | New Method |
ZJG_FM6_1 | zjg_if_new_class_wrapp6~zjg_fm6_1 |
FUNCTION ZJG_FM6_1. DATA lt_rettab TYPE bapirettab. DATA lv_c1 TYPE char64 VALUE 'ABCD'. CALL FUNCTION 'ZJG_FM1_1' " FG external FM EXPORTING * IV_GUID = '1234567812345678' if_flag = abap_false TABLES return = lt_rettab. CALL FUNCTION 'ZJG_FM6_2' " FG propriety Fm EXPORTING if_flag = abap_false TABLES return = lt_rettab CHANGING cv_1 = lv_c1 . **************************** DATA lv_out TYPE char_01. DATA lv_progname TYPE progname. DATA lv_formname TYPE edcompont. lv_progname = 'SAPLZJG_FUNCTION_MOD_AS_WRAPP3'. lv_formname = 'GET_ANYTHING'. PERFORM (lv_formname) IN PROGRAM (lv_progname) USING '1' CHANGING lv_out. **************************** DATA lt_01_itab TYPE bapirettab. DATA lt_02_struc TYPE STANDARD TABLE OF bapiret2 WITH DEFAULT KEY. DATA lv_u1 TYPE string. DATA lv_c01 TYPE string. PERFORM f01 TABLES lt_01_itab lt_02_struc USING lv_u1 CHANGING lv_c01. ENDFUNCTION. | METHOD zjg_if_new_class_wrapp6~zjg_fm6_1. DATA lt_rettab TYPE bapirettab. DATA lv_c1 TYPE char64 VALUE 'ABCD'. mo_doc->zjg_fm1_1( EXPORTING if_flag = abap_false CHANGING return = lt_rettab ). zjg_if_new_class_wrapp6~zjg_fm6_2( EXPORTING if_flag = abap_false CHANGING return = lt_rettab cv_1 = lv_c1 ). *********************************** DATA lv_out TYPE char_01. DATA lv_progname TYPE progname. DATA lv_formname TYPE edcompont. lv_progname = 'SAPLZJG_FUNCTION_MOD_AS_WRAPP3'. lv_formname = 'GET_ANYTHING'. PERFORM (lv_formname) IN PROGRAM (lv_progname) USING '1' CHANGING lv_out. ********************************* DATA lt_01_itab TYPE bapirettab. DATA lt_02_struc TYPE STANDARD TABLE OF bapiret2 WITH DEFAULT KEY. DATA lv_u1 TYPE string. DATA lv_c01 TYPE string. f01( EXPORTING u_1 = lv_u1 CHANGING t_01_itab = lt_01_itab t_02_struc = lt_02_struc c_1 = lv_c01 ). ENDMETHOD. |
Legend dangerous call, to be investigated thoroughly Replaced proprietary call Replaced external call |
Raise of classic exception | Raise of new exception class | |
Pattern | Raise old_exception | Raise exception type new_exception_class exporting former_exception = old_exception. |
Example | RAISE not_found. | RAISE EXCEPTION TYPE zcx_abc EXPORTING former exception = 'NOT_FOUND'. |
Message of classic exception | Raise of new exception class | Comment | |
Pattern | Message t100 with v1 v2 v3 v4 raising old_exception. | Raise exception type new_exception_class message id t100-msgid type t100-msgty number t100-msgno with v1 v2 v3 v4 exporting former_exception = old_exception. | The T100 key can be implemented in 4 different types,
|
Example | Message e001(D0) with ‘ANTON’ RAISING ERROR. | RAISE EXCEPTION TYPE zcx_abc Message ID ‘D0’ Type ‘E’ NUMBER ‘001’ With ‘ANTON’ EXPORTING former_exception = ‘ERROR’. | Short form of T100-Key used in message |
Example | Message TYPE ‘E’ NUMBER 001 with ‘ANTON’ RAISING NOT_FOUND. | RAISE EXCEPTION TYPE zcx_abc Message ID ‘D01’ Type ‘E’ NUMBER ‘001’ With ‘ANTON’ EXPORTING former_exception = ‘NOT_FOUND’. | The function group has a message ID D01 assigned. |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
5 | |
3 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |