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

Constants as a method parameters

former_member355168
Participant
0 Likes
2,838

Dear Experts,

I just want to know how do we find out the constants that we pass as a parameter to a method.

For example,

while implementing TOP_OF_PAGE event, I have to use ADD_TEXT method.

In this method we passing following parameters along with other

          fix_lines     = 'X'

         sap_style     = cl_dd_area=>heading

         sap_color     = cl_dd_area=>list_heading_int

         sap_fontsize  = cl_dd_area=>large

How will I find out what can be pass to above exporting parameters like I have passed following

cl_dd_area=>heading or cl_dd_area=>list_heading_int or cl_dd_area=>large.

Regards,

Jaspal Kumar

10 REPLIES 10
Read only

roberto_vacca2
Active Contributor
0 Likes
2,176

Hi.

I suppose  you need to see Interface CL_DD_DOCUMENT. From SE24 you'll see your method ADD_TEXT and its parameters.

Parameters:

TEXTImportingTypeSDYDO_TEXT_ELEMENT
TEXT_TABLEImportingTypeSDYDO_TEXT_TABLE
FIX_LINESImportingTypeSDYDO_FLAG
SAP_STYLEImportingTypeSDYDO_ATTRIBUTE
SAP_COLORImportingTypeSDYDO_ATTRIBUTE
SAP_FONTSIZEImportingTypeSDYDO_ATTRIBUTE
SAP_FONTSTYLEImportingTypeSDYDO_ATTRIBUTE
SAP_EMPHASISImportingTypeSDYDO_ATTRIBUTE
STYLE_CLASSImportingTypeSDYDO_ATTRIBUTE
DOCUMENTChangingType Ref ToCL_DD_DOCUMENT

Hope to help.

Bye

Read only

0 Likes
2,176

In the Class - CL_DD_AREA, you will find that SAP_STYLE is a Parameter of the METHOD Add_text. This parameter of type - SDYDO_ATTRIBUTE.

Now go to the "Attribute tab" of this class. Any attribute which is of type SDYDO_ATTRIBUTE can be assigned here. But since it is attribute of the class CL_DD_AREA, hence it is assigned using CL_DD_AREA=>heading , etc...

Read only

0 Likes
2,176

Ags thanks for ur reply.

you are right. I can go to the

I as asking how would I know the possible values for these parameters as I have passed

as

sap_style     = cl_dd_area=>heading.

how would i know that the attribute sap_style  will have cl_dd_area=>heading value.

regards,

Jaspal Kumar

Read only

0 Likes
2,176

Because This attribute sap_style is of data type - SDYDO_ATTRIBUTE and can only accept values of that type.


I hope i got your question correctly? Or else let me know.

Read only

0 Likes
2,176

Hi ags,

I really appreciate ur help. Let me put my question in other way.

example,

In FI module, there is a field called SHKZG for debit and credit.

whenever we use this domain , we can only enter 'S' or 'H' which is defined at domain level.

whenever we use this filed, we can enter only 'H' or 'S'.

now i come to my question.

I know that  sap_style is of data type - SDYDO_ATTRIBUTE and can only accept values of that type.

But where can i find the values for sap_style attribute. Type is ok, it can accept value of type SDYDO_ATTRIBUTE .


I hope now my question is clear.


Thanks a lot once again for help.


Regards,

Jaspal

Read only

0 Likes
2,176

Yes, because for SHKZG values are maintained at DOMAIN level, but for SDYDO_ATTRIBUTE is part of the global Type-pool. If you double click it will show. Its not maintained at Database level, but a global variable only.

So to figure out the permitted values, you can go to the class - CL_DD_AREA and check its ATTRIBUTE tab. you will see the constants with values "EMPHASIS", "HEADING" etc. You can use these.

Another way is to get inside method ADD_TEXT and check the code. 1 time effort, but it will give you better clarification how SAP handles it.

"

* handle styles

   CALL METHOD handle_styles EXPORTING sap_style     = sap_style

"

Just note that this class,typepool,constant etc belong to the same package - SDYNAMICDOCUMENTS.

So the concept is that SAP must be creating all the permitted values in same package. You can search any values of this kind in future using this concept, if you feel lost.

Read only

0 Likes
2,176

Hi Ags,

Thanks once again.

now we are very close. like you said

"So to figure out the permitted values, you can go to the class - CL_DD_AREA and check its ATTRIBUTE tab. you will see the constants with values "EMPHASIS", "HEADING" etc. You can use these."

Now My question was, where it is mentioned that the for permitted values, I have to refer CL_DD_AREA class. Or Values from CL_DD_AREA class can be used in the method ADD_TEXT.


Regards,

Jaspal

Read only

0 Likes
2,176

As I told you, if a method belongs to a class and uses CONSTANTS as its parameters, the CLASS is ought to have ATTRUBUTEs defined for the constants, or else we can never find out the values.

The values will always be there in the same class attribute or the superclass attrbutes.

Read only

0 Likes
2,176

Hi Ags,

when I check method parameters, for example only ADD_TEXT, One parameter is SAP STYLE and it is of TYPE SDYDO_ATTRIBUTE and in description, " Recommended Styles'.

This SDYDO_ATTRIBUTE does not give any recommended value list nor it is mentioning that for recommended styles, I should refer the base class CL_DD_AREA.


I just wanted to know how and where to find these recommended values from?


but your line  " The values will always be there in the same class attribute or the superclass attributes." is very helpful.

Regards,

Jaspal

Read only

jrg_wulf
Active Contributor
0 Likes
2,176

Hi,

These constants are meant to simplify your task. Because they use symbolic names rather then internal value, you should be able to deduce from their name, wich one to use.

Admittedly, in this case names and values are identical - but you get the Intention.

In your example, you used cl_dd_area=>heading, for Parameter sap_style, meaning that you want your text to appear formatted as header.

If you have an idea (and usually you will), what your text is supposed to look like, by browsing the available constant-attributes of class cl_dd_area, you should be able to decide, which ones to use.

Best regards - Jörg