‎2005 Jan 03 2:19 PM
Hi,
I have an internal table with varying no. of records. I need to pass this internal table from subroutine to SAPscript .Currently i don't have any option . Can anybody plz let me know alternatives for approaching this problem .
Thanks
‎2005 Jan 04 4:29 AM
First define the internal table and run a select query to fill the internal table with data.Assuming that Sapscript form has been activated by u.Create_Form Function where in u define the Sapscript form,Write_Form Function where in u will define the itab that need to be send to the Sapscript form provided u had defined an Element in the Sapscript form Like (\e &Itab-fieldname&) and close_form function and now run the program the data in the itab is seen in the sapscript
‎2005 Jan 09 5:17 PM
Hi Ishant,
Go to ur sapscript(se71) .
In the coding part declare the subroutine as follows.
/:PERFORM SUB1 IN PROGRAM ZSCRIPTSUBROUTINE123
/:USING &VAR1&
/:CHANGING &VAR2&
/:ENDPERFORM
provided the &VAR1& say 21 value is already declared.
we are now going to receive the value(VAR2) from
the subroutine(SUB1) in program (ZSCRIPTSUBROUTINE123).
-
Now go to the program ZSCRIPTSUBROUTINE123 .
Here you create the subroutine (SUB1).
FORM SUB1 TABLES IN_PAR STRUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
*Now
*IN_PAR has fields
NAME = 'VAR1'.
VALUE = 21.
OUT_PAR has fields
NAME = 'VAR2'.
VALUE = empty(now we are going to update * this value)
*NOW WE ARE GOING TO READ TABLE IN_PAR.
READ TABLE IN_PAR WITH KEY NAME = 'VAR1'. "VAR1 is USING parameter
CHECK SY-SUBRC = 0. " Checking whether the read operation is a success
ITEM = IN_PAR-VALUE. " provide ITEM is already declared.
SELECT *
FROM MAKT
INTO CORRESPONDING FIELDS OF TABLE I_MAKT
WHERE MATNR = ITEM ." ITEM = 21.
" I_MAKT is an internal table of type mara
****Now we are moving data to work area.
LOOP AT I_MAKT INTO WA_MAKT. "WA_MAKT is a work area of type I_MAKT.
ENDLOOP.
***NOW WE ARE GOING TO READ TABLE OUT_PAR
READ TABLE OUT_PAR WITH KEY NAME = 'VAR2'. "VAR2 is CHANGING parameter
CHECK SY-SUBRC = 0.
OUT_PAR-VALUE = WA_MAKT-MAKTX.
*******MODIFYING THE TABLE AFTER VALUE IS ALTERED
MODIFY OUT_PAR INDEX SY-TABIX.
Now OUT_PAR has fields
NAME = 'VAR2'.
VALUE = 'my material name for test 21'
ENDFORM.
-
use can test the &VAR2& in your sapscript now which will contain 'my material name for test 21'
-
Thats how the value of an internal table in a subroutine is passed to a sapscript.
‎2005 Jan 11 10:39 AM
Since i using SAP standard steering program i can't go with suresh's solution i.e calling write_form in loop .
Also, Shiva i got ur solution but its only useful if i have to return only one value. The internal table which i am using has more than 75 rows and can vary. I don't want to declare that no. of variables in SAPscript as its not feasible.
Can you please share any other logic, if u know to pass internal table with varying no. of records to SAPScript.
‎2008 Mar 26 10:12 AM
a way to trick it is to build in your report, at runtime, a standard text with your values from the internal table. Than, just include the text in your SAPscript.
BUHAHA: this is 3 years old ))
Edited by: Daniel BALTA on Mar 26, 2008 12:13 PM
‎2005 Jan 12 5:37 AM
Hi
You then have two options
You can either write your own driver program in which you can call a text element of your own.
eg.
Loop at itab. " this ids ur itab
call function 'write_element'
-
-
-
-
endloop.
Or you can copy the existing driver program and modify it
in the above manner.
As far as i know i dont thinbk you can pass an internal table to sapscript layout.
Tell me if you get a solution.
Regards,
Amit.