Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Sapscript

Former Member
0 Likes
1,139

To create a simple sap script form, I have done the following.

1. In SE71, I have created three windows.

a) Main - For PO line items.

b) window1 - For Vendor Address.

c) Window2 - For Reference No.

2. In SE72, I have created the font styles.

After doing the above, I do not know how to proceed further.

I want to populate the PO details and vendor details in the respective windows. Pls let me know where to write the codes for populating the data.

I want to create a internal table and to populate the same.

Pls guide me.

Thanks in advance,

Mark K

10 REPLIES 10
Read only

Former Member
0 Likes
1,094

hi mark,

1 . After doing the above, I do not know how to proceed further.

Create a news se38 program,

it will be called as driver program.

2. In that use

OPEN_FORM

WRITE_FORM

CLOSE_FORM

to display the layout.

3. Before all this, u will have to

populate your data in side this program,

in the internal table.

4. Then u will have to use

&variablename& inside your layout,

so that the value gets printed.

5. For line item,

LOOP AT ITAB.

CALL FUNCTION 'WRITE_FORM'

ENDLOOP.

(in this write_form, u will have to pass

the window name, element name,

so that the line items get printed.

regards,

amit m.

Read only

0 Likes
1,094

On going through some of the already programs, I found the following. What are they and what they will do.

FORM READTEXT TABLES INTAB STRUCTURE ITCSY

OUTAB1 STRUCTURE ITCSY.

Regards,

Read only

0 Likes
1,094

Hi Mark,

Sapscripr is a little bit tricky: As explained you need a print program triggering the form with open_form,start_form,..., write_form, ... close_form.

Sometimes you can create your own form but not your own print program (i.e. material purchasing is a complicted module pool you won't like to copy and/or modify).

In such cases, you can copy the SAP FORM and call subroutines directly from the form handling the modifications.

In Sapscript you call external routines like


/: PERFORM
/: GET_VAT_RATE IN PROGRAM ZPROGRAM
/: USING &KNUMV&
/: CHANGING &TATE&
/: ENDPERFORM



What you found is such a called routine, because by definbition all parameters are passed via tables of structure ITCSY. The fields are name and value for parameter name and parameter value. Note that all sapscipt parameters are passed as pure characters.

Here's just another example of mine as how a called form may look like:

*----


*

  • FORM get_banka

*----


*

FORM get_banka

TABLES inttab STRUCTURE itcsy

outtab STRUCTURE itcsy.

DATA:

lv_zbnks TYPE dzbnks,

lv_zbnkl TYPE dzbnkl,

lv_banka TYPE banka.

FIELD-SYMBOLS:

TYPE itcsy.

  • Lesen Übergabeparameter

  • loop assigning for optimal speed

LOOP AT inttab ASSIGNING .

IF sy-subrc = 0.

SELECT SINGLE banka INTO lv_banka FROM bnka

WHERE banks = lv_zbnks

AND bankl = lv_zbnkl.

  • Füllen Rückgabeparameter

  • loop assigning for optimal speed; no modify needed

  • to transfer in correect format...

LOOP AT outtab ASSIGNING

  • Wurde nichts gefunden, Rückgabeparameter löschen

ELSE.

LOOP AT outtab ASSIGNING ) using function write_form, it should exist (defined andnot being empty!) in the form (as your ITEM).

Good luck!

Regards,

Clemens

Read only

Former Member
0 Likes
1,094

Hi Mark,

Create a Z print program.Select all the data that you want to display in this print program.Call FM 'OPEN_FORM'.Pass your form name in this FM.Call FM 'WRITE_FORM'.Pass your data element of the windows in the FM WRITE_FORM'.Call FM 'CLOSE_FORM'.

In the form go to tab Page windows.Put your cursor on one window.Prss text element or 'F9'.write your value of the field in the window.

Execute the print program.You will get the layout.If you face any problem.Reply this mail

Regards,

Mukesh Kumar

Read only

Former Member
0 Likes
1,094

Hai

Go through the following Print/Driver Program for Data Population

&----


*& Report Z_WEEK5_SREEKANTH_EX1 *

*& *

&----


*& *

*& *

&----


REPORT Z_WEEK5_SREEKANTH_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

Read only

0 Likes
1,094

I have copied your code, as it is, in SE38. On executing, I am getting the error message.

"Element ITEM window MAIN is not defined for form ZTEST."

Pls let me know why error and how to correct the same.

Regards,

Read only

Former Member
0 Likes
1,094

HaI

Go through the following Print/Driver Program

for Data selection

&----


*& Report Z_WEEK5_SREEKANTH_EX1 *

*& *

&----


*& *

*& *

&----


REPORT Z_WEEK5_SREEKANTH_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

Sreeni

Read only

0 Likes
1,094

After writing the code in SE38, what I should do in SE71 Main Window. Should I give some commands?

Pls.

Regards,

Read only

former_member480923
Active Contributor
0 Likes
1,094

Hi

The structure ITCSY is known as the communication structure between the SAPScript and external preform routine called from SAPScript. So if you see thsi peice of cod ein your proram this will indicate that the SAPScript must be calling an external perform routine with the Input parameters and getting the output parameters.....

Hope this helps

Anirban