cancel
Showing results for 
Search instead for 
Did you mean: 

Add message to the error log.

Former Member
0 Kudos

Hello Friends,

I am working on Marketing Planner.

I have implemented the BAdi CRM_MKTPL to automatically generate the Marketing Plan ID. The coding mask configuration is also in place. Now, my problem is when the coding mask is exhausted, and when we create a marketing plan element, the field will be blank, no Id is generated. This is the functionality required and it is working fine till now. Now, when I save it, this gives me an information message saying "Data has not been saved - see log". And when I go to the log button that is present in the right most corner, I can find the error "Enter an identification for the marketing element".

Now my requirement is, when I coding mask is exhausted and when I try to create the marketing plan there it should give a blank Id and also fill the log with the error message saying "Enter an identification for the marketing element".

I mean the error message that Iam getting on Save should come without the information message when I create a marketing plan after coding mask is exhausted.

I tried with CALL METHOD CL_CGPL_APPLICATION_LOG=>MESSAGE_ADD but it doesnt add a message to the log.

Regards,

Raju.

Accepted Solutions (1)

Accepted Solutions (1)

singhsmi
Advisor
Advisor
0 Kudos

Hi,

I think you are talking about application log.Use the following code.

data: gs_generate_log TYPE BAL_S_LOG.

data gS_MSG_bal TYPE BAL_S_MSG.

data gt_msg_bal type table of BAL_S_MSG.

if not gt_msg_bal[] is initial. " check your message table is not empty

      • OBJECT and SUBOBJECT are maintained via SLG0

gs_generate_log-OBJECT = give object name

  • lv_partner_log-SUBOBJECT = give subobject name.

gs_generate_log-ALDATE = SY-DATUM.

gs_generate_log-ALTIME = SY-UZEIT.

gs_generate_log-ALUSER = SY-UNAME.

gs_generate_log-ALPROG = SY-REPID.

CALL FUNCTION 'BAL_LOG_CREATE'

EXPORTING

I_S_LOG = gs_generate_log.

loop at gt_msg_bal into gs_msg_bal.

CALL FUNCTION 'BAL_LOG_MSG_ADD'

EXPORTING

I_S_MSG = gs_msg_bal.

endloop.

CALL FUNCTION 'BAL_DB_SAVE'

EXPORTING

i_save_all = 'X'.

endif.

This will create a log.

Object and subobject you can find using the message which is already logged in this log for your application.

Reward with points.

Smita.

Former Member
0 Kudos

Hi Smita,

Thanks a lot for the reply.

And can you please tell me how can I find the Object and Subobject? Also do I need to maintain the object and subobject through SLG0?

And when I tried to debug I find that the values of Object and Sub-Object are blank for previous log also.

Regards,

Raju

Message was edited by:

Narayana Raju Sampathirao

Former Member
0 Kudos

Hi Smita

I got the object and subobject in the table BALSUB. I used them.

But I was getting an error message

<b>Log cannot be saved. object/subobject not found</b>.

And when I debugged, in the FM BAL_LOG_CREATE, there is a field-symbol <g>

that is filled with the log data. In that first three entries had the object and subobject as blank. Fourth entry was having the value. When I passed the values in debug mode the message is getting added to the log.

Can you tell me what could be the reason for this?

Why <g> is getting filled eventhough I am calling it only for the fourth time.

Regards,

Raju

singhsmi
Advisor
Advisor
0 Kudos

Hi,

There must already be a log added with the same Marketing Plan ID. In this case

BAL_LOG_CREATE should not be called instead call BAL_DB_SEARCH.

ls_log_filter-extnumber = lt_ext_no.

ls_log_filter-object = lt_object.

ls_log_filter-subobject = lt_subobj.

  • Check if log for this identifier exists in DB.

CALL FUNCTION 'BAL_DB_SEARCH'

EXPORTING

I_CLIENT = SY-MANDT

I_S_LOG_FILTER = ls_log_filter

IMPORTING

E_T_LOG_HEADER = lt_log_header

EXCEPTIONS

LOG_NOT_FOUND = 1

NO_FILTER_CRITERIA = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

if it is there use the existing log header do not need to create again. If it is not there then create.

Thanks and warm regards,

Smita.

singhsmi
Advisor
Advisor
0 Kudos

Hi,

If it is in DB call the FM BAL_LOG_MSG_ADD like this.

CALL FUNCTION 'BAL_LOG_MSG_ADD'

EXPORTING

i_s_msg = ls_msg

i_log_handle = gs_log_handle

IMPORTING

E_S_MSG_HANDLE = ls_msg_handle

EXCEPTIONS

LOG_NOT_FOUND = 1

MSG_INCONSISTENT = 2

LOG_IS_FULL = 3

OTHERS = 4.

Thanks and warm regards,

Smita.

Former Member
0 Kudos

Hi Smita

Thanks a lot. My problem is solved. I changed the value of save_all from 'X' to '-'. It is working fine now.

Hats Off to you.....I have awarded full points to you.

Thanks & Regards

Raju

Answers (2)

Answers (2)

Former Member
0 Kudos

can someone explain if this error can be removed by the CRM consultant and how?

I am getting this error when saving a new campaign through Marketing Planner.

thanks.

Former Member
0 Kudos

Hi Friends,

Did anyone get the solution for this?

Is this the configuration part? Can we do this by any development?

Regards,

Raju

Former Member
0 Kudos

There is a function module to add message in log : CRM_MESSAGE_COLLECT

Don't know it is suitable for your requirement or not. Just try!

Thanks,

Shweta

Former Member
0 Kudos

Hi Swetha,

Thanks for the reply.

But the FM you specified needs the CRM object name and in the table CRMC_OBJECTS there is no such object for Marketing Plan.

Can you tell me why the method CL_CGPL_APPLICATION_LOG=>MESSAGE_ADD is not working?

Regards,

Raju

former_member927251
Active Contributor
0 Kudos

Hi Narayana,

You can use the method object_message_add of the class cl_cgpl_application_log.

Refer the following code sample :

CALL METHOD cl_cgpl_application_log=>object_message_add

EXPORTING

im_msgty = 'E'

im_msgid = 'ZCMK001'

im_msgno = '000'

IM_HIERARCHY_NODE = im_project.

OR

Check out if the method that you have implemented has ET_RETURN as exporting table. You can populate this table with the error message that you want to show in the application log.

Refer the following code sample:

ls_return-msgty = 'E'.

ls_return-msgid = ''.

ls_return-msgno = ''.

ls_return-msgv1 = ''.

append ls_return to et_return.

<b>Reward points if it helps.</b>