‎2011 Sep 27 2:01 PM
Hi,
I'm working with the FM FI_FIND_PAYMENT_CONDITIONS. It works fine but sometimes it fails with the exporting parameter i_bldat. My funtion is into a loop with hundred of lines and I don't which line is making the mistake.
I know it's possible to use the the sy-subrc<>0 to control the mistake, how can I use it easily to see in which line is the problem? Can anybody give an example?
Thanks in advance.
Regards.
‎2011 Sep 27 2:13 PM
Hi,
Well, you should have something like this:
LOOP AT itab ASSIGNING <fs>.
l_tabix = sy-tabix.
"...
CALL FUNCTION 'FI_FIND_PAYMENT_CONDITIONS'
EXPORTING
i_zterm = <fs>-zterm
i_bldat = <fs>-bldat
i_budat = <fs>-budat
exceptions
terms_incorrect = 1
terms_not_found = 2
no_date_entered = 3
no_day_limit_found = 4
OTHERS = 5.
IF sy-subrc <> 0.
"L_TABIX is the index of erroneous entry
ENDIF.
"...
ENDLOOP.
Kr,
m.
‎2011 Sep 27 2:13 PM
Hi,
Well, you should have something like this:
LOOP AT itab ASSIGNING <fs>.
l_tabix = sy-tabix.
"...
CALL FUNCTION 'FI_FIND_PAYMENT_CONDITIONS'
EXPORTING
i_zterm = <fs>-zterm
i_bldat = <fs>-bldat
i_budat = <fs>-budat
exceptions
terms_incorrect = 1
terms_not_found = 2
no_date_entered = 3
no_day_limit_found = 4
OTHERS = 5.
IF sy-subrc <> 0.
"L_TABIX is the index of erroneous entry
ENDIF.
"...
ENDLOOP.
Kr,
m.
‎2011 Sep 27 2:43 PM
Thanks Manu,
but when the report has finished I get the following message (error):
"Indicate the base date for the payment deadline"
Is is possible to see the log with the errors or to write something into the
IF sy-subrc <> 0.
???????
ENDIF.
‎2011 Sep 27 2:51 PM
Hi
After return from FM, check the SY-SUBRC, if it is not equal to zero, then pass all the data to ITAB and finally display it
Shiva
‎2011 Sep 27 2:58 PM
Hi,
You could for example store the error message with the corresponding keys into a local error table...
something like:
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
INTO ls_err-msg.
ls_err-key = l_tabix.
APPEND ls_err TO gt_err.
ENDIF.
And display the table gt_err (if not empty) in a SALV grid object at the end of the report...
DATA: lr_table TYPE REF TO cl_salv_table,
lr_funct TYPE REF TO cl_salv_functions,
lr_columns TYPE REF TO cl_salv_columns_table,
CHECK gt_err[] is not INITIAL. "Errors found
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = lr_table
CHANGING
t_table = gt_err.
CATCH cx_salv_msg.
EXIT.
ENDTRY.
lr_funct = lr_table->get_functions( ).
lr_funct->set_all( abap_true ).
lr_columns = lr_table->get_columns( ).
lr_columns->set_optimize( 'X' ).
lr_table->display( ).
Kr,
m.
Edited by: Manu D'Haeyer on Sep 27, 2011 4:01 PM
‎2011 Sep 27 3:06 PM
Hi Shiva,
I've something like this:
CALL FUNCTION 'FI_FIND_PAYMENT_CONDITIONS' "Determine cash discount using ZTERM and document, posting, CPU, base date
EXPORTING
i_zterm = p_zterm " t052-zterm Terms of payment key
i_bldat = p_fent " bkpf-bldat Document date
i_budat = p_fdoc " bkpf-budat Posting date
i_cpudt = SY-DATLO " bkpf-cpudt System date
i_zfbdt = 00000000 " bseg-zfbdt Base date (optional) default 00000000
i_funcl = SPACE " t020-funcl Function class from transaction control
IMPORTING
e_t052 = " t052 Payment terms work area
e_zfbdt = i_dzfbdt " bseg-zfbdt Calculated base date
e_sklin = " sklin Cash discount
EXCEPTIONS
TERMS_INCORRECT = 1 " Cash discount line invalid
TERMS_NOT_FOUND = 2 " Key not found in T052
NO_DATE_ENTERED = 3 " No import parameters defined
. " FI_FIND_PAYMENT_CONDITIONS
IF sy-subrc <> 0.
write 'hello'.
ENDIF.
Whatever it is what I' like to write I don't get to see it, for example, the hello world.
My report finish with the empty screen and the before error message..
‎2011 Sep 27 3:16 PM
Hi
Try to use the ERROR_MESSAGE option in the exceptions:
CALL FUNCTION 'FI_FIND_PAYMENT_CONDITIONS'
..............................
EXCEPTIONS
TERMS_INCORRECT = 1
TERMS_NOT_FOUND = 2
NO_DATE_ENTERED = 3
NO_DAY_LIMIT_FOUND = 4
ERROR_MESSAGE = 5 "<---- New exception
OTHERS = 6.
IF SY-SUBRC <> 0.ERROR_MESSAGE should be triggered if an error message (without an exception) is rasied in the function module
Max
‎2011 Sep 27 3:16 PM
Hi
The FM is having message type E in it, so the system will raise exception for the same.
To avoid this, you need to validate the same before passing to FM.
Check the code of FM it is having around 5-6 error messages in it. You check them before passing to FM and handle the same using precheck condition
Shiva
‎2011 Sep 27 3:17 PM
Check the Exceptions from the FM. You are not capturing them all. Add
NO_DAY_LIMIT_FOUND
and
OTHERS.
Rob
‎2011 Sep 27 4:19 PM
Thank you everybody,
it is the problem. I needed more exceptions in my funtion.
Regards.
‎2011 Sep 27 4:37 PM
Hi
ERROR_MESSAGE is a particular exception option, just like OTHERS and it can used for every function module
Max