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

CATCH_ILLEGAL_STATE

VincentBloem
Participant
0 Likes
5,510

Hi Experts,

We have a problem on our system.

This piece of code generates a ST22 abap runtime error:

CATCH_ILLEGAL_STATE

this is the code:

DATA:
      tdname_range   TYPE RANGE OF tdname,
      tdobject_range TYPE RANGE OF tdobname,
      spras_range    TYPE RANGE OF langu.


    DATA: lt_svo TYPE zbpt_gwe_svo_id.

    LOOP AT it_ids INTO DATA(ls_id).
      APPEND INITIAL LINE TO tdname_range ASSIGNING FIELD-SYMBOL(<fs_object_name>).
      <fs_object_name>-sign = 'I'.
      <fs_object_name>-option = 'EQ'.
      <fs_object_name>-low = ls_id-id.
    ENDLOOP.


    SELECT tdname, tdobject, tdid, tdspras FROM stxh INTO TABLE @DATA(lt_stxh) WHERE tdname IN @tdname_range AND tdid = 'Z001' AND tdobject = 'BUT000'.


    LOOP AT lt_stxh INTO DATA(ls_stxh).
      APPEND INITIAL LINE TO tdobject_range ASSIGNING FIELD-SYMBOL(<fs_object>).
      <fs_object>-sign = 'I'.
      <fs_object>-option = 'EQ'.
      <fs_object>-low = ls_stxh-tdname.
    ENDLOOP.


    spras_range = VALUE #( ( sign = 'I' option = 'EQ' low = 'N') ( sign = 'I' option = 'EQ' low = 'E') ).

    SELECT tdname, clustr, clustd
            INTO TABLE @DATA(lt_stxl)
            FROM stxl
            WHERE relid    = 'TX'          "standard text
              AND tdobject = 'BUT000'
              AND tdname   IN @tdobject_range
              AND tdid     = 'Z001'
              AND tdspras  IN @spras_range.

* compressed text data without text name
    TYPES: BEGIN OF ty_stxl_raw,
             clustr TYPE stxl-clustr,
             clustd TYPE stxl-clustd,
           END OF ty_stxl_raw.
    DATA:  t_stxl_raw TYPE STANDARD TABLE OF ty_stxl_raw.
    DATA:  w_stxl_raw TYPE ty_stxl_raw.
* decompressed text
    DATA:  t_tline TYPE STANDARD TABLE OF tline.
    FIELD-SYMBOLS: <tline> TYPE tline.
    DATA:       w_stxh TYPE stxh.


    LOOP AT lt_stxl ASSIGNING FIELD-SYMBOL(<stxl>).
*   decompress text
      CLEAR: t_stxl_raw[], t_tline[].
      w_stxl_raw-clustr = <stxl>-clustr.
      w_stxl_raw-clustd = <stxl>-clustd.
      APPEND w_stxl_raw TO t_stxl_raw.
      IMPORT tline = t_tline FROM INTERNAL TABLE t_stxl_raw.


*  access text lines for further processing
      LOOP AT t_tline ASSIGNING <tline>.
        TRY .
            IF <tline>-tdline CP iv_filter.
              APPEND INITIAL LINE TO lt_svo ASSIGNING FIELD-SYMBOL(<fs_id>).
              <fs_id>-id = CONV bu_partner( <stxl>-tdname ).
            ENDIF.
*          CATCH cx_sy_itab_line_not_found.
          CATCH cx_root.
        ENDTRY.
      ENDLOOP.
    ENDLOOP.


    SORT lt_svo ASCENDING.
    DELETE ADJACENT DUPLICATES FROM lt_svo COMPARING ALL FIELDS.


    rt_ids = lt_svo.

This code filters a text based on the value of iv_filter.

It goes wrong in the last loop:

I think, the problem is causedby this line of code:

IMPORT tline = t_tline FROM INTERNAL TABLE t_stxl_raw.

Can somebody tell what the problem is?

1 ACCEPTED SOLUTION
Read only

michael_piesche
Active Contributor
0 Likes
4,462

vincentbloem, took me a little bit, but with the following code, you should be able to read the partner in the ST22 dump. Its not 'pretty' but it will work, as SAP captures system variables for ST22 dumps; but not all program variables, those are 'magically' selected, on which the system seems important (and your partner, aka <stxl>-tdname, obviously has not deemed worthy so far).

 DATA: l_cp TYPE tcp00-cpcodepage.

 " This way, you get the 'PARTNER' into the system variables for the dump in variable SY-MSGV1
 sy-msgv1 = <stxl>-tdname.  
 IMPORT tline = t_tline FROM INTERNAL TABLE t_stxl_raw
    ACCEPTING TRUNCATION        " also try out these additions to the IMPORT statement
    CODE PAGE INTO l_cp         " as this is how the standard FM READ_MULTIPLE_TEXTS calls it
    IGNORING CONVERSION ERRORS. " otherwise, you might give the FM a try, like Sandra already proposed

Hi Experts,

We have a problem on our system.

This piece of code generates a ST22 abap runtime error:

CATCH_ILLEGAL_STATE

this is the code:

DATA:
      tdname_range   TYPE RANGE OF tdname,
      tdobject_range TYPE RANGE OF tdobname,
      spras_range    TYPE RANGE OF langu.


    DATA: lt_svo TYPE zbpt_gwe_svo_id.

    LOOP AT it_ids INTO DATA(ls_id).
      APPEND INITIAL LINE TO tdname_range ASSIGNING FIELD-SYMBOL(<fs_object_name>).
      <fs_object_name>-sign = 'I'.
      <fs_object_name>-option = 'EQ'.
      <fs_object_name>-low = ls_id-id.
    ENDLOOP.


    SELECT tdname, tdobject, tdid, tdspras FROM stxh INTO TABLE @DATA(lt_stxh) WHERE tdname IN @tdname_range AND tdid = 'Z001' AND tdobject = 'BUT000'.


    LOOP AT lt_stxh INTO DATA(ls_stxh).
      APPEND INITIAL LINE TO tdobject_range ASSIGNING FIELD-SYMBOL(<fs_object>).
      <fs_object>-sign = 'I'.
      <fs_object>-option = 'EQ'.
      <fs_object>-low = ls_stxh-tdname.
    ENDLOOP.


    spras_range = VALUE #( ( sign = 'I' option = 'EQ' low = 'N') ( sign = 'I' option = 'EQ' low = 'E') ).

    SELECT tdname, clustr, clustd
            INTO TABLE @DATA(lt_stxl)
            FROM stxl
            WHERE relid    = 'TX'          "standard text
              AND tdobject = 'BUT000'
              AND tdname   IN @tdobject_range
              AND tdid     = 'Z001'
              AND tdspras  IN @spras_range.

* compressed text data without text name
    TYPES: BEGIN OF ty_stxl_raw,
             clustr TYPE stxl-clustr,
             clustd TYPE stxl-clustd,
           END OF ty_stxl_raw.
    DATA:  t_stxl_raw TYPE STANDARD TABLE OF ty_stxl_raw.
    DATA:  w_stxl_raw TYPE ty_stxl_raw.
* decompressed text
    DATA:  t_tline TYPE STANDARD TABLE OF tline.
    FIELD-SYMBOLS: <tline> TYPE tline.
    DATA:       w_stxh TYPE stxh.


    LOOP AT lt_stxl ASSIGNING FIELD-SYMBOL(<stxl>).
*   decompress text
      CLEAR: t_stxl_raw[], t_tline[].
      w_stxl_raw-clustr = <stxl>-clustr.
      w_stxl_raw-clustd = <stxl>-clustd.
      APPEND w_stxl_raw TO t_stxl_raw.
      IMPORT tline = t_tline FROM INTERNAL TABLE t_stxl_raw.


*  access text lines for further processing
      LOOP AT t_tline ASSIGNING <tline>.
        TRY .
            IF <tline>-tdline CP iv_filter.
              APPEND INITIAL LINE TO lt_svo ASSIGNING FIELD-SYMBOL(<fs_id>).
              <fs_id>-id = CONV bu_partner( <stxl>-tdname ).
            ENDIF.
*          CATCH cx_sy_itab_line_not_found.
          CATCH cx_root.
        ENDTRY.
      ENDLOOP.
    ENDLOOP.


    SORT lt_svo ASCENDING.
    DELETE ADJACENT DUPLICATES FROM lt_svo COMPARING ALL FIELDS.


    rt_ids = lt_svo.

This code filters a text based on the value of iv_filter.

It goes wrong in the last loop:

I think, the problem is causedby this line of code:

IMPORT tline = t_tline FROM INTERNAL TABLE t_stxl_raw.

Can somebody tell what the problem is?

10 REPLIES 10
Read only

former_member876
Participant
0 Likes
4,462

Yes, you are right IMPORT is an issue. Please check syntax and semantics of the IMPORT statement.IMPORT ... FROM INTERNAL TABLE itab

Looks like you have to change the first field of ty_stxl_raw. "Internal table in particular cannot be empty"

* compressed text data without text name
    TYPES: BEGIN OF ty_stxl_raw,
             clustr TYPE stxl-clustr, <==== Change this to 'clustr TYPE 'I'
             clustd TYPE stxl-clustd,
           END OF ty_stxl_raw.
Read only

michael_piesche
Active Contributor
4,462

mukeshjadhav, that is most likely not the problem, based on ABAP documentation: "The first column of itab must have the data type s or i and the second column must have the type x." This is the case with stxl-custr (2-byte integer). Otherwise, I would also expect a general error, and not just in the "last loop".

Read only

michael_piesche
Active Contributor
4,462

The error CATCH_ILLEGAL_STATE happens for instance with the IMPORT FROM INTERNAL TABLE statement, when either your fields CLUSTR or CLUSTD are empty/initial or when they contain corrupted information, that does not lead to a valid extraction of data from the data cluster.

  • So at least check that these both values are not empty, before calling the IMPORT FROM INTERNAL TABLE statement
  • Then, try to identify the values (e.g. in your case what partner), when the dump occurs, that are being passed in t_stxl_raw, and see if you can clean that data or adapt your programm accordingly
  • Obviously, your report is meant to find unwanted or special formats of business partner texts, and I wouldnt be surprised if there was some sort of manual data deletion/manipulation involved in your case that dumps, either in your system or the system where the data originates from
LOOP AT lt_stxl ASSIGNING FIELD-SYMBOL(<stxl>).
  CHECK: <stxl>-clustr IS NOT INITIAL, " at least check that these are not initial
         <stxl>-clustd IS NOT INITIAL.
   
  CLEAR: t_stxl_raw[], t_tline[].
  w_stxl_raw-clustr = <stxl>-clustr.
  w_stxl_raw-clustd = <stxl>-clustd.
  APPEND w_stxl_raw TO t_stxl_raw.
  IMPORT tline = t_tline FROM INTERNAL TABLE t_stxl_raw.

   LOOP ... .
     " ...
   ENDLOOP.
ENDLOOP.
Read only

0 Likes
4,462

Hi Michael,

I Changed the code like you said but still the same error occured:

Can you modify the code to identify the partner when the dump occures?

Read only

0 Likes
4,462

Hi Michael,

I did the code change like you said and it worked! 🙂

We found the BP that was causing the runtime error.

The problem was in the data of the BP, the text was 1748 page long ! and full of strange characters.... So we cleaned the data and now it doesn't dump anymore.

Thanks for the help!

KR,

Vincent

Read only

Sandra_Rossi
Active Contributor
0 Likes
4,462

Can't you use the standard function module READ_MULTIPLE_TEXTS? (added by note 2261311)

Read only

michael_piesche
Active Contributor
0 Likes
4,463

vincentbloem, took me a little bit, but with the following code, you should be able to read the partner in the ST22 dump. Its not 'pretty' but it will work, as SAP captures system variables for ST22 dumps; but not all program variables, those are 'magically' selected, on which the system seems important (and your partner, aka <stxl>-tdname, obviously has not deemed worthy so far).

 DATA: l_cp TYPE tcp00-cpcodepage.

 " This way, you get the 'PARTNER' into the system variables for the dump in variable SY-MSGV1
 sy-msgv1 = <stxl>-tdname.  
 IMPORT tline = t_tline FROM INTERNAL TABLE t_stxl_raw
    ACCEPTING TRUNCATION        " also try out these additions to the IMPORT statement
    CODE PAGE INTO l_cp         " as this is how the standard FM READ_MULTIPLE_TEXTS calls it
    IGNORING CONVERSION ERRORS. " otherwise, you might give the FM a try, like Sandra already proposed
Read only

4,462
vincentbloem, I changed the comment that actually helped you solve the problem to an answer, otherwise it is too hidden in the thread. Glad I could have been of help.
Read only

0 Likes
4,462

vincentbloem, please follow up on your open question.

  • comment answers or your question if there are still open issues.
  • otherwise mark an answer as accepted if it helped you solve your problem
  • or post an answer of yourself and accept it if you found another useful solution yourself
  • or redirect your question to another question that is related and was useful to solve your problem
  • in the end, close your question
Read only

Sandra_Rossi
Active Contributor
4,462

vincentbloem Again, don't you want to simplify your code with READ_MULTIPLE_TEXTS?