11-10-2015 1:18 PM
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.
Regards,
Ranjith.
11-10-2015 1: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
11-10-2015 1: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
11-10-2015 1: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
11-10-2015 2: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
11-10-2015 5:14 PM
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
11-10-2015 6: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.