Skip to Content

String operations on error messages

Hi Team,

i would to get only the SAP user id in the error message which would be 8 characters .

Could you please help me in getting the below output. I would require only the last 8 characters of the string.

  1. InputàMaterial 000000692122 is lock y PRESTOGE (string having any number of characters)
  2. Outputà PRESTOGE

Regards,

Ranjith.

ss.png (39.5 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Posted on Nov 10, 2015 at 02:20 PM

    My 2 cents ...

    The message M3(022) is defined as -

    The group data for the material & is locked by &

    So basically the fields should be mapped as: MESSAGE_V1 = <material no.> & MESSAGE_V2 = <user name>.


    I would suggest you to correct the source table X_MSG_TAB, because IMHO the content is false. The message text should be mapped to the field MESSAGE.


    BR,

    Suhas

    Add a comment
    10|10000 characters needed characters exceeded

    • I agree.

      Also, looking at the structure, it seems to be a custom development - No standard message structure would have just MESSAGE_V1 & V2 fields. Standard structures for messages will always have V1, V2, V3 and V4 fields. So, please fix the custom code, to pass back the values correctly.

      If you just need the name of the person who locked the object, you can also call the function module ENQUEUE_READ.

      Thanks,

      Juwin

  • Posted on Nov 10, 2015 at 01:27 PM

    Hi,

    what you can do is getting the last 8 chars of your string.

    data(lv_offset) = strlen(message_v1)

    lv_offset = lv_offset - 8.

    move message_v1+(lv_offset) to lv_user_id

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 10, 2015 at 01:35 PM

    Hi Ranjith,

    Pass X_MSG_TAB data to FM

    CALL FUNCTION 'FORMAT_MESSAGE' "

    * EXPORTING

    * id = SY-MSGID " Application Area

    * lang = '-D' "

    * no = SY-MSGNO "

    * v1 = SY-MSGV1 " 1st parameter

    * v2 = SY-MSGV2 " 2nd parameter

    * v3 = SY-MSGV3 " 3rd parameter

    * v4 = SY-MSGV4 " 4th Parameter

    IMPORTING

    msg = MESSAGE

    EXCEPTIONS

    NOT_FOUND = 1 "

    . " FORMAT_MESSAGE

    so you will get complete message "Input Material 000000692122 is locked by PRESTOGE" in Message variable.

    After that Use Split command.

    Data: text type string,

    username type sy-uname.

    SPLIT MESSAGE AT 'by' into text username.

    In Username variable you will get PRESTOGE.

    Thanks.

    Regards,

    Ashish Desai

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 10, 2015 at 01:37 PM

    Your assumption is wrong. The user ID maynot be always 8 characters ( It can be upto 12 characters )

    Also looking at the message M3 023 - "The group data for the material & is locked by &" your population of MESSAGE_V1 and MESSAGE_V2 is not right.

    Anyway.

    I would not go for offset as I explained in the first paragraph.

    I would use

    1.concatenate MESSAGE_V1 and MESSAGE_V2 into a <string>.

    2. Split string at space into table itab.

    3. Will read the last line of Itab and get the user ID.

    data(lv_lines) = LINES(itab).

    read table itab index lv_lines.

    R

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 10, 2015 at 06:05 PM

    What transaction code are you running?

    When does this error message occur in the program?

    If it is a standard message, you can read the message class and number and go to the message table T100, read the message into a string variable and read the last 8 characters using the offset function.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.