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

Error in SAP-SCRIPT control command-newpage.

Former Member
0 Likes
844

Hi Friends,

I am working on scripts in that i have given conditional page break, though its working but lastly it is printing one more additional page, I want to avoid that page. pls go thro the code and guide me how to avoid that?

LOOP AT XVBPLK WHERE KZOBE = 'X'.

PERFORM PACKING_TREE USING XVBPLK-VENUM.

CALL FUNCTION 'CONTROL_FORM'

EXPORTING

COMMAND = 'NEW-PAGE'.

ENDLOOP.

FORM PACKING_TREE USING VALUE(SHENR).

  • Daten des Versandelements shenr ausgeben, also Wurzel des Teilbaums

MOVE SPACE TO XVBPLK.

XVBPLK-VENUM = SHENR.

READ TABLE XVBPLK.

VBPLK = XVBPLK.

  • CALL FUNCTION 'WRITE_FORM'

  • EXPORTING ELEMENT = 'SHELEM'.

LOOP AT XVBPLP WHERE VENUM = SHENR.

SELECT PVSART RBEZEI FROM LIKP AS P INNER JOIN T173T AS R

ON PVSART = RVSART INTO CORRESPONDING FIELDS OF TABLE IT

WHERE VBELN = XVBPLP-VBELN AND SPRAS EQ 'E'.

IF XVBPLP-POSNR IS INITIAL.

  • Versandelement

PERFORM PACKING_TREE USING XVBPLP-UNVEL.

ELSE.

  • Lieferposition (Anteil)

VBPLP = XVBPLP.

LOOP AT IT INTO IT.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'MODE'

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'DESPATCH'.

ENDLOOP.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'DELPOS'.

ENDIF.

clear vbplp.

ENDLOOP.

ENDFORM. "PACKING_TREE

Thanks and regards,

Pritesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
755

Try the below logic.

XVBPLK1[] = XVBPLK[].

DELETE XVBPLK WHERE KZOBE <> 'X'.

LOOP AT XVBPLK.

PERFORM PACKING_TREE USING XVBPLK-VENUM.

AT LAST.

LFLAG = 'X'.

ENDAT.

CHECK LFLAG <> 'X'.

CALL FUNCTION 'CONTROL_FORM'

EXPORTING

COMMAND = 'NEW-PAGE'.

ENDLOOP.

5 REPLIES 5
Read only

Former Member
0 Likes
755

Hi,

can you try this one ..

LOOP AT XVBPLK WHERE KZOBE = 'X'.

CALL FUNCTION 'CONTROL_FORM'

EXPORTING

COMMAND = 'NEW-PAGE'.

PERFORM PACKING_TREE USING XVBPLK-VENUM.

ENDLOOP.

Regards

Sudheer

Read only

0 Likes
755

Hi Sudheer,

I have already tried this and its printing more pages i.e. its not working properly.

Read only

Former Member
0 Likes
756

Try the below logic.

XVBPLK1[] = XVBPLK[].

DELETE XVBPLK WHERE KZOBE <> 'X'.

LOOP AT XVBPLK.

PERFORM PACKING_TREE USING XVBPLK-VENUM.

AT LAST.

LFLAG = 'X'.

ENDAT.

CHECK LFLAG <> 'X'.

CALL FUNCTION 'CONTROL_FORM'

EXPORTING

COMMAND = 'NEW-PAGE'.

ENDLOOP.

Read only

Former Member
0 Likes
755

Hi,

can you try this one ..

LOOP AT XVBPLK WHERE KZOBE = 'X'.

if sy-tabix ne '1'.

CALL FUNCTION 'CONTROL_FORM'

EXPORTING

COMMAND = 'NEW-PAGE'.

endif.

PERFORM PACKING_TREE USING XVBPLK-VENUM.

ENDLOOP.

Read only

Former Member
0 Likes
755

Hello Experts ...

Could you please tell me relevance of KZOBE field...

Why we require check on this field ...as shown above ...

Is it mandatory at Handling Unit level also

Thanks in advance ..