cancel
Showing results for 
Search instead for 
Did you mean: 

Want to show my own Error message after sending data through Input Schedule

Former Member
0 Kudos

Hi,

I want to show some Validation Messages.

I did the calculation in a Custome Logic BAdI.

To show the message I wrote :

              

            Data : l_log TYPE String.

            IF tot_percent > 1.

                  l_log  = |'Warning : Total Percentage exceeds 100%'|.
                 cl_ujk_logger=>log( i_object = l_log ).

           ENDIF.

Please suggest How to achieve this.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

former_member200327
Active Contributor
0 Kudos

Hi Shubhranshu,

This kind of messages are better handled handled by Validation rules. Check transaction UJ_VALIDATION.

Gersh

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

If restricting users from entering total percentage more than 100% is what you are looking for, why cannot this be handled in the input form itself, by using the combination of excel formula and simple macro.

Regards,

Sumanth

Former Member
0 Kudos

Hi Sumanth,

We can do this using excel formula and macro, if the input schedule is like a static report.

But here the input schedules are very dynamic and we have appx 30-40 input schedules.

So It's a very though task to write macro.

Thanks for your reply

former_member186338
Active Contributor
0 Kudos

Hi,

You can add some messages only in write back badi, not in the custom logic badi.

B.R. Vadim

former_member186338
Active Contributor
0 Kudos

P.S.

In theory you can store the message text in some place (per user) by custom logic badi and then inside write back badi check this place and if it's not empty - append this text to messages and clear the place. But this approach is very tricky...

Vadim

Former Member
0 Kudos

Hi Vadim,

I have few doubts :

1. What is the Use of  ET_MESSAGE parameter in both Custom and Write Back BAdI ?

2. How can I populate this ET_MESSAGE with my own Custom Message.

3. If you are telling, we can add our custom message  from Write Back BAdI. Please tell how to do it?

Thank You.

former_member186338
Active Contributor
0 Kudos

Hi,

I will show some working code in the write back badi. This code will test if the current member of the account dimension has property IS_INPUT set to Y, and if not set to Y then reject the record and show error in the excel popup message.

ASSIGN COMPONENT 'IS_INPUT' OF STRUCTURE <ls_account_mbr> TO <lf_input>.

  IF sy-subrc = 0.

    "Disallow writing to members of account dimension with property IS_INPUT<>Y from input schedule or journal (allow for DM only)

    IF ( <lf_input> <> 'Y' ) AND ( I_MODULE_ID <> 'DM' ).

      CONCATENATE '>> Dimension' <l_account> 'has property IS_INPUT<>"Y". Record rejected.' INTO log_msg SEPARATED BY SPACE.

      cl_ujk_logger=>log( log_msg ).

      CONVERT_CTDATA2STR( exporting PT_DATA     = <ls_record>

                                    PT_DIM_OBJ = IT_DIM_OBJ

                          importing PT_STR      = log_msg ).

      CONCATENATE 'IS_INPUT<>"Y">' log_msg INTO log_msg.

      ls_message-MSGID = 'ZBPC'.

      ls_message-MSGNO = '042'.

      ls_message-MSGTY = 'E'.

      ls_message-MESSAGE = log_msg.

      ls_message-RECNO = sy-TABIX.

      APPEND ls_message TO ET_MESSAGE.

      APPEND <ls_record> TO ET_ERROR_RECORDS. " Rejected records +1.

      DELETE ct_array. "Delete current record

      CONTINUE.

    ENDIF.

  ENDIF.

The message is like this:

Vadim

P.S. The same code can be written in UJ_VALIDATION...

Former Member
0 Kudos

Hi Vadim,

Q 1. How you determine the below values

                ls_message-MSGID = 'ZBCP'

                ls_message-MSGNO = '042'.

                ls_message-MSGTY = 'E'.

Q 2. If you are showing the Error message with the help of ET_MESSAGE,

          then you are using " cl_ujk_logger=>log( log_msg ). " statement. What is the use of this line.

Q 3. ET_MESSAGE Parameter is available for Custom Logic also, then why we can't show our Own message from Custom BAdI ?

Thank You

former_member186338
Active Contributor
0 Kudos

1. I don't remember - from this forum, from How-To guides, debugging the original BPC ABAP code...

2. The log will be written to the log file independent from ET_MESSAGE. It's possible to find this log in UJFS and see this text.

3. As far as I remember the ET_MESSAGE of custom logic badi will not be shown in the Excel popup.

Vadim

Former Member
0 Kudos

Hi Vadim,

I tried to implement this, but it's not showing any message.

former_member200327
Active Contributor
0 Kudos

Hi Shubhranshu,

Short explanation to Q 1. above.

SAP has a standard way of reporting messages back to user. Message templates are stored in message classes (t/a SE91). So, MSGID is Message Class. Custom message classes start form Z.

Each message has a unique numeric ID - message number. So, MSGNO - is message number.

There is a number of message types that SAP supports - E for error, W for warning, etc.

Usually message also has parameters that are &1, &2, etc in the message and VAR1, VAR2, etc when message is called. Alternatively one can use field MESSAGE, but this makes translation much more difficult.

Hope this helps,

Gersh

former_member186338
Active Contributor
0 Kudos

Hi Shubhranshu,

Where do you implement this code? In write back badi or in custom logic badi? If you do it in custom logic badi then you will see no message... (Q3)

Vadim

Former Member
0 Kudos

I just tried implement the TRIC you talked in your 1st post.

Means,

I just poulated some data in CT_DATA in Custome logic,

then inside Write Back, I am trying to read that data from CT_ARRAY.

and populating the ET_MESSAGE and ET_ERROR_RECORDS.

It's not working.

Can you tell me which part of Code is responsible to write the Data to Output screen?

Thanks

former_member186338
Active Contributor
0 Kudos

First: create a write back badi and test my code with some modifications to test some condition to ensure that you can see message in excel. The code to write data to output screen is internal BPC code, I only prepare the ET_MESSAGE: APPEND ls_message TO ET_MESSAGE.

Then continue with experiments.

In general:

If you want to validate input and reject records send by user (if something > 100 then reject) - then use badi in validation rule.

If you want to do some calculation like multiply 2 input members and store the result in the 3rd member, but you want also to validate the result - then you can combine both things in write back badi.

Vadim