cancel
Showing results for 
Search instead for 
Did you mean: 

sapscript conditional page

Clemenss
Active Contributor
0 Kudos

My customer wants to modify an existing SAPSCRIPT FORM which has a First Page and various numbers of Next pages now. They want to insert a new first page but only under certain conditions.
I know in SMARTFORMS I can add a condition for a page but I have no good idea as how to do the same in SAPScript. Is there a way to skip pages?

Thanks a lot

Best regards

Clemens

Accepted Solutions (0)

Answers (2)

Answers (2)

Jelena
Active Contributor

With SAPScript, the print program is what drives the whole printing process. It's not at all like Smartform where FM does all the job. If you look at that program for the SAPScript in question you'll see how each page and element is called. So all you'd need to do is just insert some IF... there. I'm sure you'll understand this immediately when you see the program.

Good luck!

Clemenss
Active Contributor
0 Kudos

Thank you Jelena,

yes I know this for elements. Not for pages. Please give an example found in SAP standard.

Regards

Clemens

chaouki_akir
Contributor
0 Kudos

You can try to call function START_FORM and to fill its importing parameter STARTPAGE

Clemenss
Active Contributor
0 Kudos

did you try, success, example?

Regards Clemens

Jelena
Active Contributor
0 Kudos

Well, did you try? We don't have a SAPScript program at hand but you do, I assume. So what's preventing you from typing in some code in it? I'm confused...

chaouki_akir
Contributor
0 Kudos

Hello,

here a sample (SAP 46C) that you can test in your system. Using form MEDRUCK, depending on selection-screen entry, you can start with page FIRST or with page NEXT

REPORT ztest_carcd .

PARAMETERS form    TYPE thead-tdform DEFAULT 'MEDRUCK'. "PSFC_STD_LAYOUT
PARAMETERS page    TYPE itctg-tdpage .




AT SELECTION-SCREEN ON VALUE-REQUEST FOR page.
  PERFORM value_request_page.



AT SELECTION-SCREEN.
  CASE sy-ucomm.
    WHEN 'ONLI'.
      PERFORM action.
  ENDCASE.
*&---------------------------------------------------------------------*
*&      Form  action
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM action.
  DATA lv_flg_start TYPE flag.


  DATA options TYPE itcpo.


  options-tddest     = 'LOCL                         '.
  options-tdprinter  = 'HPLJ4                         '.
  options-tdpreview  = 'X'.
  options-tdimmed    = ' '.
  options-tddelete   = 'X'.
  options-tdreceiver = '                                 '.
  options-tddivision = '                                 '.
  options-tdcover    = ' '.
  options-tdnewid    = 'X'.
  options-tdtest     = 'X'.
  options-tdcovtitle = '                                             '.
  options-tdcovtitle+40(28) = '                                      '.


  CALL FUNCTION 'OPEN_FORM'
       EXPORTING
            form    = form
            options = options
       EXCEPTIONS
            OTHERS  = 11.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    IF NOT page IS INITIAL.
      lv_flg_start = 'X'.
      CALL FUNCTION 'START_FORM'
           EXPORTING
                startpage   = page
           EXCEPTIONS
                form        = 1
                format      = 2
                unended     = 3
                unopened    = 4
                unused      = 5
                spool_error = 6
                OTHERS      = 7.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ELSE.
      lv_flg_start = ''.
    ENDIF.


    CALL FUNCTION 'WRITE_FORM'
         EXPORTING
*            element = 'SKIP'
              window  = 'MAIN'
         EXCEPTIONS
              OTHERS = 0.

    IF lv_flg_start = 'X'.
      CALL FUNCTION 'END_FORM'
           EXCEPTIONS
                unopened                 = 1
                bad_pageformat_for_print = 2
                spool_error              = 3
                OTHERS                   = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDIF.

    CALL FUNCTION 'CLOSE_FORM'
         EXCEPTIONS
              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.
  ENDIF.
ENDFORM.                    " action
*&---------------------------------------------------------------------*
*&      Form  value_request_page
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM value_request_page.
  DATA pages TYPE STANDARD TABLE OF itctg.
  DATA found TYPE flag.

  CALL FUNCTION 'READ_FORM'
       EXPORTING
            form  = form
       IMPORTING
            found = found
       TABLES
            pages = pages.
  IF found IS INITIAL.
    CALL FUNCTION 'READ_FORM'
         EXPORTING
              form          = form
              throughclient = 'X'
         TABLES
              pages         = pages.
  ENDIF.
  .
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
       EXPORTING
            retfield    = 'TDPAGE'
            dynprofield = 'PAGE'
            dynpprog    = sy-cprog
            dynpnr      = sy-dynnr
            value_org   = 'S'
       TABLES
            value_tab   = pages.


ENDFORM.                    " value_request_page<br>


Chaouki

former_member220028
Active Contributor

with open_form and Close_form you get the "outer" Frame of sap-script coding

inside this Frame you can call several start_form and Close form FMs

so :

1: put a start_form - close_form around the existing script coding.

2: now add start_form-close_form for your additional page. this has to be called bevor the existing coding

3: implement your own script (SE71) with your wanted page / window whatever.

4: call the write_form Statements between start_form-end_form

5: put a condition "around" the start-Form-close_Form

regards

Stefan