‎2005 Dec 16 5:56 AM
Hi,
I have a requirement like this
i have to retrive internal table from subroutine
(i.e. I have a internal table in include prg)
I want to retrive that internal table using subroutine how i can write subroutine prog.
If any body knows tell me
Like this
perform get_it using <variable> changing <internal table>
Internal table is in include prg.
Thanks
Regards,
Nandha
‎2005 Dec 16 7:59 AM
Hi nandha,
1. try this code (just copy paste)
REPORT abc.
*----
Can be in Include
DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
pernr LIKE pa0001-pernr,
END OF itab.
*----
DATA : t LIKE table of itab with header line.
PERFORM myform TABLES t.
*----
FORM myform TABLES tb STRUCTURE itab.
ENDFORM. "myform
*----
2. Specifically Note the following :
a) as u said ITAB is already defined in an include.
thats ok.
b) in form definition, use statement
Tables STRUCTURE Itab
(this will tell the form about the strucutre/defn
of table which is going to pass)
I hope it helps.
regards,
amit m.
‎2005 Dec 16 6:04 AM
perform get_it using var
tables itab.
if itab is in global include then you can access that..
regards
vijay
‎2005 Dec 16 6:05 AM
WRITE like this.
perform mod1 TABLES itab.
FORM mod1 TABLES p_tab1 STRUCTURE itab.
do the coding.
ENDFORM.
Reward points if it is helpful
‎2005 Dec 16 6:05 AM
Hi,
Declare the internal table in main program globally.
I hope you will have includes statement for calling the include from the main program.
If it is available in include,no need of retriving it again.You can directly use the internal table in the main program.
Kindly reward points by clikcing the star on the left of reply,if it is useful.
‎2005 Dec 16 6:06 AM
Hi
Pass the program name using IN PROGRAM addition to your subroutine call..
Regards,
Abdul
‎2005 Dec 16 6:20 AM
Hi nandha,
1. ur requirement is not clear.
2. are u asking the code for PERFORM
or subroutine defintion FORM.
regards,
amit m.
‎2005 Dec 16 7:54 AM
‎2005 Dec 16 8:00 AM
perform getdata using var
TABLES itab.
form getdata using p_var
table p_itab STRUCTURE itab.
do necessary code here...
endform.
‎2005 Dec 16 7:59 AM
Hi nandha,
1. try this code (just copy paste)
REPORT abc.
*----
Can be in Include
DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
pernr LIKE pa0001-pernr,
END OF itab.
*----
DATA : t LIKE table of itab with header line.
PERFORM myform TABLES t.
*----
FORM myform TABLES tb STRUCTURE itab.
ENDFORM. "myform
*----
2. Specifically Note the following :
a) as u said ITAB is already defined in an include.
thats ok.
b) in form definition, use statement
Tables STRUCTURE Itab
(this will tell the form about the strucutre/defn
of table which is going to pass)
I hope it helps.
regards,
amit m.
‎2005 Dec 16 8:12 AM
Hi,
Thanks for the reply.according to you your just getting itab not passing variable with itab.
Here i want to pass variable with internal table
that is
perform subrotin using pernr changing instead of variable <itab>.
here i am passing variable(pernr) to the subrotine and i want the internal table for that specific pernr detail from include(subroutine)
for this how i can write.
i tried this
perform get_vleave_info using pernr job_n changing itab1 totdays.
its not working
Thanks
Regards,
Nandha
‎2005 Dec 16 8:19 AM
for passing internal tables you need to pass tables statement...
perform get_vleave_info using pernr job_n
changing totdays
tables itab1 .
FORM get_vleave_info USING P_PERNR
P_JOB_N
CHANGING P_TOTDAYS
TABLES P_ITAB1 STRUCTURE ITAB.
"write your code here...
ENDFORM. " get_vleave_info
‎2005 Dec 16 10:10 AM
Hi,
This code is raising error
Field table is unknown.not defined
Thanks
Regards,
nandha
‎2005 Dec 16 10:23 AM
‎2005 Dec 16 10:30 AM
In Main program
*DATA : itab2 LIKE table of itab3 with header line.
*
clear v_totdays.
perform get_vleave_info using v_pernr
v_job_n
changing v_totdays
tables itab2.
loop at itab2.
Write:itab2-v_stdate.
endloop.
In Include Program
*FORM get_vleave_info USING V_PERNR
V_JOB_N
CHANGING V_TOTDAYS
TABLES itab1 STRUCTURE itab3.
Data : Begin of itab3 occurs 0,
v_stdate(16) type c,
v_enddate(16) type c,
v_days type i,
end of itab3.
This is the code.
Thanks
Nandha
‎2005 Dec 16 10:44 AM
Data : Begin of itab3 occurs 0,
v_stdate(16) type c,
v_enddate(16) type c,
v_days type i,
end of itab3.
DATA : itab2 LIKE table of itab3 with header line.
clear V_TOtDAYS.
perform get_vleave_info using v_pernr v_job_n
changing v_totdays
itab2.
loop at itab2.
Write:itab2-v_stdate.
endloop.
In Include Program
FORM get_vleave_info USING P_V_PERNR
P_V_JOB_N
CHANGING P_V_TOTDAYS
P_ITAB2 structure itab3.
ENDFORM. " get_vleave_infocheck this now.....
‎2005 Dec 16 11:52 AM
Hi,
Thanks for the reply.
still i am getting error -P_itab2 is not a internal table occurs n missing -- in include program(if i append the internal table P_itab2 )
Thanks
Regards,
Nandha
‎2005 Dec 16 11:57 AM
change this
DATA : itab2 LIKE table of itab3 with header line.to
DATA : itab2 LIKE itab3 occurs 0 with header line.vijay and try...
‎2005 Dec 16 12:02 PM
Hi Nanda,
It is working fine....
Copy and paste this code......
REPORT ZSANJAY_TEST.
DATA : BEGIN OF ITAB3 OCCURS 0,
V_STDATE(16) TYPE C,
V_ENDDATE(16) TYPE C,
V_DAYS TYPE I,
END OF ITAB3.
DATA : ITAB2 LIKE TABLE OF ITAB3 WITH HEADER LINE.
DATA : V_TOTDAYS TYPE I,
V_PERNR TYPE PERNR,
V_JOB_N TYPE I.
CLEAR V_TOTDAYS.
PERFORM GET_VLEAVE_INFO USING V_PERNR V_JOB_N
CHANGING V_TOTDAYS
ITAB2.
LOOP AT ITAB2.
WRITE:ITAB2-V_STDATE.
ENDLOOP.
INCLUDE ZSANJAY_TEST_INCLUDE.
Copy and paste the down code in an include.
----
INCLUDE ZSANJAY_TEST_INCLUDE
*----
FORM get_vleave_info USING P_V_PERNR
P_V_JOB_N
CHANGING P_V_TOTDAYS
P_ITAB2 structure itab3.
- Sanjay
‎2005 Dec 16 1:09 PM
‎2005 Dec 16 1:19 PM
can you paste the code fully ..as you are giving bits and pieces .., but what ever you gave it is working fine...
try to provide maximum..as much as you can...
regards
vijay
‎2005 Dec 19 4:55 AM
IN Report prg.
Data : Begin of itab3 occurs 0,
v_stdate(16) type c,
v_enddate(16) type c,
v_days type i,
end of itab3.
DATA : itab2 LIKE itab3 occurs 0 with header line.
clear V_TOtDAYS.
perform get_vleave_info using v_pernr v_job_n
changing v_totdays
itab2.
loop at itab2.
Write:itab2-v_stdate.
endloop.
In Include Program.
FORM get_vleave_info USING P_V_PERNR
P_V_JOB_N
CHANGING P_V_TOTDAYS
P_ITAB2 structure itab3.
Loop at itab.
clear v_stdate.
clear v_enddate.
clear v_days.
perform get_date_days using itab-v_start_dt
itab-v_end_dt
changing v_stdate
v_enddate
v_days.
itab1-v_stdate = v_stdate.
itab1-v_enddate = v_enddate.
itab1-v_days = v_days.
Append itab1.
Endloop.
Here itab1 is i am passing from include prg to main prg.I f append itab1.
It's throughing error -Itab1 is not internal table ,the occurs n specification is missing,
Thanks
Nandha
‎2005 Dec 19 4:59 AM
‎2005 Dec 19 5:02 AM
Sorry,
This is code for itab1
FORM get_vleave_info USING P_V_PERNR
P_V_JOB_N
CHANGING P_V_TOTDAYS
ITAB1 structure itab3.
Regards
Nandha
‎2005 Dec 19 5:02 AM
Hi nandha,
1.
error -Itab1 is not internal table ,the occurs n specification is missing
The error means that ITAB1 is delcared
as a simple variable(field - string)
BUT NOT AS A TABLE.
2. Hence, the delcaration should be somewhat like this.
data : ITAB1 LIKE TABLE OF XYZ WITH HEADER LINE.
(please note the words TABLE OF )
(There is another way also to declarare,
but one can go with this type of declaration)
3. How & Where is the declaration of itab1.
can u show the code.
regards,
amit m.
‎2005 Dec 19 5:04 AM
Hi again,
1. it should be like this
FORM get_vleave_info
TABLES P_V_TOTDAYS ITAB1 structure itab3
USING P_V_PERNR P_V_JOB_N.
2. In FORM definition, use the word TABLEs,
not changing
(bcos we want to pass a table)
3. While calling using PERFORM
use the syntax like this.
perrform get_vleave_info
TABLES xyz
using var1 var2.
( xyz should be an INTERNAL TABLE
and not just a variable / field string.
More over it should be of type ITAB3.
)
regards,
amit m.
Message was edited by: Amit Mittal
Message was edited by: Amit Mittal
‎2005 Dec 19 5:04 AM
Hi,
Check this part.Kindly reward points if it helps.
In Include Program.
FORM get_vleave_info USING P_V_PERNR
P_V_JOB_N
CHANGING P_V_TOTDAYS
P_ITAB2 structure itab3.
Loop at itab.
clear v_stdate.
clear v_enddate.
clear v_days.
perform get_date_days using itab-v_start_dt
itab-v_end_dt
changing v_stdate
v_enddate
v_days.
<b>P_ITAB2 -v_stdate = v_stdate.
P_ITAB2 -v_enddate = v_enddate.
P_ITAB2 -v_days = v_days.
Append P_ITAB2 .</b>
Endloop.
‎2005 Dec 19 5:08 AM
FORM get_vleave_info USING P_V_PERNR
P_V_JOB_N
CHANGING P_V_TOTDAYS
P_ITAB1 structure itab3.
Loop at itab.
clear v_stdate.
clear v_enddate.
clear v_days.
perform get_date_days using itab-v_start_dt
itab-v_end_dt
changing v_stdate
v_enddate
v_days.
p_itab1-v_stdate = v_stdate.
p_itab1-v_enddate = v_enddate.
p_itab1-v_days = v_days.
Append p_itab1.
Endloop.
‎2005 Dec 19 5:25 AM
Problem Solved
Code is
Main Prg
Data : Begin of itab3 occurs 0,
v_stdate(16) type c,
v_enddate(16) type c,
v_days type i,
end of itab3.
DATA : itab2 LIKE table of itab3 with header line.
clear V_TOtDAYS.
perform get_vleave_info TABLES itab2
using v_pernr v_job_n
changing v_totdays.
Include Prg
FORM get_vleave_info TABLES ITAB1 structure itab3
USING V_PERNR V_JOB_N changing P_V_TOTDAYS.
Loop at itab.
clear v_stdate.
clear v_enddate.
clear v_days.
perform get_date_days using itab-v_start_dt
itab-v_end_dt
changing v_stdate
v_enddate
v_days.
itab1-v_stdate = v_stdate.
itab1-v_enddate = v_enddate.
itab1-v_days = v_days.
Append itab1.
Endloop.
Thanks
Regards,
Nandha