‎2006 Jan 31 9:27 PM
Hi all,
This is the code I have written in the main window of sap scrpt.
/: BOX FRAME 10 TW
/E MAIN
p3 &spaces(3)&&itab-carrid& &spaces(35)& &itab-connid&
= &spaces(25)&&itab-fldate&
/: PERFORM Z_V_SCRIPT IN PROGRAM Z_V_SCRIPT_SR
/: USING &COUNTER&
/: CHANGING &COUNTER&
/: ENDPERFORM
/: IF &COUNTER& EQ '1'
/: &ULINE(45)&
/: DEFINE &COUNTER& = 0
/: endif
This is the code for external subroutine z_v_script_sr.
REPORT Z_V_SCRIPT_SR.
FORM z_v_script TABLES IN_PAR STrUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
data : cntr type i value -1.
data : ch(3) type c.
read table in_par with key 'COUNTER'.
if sy-subrc = 0.
cntr = in_par-value.
endif.
cntr = cntr + 1.
ch = cntr.
read table out_par with key 'COUNTER'.
if sy-subrc = 0.
out_par-value = ch.
endif.
MODIFY OUT_PAR INDEX SY-TABIX.
write : 'vijay'.
endform.
I do not understand where I am going wrong.If I debug the subroutine the value of counter is being changed to 1 but it is not reflected when I debug my script. Please explain me where I am going wrong.
Regards,
Varun
‎2006 Jan 31 9:28 PM
Hi Varun,
Declare the cntr above the form after your report starement,not in the form.
REPORT Z_V_SCRIPT_SR.
<b>data : cntr type i value -1.</b>
FORM z_v_script TABLES IN_PAR STrUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
‎2006 Jan 31 9:31 PM
Hi Phani,
I tried doing the sameway but still it doesn't work.
Regards,
Varun
‎2006 Jan 31 9:35 PM
Hi varun,
Can you declare the changing variable as some thing else,like declare it as v_counter,i mean it should be different from the passing variable.
‎2006 Jan 31 9:38 PM
Hi varun,
You can assign the value -1 in the form not in the declaration.
‎2006 Jan 31 9:37 PM
You counter must be held in global memory, otherwise it will always be the same. PUt the data statement at the top of your print program. Having it defined in the routine, means that everytime the routine is fired, it will be that value. In this case -1.
data : cntr type i value -1.ALso, comment out the USING line in the SAPscript.
/: PERFORM Z_V_SCRIPT IN PROGRAM Z_V_SCRIPT_SR
<b>/* USING &COUNTER&</b>
/: CHANGING <b>&COUNTER&</b>
/: ENDPERFORM
/: IF &COUNTER& EQ '1'
/: &ULINE(45)&
/: DEFINE &COUNTER& = 0
/: endifAlso shouldn't the counter field be defined in the print program as well.
Is COUNTER defined in the print program?
Regards,
Rich Heilman
‎2006 Jan 31 9:44 PM
Hi ,
I made the declaration global by placing the data statement after the report statement. NOw when I try to execute the program it gives me a short dump saying
<b>"TABL_INVALID_INDEX".</b>
Regards,
Varun.
‎2006 Jan 31 9:49 PM
Hi Varun,
Your program will work just made one change as mentioned below :
Program :
data : ch(3) type c.
Changes the abovce to
data : ch(1) type c.
In SAP SCript Please change the following :
/: &ULINE(45)&
to (Please remove command paragraph)
&ULINE(45)&
don't make any other changes you program will work with that one change.
Lanka
Message was edited by: Lanka Murthy
‎2006 Jan 31 9:49 PM
That's because you did:
if sy-subrc = 0.
out_par-value = ch.
endif.
MODIFY OUT_PAR INDEX SY-TABIX.
write : 'vijay'.
endformTry:
if sy-subrc = 0.
out_par-value = ch.
MODIFY OUT_PAR INDEX SY-TABIX.
endif.
write : 'vijay'.
endformI don't like to sound like a broken record, but I think this would be alot easier handling the counter from the main program.
Rob
‎2006 Jan 31 9:58 PM
Hi Rich,
The counter is defined in the print program.
Regards,
Varun.
‎2006 Jan 31 9:59 PM
Hi Varun,
Your program will work just made one change as mentioned below :
Program :
data : ch(3) type c.
Changes the abovce to
data : ch(1) type c.
In SAP SCript Please change the following :
/: &ULINE(45)&
to (Please remove command paragraph)
&ULINE(45)&
don't make any other changes you program will work with that one change.
Lanka
‎2006 Jan 31 11:25 PM
Hi Rob,
Thanks Rob. As you said this is lot easier handling from the print program.Thank you very much for your suggestion.
Regards,
Varun.
‎2006 Feb 01 1:33 AM
Glad to help - if your question is answered, please close the thread.
Rob
‎2006 Feb 03 11:13 AM
Hi,
You are using the COUNTER parameter for both USING and CHANGING of the perform statement. Since the parameters COUNTER used in USING , cannot be changed . It is should be used only in the subroutine but can not be changed. But Changing parameter can used and value also can be changed in inside subroutine. So , it is better to use two different variables in the perform statement .
Regards,
M.Saravanan
‎2006 Feb 03 12:19 PM
/:PERFORM Z_V_SCRIPT IN PROGRAM Z_V_SCRIPT_SR
/: USING &COUNTER&
in the place of USING, use CHANGING