cancel
Showing results for 
Search instead for 
Did you mean: 

Reg : SAP SCRIPT Form

Former Member
0 Kudos

Dear experts,

I have created a new form for my requirement inthat i need to print the values in my internal table also d layout should be in A4. How to do..? Plz help

regards

e arthi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

First use OPEN_FORM Fm to Form the form

And USE . I_itemdata will contain your Internal Table information. as below

LOOP AT i_itemdata.

PERFORM write_form USING 'ELES' 'APPEND' 'MAIN'.

ENDLOOP.

    • CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = ele

function = fun

  • TYPE = 'BODY'

window = win..

and in the Form in the MAIN WIndow use this ELEMENT "ELES"

/E ELES

/: &vline&,,&I_itemdata-sgtxt&,,&VLINE& &I_itemdata-date&&VLINE&

/: &I_itemdata-wrbtr&,,&vline&

***

Surya

Former Member
0 Kudos

Hai,

Thanks a lot .. Let me try if i have any issues i wil come back..

Former Member
0 Kudos

I tried as u mentioned but only single item is appearing

Wat to do.. Help me

SELECT VBELN POSNR FROM VBAP INTO TABLE IT_VBAP

WHERE VBELN IN S_VBELN.

LOOP AT IT_VBAP.

************************************************************************

  • Execute the element "HELLO" in window MAIN

  • - Nothing happens if /E HELLO is not declared in MAIN

************************************************************************

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'ITEM' "execute element /E ITEM

FUNCTION = 'APPEND'

TYPE = 'BODY' "normal output

WINDOW = 'MAIN' "to window MAIN

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

ELEMENT = 1

FUNCTION = 2

TYPE = 3

UNOPENED = 4

UNSTARTED = 5

WINDOW = 6

BAD_PAGEFORMAT_FOR_PRINT = 7

OTHERS = 8.

ENDLOOP.

This is my code

Former Member
0 Kudos

This is my SAPSCRIPT Code

/E ITEM

/: &it_vbap-vbeln&

Former Member
0 Kudos

Hi,

Please relook into the following.

-> Check if your internal table is populated with more than one row.

-> Check if your window size in the script is large enough to hold multiple values.

->Try commenting the exporting parameter 'FUNCTION' or set it to default value 'SET'.

sridhar_meesala
Active Contributor
0 Kudos

Hi,

&it_vbap-vbeln& is going to give only the first value in the itab. To get all the values you should use loop at command in the print program and then display the values.

Thanks,

Sri.

Former Member
0 Kudos

How to loop that

Former Member
0 Kudos

How to loop that ..? Plz help me

Former Member
0 Kudos

Hi,



LOOP AT IT_VBAP.

  CALL FUNCTION 'WRITE_FORM'
   EXPORTING
     ELEMENT                        = 'MAIN'
*     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.


ENDLOOP.

Please see if you have used the MAIN window. You gotto use the MAIN window to display multiple lines of data. Please write your /: &it_vbap-vbeln& in MAIN window. I dont think you are using the MAIN window here. Please write the code in the SAP script in the MAIN window. That will be available by default in the Script.

Former Member
0 Kudos

Ya i used the same but multiple line items not coming

Former Member
0 Kudos

Hai experts,

Atleast provide me any sample programs u did...

Former Member
0 Kudos

Hi,

Did you check if your window size was large enough to hold the data items?

Check in debug mode how many times the WRITE_FORM gets executed. If there are multiple rows in the internal table, then the LOOP will execute that many number of times. Please check on that.

Please check if your internal table is populated with multiple rows.


    SELECT POSNR MATNR ARKTX UEPOS GRPOS
    FROM VBAP
    INTO CORRESPONDING FIELDS OF TABLE T_BODY
    WHERE VBELN EQ P_VBELN.
CALL FUNCTION 'OPEN_FORM'
 EXPORTING
   FORM                              = 'ZSAPSCRIPTS'
 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.
LOOP AT T_BODY INTO WA_BODY.
CALL FUNCTION 'WRITE_FORM'
   EXPORTING
     ELEMENT                        = 'MAIN'
     WINDOW                         = 'MAIN'
   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.
ENDLOOP.
CALL FUNCTION 'CLOSE_FORM'
 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.

Edited by: Nitwick on Aug 6, 2009 12:30 PM

Former Member
0 Kudos

Hai,

Thanks yaar.. Shal i send my code

Former Member
0 Kudos

Yes...please...

Former Member
0 Kudos

REPORT YDEMO_HELLOWORLD .

----


TABLES: VBAP.

PARAMETERS: FORM LIKE RSSCF-TDFORM DEFAULT 'YDEMO_HELLOWORLD'.

----


*DATA DECLARATION

----


DATA : BEGIN OF IT_VBAP OCCURS 100,

VBELN LIKE VBAP-VBELN,

POSNR LIKE VBAP-POSNR,

END OF IT_VBAP.

----


*SELECTION SCREEN

----


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE T1.

SELECT-OPTIONS : S_VBELN FOR VBAP-VBELN,

S_POSNR FOR VBAP-POSNR.

SELECTION-SCREEN END OF BLOCK B1.

START-OF-SELECTION.

************************************************************************

  • Open the SapScript Form with the "form" *

************************************************************************

CALL FUNCTION 'OPEN_FORM'

EXPORTING

APPLICATION = 'TX' " this is SapScript Appl

DEVICE = 'SCREEN' " allow output to printer

DIALOG = 'X' " printer dialog requested

FORM = 'YDEMO_HELLOWORLD'

LANGUAGE = SY-LANGU

  • OPTIONS = ' '

EXCEPTIONS

CANCELED = 1

DEVICE = 2

FORM = 3

OPTIONS = 4

UNCLOSED = 5

MAIL_OPTIONS = 6

OTHERS = 7.

SELECT VBELN POSNR FROM VBAP INTO TABLE IT_VBAP

WHERE VBELN IN S_VBELN.

LOOP AT IT_VBAP.

PERFORM WRITEFORM.

ENDLOOP.

PERFORM CLOSEFORM.

FORM WRITEFORM.

************************************************************************

  • Execute the element "HELLO" in window MAIN

  • - Nothing happens if /E HELLO is not declared in MAIN

************************************************************************

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'ITEM' "execute element /E ITEM

  • FUNCTION = 'ADD'

  • TYPE = 'BODY' "normal output

WINDOW = 'MAIN' "to window MAIN

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

ELEMENT = 1

FUNCTION = 2

TYPE = 3

UNOPENED = 4

UNSTARTED = 5

WINDOW = 6

BAD_PAGEFORMAT_FOR_PRINT = 7

OTHERS = 8.

ENDFORM.

FORM CLOSEFORM.

************************************************************************

  • Close the current SapScript Form

************************************************************************

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

UNOPENED = 1

BAD_PAGEFORMAT_FOR_PRINT = 2

OTHERS = 3.

ENDFORM.

Former Member
0 Kudos

Haii,

Give ur mail Id .. I wil send d code

Former Member
0 Kudos

How to include Lines in my form Vertical & Horizontal ( Like Table )

Former Member
0 Kudos

How to include image in my form

Former Member
0 Kudos

Hi experts,

How to include line in my form and also more than one page print

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

By OPEN_FORM function module we can call the form to report program and with WRITE_FORM we can print the internal table data, CLOSE_FORM we can close the form.

Here is a sample code:

CALL FUNCTION 'OPEN_FORM'
* EXPORTING
*   APPLICATION                       = 'TX'
*   ARCHIVE_INDEX                     =
*   ARCHIVE_PARAMS                    =
*   DEVICE                            = 'PRINTER'
*   DIALOG                            = 'X'
*   FORM                              = '<FORM NAME> '
*   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.


CALL FUNCTION 'WRITE_FORM'
* EXPORTING
*   ELEMENT                        =  '<PASS THE FIELDSTING>>'
*   FUNCTION                       = 'SET'
*   TYPE                           = 'BODY'
*   WINDOW                         = 'WINDOW NAME
* 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.

Hope this helps you

Regards,

Rajani

sridhar_meesala
Active Contributor
0 Kudos

Hi,

You need to write a report program to fill in the form with internal table values.

In START-OF-SELECTION you select the data and

in END-OF-SELECTION you call the FMs

CALL FUNCTION 'OPEN_FORM'

CALL FUNCTION 'WRITE_FORM'

CALL FUNCTION 'CLOSE_FORM'

Thanks,

Sri.

Former Member
0 Kudos

Hai,

Thanx for ur reply.. i have created a internal table with values hw to invoke in my print program.

Plz help

regards

e arthi

sridhar_meesala
Active Contributor
0 Kudos

Hi,

In the print program you need to give

/: for commands

/* for comments

/E for text element

= for extended line

to fetch value from internal table into the form you have to write

/: &internal_table_name-field_name&

to get a box in the form you can writ

/: box xpos'1.0'cm ypos '1.0'cm width '1.0'cm height '1' cm frame 10

Hope it helps you.

Thanks,

Sri.

Former Member
0 Kudos

How to draw lines (vertical & horizontal) ..alignment help plz

Former Member
0 Kudos

According to the forum rules you should not post more than 1 question in a thread.