
CLASS zcx_my_exception DEFINITION
PUBLIC
INHERITING FROM cx_static_check
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_t100_message .
"Start of addition
DATA msgty TYPE symsgty .
DATA text1 TYPE sylisel .
DATA text2 TYPE sylisel .
DATA text3 TYPE sylisel .
DATA text4 TYPE sylisel .
"End of addition
METHODS constructor
IMPORTING
!textid LIKE if_t100_message=>t100key OPTIONAL
!previous LIKE previous OPTIONAL
!msgty TYPE symsgty OPTIONAL
!text1 TYPE sylisel OPTIONAL
!text2 TYPE sylisel OPTIONAL
!text3 TYPE sylisel OPTIONAL
!text4 TYPE sylisel OPTIONAL .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS lcl DEFINITION.
PUBLIC SECTION.
METHODS get_master_data
RAISING zcx_my_exception.
METHODS call_function
RAISING zcx_my_exception.
METHODS call_bapi
RAISING zcx_my_exception.
ENDCLASS.
CLASS lcl IMPLEMENTATION.
METHOD get_master_data.
"Prep the material number, etc
me->call_function( ).
"Post call routine - Do something with data
me->call_bapi( ).
ENDMETHOD.
METHOD call_function.
CALL FUNCTION 'MATERIAL_READ'
EXPORTING
schluessel = key_fields " Material master key fields
IMPORTING
matdaten = view_tab " Material master view
return = return
matper = matper
EXCEPTIONS
account_not_found = 1
batch_not_found = 2
forecast_not_found = 3
lock_on_account = 4
lock_on_material = 5
lock_on_plant = 6
lock_on_sales = 7
lock_on_sloc = 8
lock_on_batch = 9
lock_system_error = 10
material_not_found = 11
plant_not_found = 12
sales_not_found = 13
sloc_not_found = 14
slocnumber_not_found = 15
sloctype_not_found = 16
text_not_found = 17
unit_not_found = 18
invalid_mch1_matnr = 19
invalid_mtcom = 20
sa_material = 21
wv_material = 22
waart_error = 23
t134m_not_found = 24
error_message = 25
OTHERS = 26.
IF sy-subrc <> 0.
RAISE EXCEPTION TYPE zcx_my_exception
EXPORTING
textid = VALUE scx_t100key( msgid = sy-msgid
msgno = sy-msgno
attr1 = 'TEXT1'
attr2 = 'TEXT2'
attr3 = 'TEXT3'
attr4 = 'TEXT4' )
msgty = sy-msgty
text1 = CONV sylisel( sy-msgv1 )
text2 = CONV sylisel( sy-msgv2 )
text3 = CONV sylisel( sy-msgv3 )
text4 = CONV sylisel( sy-msgv4 ).
ENDIF.
ENDMETHOD.
METHOD call_bapi.
DATA:
bapiret_tab TYPE STANDARD TABLE OF bapiret2.
CALL FUNCTION 'BAPI_PRODORD_CREATE'
EXPORTING
orderdata = orderdata " Transfer Structure for Creating Production Orders
IMPORTING
return = bapiret_tab " Return Parameters
order_number = e_order_number. " Production order number
LOOP AT bapiret_tab INTO DATA(bapiret) WHERE type = 'E'.
RAISE EXCEPTION TYPE zcx_my_exception
EXPORTING
textid = VALUE scx_t100key( msgid = bapiret-id
msgno = bapiret-number
attr1 = 'TEXT1'
attr2 = 'TEXT2'
attr3 = 'TEXT3'
attr4 = 'TEXT4' )
msgty = bapiret-type
text1 = CONV sylisel( bapiret-message_v1 )
text2 = CONV sylisel( bapiret-message_v2 )
text3 = CONV sylisel( bapiret-message_v3 )
text4 = CONV sylisel( bapiret-message_v4 ).
ENDLOOP.
ENDMETHOD.
ENDCLASS.
TRY.
DATA(obj) = NEW lcl( ).
obj->get_master_data( ).
CATCH zcx_my_exception INTO DATA(ocx_my).
" Do some clean up work
" ....
" Show the user the error message
MESSAGE ID ocx_my->if_t100_message~t100key-msgid
TYPE ocx_my->msgty
NUMBER ocx_my->if_t100_message~t100key-msgno
WITH ocx_my->text1
ocx_my->text2
ocx_my->text3
ocx_my->text4.
ENDTRY.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |