Application Development 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: 

Local field in SQ01

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

13 REPLIES 13

Former Member
0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

Hi Dave,

As indicated in the error, PERIOD is missing in the statement. Every ABAP statement must end in a '.'.

Regards,

Rammel

0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

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