09-28-2012 3:23 PM
Hi all,
I'm trying to add a local field in a SAP query which clips the last 18 characters of a text field. I've tried using the =right() formula that works in Excel but can't get it to work.
Has anyone got an example of what to put in the Condition and Calculation boxes to get this to work?
Kind regards,
Dave
09-29-2012 4:13 AM
Hi,
I haven't really tried to add a local field in the query itself. What I do is if there to add the field in the infoset instead and provide there the logic.
Check "Creating Custom Fields" topic in this link:
http://scn.sap.com/community/erp/hcm/blog/2008/06/16/sap-adhoc-query-sq01-sq02-sq03
Thanks!
Rammel
09-29-2012 4:13 AM
Hi,
I haven't really tried to add a local field in the query itself. What I do is if there to add the field in the infoset instead and provide there the logic.
Check "Creating Custom Fields" topic in this link:
http://scn.sap.com/community/erp/hcm/blog/2008/06/16/sap-adhoc-query-sq01-sq02-sq03
Thanks!
Rammel
10-02-2012 12:51 PM
Hi Rammel,
Thanks for the reply! I am trying to get just the last 18 characters from the field CASE_GUID. Do you know what code I could use to achieve this in SQ02?
Many thanks
Dave
10-03-2012 2:06 AM
Hi,
I checked for CASE_GUID field and its length is 32. So basically the code would be NEW_CASE_GUID = CASE_GUID+14(18). You have to add another field in SQ02 and name it NEW_CASE_GUID. Then set this field to be displayed in SQ01.
Rammel
10-03-2012 5:42 PM
Hi,
Thanks again Rammel. I've tried the code but get an error and the infoset won't generate. Is the field type C? Do i just put NEW_CASE_GUID = CASE_GUID+14(18) in the code section and nothing else?
Thanks
Dave
10-04-2012 6:16 AM
Hi,
What error did you encounter? I checked field CASE_GUID in SE15, in most tables, it is defined as CHAR32. Did you follow the steps in this document for Creating Custom Fields?
http://scn.sap.com/community/erp/hcm/blog/2008/06/16/sap-adhoc-query-sq01-sq02-sq03
Thanks!
Rammel
10-05-2012 9:42 AM
Hi Rammel,
Yes I've followed the instructions, assigned the custom field to the group that contains field CASE_GUID. The code section is 'DATA' is that correct.?
Line 1 NEW_CASE_GUID = CASE_GUID+14(18)
The error is 'The last statement is not complete (period missing).
Many thanks
Dave
10-05-2012 10:29 AM
Hi Dave,
As indicated in the error, PERIOD is missing in the statement. Every ABAP statement must end in a '.'.
Regards,
Rammel
10-05-2012 11:59 AM
Hi Rammel,
I had to include the table name before the field name as it was not recognising it. This now works.
NEW_CASE_GUID = SCMG_T_CASE_ATTR-CASE_GUID+14(18).
Thank you very much it's really appreciated!
Regards
Dave
10-05-2012 1:07 PM
Hi Rammel,
I've just realised i also need the first five characters of the CASE_GUID field. Would it be possible to have them immediately before the last 18 characters in the same field? So i want to cut out the characters 6 to 14.
Many thanks
Dave
10-05-2012 4:17 PM
Hi Dave,
I am not sure if this the requirement, but you can use the concept governing this code. You can define 2 local variables in your ABAP Code.
LV_CHAR1 = SCMG_T_CASE_ATTR-CASE_GUID(5).
LV_CHAR2 = SCMG_T_CASE_ATTR-CASE_GUID+14(18).
CONCATENATE LV_CHAR1 LV_CHAR2 INTO NEW_CASE_GUID.
Rammel
10-08-2012 2:16 PM
Hi Rammel. I tried those three lines of code together but kept getting the error 'period is missing' even though full stops were at the end of each line. I set up three fields using the codes and that works fine. Thank you again.
Kind regards
Dave
10-03-2012 3:16 AM
Hi ,
Just wanted to check with you that is you r able to create local field if not let us know we will send you step by step process to define local variable & use calculation also .
Regards,
Yukti
10-03-2012 5:45 PM
Hi Yukti,
I have created some local fields with calculations that work ok. This is this first one i have had a problem with. I'm guessing that the =right(a1,18) formula that i use in Excel does not work in SQ01. Can you only choose from the functions listed + - DIV etc?
Thanks
Dave