‎2011 Jul 12 3:27 AM
Do you have any idea on how to return error messages from FM RH_INSERT_INFTY? im looking for something similar to HR_INFOTYPE_OPERATION bapi return 2.
‎2011 Jul 12 5:03 AM
Just handling its Exceptions should be enough as it does not have any RETURN tables like the other ones. This is how I did it sometimes ago, you might find it helpful to refer to the below code.
FORM update_pd_infty USING pt_old_pnnnn TYPE piq_p1001_t
ps_new_pnnnn TYPE p1001
CHANGING pv_ok TYPE boole_d.
DATA:
wplog_record TYPE wplog,
wplog_record_tab TYPE wplog_tab.
FIELD-SYMBOLS:
<ls_old_pnnnn> TYPE p1001.
* check the old & new infotype records are not passed blank
CHECK:
pt_old_pnnnn IS NOT INITIAL,
ps_new_pnnnn IS NOT INITIAL.
* convert the Old PNNNN structure to WPLOG structure
LOOP AT pt_old_pnnnn ASSIGNING <ls_old_pnnnn>.
CALL METHOD cl_hrrcf_infotype=>pnnnn_to_wplog
EXPORTING
pnnnn = <ls_old_pnnnn>
IMPORTING
wplog = wplog_record.
APPEND wplog_record TO wplog_record_tab.
ENDLOOP.
* delete the existing records (at buffer level only at this stage)
CALL FUNCTION 'RH_DELETE_INFTY'
EXPORTING
vtask = 'B'
authy = abap_false
TABLES
innnn = wplog_record_tab
EXCEPTIONS
error_during_delete = 1
no_authorization = 2
delete_first_record = 3
corr_exit = 4
OTHERS = 5.
IF sy-subrc <> 0.
RETURN.
ENDIF.
CLEAR:
wplog_record,
wplog_record_tab.
* convert the New PNNNN structure to WPLOG structure
CALL METHOD cl_hrrcf_infotype=>pnnnn_to_wplog
EXPORTING
pnnnn = ps_new_pnnnn
IMPORTING
wplog = wplog_record.
APPEND wplog_record TO wplog_record_tab.
* insert/create the new record (at buffer level only at this stage)
CALL FUNCTION 'RH_INSERT_INFTY'
EXPORTING
vtask = 'B'
authy = abap_false
TABLES
innnn = wplog_record_tab
EXCEPTIONS
no_authorization = 1
error_during_insert = 2
repid_form_initial = 3
corr_exit = 4
begda_greater_endda = 5
OTHERS = 6.
IF sy-subrc <> 0.
RETURN.
ENDIF.
* update the database now for all buffer changes above
CALL FUNCTION 'RH_UPDATE_DATABASE'
EXPORTING
vtask = 'D'
EXCEPTIONS
corr_exit = 1
OTHERS = 2.
IF sy-subrc <> 0.
RETURN.
ENDIF.
pv_ok = abap_true.
ENDFORM. " UPDATE_PD_INFTY
Hope this helps.
Cheers,
Sougata.
‎2011 Jul 12 9:08 AM
all i see is that the exception is being returned. what im looking for is how to get the error message means if its exception is 1 then should have message so and so. if not then do i have to hardcode the message?
‎2011 Jul 12 9:22 AM
When exception is returned, you can actually have the values in
SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
you can use 'BAPI_MESSAGE_GETDETAIL' or
'BALW_BAPIRETURN_GET2' to get the messages by pushing the above values
Edited by: ssm on Jul 12, 2011 2:07 PM
‎2011 Jul 12 9:51 AM
the thing is that when the exceptions are returned the system fields are not populated.