Skip to Content
author's profile photo Former Member
Former Member

sap script

hi all

i have to generate a report through script

i have created form with HEADER, MAIN and FOOTER.

in the Header window i should get logo and heading for the report in center.

in the FOOTER window i should get page number

in the MAIN window i should get as below

Customer Name Country

values values values

values values values

values values values

values values values

......... ........ .........

now in print program i took all these fields into internal table.

Can any one tell me wat to write in print program once we get all the values into internal table. And how to call those values in form.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2007 at 06:45 PM

    Hi,

    Once you get the values in the internal table..Then call the sap script function modules..

    Example

    -


    CALL FUNCTION 'OPEN_FORM'

    EXPORTING

    form = <b>'Sapscript form name'</b>

    language = sy-langu

    EXCEPTIONS

    canceled = 1

    device = 2

    form = 3

    options = 4

    unclosed = 5

    OTHERS = 11.

    LOOP AT ITAB.

    CALL FUNCTION 'WRITE_FORM'

    EXPORTING

    element = <b>'Give the text element name'</b>

    window = 'MAIN'

    EXCEPTIONS

    element = 1

    function = 2

    type = 3

    unopened = 4

    unstarted = 5

    window = 6

    bad_pageformat_for_print = 7

    spool_error = 8

    OTHERS = 9.

    ENDLOOP.

    CALL FUNCTION 'CLOSE_FORM'

    EXCEPTIONS

    unopened = 1

    bad_pageformat_for_print = 2

    OTHERS = 5.

    Thanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      hi satya,

      check this sample code...

      PRINT PROGRAM

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

      <b>REPORT z_script_prog .

      TABLES: mseg.

      DATA: itab LIKE mseg OCCURS 3 WITH HEADER LINE.

      SELECT * FROM mseg INTO TABLE itab.

      SORT itab BY matnr.

      DELETE ADJACENT DUPLICATES FROM itab COMPARING matnr.

      CLEAR itab.

      PERFORM oform.

      PERFORM sform.

      LOOP AT itab INTO mseg.

      PERFORM wform.

      ENDLOOP.

      PERFORM eform.

      PERFORM cform.

      &----


      *& Form oform

      &----


      • text

      ----


      FORM oform.

      CALL FUNCTION 'OPEN_FORM'

      EXPORTING

      form = 'ZSAB' " UR SAPSCRIPT NAME

      language = sy-langu.

      ENDFORM. "oform

      &----


      *& Form sform

      &----


      • text

      ----


      FORM sform.

      CALL FUNCTION 'START_FORM'

      EXPORTING

      • ARCHIVE_INDEX =

      form = 'ZSAB' " UR SAPSCRIPT NAME

      language = sy-langu

      startpage = 'PAGE1'

      .

      ENDFORM. "sform

      &----


      *& Form wform

      &----


      • text

      ----


      FORM wform.

      CALL FUNCTION 'WRITE_FORM'

      EXPORTING

      element = 'DATA' " UR TEXT ELEMENT NAME

      function = 'SET'

      type = 'BODY'

      window = 'MAIN'.

      ENDFORM. "wform

      FORM eform.

      CALL FUNCTION 'END_FORM'.

      ENDFORM. "eform

      &----


      *& Form cform

      &----


      • text

      ----


      FORM cform.

      CALL FUNCTION 'CLOSE_FORM'.

      ENDFORM. "cform</b>

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

      SCRIPT PROGRAM - MAIN WINDOW

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

      <b>/E DATA " UR TEXT ELEMENT NAME

      PR Material Number : &mseg-matnr&

      PR Plant: &mseg-werks&

      PR Storage Location : &mseg-lgort&</b>

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

      WHERE PR is a paragraph format... if u dont create one then u can use *.

      Regards

      SAB

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2007 at 07:14 PM

    Hi,

    Go to the MAIN window..And give the following..

    Sap script changes

    -


    /E LINEITEM_HEADER

    P1 Customer Name Country

    /E LINEITEM_DETAIL

    P1 &ITAB-KUNNR& &ITAB-NAME& &ITAB-LAND1&

    Print program changes

    -


    LOOP AT ITAB.

    AT FIRST.

    • Print the header..

    CALL FUNCTION 'WRITE_FORM'

    EXPORTING

    element = LINEITEM_HEADER

    window = 'MAIN'.

    ENDAT.

    • Print the customer details

    CALL FUNCTION 'WRITE_FORM'

    EXPORTING

    element = LINEITEM_DETAIL

    window = 'MAIN'.

    ENDLOOP.

    Hope this helps..

    Thanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.