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

How to sort an message internal table.?

Former Member
0 Likes
1,038

Hi Folks,

I'm looping the standard messages of SAP into an internal table.

The standard messages were stored in SAP internal table as below format.

MSGTYP MSGID MSGNO MSGV1 MSGV2 MSGV3

W FB_ICRC 058 1 Company 008340

W FB_ICRC 058 2 Company 008340

W FB_ICRC 058 3 Company 008340

W FB_ICRC 058 4 Company 008340

W FB_ICRC 058 5 Company 008340

I am using the function module CALL FUNCTION 'FORMAT_MESSAGE' and pass the above parameters ,to get the original messages..

My Issue is that i am getting the duplicate entries in the internal table,

Line 5: Field Company: 008340 not valid according to restrictions

Line 4: Field Company: 008340 not valid according to restrictions

Line 3: Field Company: 008340 not valid according to restrictions

Line 2: Field Company: 008340 not valid according to restrictions

Line 1: Field Company: 008340 not valid according to restrictions

Line 4: Field Company: 008340 not valid according to restrictions

Line 3: Field Company: 008340 not valid according to restrictions

Line 2: Field Company: 008340 not valid according to restrictions

Line 1: Field Company: 008340 not valid according to restrictions

Line 3: Field Company: 008340 not valid according to restrictions

Line 2: Field Company: 008340 not valid according to restrictions

Line 1: Field Company: 008340 not valid according to restrictions

Line 2: Field Company: 008340 not valid according to restrictions

Line 1: Field Company: 008340 not valid according to restrictions

I'm getting the duplicate entries which is leading to SAP Dump because of Paging Memory ...while i'm trying to export the internal table...

How to eliminate the duplicate entries in the above internal table?

6 REPLIES 6
Read only

former_member206439
Contributor
0 Likes
980

SORT the table based on MSGTYP MSGID MSGNO and delete the adjacent duplicates from the table by using DELETE ADJACENT DUPLICATES statement.

Read only

Former Member
0 Likes
980

Can i use the function module BAL_LOG_MSG_ADD instead of 'FORMAT_MESSAGE' to eliminate the duplicate entries?

Read only

Former Member
0 Likes
980

Hi naresh,

The MSG TYP, MSG ID were in SAP internal table (standard) i cant change the standard fuunctionality.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
980

You said you are using 'FORMAT_MESSAGE' to display the message. So we understand there is a custom code written somewhere. This implies you've access to the internal table with the messages. The idea is to sort the table & delete the duplicate recs before calling 'FORMAT_MESSAGE'.

SORT IT_MSG.

DELETE ADJACENT DUPLICATES FROM IT_MSG COMPARING ALL FIELDS.

Now i don't understand why you can't write the above logic in your code.

BR,

Suhas

PS: You can use MESSAGE ... INTO addition instead of FORMAT_MESSAGE to get the message text.

Read only

0 Likes
980

If your getting this dump in standard program then you have to contact SAP on this issue.

If you are using some standard FM return message internal table in custom program then you can delete adjacent duplicates no issues.

Read only

Former Member
0 Likes
980

Try the below code

LOOP AT it_msg ASSIGNING <fs_msg>.


  MESSAGE ID <fs_msg>-msgid TYPE <fs_msg>-msgty NUMBER <fs_msg>-msgno
                INTO wa_msg
                WITH <fs_msg>-msgv1 <fs_msg>-msgv2 <fs_msg>-msgv3.

  APPEND wa_msg TO it_output.

ENDLOOP.

SORT it_output ASCENDING.

DELETE ADJACENT DUPLICATES FROM it_output COMPARING ALL FIELDS.