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

Try select... endtry

Former Member
0 Likes
4,200

Hello,

I need help.

I have the following consultation and I want to control possible dumps in the dynamic consultation:

DATA: BEGIN OF i_campos_select OCCURS 0,

campo TYPE fieldname,

END OF i_campos_select.

FIELD-SYMBOLS : <sucesos> TYPE table.

DATA: BEGIN OF i_where OCCURS 0,

line LIKE rsdswhere-line,

END OF i_where.

SELECT (i_campos_select)

INTO CORRESPONDING FIELDS OF TABLE <sucesos>

FROM (i_tipos_buzon-tabla)

WHERE (i_where).

I want to use TRY ... CATCH and ENDTRY sentences:

The problem is that I don't know wich is the exceptionn will be raised.

Someone can help me, please?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,896

Try somthing like this

DATA: BEGIN OF i_campos_select OCCURS 0,

campo TYPE fieldname,

END OF i_campos_select.

FIELD-SYMBOLS : <sucesos> TYPE table.

DATA: BEGIN OF i_where OCCURS 0,

line LIKE rsdswhere-line,

END OF i_where.

TRY.

SELECT (i_campos_select)

INTO CORRESPONDING FIELDS OF TABLE <sucesos>

FROM (i_tipos_buzon-tabla)

WHERE (i_where).

CATCH CX_SY_DYNAMIC_OSQL_SYNTAX.

MESSAGE E???.

ENDTRY.

3 REPLIES 3
Read only

former_member222860
Active Contributor
1,896

Hi,

you will get the exception with the FM : POPUP_TO_INFORM

Can use the Exception Handling like this:

DATA:   o_field TYPE REF TO cx_root," object to catch exception
            text TYPE string. "string variable to store exception text.

  TRY.
     --- Your logic
*Exception Catching.

    CATCH cx_root INTO o_field.
      text = o_field->get_text( ).

* Calling Function to give information message regarding Exception

      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = text-t03
          txt1  = text
          txt2  = text-t04.
      LEAVE TO LIST-PROCESSING.
  ENDTRY.

thanks\

Mahesh

Read only

Former Member
0 Likes
1,897

Try somthing like this

DATA: BEGIN OF i_campos_select OCCURS 0,

campo TYPE fieldname,

END OF i_campos_select.

FIELD-SYMBOLS : <sucesos> TYPE table.

DATA: BEGIN OF i_where OCCURS 0,

line LIKE rsdswhere-line,

END OF i_where.

TRY.

SELECT (i_campos_select)

INTO CORRESPONDING FIELDS OF TABLE <sucesos>

FROM (i_tipos_buzon-tabla)

WHERE (i_where).

CATCH CX_SY_DYNAMIC_OSQL_SYNTAX.

MESSAGE E???.

ENDTRY.

Read only

0 Likes
1,896

Hi,

DATA: BEGIN OF i_campos_select OCCURS 0,
        campo TYPE fieldname,
      END OF i_campos_select.

FIELD-SYMBOLS : <sucesos> TYPE table.

DATA: BEGIN OF i_where OCCURS 0,
        line LIKE rsdswhere-line,
      END OF i_where.

DATA: BEGIN OF i_tipos_buzon OCCURS 0, 
        tabla TYPE TABLE,    " This statement is giving me error how to declare i_tipos_buzon-tabla
      END OF i_tipos_buzon.


SELECT (i_campos_select)
INTO CORRESPONDING FIELDS OF TABLE <sucesos>
FROM (i_tipos_buzon-tabla)
WHERE (i_where).

How to declare a Field Symbol table (i_tipos_buzon-tabla).

Regards,

Suneel G