‎2007 Mar 01 7:34 AM
Can anyone please for what do we use each of the below.
constants: c_3(1) type c value '3' ,
c_i(1) type c value 'I' ,
c_x(1) type c value 'X' ,
c_eq(2) type c value 'EQ' ,
c_pl03 like p0001-werks value 'PL03'.
For example:
constants: c_1(1) type c value '1' ."checks if reading is succesful
Thanks.
‎2007 Mar 01 7:38 AM
Hi Shakeen,
It's a <b>CONSTANT</b> (It's value never change at any point)
c_3(1) = 3.
Whereever u use the c_3 it's value will be 3.
Variable - value change often,
Constant - value never change.
Rgds,
Jothi.P
‎2007 Mar 01 7:38 AM
Hi Shakeen,
It's a <b>CONSTANT</b> (It's value never change at any point)
c_3(1) = 3.
Whereever u use the c_3 it's value will be 3.
Variable - value change often,
Constant - value never change.
Rgds,
Jothi.P
‎2007 Mar 01 7:40 AM
Hi shaheen,
Here we r assigning some constant values for those variables which are of char type and p0001-werks type.
‎2007 Mar 01 7:42 AM
Hi!
use
constants: c_3(1) type c value '3' ,
c_i(1) type c value 'I' ,
c_x(1) type c value 'X' ,
c_eq(2) type c value 'EQ' ,
c_pl03(4) value 'PL03'.
I think it's help you.
And you can do this too:
data: c_pl03 like p0001-werks value 'PL03'.
‎2007 Mar 01 7:48 AM
Hi Shaheen,
The Code that has been wirtten is called as constant decleration.
Constatns are used in coding for keeping a fixed value in a varible.
Suppose say
constants: c_3(1) type c value '3' .
Whereever you use c_3 it will be replaced with value 3 in runtime of the program.
And constants are used for avoiding hardcoing in the coding also and it will easy to change a value in the code which is used many times.
Regards,
Harsha
Reward points if helpful.
‎2007 Mar 01 7:54 AM
using CONSTANT u can define a constant whose value will not change, i mean in prog if u r using one value at more than one places then u can assign it to one constant and use that constant everywhere and lateron if u want to change that value then u need to change it only at one place ...
Variable - data objects whose value change often,
Constant - data objects whose value never changes.
reward if useful.
‎2007 Mar 01 7:57 AM
‎2007 Mar 01 7:59 AM
that is just a naming convension c for constant and i for integer and so on....
reward if useful.
‎2007 Mar 01 8:04 AM
Thanks alot. So if I want to set a default value for active employee do I need to have the following code
pnpstat2-sign = c_i.
pnpstat2-option = c_EQ.
pnpstat2-low = c_3. " active employee
append pnpstat2.
Or simply can I write
pnpstat2-low = c_3. " active employee
append pnpstat2.
‎2007 Mar 01 8:09 AM
Hi Shaheen,
You need to use the first code i.e. :
pnpstat2-sign = c_i.
pnpstat2-option = c_EQ.
pnpstat2-low = c_3. " active employee
append pnpstat2.
Thanks,
Imran
‎2007 Mar 01 8:12 AM
Thanks, but can you explain why? aren't they just a naming convention
‎2007 Mar 01 8:25 AM
Shaheen,
naming conventions are the rules that ur organization follows.
nothing more than that.
Regards,
Sujatha.
‎2007 Mar 01 8:43 AM
Hi Shaheen,
Naming conventions are set of rules defined by a org/pers. It's not <b>mandatory.</b>
It's easy to use.You can give any name for your variable,internal table,structure in your program.But if someother person wants to modify your code he may be confused.So you hav to define naming convention for your org.
For example..
All the variables should start with V_xxx,
Internal tables should start with Itab_xxxx,
All the program names should start with YHRxxxx -> for customized HR pgms.
YFIxxxx -> for customized FI pgms
Hope you got idea.
Rgds,
Jothi.P
‎2007 Mar 01 8:01 AM
Hi ,
those r some variable names ,it can be anything.
c_i(1) means its a variable the name c_i occupying 1 char.
c_x(1) means varaible c_x having 1 char memory.
c_eq(2) means variable can hold 2 characters
‎2007 Mar 01 8:11 AM
‎2007 Mar 01 8:16 AM
Hi,
select-options: s_ppnstat2 for .......default 'c_3'.
here s_ppnstat2 is a variable .but its select-option ,so using s_ppnstat2.
then if we give default value that will be assigned to low only,so no need to specify as ppnstat2-low = 'c_3'.