cancel
Showing results for 
Search instead for 
Did you mean: 

SAP SCRIPT and the report

Former Member
0 Kudos

Hi Peers,

I am working on the report which calling the Form from SAP Script and displaying the form.

I wanted a selection screen in which if the user enters some value it should automatically preview in the form.

I am really new to the ABAP Pls some help on this .

Any code is appreciated.

Every answers will be rewarded.

Pls peers help on this.

Seema.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

where is a simple example:

PARAMETERS: KUNNR(10).

PARAMETERS: PREVI AS CHECKBOX DEFAULT 'X'.

START-OF-SELECTION.

PERFORM OPEN_FORM.

PERFORM START_FORM.

PERFORM PRINT_DATA.

PERFORM END_FORM.

PERFORM CLOSE_FORM.

*&----


*

*& Form OPEN_FORM

*&----


*

FORM OPEN_FORM.

CLEAR ITCPO.

ITCPO-TDCOPIES = 1.

ITCPO-TDDEST = PRINTER.

IF PREVI = 'X'.

ITCPO-TDPREVIEW = 'X'.

ENDIF.

ITCPO-TDNEWID = 'X'.

ITCPO-TDDATASET = 'test'.

ITCPO-TDSUFFIX1 = PRINTER.

ITCPO-TDSUFFIX2 = 'test'.

ITCPO-TDDELETE = ' '. " Não eliminar imediatamente

CALL FUNCTION 'OPEN_FORM'

EXPORTING

DEVICE = 'PRINTER'

DIALOG = ' '

FORM = 'YOUR_FORM_NAME'

LANGUAGE = SY-LANGU

OPTIONS = ITCPO

EXCEPTIONS

CANCELED = 1

DEVICE = 2

FORM = 3

OPTIONS = 4

UNCLOSED = 5

OTHERS = 6.

ENDFORM. " OPEN_FORM

*&----


*

*& Form START_FORM

*&----


*

FORM START_FORM.

CALL FUNCTION 'START_FORM'

EXPORTING

LANGUAGE = SY-LANGU.

ENDFORM. " START_FORM

*&----


*

*& Form PRINT_DATA

*&----


*

FORM PRINT_DATA.

SELECT * FROM KNA1 WHERE KUNNR EQ KUNNR.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'TEST'

WINDOW = 'MAIN'.

ENDFORM. " PRINT_DATA

*&----


*

*& Form END_FORM

*&----


*

FORM END_FORM.

CALL FUNCTION 'END_FORM'.

ENDFORM. " END_FORM

*&----


*

*& Form CLOSE_FORM

*&----


*

FORM CLOSE_FORM.

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

UNOPENED = 1

OTHERS = 2.

ENDFORM. " CLOSE_FORM

Then, you must create your SapScript in order to print some information.

Regards,

Former Member
0 Kudos

Hi Pedro ,

I already created SAP script just to call the value and display.

Let me more clear by example.

name ________ Signature _________

Designation_______

Suppose i am giving in the first page of the report name = abc

then this abc should display in the form also as ABC .

Seema.

Former Member
0 Kudos

Hi Seema,

Please use the below code.

Print Program:

Report zprg no standard page heading.

selection-screen begin of block b1.

parameters : name(20) type c,

designa(20) type c,

signatu(20) type c.

selection-screen end of block b1.

start-of-selection.

call function 'OPEN_FORM'

exporting

form = 'Z_TESTING1'

language = sy-langu.

call function 'START_FORM'

exporting

form = 'Z_TESTING1'

language = 'E'

startpage = 'PAGE1' .

call function 'WRITE_FORM'

exporting

element = 'MAIN'

type = 'BODY'

window = 'MAIN' .

call function 'END_FORM' .

call function 'CLOSE_FORM'.

SAPScript:

Create a Main Window, a Paragraph as 'A' and Page as 'PAGE1' and use the below code in the text element of the Main Window.

/E MAIN

A &NAME&

A &DESIGNA&

A &SIGNATU&

Hope this helps.

Thanks,

Srinivasa

Former Member
0 Kudos

Hi

define Parameters , in start-of-selection , put the same in the Script , write that field in Script like &name&, &signatur& etc.....

This is very simple .

Take care.

Manoj Shakya.

Former Member
0 Kudos

Hi

Did you tried it?

Manoj Shakya.

Former Member
0 Kudos

Hi Manoj

It came in the form still it is giving little problem other side , I tried your no. , But you are busy .

Pls more help is required.

seema.

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Manoj

It came in the form still it is giving little problem other side , I tried your no. , But you are busy .

Pls more help is required.

seema.

Former Member
0 Kudos

Hi Seema ,

Here is the simplest Code for your requirement:

It is just a replica of Srinivas Code with little additions & deletionsl.

REPORT ZPRINTPROGRAM no standard page heading.

selection-screen begin of block b1.

parameters : name(20) type c,

designation (20) type c,

signature (20) type c.

selection-screen end of block b1.

start-of-selection.

call function 'OPEN_FORM'

exporting

form = 'ZFORM'

language = sy-langu

call function 'WRITE_FORM'

exporting

element = 'MAIN'

type = 'BODY'

window = 'MAIN' .

call function 'END_FORM' .

call function 'CLOSE_FORM'.

                        • END of the Print Program **********************

Now, goto SE71

Create Form 'ZFORM'.

Go to PAGES , define page : Page1 and the description.

Then goto Window you will find MAIN window ---> Goto Page Windows

---> Click on EDIT ---> Create Element ---> Double click on Main Window .

The Main Window is include in the Page Windows.

when the Main Window is selected(Indication: Blue color)

go to EDIT -


> Text Elements.

In Text Editor:

/E : MAIN

P1: Name: &NAME&

P1: Desination: &DESIGNATION&

P1: Signature: &SIGNATURE&.

Goto Basic Settings.

Page Format : DINA4

First Page : Page1

Default Paragraph: P1

Just Copy & Paste the code it will work.

Regards,

Daniel.

Former Member
0 Kudos

Hi!

Here's a working example to run a SAPScript from a report program. You have to create the SAPScript in SE71 (in the program it is called Z_NYT), with the right window names.



REPORT ZTESZT.
DATA: gv_index LIKE sy-index.
BREAK-POINT.

CALL FUNCTION 'OPEN_FORM'
  EXPORTING
    DIALOG                            = 'X'
    FORM                              = 'Z_NYT'
    LANGUAGE                          = SY-LANGU
  EXCEPTIONS
    CANCELED                          = 1.
IF SY-SUBRC <> 0. ENDIF.

CALL FUNCTION 'START_FORM'
  EXPORTING
    FORM                   = 'Z_NYT'
    LANGUAGE               = sy-langu
  EXCEPTIONS
    FORM                   = 1.
IF SY-SUBRC <> 0. ENDIF.

DO 10 TIMES.
  MOVE sy-index TO gv_index.
  CALL FUNCTION 'WRITE_FORM'
    EXPORTING
      ELEMENT                   = 'ELEM' 
      FUNCTION                  = 'SET'  "set, append, delete 
      TYPE                      = 'BODY' "body, top, bottom 
      WINDOW                    = 'MAIN' "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. ENDIF.
ENDDO.

CALL FUNCTION 'END_FORM'.
IF SY-SUBRC <> 0. ENDIF.

CALL FUNCTION 'CLOSE_FORM'.
IF SY-SUBRC <> 0. ENDIF.

Regards

Tamá

Former Member
0 Kudos

Hi Tamas,

The code seems good but i have the field like

name ________ Signature _________

Designation_______

Suppose i am giving in the first page of the report name = abc

then this abc should display in the form also as ABC .

Seema.

former_member632991
Active Contributor
0 Kudos
Former Member
0 Kudos

Hi Sonika,

Pls provide soem example.

I am new to this domain.

Seema.

Former Member
0 Kudos

Hi,

do you mean, creating a report, that call's a SapScript? (and not the oposite)

If yes, you would like to create a zreport, with a selection screen parameters, and after executing the report, the SapScript preview will appear?

Regards

Message was edited by:

Pedro Rosa

Former Member
0 Kudos

Hi Pedro,

Yes thats correct. From report calling SAP Script.

If you can provide any code that is really helpful.

Seema.