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

perform using and changing addtions in global declaration

Former Member
0 Likes
1,362

experts

1)

data : tedi_ds type edi_ds.

perform inteakm changing tedi_ds.

form inteakm changing tedi_ds.

-


---

endform.

in above statement it gives a error like

The data object "TEDI_DS" has no structure and therefore no component called " TABNAM".

=== here tabnam is the field of edi_ds.this is not a probelm.

If i decalre the same above statement like this it wont give the problem.

form inteakm changing tedi_ds like edi_ds.

=====================

2)

I checked the same scenario with using.

perform inteakm using tedi_ds.

form inteakm using tedi_ds.

here i didnt get any error , why its not giving probelm in using and why only changing can any one tell me.

===========

3)

i used the same name in perform and form ie tedi_ds. Is it necessary to change in form ?

perform inteakm using tedi_ds.

form inteakm using p_tedi_ds.

---

---

endfrom.

as per standard do we need to maintain the same name or differnt name. if we have the same name do we face any problems?

=========

4)in the above i have declared

data :tedi_ds type edi_ds in the global section of the report.

so eventhough i not using the using and changing additions still the data in the work area is visible in the other subroutines in the program.

Do I still need to use the using and changing? When actually we need to use this additions as per the coding standards?

thanks for the help.

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
1,158

I thought it was specific, but if you still feel hungry of knowledge let me help you;)

1) define your form with


form inteakm changing tedi_ds type edi_ds.
   "here you will  be able to address TABNAM
   tedi_ds-tabnam = ....  
endform.

or


form inteakm changing tedi_ds structure edi_ds.
  "same here, as the system knows that TED_DS is of structure EDI_DS
enform.

2) USING or CHANGING it doesn't really matter, the system should show you in both cases the same error if you are trying to use some component like TABNAM inside it without giving exact structure type


form inteakm CHANGING tedi_ds.
     tedi_ds-tabnam = 'Some text'.  "this will be an error, system simple can't be sure that TEDI_DS has this component as you didn't say that in form's interface (parameter is untyped - no EDI_DS type was specified)
endform.

I checked it myself and in both cases I can error only if I try to adress some component of TEDI_DS inside form, otherwise system will not yell.

3) As told before, name should be different i.e but don't have to


data : tedi_ds type edi_ds.

perform inteakm changing tedi_ds.

form inteakm CHANGING f_tedi_ds TYPE edi_ds.  
   "now you know
   f_tedi_ds-tabnam = ... "now you know that you are working with formal parameter F_TEDI_DS, otheriwse if names are the same it is confusing to someone who reads the code, but is not forbidden
endform.

4) This global data will be visible accross your entire report, also in all its subroutines (as subroutine is part of report).

But due to reason I described before you should avoid changing/using global data inside subroutines. Always pass data to subroutine which you are working with inside it. i.e.


data: var1 type c.

form sub1 changing f_var1 type c.
   "now you work with formal parameter not the global one
endform.

"...althought global parameter is passed to SUB1
PERFORM sub1 changing VAR1.

Regards

Marcin

I thought it was specific, but if you still feel hungry of knowledge let me help you;)

1) define your form with


form inteakm changing tedi_ds type edi_ds.
   "here you will  be able to address TABNAM
   tedi_ds-tabnam = ....  
endform.

or


form inteakm changing tedi_ds structure edi_ds.
  "same here, as the system knows that TED_DS is of structure EDI_DS
enform.

2) USING or CHANGING it doesn't really matter, the system should show you in both cases the same error if you are trying to use some component like TABNAM inside it without giving exact structure type


form inteakm CHANGING tedi_ds.
     tedi_ds-tabnam = 'Some text'.  "this will be an error, system simple can't be sure that TEDI_DS has this component as you didn't say that in form's interface (parameter is untyped - no EDI_DS type was specified)
endform.

I checked it myself and in both cases I can error only if I try to adress some component of TEDI_DS inside form, otherwise system will not yell.

3) As told before, name should be different i.e but don't have to


data : tedi_ds type edi_ds.

perform inteakm changing tedi_ds.

form inteakm CHANGING f_tedi_ds TYPE edi_ds.  
   "now you know
   f_tedi_ds-tabnam = ... "now you know that you are working with formal parameter F_TEDI_DS, otheriwse if names are the same it is confusing to someone who reads the code, but is not forbidden
endform.

4) This global data will be visible accross your entire report, also in all its subroutines (as subroutine is part of report).

But due to reason I described before you should avoid changing/using global data inside subroutines. Always pass data to subroutine which you are working with inside it. i.e.


data: var1 type c.

form sub1 changing f_var1 type c.
   "now you work with formal parameter not the global one
endform.

"...althought global parameter is passed to SUB1
PERFORM sub1 changing VAR1.

Regards

Marcin

5 REPLIES 5
Read only

MarcinPciak
Active Contributor
0 Likes
1,158

This is beacuse when you don't type your formal parameter (the one in subroutine signature), the strcutrue of the component passed to it will be only known during runtime. So you cannot address its components statically


form inteakm changing tedi_ds . "here using TYPE or STRUCTURE will set static type for TEDI_DS.
  "so here you will be able to address its componetns
  tedi_ds-field1..
  "Otherwise it will be impossible as system don't know if you are passing strcutre which REALLY has this component , it may not
ENDFORM.

So you must type it fully (give exact type in order to adrress its componetns in form body). Or you will have to address its components dynamically, ie. via field-symbols (if you will omit this TYPE ...).

Names here doens't affect anything. They can be the same, although it is recommended to name them differently as it create confusions whether you are adrressing TEDI_DS (which is global) or TEDI_DS (which is local).

As for the last question in order data can be encapsulated, you should never address any global components inside it. Image if someone would like to use your subroutine. He would call it externally and system would dump out as he would not recognize your global data externally. You must always look at the object you create (subroutines, methods, function modules) as of you were the user and someone who doesn't know its implementation. So the interface of such object is his IDENTITY to user. He only knows its name (which might be ambigous) and parameters (interface). So only based on that he can use it correctly.

Please note!

In function modules you may address global data, but only because they are encapsulated in more general Function Group (so you are in fact addressing only function group's global data which is hidden for user). The same applies to Classes. Method can address global data of method, which are its attributes. Nevetherlses the whole class still remains one enitity invisible to user.

Hope now you undestand the concept

Regards

Marcin

Read only

0 Likes
1,158

experts could i get specific answers to my questions 1 ,2,3,4..

Read only

Former Member
0 Likes
1,158

1.

for a FORM signature you have to give the type of parameter you are passing to it.

data : tedi_ds type edi_ds.
perform inteakm changing tedi_ds.

form inteakm changing p_tedi_ds type edi_ds.
---
endform.

in this pattern when the form is called it will pass the actual parameter tedi_ds to the form parameter p_tedi_ds. which is of same type. u need to specify the type. else its of type c

just as the same as

data : p1. "=>p1 is a variable of type C length 1. does it have any field in it? NO. same in the case of subroutine declarations.

_______________________

2.

both case it will give error.

3)

i used the same name in perform and form ie tedi_ds. Is it necessary to change in form ?

perform inteakm using tedi_ds.
form inteakm using p_tedi_ds.
---
---
endfrom.

same name is not needed. because in perform we pass the actual parameter and in form endform it passes the values the subroutine parameter

=========

4)in the above i have declared

data :tedi_ds type edi_ds in the global section of the report.

so eventhough i not using the using and changing additions still the data in the work area is visible in the other subroutines in the program.
Do I still need to use the using and changing? When actually we need to use this additions as per the coding standards?

if you declare it as a global variable no need to pass it in the FM.

passing is needed ny when you have different things to pass. like in the case of multiple calls to the subroutine.

________

just compare the form endform and perform in the similar way of call function <FM name>. here also you have parameters and names.

Edited by: soumya prakash mishra on Aug 18, 2009 4:50 PM

Read only

0 Likes
1,158

thanks for both of you for investing time to help me understand.

Read only

MarcinPciak
Active Contributor
0 Likes
1,159

I thought it was specific, but if you still feel hungry of knowledge let me help you;)

1) define your form with


form inteakm changing tedi_ds type edi_ds.
   "here you will  be able to address TABNAM
   tedi_ds-tabnam = ....  
endform.

or


form inteakm changing tedi_ds structure edi_ds.
  "same here, as the system knows that TED_DS is of structure EDI_DS
enform.

2) USING or CHANGING it doesn't really matter, the system should show you in both cases the same error if you are trying to use some component like TABNAM inside it without giving exact structure type


form inteakm CHANGING tedi_ds.
     tedi_ds-tabnam = 'Some text'.  "this will be an error, system simple can't be sure that TEDI_DS has this component as you didn't say that in form's interface (parameter is untyped - no EDI_DS type was specified)
endform.

I checked it myself and in both cases I can error only if I try to adress some component of TEDI_DS inside form, otherwise system will not yell.

3) As told before, name should be different i.e but don't have to


data : tedi_ds type edi_ds.

perform inteakm changing tedi_ds.

form inteakm CHANGING f_tedi_ds TYPE edi_ds.  
   "now you know
   f_tedi_ds-tabnam = ... "now you know that you are working with formal parameter F_TEDI_DS, otheriwse if names are the same it is confusing to someone who reads the code, but is not forbidden
endform.

4) This global data will be visible accross your entire report, also in all its subroutines (as subroutine is part of report).

But due to reason I described before you should avoid changing/using global data inside subroutines. Always pass data to subroutine which you are working with inside it. i.e.


data: var1 type c.

form sub1 changing f_var1 type c.
   "now you work with formal parameter not the global one
endform.

"...althought global parameter is passed to SUB1
PERFORM sub1 changing VAR1.

Regards

Marcin