cancel
Showing results for 
Search instead for 
Did you mean: 

Box in MAIN window of sapscript keeps misaligning...

aris_hidalgo
Contributor
0 Kudos

Hello Experts,

I am currently modifying a sapscript and inside the MAIN window, there is a box command that 'boxes' a

static text. But the problem is, the box misaligns since the number of line items is dynamic.

So, how can I make the box command to just 'box' the static text correctly even though the line item is

dynamic?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI,

Declare the Box and Static text in the main window with a new text element after the text element of the line items . so it will print it in the end when all of the Line items are printed..

(or)

Just create another script with the BOX and the text you want inside the BOX. i.e. this becomes another script which is separate from the line items you are printing there.

call this script in your driver program with start_form FM.

REPORT  YTEST_SCRIPT.
DATA:
  ITAB TYPE TABLE OF SFLIGHT,
  FS TYPE SFLIGHT.

SELECT * FROM SFLIGHT INTO TABLE ITAB.

CALL FUNCTION 'OPEN_FORM'
  EXPORTING
    FORM                              = 'ZSCRIPT_TEST'.
IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT ITAB INTO FS.
  CALL FUNCTION 'WRITE_FORM'
    EXPORTING
      ELEMENT                        = 'TEST'
      WINDOW                         = 'MAIN'.
  IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDLOOP.
CALL FUNCTION 'END_FORM'.      "---------->Ends the previous form
 IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'START_FORM'    "------------> Starts your new script with BOX and Static text
  EXPORTING
    FORM                   = 'ZSCRIPT_TEST1'.
IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'WRITE_FORM'
 EXPORTING
    ELEMENT                        = 'TEST'
    WINDOW                         = 'MAIN'.
IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'CLOSE_FORM'.
IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

This will print the BOX and the Static text in a new page after the line items got printed..

This will solve your issue...

Thanks&Regards

Sarves

Answers (0)