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

Control / Variable name causes confusion .

Former Member
0 Likes
408

while working on screen programming. example code:

PROGRAM  ZTEST_SCREEN_ONE.
*&---------------------------------------------------------------------*
*&      Module  ZPRNV_ADD  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE ZPRNV_ADD INPUT.
"UNCOMMENT THE MODULE AND GIVE A NAME AND DOUBLE CLICK TO CREATE PAI MODULE
  



"SY-UCOMM system variable which gives the command name which triggered this function
  IF SY-UCOMM = 'ADD'.
    
    "declare the variable with same name as the name given in design layout 
    "with this data will be mapped automatically on/off the screen
    DATA: TXT_A TYPE I  ,
          TXT_B TYPE I ,
          TXT_RESULT TYPE I.

    TXT_RESULT = TXT_A + TXT_B .


  ELSE.
    LEAVE.
  ENDIF.

ENDMODULE.                 " ZPRNV_ADD  INPUT

if we somehow declare a variable in the function with the same name as of a control(eg textbox) , compiler maps them into one .

This may raise errors if we aren't aware of the variable names that are already in use and start to code on modules.

Q: Is there any way to avoid the same ?

i m new to ABAP

2 REPLIES 2
Read only

Former Member
0 Likes
384

Hi,

In this condition u can use any variables so to diffrentiate frm urs better add 'Z' infront of the variable so tht u can easily identify.

Thanks,

Arunprasad.P

Reward if useful.

Read only

Former Member
0 Likes
384

Hi,

Declare variables in main program and then use it in screen.We can use Screen field and prg variables are same in SAP.this method is better. don't use diferent name for screen and prg. that will not suport for long time. you will get idea about this.you just use this concept now.