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

regarding message statement

Former Member
0 Likes
1,612

hi experts,

1) i m Modifying record in my own database table using modify statement ,what i want that after modify it will display message "data modify successfully"

2) i m Deleting record in my own database table using delete statement ,what i want that after delete it will display message "data delete successfully"

plz help me how will i use the message statement......

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,543

REPORT ZDESKDLC NO STANDARD PAGE HEADING LINE-SIZE 255.

----


  • DATA DECLARATION

----


TABLES : ZDESKDLC.

*start-of-selection.

data: flag.

*flag = 1 .

----


  • SELECTION SCREEN

----


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS: CCOD LIKE ZDESKDLC-CCODE MODIF ID ABC.

PARAMETERS: DESKCODE LIKE ZDESKDLC-DESK_CODE MODIF ID ABC.

SELECTION-SCREEN END OF BLOCK B1.

----


  • SELECTION SCREEN WITH RADIO BUTTON

----


PARAMETERS: DELETE RADIOBUTTON GROUP G1 USER-COMMAND R DEFAULT 'X'.

PARAMETERS: UPDATE RADIOBUTTON GROUP G1.

----


  • SELECTION SCREEN

----


SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001.

PARAMETERS: CCOD1 LIKE ZDESKDLC-CCODE MODIF ID DEF,

DESKCD LIKE ZDESKDLC-DESK_CODE MODIF ID DEF,

SR_MANAG LIKE ZDESKDLC-SR_MANAGEMENT MODIF ID DEF,

LASTNAME LIKE ZDESKDLC-LAST_NAME MODIF ID DEF,

FIRSTNM LIKE ZDESKDLC-FIRST_NAME MODIF ID DEF,

DEPART LIKE ZDESKDLC-DEPARTMENT MODIF ID DEF,

ADM_SYS LIKE ZDESKDLC-ADMIN_SYSTEM MODIF ID DEF,

RACF_ID LIKE ZDESKDLC-RACF_ID MODIF ID DEF,

OPEN_DT LIKE ZDESKDLC-OPEN_DATE MODIF ID DEF,

CLOSE_DT LIKE ZDESKDLC-CLOSE_DATE MODIF ID DEF,

SAPUSRID LIKE ZDESKDLC-SAP_USER_ID MODIF ID DEF.

SELECTION-SCREEN END OF BLOCK B2.

----


  • AT SELECTION-SCREEN.

----


AT SELECTION-SCREEN OUTPUT.

IF DELETE = 'X'.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'DEF'.

SCREEN-ACTIVE = '0'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

IF UPDATE = 'X'.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'ABC'.

SCREEN-ACTIVE = '0'.

screen-invisible = '1'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

----


  • DELETE QUERY

----


IF DELETE = 'X'.

DELETE from zdeskdlc where

CCODE = CCOD AND

DESK_CODE = DESKCODE.

IF SY-SUBRC = 0.

MESSAGE s001(zig) WITH 'data delete successfully'.

ENDIF.

ENDIF.

----


  • UPDATE QUERY

----


IF UPDATE = 'X'.

ZDESKDLC-CCODE = CCOD1.

ZDESKDLC-DESK_CODE = DESKCD.

ZDESKDLC-SR_MANAGEMENT = SR_MANAG.

ZDESKDLC-LAST_NAME = LASTNAME.

ZDESKDLC-FIRST_NAME = FIRSTNM.

ZDESKDLC-DEPARTMENT = DEPART.

ZDESKDLC-ADMIN_SYSTEM = ADM_SYS.

ZDESKDLC-RACF_ID = RACF_ID.

ZDESKDLC-OPEN_DATE = OPEN_DT.

ZDESKDLC-CLOSE_DATE = CLOSE_DT.

ZDESKDLC-SAP_USER_ID = SAPUSRID.

MODIFY ZDESKDLC.

ENDIF.

IF SY-SUBRC = 0.

MESSAGE s001(zig) WITH 'data modify successfully'.

ENDIF.

15 REPLIES 15
Read only

Former Member
0 Likes
1,543

Hi,

You can write some thing like this

message text-e01 type 'E'.

You can use different types according to ur requirement like

A - Abend

: Transaction terminated

E - Error

: Error message

I - Info

: Information

S - Status

: Status message

W - Warning

: Correction possible

X - Exit

: Transaction terminated with short dump

In text elements maintain the message description you want to ddisplay. For eg: Double click on text-e01 and write the description.

Sri

Message was edited by:

Sri Tayi

Read only

Former Member
0 Likes
1,543

Hi Zenithi,

Check sy-subrc after the statement,

modify <ztable>

if sy-subrc = 0.

message s000(message class) with "data modify successfully"

endif.

delete <ztable> from <workarea>

if sy-subrc = 0.

message s000(message class) with "data delete successfully"

endif.

Hopes it will help you.

Ali

Read only

Former Member
0 Likes
1,543

Hi Sri,

I tried this statement :

IF SY-SUBRC = 0.

MESSAGE s001(zzg) WITH 'UPDATE SUCCESFULLY'.

ENDIF.

but this statement fired before i modify anything, so which place i put this statement. in program..........

Read only

0 Likes
1,543

can you post your entire code?

Read only

Former Member
0 Likes
1,544

REPORT ZDESKDLC NO STANDARD PAGE HEADING LINE-SIZE 255.

----


  • DATA DECLARATION

----


TABLES : ZDESKDLC.

*start-of-selection.

data: flag.

*flag = 1 .

----


  • SELECTION SCREEN

----


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS: CCOD LIKE ZDESKDLC-CCODE MODIF ID ABC.

PARAMETERS: DESKCODE LIKE ZDESKDLC-DESK_CODE MODIF ID ABC.

SELECTION-SCREEN END OF BLOCK B1.

----


  • SELECTION SCREEN WITH RADIO BUTTON

----


PARAMETERS: DELETE RADIOBUTTON GROUP G1 USER-COMMAND R DEFAULT 'X'.

PARAMETERS: UPDATE RADIOBUTTON GROUP G1.

----


  • SELECTION SCREEN

----


SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001.

PARAMETERS: CCOD1 LIKE ZDESKDLC-CCODE MODIF ID DEF,

DESKCD LIKE ZDESKDLC-DESK_CODE MODIF ID DEF,

SR_MANAG LIKE ZDESKDLC-SR_MANAGEMENT MODIF ID DEF,

LASTNAME LIKE ZDESKDLC-LAST_NAME MODIF ID DEF,

FIRSTNM LIKE ZDESKDLC-FIRST_NAME MODIF ID DEF,

DEPART LIKE ZDESKDLC-DEPARTMENT MODIF ID DEF,

ADM_SYS LIKE ZDESKDLC-ADMIN_SYSTEM MODIF ID DEF,

RACF_ID LIKE ZDESKDLC-RACF_ID MODIF ID DEF,

OPEN_DT LIKE ZDESKDLC-OPEN_DATE MODIF ID DEF,

CLOSE_DT LIKE ZDESKDLC-CLOSE_DATE MODIF ID DEF,

SAPUSRID LIKE ZDESKDLC-SAP_USER_ID MODIF ID DEF.

SELECTION-SCREEN END OF BLOCK B2.

----


  • AT SELECTION-SCREEN.

----


AT SELECTION-SCREEN OUTPUT.

IF DELETE = 'X'.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'DEF'.

SCREEN-ACTIVE = '0'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

IF UPDATE = 'X'.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'ABC'.

SCREEN-ACTIVE = '0'.

screen-invisible = '1'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

----


  • DELETE QUERY

----


IF DELETE = 'X'.

DELETE from zdeskdlc where

CCODE = CCOD AND

DESK_CODE = DESKCODE.

IF SY-SUBRC = 0.

MESSAGE s001(zig) WITH 'data delete successfully'.

ENDIF.

ENDIF.

----


  • UPDATE QUERY

----


IF UPDATE = 'X'.

ZDESKDLC-CCODE = CCOD1.

ZDESKDLC-DESK_CODE = DESKCD.

ZDESKDLC-SR_MANAGEMENT = SR_MANAG.

ZDESKDLC-LAST_NAME = LASTNAME.

ZDESKDLC-FIRST_NAME = FIRSTNM.

ZDESKDLC-DEPARTMENT = DEPART.

ZDESKDLC-ADMIN_SYSTEM = ADM_SYS.

ZDESKDLC-RACF_ID = RACF_ID.

ZDESKDLC-OPEN_DATE = OPEN_DT.

ZDESKDLC-CLOSE_DATE = CLOSE_DT.

ZDESKDLC-SAP_USER_ID = SAPUSRID.

MODIFY ZDESKDLC.

ENDIF.

IF SY-SUBRC = 0.

MESSAGE s001(zig) WITH 'data modify successfully'.

ENDIF.

Read only

0 Likes
1,543

Once you are finished with your AT SELECTION SCREEN event, you have to start the START-OF-SELECTION event,, if not all the code you have written will be triggered just when the selection screen is built.

So may be before your DELETE QUERY put the START-OF-SELECTION event.

Sri

Read only

0 Likes
1,543

sri

thank you very much.

zenithi

Read only

0 Likes
1,543

You have some bad coding:

*----------------------------------------------------------------------*
* UPDATE QUERY
*----------------------------------------------------------------------*
IF UPDATE = 'X'.
ZDESKDLC-CCODE = CCOD1.
ZDESKDLC-DESK_CODE = DESKCD.
ZDESKDLC-SR_MANAGEMENT = SR_MANAG.
ZDESKDLC-LAST_NAME = LASTNAME.
ZDESKDLC-FIRST_NAME = FIRSTNM.
ZDESKDLC-DEPARTMENT = DEPART.
ZDESKDLC-ADMIN_SYSTEM = ADM_SYS.
ZDESKDLC-RACF_ID = RACF_ID.
ZDESKDLC-OPEN_DATE = OPEN_DT.
ZDESKDLC-CLOSE_DATE = CLOSE_DT.
ZDESKDLC-SAP_USER_ID = SAPUSRID.

MODIFY ZDESKDLC.
ENDIF.

IF SY-SUBRC = 0.
MESSAGE s001(zig) WITH 'data modify successfully'.
ENDIF.

The message will be sent even if the MODIFY is not done because the Message code is outside the IF statement in which the MODIFY is contained.

Your delete code is done OK.

The MODIFY message will display when you don't expect it.

You need to make this change in addition to the other suggestions.

Good luck

Brian

Adjust wording

Message was edited by:

Brian Sammond

Read only

Former Member
0 Likes
1,543

Hi Sri

one more question........

1) suppose i am Modifying record in my own database table using modify statement , but data already there... now i want to put the message "data is alreday inserted"... so what to do.............

zenithi

Read only

0 Likes
1,543

Use sy-subrc NE 0

If an entry is modified sy-subrc = 0, if not sy-subrc NE 0.

Sri

Read only

0 Likes
1,543

Zenithi,Before modify statement read that table.

coz modify statement will inseart a new record if that record already exists.

like

Read table <table> with key <filed> = <table >-<field>.,

if sy-subrc = 0.

"data is already inserted".

else.

modify <table>

if sy-subrc = 0.

message "uploaded successfully"

endif.

endif.

Ali

Message was edited by:

Quadri

Read only

Former Member
0 Likes
1,543

hi experts,

In my report i have selecttion screen, in selection screen 10 text box. like company code, first name , last name.... etc. what i want user enter company code in first text box and press execute after that company code related data automatically fill in all other text box. like first name = xxxx, last name = yyyy.

so which query i use for this statement.

plz help me how will i use the query

Read only

Former Member
0 Likes
1,543

hi experts,

In my report i have selecttion screen, in selection screen 10 text box. like company code, first name , last name.... etc. what i want user enter company code in first text box and press execute after that company code related data automatically fill in all other text box. like first name = xxxx, last name = yyyy.

so which query i use for this statement.

plz help me how will i use the query

Read only

0 Likes
1,543

Hi,

Use the AT SELECTION SCREEN EVENT.

FOR Eg:

You have 2 parameters in the Sel Screen, Customer No(KUNNR) and Name

Paramters: P_KUNNR type KUNNR,

P_name like KNA1-Name1.

at selection-screen.

If not P_KUNNR is initial.

Select single name into P_NAME from KNA1 where kunnr = P_kunnr.

Endif.

This fills in the Name of the customer if you just enter the Customer Number.

Sri

Read only

Former Member
0 Likes
1,543

MESSAGE statement in ABAP is used to put output messages. Please find some information on this topic and reward points if you find the information useful.

MESSAGE xnnn.

MESSAGE ID id TYPE mtype NUMBER n.

MESSAGE xnnn(mid).

Effect

Sends a message. Messages are stored in the table T100, are processed using transaction SE91 and can be created by forward navigation.

The ABAP runtime environment handles messages according to the type declared in the MESSAGE statement and the context in which the message was sent. The following message types exist:

A - Abend

: Transaction terminated

E - Error

: Error message

I - Info

: Information

S - Status

: Status message

W - Warning

: Correction possible

X - Exit

: Transaction terminated with short dump

Messages are mainly used to handle user input on screens. The following table shows the behavior of each message type in each context. An explanation of the numbers used is included at the end of the table:

A E I S W X

-


PAI Module 1 2 3 4 5 6

PAI Module for POH 1 7 3 4 7

6

PAI Module for POV 1 7 3 4 7

6

-


AT SELECTION-SCREEN ... 1 8 3 4 9 6

AT SELECTION-SCREEN for POH 1 7 3 4 7 6

AT SELECTION-SCREEN for POV 1 7 3 4 7 6

AT SELECTION-SCREEN ON EXIT 1 7 3 4 7 6

-


AT LINE-SELECTION 1 10 3 4 10 6

AT PFn 1 10 3 4 10 6

AT USER-COMMAND 1 10 3 4 10 6

-


INITIALIZATION 1 11 3 4 11 6

START-OF-SELECTION 1 11 3 4 11 6

GET 1 11 3 4 11 6

END-OF-SELECTION 1 11 3 4 11 6

-


TOP-OF-PAGE 1 11 3 4 11 6

END-OF-PAGE 1 11 3 4 11 6

TOP-OF-PAGE DURING ... 1 10 3 4 10 6

-


LOAD-OF-PROGRAM 1 1 4 4 4 6

-


PBO Module 1 1 4 4 4 6

AT SELECTION-SCREEN OUTPUT 1 1 4 4 4 6

-


Procedure: see

Messages

-


1. The message appears in a dialog box and the program terminates. When the user has confirmed the message, control returns to the next- highest area. All the internal sessions are deleted from the stack.

2. The message appears in the status line. Then PAI terminates and the system returns to the current screen. All the screen fields combined using FIELD or CHAIN are now ready for input. The user must enter new values. The system triggers the PAI event again, with the new values.

3. The message appears in a dialog box. Once the user has confirmed the message, the program continues immediately after the MESSAGE statement.

4. The message appears in the status line of the next screen. The program continues immediately after the message statement.

5. The message appears in the status line. Then the system continues as in 2, except that the user can quit the message using ENTER without having to enter new values. The system continues handling the PAI event from immediately after the message statement.

6. No message is displayed and a runtime error, MESSAGE_TYPE_X, is triggered. The short dump text contains the message identification.

7. The program terminates with a runtime error DYNPRO_MSG_IN_HELP. While F1 and F4 are processed, the system cannot send error messages or warnings.

8. The message appears in the status line. Then the system stops selection screen processing and returns to the selection screen itself. The screen fields specified in the additions to the AT SELECTION-SCREEN statement are now ready for input. The user must enter new values. The system then starts processing the selection screen again with the new values.

9. The message appears in the status line. Then the system continues as in 8, except the the user can quit the message using ENTER, without having to enter new values. The system continues handling the PAI event from immediately after the message statement.

10. The message appears in the status line and the processing block terminates. The list level is displayed as before.

11. The message appears in the status line and the processing block terminates. The system then returns to the program call.

12. For a demonstration of messages in different contexts, see Example Programs for Messages.

Variant 1

MESSAGE xnnn.

Extras:

... WITH f1 ... f4

... RAISING exception

... INTO f

Effect

Outputs the message nnn from the message class i with the type x. You can specify the message class i using the MESSAGE-ID addition to the REPORT statement, PROGRAM, or another introductory program statement.

Example

MESSAGE I001.

  • You can specify a different message class in parentheses after the error number, for example MESSAGE I001(SU).

  • When executing the statement, the following system variables are set:

  • SY-MSGID (message class)

  • SY-MSGTY (message type)

  • SY-MSGNO (message number)

Addition 1

... WITH f1 ... f4

Effect

Inserts the contents of a field fi in the message instead of in the placeholder &i. If unnumbered variables (&) are used in a message text, these are replaced consecutively by the fields f1 to f4.

To aid compilation, only numbered variables (&1 to &4) are to be used in future if several fields are involved.

If a "&" is supposed to appear in the message at runtime, you must enter &&.

In the long text of a message, the symbol &Vi& is replaced by the field contents of fi.

After WITH, you can specify 1 to 4 fields.

Note

You can output up to 50 characters per field. If the field contains more characters, these are ignored.

Example

MESSAGE E0004 WITH 'Hugo'.

Note

When executing the statement, the contents of the fields f1 to f4 are assigned to the system fields SY-MSGV1, SY-MSGV2, SY-MSGV3 and SY-MSGV4.

Addition 2

... RAISING exception

Effect

Only possible within a function module or a method (see FUNCTION, METHOD):

Triggers the exception exception.

If the program calling the function module or method handles the exception itself, control returns immediately to that program (see CALL FUNCTION and CALL METHOD). Only then are the current values passed from the procedure to the EXPORTING-, CHANGING- (und RETURNING) parameters of the function module or method, if they are specified as pass-by- reference. However, the calling program can refer to the system field values (see above).

If the calling program does not handle the exception itself, the message is output (see RAISE).

You cannot use this addition in conjunction with the ... INTO cf addition.

Example

MESSAGE E001 RAISING NOT_FOUND.

Addition 3

... INTO f

Effect

Instead of displaying the message, the system places the message text in the field f. The message type is not evaluated.

You cannot use this addition in conjunction with the ...RAISING exception addition. The system sets the following system variables: SY-MSGID (message class), SY-MSGTY (message type), SY-MSGNO (message number) and SY-MSGV1, SY-MSGV2, SY-MSGV3, SY-MSGV4 (parameters).

Example

DATA msgtext(72).

...

MESSAGE E004 WITH 'Hugo' INTO msgtext.

Variant 2

MESSAGE ID id TYPE mtype NUMBER n.

Effect

As for variant 1, where you can set the following message components dnyamically:

ID

Message class

TYPE

Message type

NUMBER

Message number

You can also use all the other additions as with the basic form.

Example

MESSAGE ID 'SU' TYPE 'E' NUMBER '004' WITH 'Hugo'.

Outputs the message with the number 004 and MESSAGE-ID SU (see above) as an E (Error) message and replaces the first variable (&) with 'Hugo'.

Example

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

Constructs the message dynamically from the contents of the system fields SY-MSGID, SY-MSGTY, SY-MSGNR , SY-MSGV1 , SY-MSGV2,SY-MSGV3,and SY-MSGV4. These may, for example, be set by an exception after CALL FUNCTION or CALL TRANSACTION ... USING.

Variant 3

MESSAGE xnnn(mid).

Effect

As in variant 2.

Example

MESSAGE X004(SU) WITH 'Hugo'.

Note

Non-Catchable Exceptions:

  • MESSAGE_TYPE_UNKNOWN: message type unknown

  • MESSAGE_TYPE_X: Triggers termination with a short dump