cancel
Showing results for 
Search instead for 
Did you mean: 

PROTECT & ENDPROTECT

Former Member
0 Kudos

HII

HOW TO USE PROTECT & ENDPROTECT

PLEASE REPLY WITH EXAMPLE

THANK U

REGARDS

JAIPAL

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

As far as my knowledge is concerned protect & end protect is used in sapscripts to protect the paragraph overflow.

particular paragraph should not be split in two by a page break. If this page protect attribute is set, then the complete paragraph is always printed on one page. This property applies only to that particular paragraph.

Ex:

/: PROTECT

P &VAR&

P THIS IS for test

P This is test

/:ENDPROTECT

/: PROTECT

:

:

/: ENDPROTECT

The lines to be protected lie between the two commands.

Thanks,

Anitha

Answers (4)

Answers (4)

Former Member
0 Kudos

HI...I have one more query on this...Can this statement be used as a nested statement ?

Former Member
0 Kudos

Hi Suveer,

no it can't. I could not come up with a scenario where nesting might make sense for this command.

As Anitha pointed out, the statement

/: PROTECT

* line 1

* line 2

/:ENDPROTECT

prevents a page-break between line 1 and line 2. That means, the text is printed on the actual page, and in case there is not enough space for both lines, the PROTECT ... ENDPROTECT statement is equal to

/: NEW-PAGE

Kind regards

Matthias

Former Member
0 Kudos

HI ANITHA, THANKS FOR UR REPLY, BUT CAN U PLEASE GIVE IT IN MORE SPECIFIC WAY WITH A DETAIL EXPLAINATION OF EXAMPLE

Former Member
0 Kudos

Hello,


Preventing Page Breaks: PROTECT 

You can specify, either in the style or in the form, that a particular paragraph should not be split in two by a page break. If this page protect attribute is set, then the complete paragraph is always printed on one page. This property applies only to that particular paragraph.

This attribute is not intended to be used to protect all paragraphs against a page break. The point is that a page break is by its very nature a dynamic event and the exact point at which it occurs depends on the current state (length and contents) of the preceding text. It is also possible that you may want to protect only certain parts of a paragraph against a page break. One way to achieve this is to use the NEW-PAGE command immediately before the text concerned starts. Explicitly beginning a new page at this point should ensure that a further page break does not occur within the text. However, this technique is not change-friendly. For example, you format your text with the help of the NEW-PAGE command so that no page breaks occur where they should not. At a later time, you insert or delete some lines. These changes cause all the subsequent text to be moved relative to the printed page, and you must check each NEW-PAGE command you previously inserted to see if it is still in the correct place.

To allow you to define the areas to be protected against a page break on an individual basis, SAPscript provides the PROTECT.. ENDPROTECT command pair. If you enclose the text to be protected in these commands, then SAPscript will ensure that each line of this text is printed together on the same page. If the complete text fits in the space remaining on the current page, then it is printed on this page just as it would be if no PROTECT command had been used. If, however, the remaining space is not sufficient for the text, then the PROTECT command has the same effect as a NEW-PAGE command and text is printed on a new page.

Thus the PROTECT/ENDPROTECT commands may be regarded as a kind of conditional NEW-PAGE command, the condition being whether or not the lines enclosed between the two commands fit in the space remaining in the current main window.

Syntax:

/: PROTECT 
: 
: 
/: ENDPROTECT

The text lines to be protected are enclosed between the two commands.



An ENDPROTECT command without a preceding PROTECT command has no effect.
If the terminating ENDPROTECT is missing, SAPscript assumes it at the end of the text. 
PROTECT.. ENDPROTECT command pairs cannot be nested. If a second PROTECT command occurs before the first one has been terminated by an ENDPROTECT, it is ignored.
If the text enclosed by a PROTECT.. ENDPROTECT pair is itself too long for a single page, then a page break is generated immediately before the text and the text is printed in the normal way. It is then unavoidable that a page break will occur at some point within the text.

If useful reward.

Vasanth

Former Member
0 Kudos

PROTECT: Protect from page break

You can determine that a paragraph must not be separated by a page break in the style or layout set. If the attribute page protection is set, then all the lines of this paragraph are always output together on one page. This attribute is linked to the respective paragraph.

It certainly does not make sense, to provide all the paragraphs with a page protection attribute to neutralize an unwanted page break. This event is much too dynamic for this and only results from the current text. Furthermore, it can also happen that you only want to protect parts of a paragraph from a page break. In principle, you could solve this problem using the command NEW-PAGE, by explicitly starting a new page before the affected parts of the text. However, this procedure is not very easy to make changes to. Assume that you have formatted your text using the NEW-PAGE command so that you have no unwanted

page breaks. If you now insert new lines or delete existing ones, you would have to check all the NEW-PAGE commands inserted after this point in the text, as changes can result in the movement of page breaks. With the command pair PROTECT. ENDPROTECT, SAPscript offers you the option of individually defining protection from a page break. If you parenthesize the text in question using these commands, SAPscript automatically guarantees that all the lines it contains are printed together on one page. If the lines fit on the current output page, they are output there, in exactly the same way as if the PROTECT

command was not used. If, however, the space is not sufficient, the PROTECT command then works as a NEW-PAGE and generates a form feed .For this reason, you can view PROTECT/ENDPROTECT as a conditional NEW-PAGE command, whose condition consists of whether the included lines fit into the current window MAIN or not.

Syntax:

/: PROTECT

:

:

/: ENDPROTECT

The lines to be protected lie between the two commands.

•An ENDPROTECT command without a preceding PROTECT command

is ineffective.

•If the last ENDPROTECT is missing, it is implicitly assumed at the end

of the text.

•PROTECT .. ENDPROTECT commands cannot be nested. If a second

PROTECT command is recognized while another is active, the second is

ignored.

•If the text between PROTECT and ENDPROTECT is so extensive that it

would not completely fit on an empty page, then only one form feed is

generated and the text is then output normally. Thus, in this case, the

section to be protected can be separated by a page break.

Regards,

Santosh