Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Protec - endprotec

Former Member
0 Likes
673

Hi,

I am working on SAP Script.

I have to print the details of one operation and then next operation and so on.

<b>Now, if the space on the page is very less so as to accomodate the complete details of next operation on same page then it should go on next page otherwise the same operation along with it details should continue on the page.</b>

<b>How do I achieve this ? I guess I have to use protec-endprotect ? Do I have to write this as control command in SCRIPT EDITOR or write it in abap driver program ?</b>My sample code is as follows:

LOOP AT IAFVC.

LOOP AT IRB.

IF IRB-VORNR = IAFVC-VORNR.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'COMPONENT_LISTING'

WINDOW = 'MAIN'.

ENDIF.

ENDIF.

ENDLOOP.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'PRT_LABELS'

WINDOW = 'MAIN'.

CALL FUNCTION 'READ_TEXT'

EXPORTING

id = 'AVOT' "Text ID

language = 'E' "Laguage

name = XTDNAME2 "Text name

object = 'AUFK' "text object

tables = IT_TEXTS. "Int.table

LOOP AT IT_TEXTS.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'OPERATION_LONG_TEXT'

WINDOW = 'MAIN'.

ENDLOOP.

ENDLOOP.

So the each operation number will keep on looping and its respective details will be printed.

<b>Note: Its not a paragraph that I want to protect using protect-endprotect but its the complete operation detail with different elements.</b>

4 REPLIES 4
Read only

Former Member
0 Likes
620

Hi Tushar,

You need to put PROTECT...ENDPROTECT in your SAP Script screen code. Then the written elements within will always be printed on one page, never split across two.

Gill

Read only

Former Member
0 Likes
620

Hi

If you want to protect the text elements you called into loop, you should use it in you program:

CALL FUNCTION CONTROL_FORM

EXPORTING

COMMAND = 'PROTECT'.

LOOP AT..

CALL FUNCTION WRITE

.....

ENDLOOP.

CALL FUNCTION CONTROL_FORM

EXPORTING

COMMAND = 'ENDPROTECT'.

Max

Message was edited by: max bianchi

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
620

Then trigger the protection inside the print program.

  call function 'CONTROL_FORM'
       exporting
            command   = 'PROTECT'
       exceptions
            unopened  = 01
            unstarted = 02.

  • Your Code goes here

  call function 'CONTROL_FORM'
       exporting
            command   = 'ENDPROTECT'
       exceptions
            unopened  = 01
            unstarted = 02.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
620

Hi

I guess PROTECT ENDPROTECT will not work across TEXT ELEMENT boundaries . It will work for only one text element . You can combine all the text elements into one

and use IF condition in SAPSCRIPT itself to supress some of the lines if required. Use PROT ENDPROT on this one text element only ( either in program or in SAPSCRIPT).

Cheers