2014 Feb 24 8:33 AM
Hi guys
I have to work on an SAP Script and I need to fill a variable with data from database table. I searched on the internet and found out that I can create a program, in it I can create an FORM and from SAP Script I can PERFORM the form. And I did this but it shows me an Error:
Short text
Too many parameters specified with Perform
Error Analysis
"... This routine contains 2 formal parameters, but the current call contains 4 actual parameters."
The report that I've created is this:
REPORT z_sapscript_forms.
FORM get_text_0014 USING l_lgart TYPE pa-lgart
CHANGING l_text TYPE t511t-lgtext.
SELECT SINGLE lgtxt FROM t511t INTO l_text WHERE lgart = l_lgart.
ENDFORM.
And here is how I call the from from the SAP Script:
PERFORM GET_TEXT_0014 IN PROGRAM Z_SAPSCRIPT_FORMS
USING &LGART0014&
CHANGING &LGTXT0014&
ENDPERFORM
What is the problem here ? I don't give in SAP script 4 parameters?? I give 2 parameters but it doesn't work ??
Can someone help me with this ?
2014 Feb 24 9:00 AM
Hi,
Use the following code:
FORM get_text_0014 TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
READ TABLE in_tab WITH KEY name = 'LGART0014'.
if sy-subrc eq 0.
MOVE in_tab-value TO v_lgart.
SELECT SINGLE lgtxt FROM t511t INTO l_text WHERE lgart = v_lgart.
if sy-subrc eq 0.
MOVE: 'LGTXT0014' TO out_tab-name,
l_text TO out_tab-value.
APPEND out_tab.
endif.
endif.
ENDFORM. "get_text_0014
Regards
Sajid
2014 Feb 24 8:52 AM
Hi Taly
The definition of subroutine pool is wrong. Please find below screen shot highlighting how to do
Nabheet
2014 Feb 24 9:00 AM
Hi,
Use the following code:
FORM get_text_0014 TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
READ TABLE in_tab WITH KEY name = 'LGART0014'.
if sy-subrc eq 0.
MOVE in_tab-value TO v_lgart.
SELECT SINGLE lgtxt FROM t511t INTO l_text WHERE lgart = v_lgart.
if sy-subrc eq 0.
MOVE: 'LGTXT0014' TO out_tab-name,
l_text TO out_tab-value.
APPEND out_tab.
endif.
endif.
ENDFORM. "get_text_0014
Regards
Sajid
2014 Feb 24 9:07 AM
Hi Sajid.
I wanted to ask you, now that we have these two Tables as parameters... how should I call it from SAP Script? What parameters should I give?
2014 Feb 24 9:11 AM
Hi Taly
If you look at the screen shot.. It clearly mentions how to call it from SAP script. You define the variable first and then do a perform as shown
Nabheet
2014 Feb 24 9:25 AM
I saw the picture that you uploaded... I added the parameters &PAGE& and &NEXTPAGE& and the dump isn't appearing anymore.
With the code that Sajid gave me, and the parameters that I have added (like in your images) the dump isn't showing anymore but the problem is that the LGTXT0014 still has no value assigned to it when I execute the SAP script in PRINT PREVIEW.
Do you have any idea why ?
2014 Feb 24 9:31 AM
Put a break point inside the subroutine. Are you updating back the OUTDATA with variable name and its values..? Please attaach your sample code of script and sub routine
Nabheet
2014 Feb 24 9:37 AM
Hi,
The way you are calling the form is correct.
As Nabheet suggested, Debug it and you can find the issue.
Regards
Sajid
2014 Feb 24 9:43 AM
I am putting a break point into the subroutine but when I click on Print Preview it doesn't go into it... don't know why .
Here is my code of the subroutine;
FORM get_text TABLES in_par STRUCTURE itcsy
out_par STRUCTURE itcsy.
DATA: l_text TYPE t512t-lgtxt,
l_lgart TYPE pa0014-LGART.
READ TABLE in_par WITH KEY name = 'LGART0014'.
if sy-subrc eq 0.
MOVE in_par-value TO l_lgart.
SELECT SINGLE lgtxt FROM t512T INTO l_text WHERE lgart = l_lgart.
if sy-subrc eq 0.
MOVE: 'LGTXT0014' TO out_par-name,
l_text TO out_par-value.
APPEND out_par.
endif.
endif.
ENDFORM.
2014 Feb 24 9:46 AM
Tally
You have different development and testing client..? if yess did you do an SCC1 for sapscript. Seconldly just do a refresh OUT_PAR as it will have variable name before appending the values
Nabheet
2014 Feb 24 9:47 AM
2014 Feb 24 10:45 AM
Nabheet... sorry I wasn't here and couldn't reply to you.
I am developing and testing in the same Client. Now I tested the Form if it works, I gave manually the data to the in_par Table and it returned me the result that I want.
But the only problem is, why doesn't &LGTXT0014& in SAP script take the value given from the subroutine ?
2014 Feb 24 11:49 AM
In debugging does it fill OUT_PAR table..? Please attach the code of your subroutine call in SAP Script
Nabheet
2014 Feb 24 12:14 PM
I can't debug the subroutine I just can debug the SAP Script as Sajid said by Enabling the Debugger in SE71.
Here is the code how I call the subroutine in SAP script:
PERFORM GET_TEXT IN PROGRAM Z_SAPSCRIPT_FORMS
USING &PAGE&
USING &NEXTPAGE&
CHANGING &LGTXT0014&
ENDPERFORM
2014 Feb 24 12:55 PM
Hi,
Also Put a Break Point in the Program Z_SAPSCRIPT_FORMS.
Regards
Sajid
2014 Feb 24 12:58 PM
Nabheet... I can debug it now... i was logged in one place in English and in the other one in German .
The OUT_PAR Table returns only the Name of the Variable not it's Value.
I tried manually to add in the OUT_PAR table: NAME: LGTXT0014, VALUE: 'some text'. After the execution it didn't show anything.
2014 Feb 24 9:10 AM
Hi Taly,
In your calling Z program just change the definition of i_lgart and i_text type itcsy.
Here type you defined won't be dictionary structure when you are calling subroutine from SAPSCRIPT.
Thanks and Regards
Srimanta