Skip to Content
avatar image
Former Member

Conditional Page break in sapscript

Hi All

I need to output the data in sapscript related to each vendor in new page.

I tried with below code but its not picking all the records related to 1 vendor.

LOOP AT it_data3.

CALL FUNCTION 'START_FORM'

EXPORTING

  • ARCHIVE_INDEX =

form = 'Z_FORM_16'

  • LANGUAGE = ' '

  • STARTPAGE = ' '

program = 'Z_FORM_16'.

ON CHANGE OF it_data3-wt_acco.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

  • element = ' '

  • FUNCTION = 'SET'

  • TYPE = 'CONST'

window = 'MAIN'.

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 'END_FORM'

  • IMPORTING

  • RESULT =

  • EXCEPTIONS

  • UNOPENED = 1

  • BAD_PAGEFORMAT_FOR_PRINT = 2

  • SPOOL_ERROR = 3

  • CODEPAGE = 4

  • OTHERS = 5

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDON.

ENDLOOP.

Pls give ur valuable suggestions.

Regards

Babita

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Apr 25, 2007 at 07:36 AM

    You can add a call of the function

    regards,

    Hans

    Please reward all helpful answers !!!!! module CONTROL_FORM with NEW-PAGE.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Hans . Could you please specify where to put this control_form.

      also I tried something like this and getting repeated data and 1 blank page between each vendor.

      LOOP AT it_data3.

      CALL FUNCTION 'START_FORM'

      EXPORTING

      • ARCHIVE_INDEX =

      form = 'Z_FORM_16'

      • LANGUAGE = ' '

      • STARTPAGE = ' '

      program = 'Z_FORM_16'.

      • ON CHANGE OF it_data3-wt_acco.

      • at end of wt_acco.

      CALL FUNCTION 'WRITE_FORM'

      EXPORTING

      • element = ' '

      • FUNCTION = 'SET'

      • TYPE = 'CONST'

      window = 'MAIN'.

      IF sy-subrc <> 0.

      • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

      • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

      ENDIF.

      ON CHANGE OF it_data3-wt_acco.

      CALL FUNCTION 'CONTROL_FORM'

      EXPORTING

      command = 'NEW-PAGE'

      • EXCEPTIONS

      • UNOPENED = 1

      • UNSTARTED = 2

      • OTHERS = 3

      .

      IF sy-subrc <> 0.

      • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

      • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

      ENDIF.

      ENDON.

      CALL FUNCTION 'END_FORM'

      • IMPORTING

      • RESULT =

      • EXCEPTIONS

      • UNOPENED = 1

      • BAD_PAGEFORMAT_FOR_PRINT = 2

      • SPOOL_ERROR = 3

      • CODEPAGE = 4

      • OTHERS = 5

      .

      IF sy-subrc <> 0.

      • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

      • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

      ENDIF.

      • ENDON.

      *endat.

      ENDLOOP.

      also I want all data i.e. rows of a particular vendor should be printed on same page but right now after every line item a new page is getting triggered.

      Hope I am able to explain the issue.

      Awaiting quick reply for all Abapers.

      Thanks

      Babita

  • Apr 25, 2007 at 08:08 AM

    After the ON CHANGE OF statement, you can add :

    CALL FUNCTION 'CONTROL_FORM'

    EXPORTING

    command = 'NEW-PAGE'

    • EXCEPTIONS

    • UNOPENED = 1

    • UNSTARTED = 2

    • OTHERS = 3

    .

    The ON CHANGE will only work if the IT_DATA3 internal table is sorted on the field WT_ACCO.

    regards,

    Hans

    Please reward all helpful answers !!!!!

    Add comment
    10|10000 characters needed characters exceeded