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

Error message

Former Member
0 Likes
783

Hi Friends,

How to write error messages on the selection screen, pls give me an example.

Regards,

Venu

7 REPLIES 7
Read only

Former Member
0 Likes
743

Hi venu

IF NOT S_PERSK IS INITIAL.

SELECT SINGLE PERSK

FROM PA0001

INTO PA0001-PERSK

WHERE PERSK IN S_PERSK.

IF SY-SUBRC NE 0.

MESSAGE E003(ZMESS).

ENDIF.

ENDIF.

Write above code...

what evr the field u want to validate..

award points if useful..

cheers

Read only

Former Member
0 Likes
743

and click on ZMESS and it will take to se93 and there declare the messages

Read only

Former Member
0 Likes
743

at selection-screen.

if <condition>.

MESSAGE 'Error' TYPE 'E'.

endif.

Read only

Former Member
0 Likes
743

Hi Venu,

E- ERROR MESSAGE

S-STATUS MESSAGE

IF NOT S_EBELN[] IS INITIAL.

SELECT SINGLE EBELN

INTO LV_EBELN

FROM EKKO

WHERE EBELN IN S_EBELN.

IF SY-SUBRC <> 0.

<b> MESSAGE E000(ZLKPL_MSGCLASS) WITH 'Enter a</b> Material Number'.

V_FLAG = 'X'.

ENDIF.

Thanks

Vikranth Khimavath

Read only

Former Member
0 Likes
743

Hi u have to define ur msg class via transaction se91 and define ur msg at there.

These r some examples:

DATA: mid TYPE sy-msgid VALUE 'SABAPDOCU',

mtype TYPE sy-msgty VALUE 'I',

num TYPE sy-msgno VALUE '014'.

MESSAGE ID mid TYPE mtype NUMBER num.

DATA: oref TYPE REF TO cx_sy_arithmetic_error,

text TYPE string.

TRY.

...

CATCH cx_sy_arithmetic_error INTO oref.

text = oref->get_text( ).

MESSAGE text TYPE 'I'.

ENDTRY.

DATA mtext TYPE string.

CALL FUNCTION ... EXCEPTIONS error_message = 4.

IF sy-subrc = 4.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

INTO mtext

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

MESSAGE i010 WITH 'This' 'is' 'not' 'America'.

Read only

Former Member
0 Likes
743

Hi Venu,

If You want to give an error message on Selection Screen You can write the code as per the below example code.

  • Let say You want to validate Company Code

IF NOT S_BUKRS[] IS INITIAL.

SELECT SINGLE BUKRS

INTO T001-BUKRS

FROM T001

WHERE BUKRS IN S_BUKRS.

IF SY-SUBRC <> 0.

Message e000(zz) with 'Invalid Company Code'.

ENDIF.

ENDIF.

Hope this example helps your objective.

Regards,

sksingh

Read only

Former Member
0 Likes
743

Hi,

at selection-screen.

SELECT SINGLE * FROM APQI INTO IT_APQI

WHERE DATATYP = GC_BDC

AND MANDANT = SY-MANDT

AND ( ( GROUPID = GC_GROUP1 OR

GROUPID = GC_GROUP2 ) )

AND QSTATE <> GC_QSTATE.

IF SY-SUBRC EQ 0.

MESSAGE E000(ZZ) WITH TEXT-050 TEXT-051.

ENDIF.

regards

amole