cancel
Showing results for 
Search instead for 
Did you mean: 

SAPScript: Dynamic Pages

dru_marcellana
Participant
0 Kudos

Hi,

I am working on a form which is launched in VF03. Having known that a billing might have many deliveries, the requirement is to produce a new page with header, item and footer for every deliveries.

The program is almost finished. However, when I'm testing it, I found a bug.

In the first delivery, the output is OK. It has the header, items and footer. But for the next deliveries (new page), the footer part which is placed in MAIN window element FOOTER, always appear. It must only appear when all the items are displayed.

Can you please give me a solution for this?

Below is the code for passing data in sapscript:

DO nast_anzal TIMES.

PERFORM

f_open_form USING xscreen

t001-land1.

CHECK retcode EQ 0.

PERFORM

f_start_form.

CHECK retcode EQ 0.

LOOP AT i_vbfa_j INTO wa_vbfa.

ON CHANGE OF wa_vbfa-vbelv.

IF sy-tabix NE 1.

PERFORM f_control_form USING 'NEW-PAGE'.

ENDIF.

PERFORM:

f_fill_title_window,

f_fill_header1a_window,

f_fill_header1b_window,

f_fill_header2_window,

f_fill_item_header_window,

f_fill_page_window.

ENDON.

f_fill_item_window. (MAIN)

AT END OF vbelv.

PERFORM

f_fill_footer_window.

  • FOOTER is placed in MAIN window

IF v_pending_flag EQ c_mark.

PERFORM f_control_form USING 'NEW-PAGE'.

ENDIF.

ENDAT.

CLEAR:

wa_vbfa.

ENDLOOP.

PERFORM

f_close_form.

CHECK retcode EQ 0.

ENDDO.

Thanks,

Druzz

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Dru,

why don't you keep a separate window for FOOTER and keep it in all pages in script.

Former Member
0 Kudos

Hullo,

if the requirement is to have the footer window displayed at the end of the internal table, maybe you might want to try "AT LAST" instead of "AT END OF".

AT last.

PERFORM f_fill_footer_window.
* FOOTER is placed in MAIN window

Hope this helps.

dru_marcellana
Participant
0 Kudos

Hi,

The footer must appear for every end of delivery or new delivery.

Former Member
0 Kudos

Have you sorted i_vbfa_j by vbelv? What is the structure of table i_vbfa_j?

dru_marcellana
Participant
0 Kudos

Hi Tomasz,

Yes I sorted it. The creation of new page per delivery is working. The footer is the only. It always appear on the succeeding pages. For example, the first delivery has only 1 page. Thus, it will show the footer. After this, a new page will be created for the next delivery. But the data of this delivery is not enough for one page. In its first page, the footer still appears which should not. It must only appear when all the items of the delivery are printed.

Thanks,

Dru

Former Member
0 Kudos

Dru, perhaps the structure of your internal table is wrong. If there are any columns before vbelv and their values are not the same for a given vbelv, 'at end of vbelv' is called too many times...

dru_marcellana
Participant
0 Kudos

Hi Tomasz,

This is the structure of the internal table:

vbelv LIKE vbfa-vbelv

vbeln LIKE vbfa-vbeln

vbelv is unique.

I don't know if the problem comes from writing the window. I mean, when the window is already written using WRITE_FORM, it will always appear. I'm not sure, though.

Thanks,

Dru

Former Member
0 Kudos

Dru,

Can you paste your piece of code that call element footer, I mean how are you calling FM 'write_form'?

dru_marcellana
Participant
0 Kudos

Hi Tomasz,

I am testing two ways:

PERFORM f_write_form_check USING 'FOOTER'

'MAIN'

'BOTTOM'

CHANGING v_pending_flag.

PERFORM f_write_form USING 'FOOTER'

'FOOTER'.

FORM f_write_form USING p_element

p_window.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = p_element

window = p_window

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

OTHERS = 9.

IF sy-subrc NE 0.

retcode = sy-subrc.

PERFORM protocol_update.

ENDIF.

FORM f_write_form_check USING p_element

p_window

p_type

CHANGING p_pending_flag.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = p_element

type = p_type

window = p_window

IMPORTING

pending_lines = p_pending_flag

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

OTHERS = 9.

IF sy-subrc NE 0.

retcode = sy-subrc.

PERFORM protocol_update.

ENDIF.

Thanks!

Former Member
0 Kudos

Dru, replace BOTTOM with BODY and should be fine.

dru_marcellana
Participant
0 Kudos

Hi Tomasz,

By doing that, the footer will not be placed in the bottom of the page. I used the bottom so that it will be always placed at the bottom of the MAIN window and that is the requirement.

I read something and it tells that it will indeed always appear in the MAIN window. I think I shouldn't use this WRITE command with type.

I don't if it will work if I remove the footer window in the NEXT page which I assigned as "Next Page" for page, FIRST.

Thanks,

Dru