Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

provide statement and function module

former_member226519
Active Contributor
0 Likes
1,062

I am getting a syntax error when using both PROVIDE and RAISE within a function module: "Old and new exceptions cannot be used at the same time .."

I managed to solve the problem by putting the PROVIDE into an include of the function group.

But this could not be the state of the art solution, could it?

8 REPLIES 8
Read only

matt
Active Contributor
0 Likes
1,003

PROVIDE is a statement for extracting data from time dependent tables. It seems to be entirely unlikely that it has anything to do with the error message ""Old and new exceptions cannot be used at the same time ...".

What is the signature (import/export/changing/table paramaters) of your function module, and how are you raising exceptions?

matt

Read only

0 Likes
1,003

I know it is very odd.

The fm imports PERNR, BEGDA, ENDDA and exports two numeric values.

And I have 2 exceptions defined: DATA_ERROR and RESULTS_NOT_COMPLETE.


    if sy-subrc <> 0.
      gf_results_not_complete = yes.
    endif.
.....

  if gf_results_not_complete = yes.
    raise results_not_complete.
  endif.
endfunction.

Read only

matt
Active Contributor
0 Likes
1,003

Can you post the exact FM signature - i.e. the header bit of the source code.

thanks

matt

Read only

ThomasZloch
Active Contributor
0 Likes
1,003

Sounds rather like you used both RAISE (old) and RAISE EXCEPTION (new) in the same context, please doublecheck.

Thomas

Read only

0 Likes
1,003

*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(PERNR) TYPE  PERSNO
*"     VALUE(BEGDA) TYPE  BEGDA
*"     VALUE(ENDDA) TYPE  ENDDA
*"  EXPORTING
*"     VALUE(DAYS_SOLL) TYPE  ATSOL
*"     VALUE(DAYS_UNPAYED) TYPE  ATAKL
*"  EXCEPTIONS
*"      DATA_ERROR
*"      RESULTS_NOT_COMPLETE
*"----------------------------------------------------------------------
...
* 
  select * from zvpr_awarts into table gt_awarts
                            where endda >= begda.
  if sy-subrc <> 0.
    raise data_error.
  endif.
*
...
    call function 'HR_TIME_RESULTS_GET'
      exporting
        get_pernr             = l_pernr
        get_pabrj             = gs_549q-pabrj
        get_pabrp             = gs_549q-pabrp
      tables
        get_wpbp              = gt_wpbp
        get_ab                = gt_ab
        get_zes               = gt_zes
        get_psp               = gt_psp
      exceptions
        no_period_specified   = 1
        wrong_cluster_version = 2
        no_read_authority     = 3
        cluster_archived      = 4
        technical_error       = 5
        others                = 6.
    if sy-subrc <> 0.
      gf_results_not_complete = yes.
    endif.
...

*--> this is the part causing problems
*data: lf_ab.
*    provide fields * from gt_ab into gs_ab valid lf_ab
*                                           bounds begda
*                                           and    endda
*                                           where  awart in gr_awart
*            between gs_549q-begda and gs_549q-endda.
*      clear gt_awart_tmp.
*      gt_awart_tmp = gs_ab.
*      append gt_awart_tmp.
*    endprovide.
*
*--> this is the way it works
    perform fill_awart_tmp tables gt_ab
                                  gt_awart_tmp
                           using  gs_549q-begda
                                  gs_549q-endda.
.....
*
  days_soll    = l_soll.
  days_unpayed = l_unpayed.
  if gf_results_not_complete = yes.
    raise results_not_complete.
  endif.
endfunction.
Read only

matt
Active Contributor
0 Likes
1,003

No, I can't see anything wrong. As Thomas says, you get this error when mixing RAISE and RAISE EXCEPTION. I can't see any connection to the PROVIDE statement. I think you have to take this to SAP.

matt

Read only

0 Likes
1,003

I found that PROVIDE obviously uses RAISE EXCEPTION internally and this conflicts with my simple RAISE.

Thanks a lot for your help.

Read only

matt
Active Contributor
0 Likes
1,003

Really? That's pretty bad then! You should still raise it with SAP (if it isn't already there) - it means that ABAP is broken...