06-19-2006 5:41 AM
Hi Friends,
I want to create a sapscript form. For this purpose, I have created the layout (SE71) and written code in SE38 to get the data in an internal table.
Now, I want to populate this data in the sapscript form (laout). How to do the same.
Kindly guide me.
Thanks in advance,
Mark K.
06-19-2006 5:47 AM
hi
you need to create <b>program symbols</b> in your form and pass the data to it from your WRITE_FORM statement.
Cheers,
Abdul Hakim
06-19-2006 5:53 AM
Hi Abdul Hakim,
Could u pls help me in, how to create program symbols in the form and pass the data to it through write_form statement.
Pls guide me with sample code.
Regards,
06-19-2006 5:59 AM
Choose edit->textelements..it will take you to the form editor from there choose insert->symbols->program symbols.
then you insert it for eg.i want to pass the values of an internal table from my print program.then the correponding program symbol should look like
&itab-col1& &itab-col2&
itab->is the name of my internal table.you can use any name.
my print program should look like.
LOOP AT ITAB.
<CALL WRITE FORM HERE>.
ENDLOOP.
Cheers,
Abdul Hakim
06-19-2006 6:01 AM
hi mark,
just visit the link for a step by step procedure of how to execute a Script from a program<a href="http://www.sapdevelopment.co.uk/sapscript/sapscripthome.htm">http://www.sapdevelopment.co.uk/sapscript/sapscripthome.htm</a>
regards
satesh
06-19-2006 5:53 AM
hi mark,
use the three important function modules... used to access a form from your program..
FM OPEN_FORM is used to open a form for writing..
FM WRITE_FORM is used for writing your elements in the form..
and finally call the FM CLOSE_FORM to close it..
you can write your internal table fields in the script just as you write in the program.. except with a addition &<f>& ( & ) in the front and back of the name of the symbol..
regards
satesh
06-19-2006 5:54 AM
Hi
Please check this link
<a href="http://www.thespot4sap.com/articles/SAPscript_Introduction.asp">SAPScript Development</a>
Hope it helps
Anirbsn
06-19-2006 7:33 AM
Hi Anirbsn,
The document link you gave is realy very good. I am doing as per the document. But I am not clear with the layout set for the following portion.
-
Windows Attributes
MAIN Main window
Window type MAIN
HEADER Main window
Window type CONSTANT
FOOTER Main window
Window type CONSTANT
Pages Attributes
FIRST First Page
Standard attributes
Next page FIRST
Page counter
Mode START
Numbering type Arabic numerals
Page window
HEADER Left margin 00.00 CM
Upper margin 00.00 CM
Window width 20.00 CM
Window height 04.00 CM
MAIN Left margin 00.00 CM
Upper margin 05.00 CM
Window width 20.00 CM
Window height 20.00 CM
FOOTER Left margin 00.00 CM
Upper margin 25.00 CM
Window width 20.00 CM
Window height 04.00 CM
-
I am able to create the windows, but how to make them as CONSTANT and also to define other attributes for the windows.
Pls guide me.
Regards,
06-19-2006 9:42 AM
On executing the Sapscript program, I am getting the following error.
-
Window HEADER is not defined for form Z_TESTSCRIPT
-
What could be the reason, and how to correct the same.
Regards,
06-19-2006 10:13 AM
Hi Mark,
In the FM WRITE_FORM you may have passed 'HEADER' to the parameter 'WINDOW' and you may not have created any window with this name in your sapscript
Regards,
Mukesh Kumar
06-19-2006 5:58 AM
Hi,
To populate the data in sapscript use text element in the window element of layout.
for further information check this document
http://www.sappoint.com/abap/sscript.pdf
Namrata
06-19-2006 5:58 AM
Hi,
Use function muduleS OPEN_FORM.
WRITE_FORM.
CLOSE_FORM.
In OPEN_FORM specifu your form name & language.
In WRITE_FORM you can provide your internal table name & get the data displayed out there.
At the end call function CLOSE_FORM.
If the answer solves your problem pls reward points.
Rever on queries.
Regards,
Dilip Gupchup
06-19-2006 6:18 AM
HI Mark,
In your print program do the following processing after populating the internal table.
CALL FM OPEN_FORM.Pass your form name in this FM
Loop at internal table.
Call FM 'WRITE_FORM'.
pass your text element to this FM.
Endloop.
CALL CLOSE_FORM.
Write your values to the corresponding fields in the respective windows in the SAPSCRIPT form.
Regards,
Mukesh Kumar
06-19-2006 6:44 AM
Hi,
You can go through the following steps.
1) In this Open_form function pass the form name you have created.(In upper case).e.g.'MY_FORM'
CALL FUNCTION 'OPEN_FORM'
EXPORTING
= 'X'
FORM = 'MY_FORM'
.
2)Write_form : In this function u have to pass, text element(TE1) and the internal table (ITAB) in which u have populated the data.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'TE1 '
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
table = ITAB
3)and finally call 'CLOSE_FORM' as it is.
Hope this will serve your purpose.
06-19-2006 8:36 AM
Hi Mark,
Pupoulate Internal table in your driver program. Now you will have to pass this table to FM 'WRITE_FORM' with internal table assigned to tables variale as follows.
loop at itab.
call function 'WRITE_FORM'
exporting
element = ' '(Data Element used)
function = 'SET'
type = 'BODY'
window = 'MAIN'
table = (Internal Table Name)itab
endloop.
now in Script layout window use program symbold i.e wherever you want to access internal tables values use &itab-field_name&.
06-19-2006 8:41 AM
Hi,
Check the below links. u got better idea.
http://help.sap.com/saphelp_47x200/helpdata/en/d6/0db74a494511d182b70000e829fbfe/frameset.htm
http://www.sap-img.com/sapscripts.htm
http://www.henrikfrank.dk/abapexamples/SapScript/sapscript.htm
http://www.henrikfrank.dk/abapexamples/SapScript/symbols.htm
http://sapbrain.com/TUTORIALS/TECHNICAL/SAPSCRIPTS_tutorial.html
http://www.sappoint.com/abap/sscript.pdf
http://www.thespot4sap.com/articles/SAPscript_Introduction.asp
http://www.sapdevelopment.co.uk/sapscript/sapscripthome.htm
- Selvapandian Arunachalam
06-19-2006 8:48 AM
Hai Mark
Go through the following Progrma "How to Call a SAP Script Form into a Driver/SE38 Progrm'
&----
*& Report Z_EX1 *
*& *
&----
*& *
*& *
&----
REPORT Z_EX1 .
TABLES: MARA, MAKT.
DATA: BEGIN OF IT_MARA OCCURS 0,
MTART LIKE MARA-MTART,
MATNR LIKE MARA-MATNR,
PSTAT LIKE MARA-PSTAT,
MATKL LIKE MARA-MATKL,
MBRSH LIKE MARA-MBRSH,
NTGEW LIKE MARA-NTGEW,
VOLUM LIKE MARA-VOLUM,
END OF IT_MARA.
DATA: BEGIN OF IT_MAKT OCCURS 0,
MATNR LIKE MAKT-MATNR,
MAKTX LIKE MAKT-MAKTX,
END OF IT_MAKT.
DATA: V_TOP TYPE C,
V_TEMP TYPE C VALUE 'X'.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_MBRSH LIKE MARA-MBRSH,
P_NOREC(5) TYPE N DEFAULT '10'.
SELECTION-SCREEN END OF BLOCK B1.
AT SELECTION-SCREEN.
IF P_MBRSH IS INITIAL.
MESSAGE E004(ZI) WITH 'INDUSTRY SECTOR IS NOT SPECIFIED'.
STOP.
ENDIF.
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM OPEN_FORM.
PERFORM WRITE_FORM.
PERFORM CLOSE_FORM.
&----
*& Form GET_DATA
&----
FORM GET_DATA .
SELECT MTART
MATNR
PSTAT
MATKL
MBRSH
NTGEW
VOLUM
FROM MARA
UP TO P_NOREC ROWS
INTO TABLE IT_MARA
WHERE MBRSH = P_MBRSH.
IF NOT IT_MARA[] IS INITIAL.
SELECT MATNR
MAKTX
FROM MAKT
INTO TABLE IT_MAKT
FOR ALL ENTRIES IN IT_MARA
WHERE MATNR = IT_MARA-MATNR.
ENDIF.
SORT IT_MARA BY MTART.
ENDFORM. " GET_DATA
&----
*& Form OPEN_FORM
----
FORM OPEN_FORM .
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = 'X'
FORM = 'Z_SREE_EX1'
LANGUAGE = SY-LANGU
OPTIONS =
MAIL_SENDER =
MAIL_RECIPIENT =
MAIL_APPL_OBJECT =
RAW_DATA_INTERFACE = '*'
IMPORTING
LANGUAGE =
NEW_ARCHIVE_PARAMS =
RESULT =
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
MAIL_OPTIONS = 6
ARCHIVE_ERROR = 7
INVALID_FAX_NUMBER = 8
MORE_PARAMS_NEEDED_IN_BATCH = 9
SPOOL_ERROR = 10
CODEPAGE = 11
OTHERS = 12
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " OPEN_FORM
&----
*& Form WRITE_FORM
----
FORM WRITE_FORM .
LOOP AT IT_MARA.
V_TOP = 'Y'.
AT NEW MTART.
V_TOP = 'X'.
ENDAT.
READ TABLE IT_MAKT WITH KEY MATNR = IT_MARA-MATNR.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
IMPORTING
PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
CODEPAGE = 9
OTHERS = 10
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
V_TEMP = 'Y'.
ENDLOOP.
ENDFORM. " WRITE_FORM
&----
*& Form CLOSE_FORM
----
FORM CLOSE_FORM .
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT =
RDI_RESULT =
TABLES
OTFDATA =
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
CODEPAGE = 5
OTHERS = 6
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " CLOSE_FORM
Thanks & regards
Sreenivasulu P