|Home • Trainings • Quiz • Tips • Tutorials • Functional • Cert Q's • Interview Q's • Jobs • Testimonials • Advertise • Contact Us|
Printing internal table contents dynamically in SAPScript
By C.Lakshmi Prasanna, Stride Software
is a Script in which an internal table is displayed with each record enclosed
with a box and can grow according to the no of records given as the input.
input is given as 4 records
Script is displaying the 4 records with each record enclosed in a Box
no of records chosen is 12
that now 12 records are enclosed with the boxes.
follows the listing of the code which is the Driver program for the above Script
*&-------------------------------------------------------------* *& Report ZSCRIPT *&-------------------------------------------------------------*
data:begin of itab occurs 0, matnr type matnr, maktx type maktx, end of itab.
PARAMETERS:P_SNO TYPE I. data:i type i. move p_sno to i.
select matnr maktx from makt into table itab up to i rows. CALL FUNCTION 'OPEN_FORM' EXPORTING FORM = 'ZSCRIPT_NEW' EXCEPTIONS CANCELED = 1 DEVICE = 2 FORM = 3 OPTIONS = 4 UNCLOSED = 5 MAIL_OPTIONS = 6 ARCHIVE_ERROR = 7 INVALID_FAX_NUMBER = 8 MORE_PARAMS_NEEDED_IN_BATCH = 9 SPOOL_ERROR = 10 CODEPAGE = 11 OTHERS = 12 . 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. CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = 'ELEMENT ' FUNCTION = 'SET' TYPE = 'BODY' WINDOW = 'MAIN' EXCEPTIONS ELEMENT = 1 FUNCTION = 2 TYPE = 3 UNOPENED = 4 UNSTARTED = 5 WINDOW = 6 BAD_PAGEFORMAT_FOR_PRINT = 7 SPOOL_ERROR = 8 CODEPAGE = 9 OTHERS = 10 . 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.
the details of the LAYOUT
Script is designed with two pages FIRST and
have not enclosed the details of the steps involved in creating the Pages)
following Text element I have used two Box commands one enclosing MATNR and one
enclosing MAKTX but as they are both laid next to each other the out come is a
single BOX enclosing MATNR and MAKTX with a vertical separator
is the variable which iam using to dynamically increase the YPOS for drawing the
BOX around each record as and when the internal table grows
first BOX command which is enclosing the MATNR,,observe that here the
sapscript_counter is incremented by 1 which is achieved by
again the sapscript-counter value is reinitialized to its previous value as the
another BOX command this time to enclose MAKTX
writing of the internal table variables MATNR and MAKTX to enable them to be
displayed on the output
&SAPSCRIPT-COUNTER_0& = -1
&SAPSCRIPT-COUNTER_0(+)& LN WIDTH '2' CM HEIGHT '1' LN
FRAME 10 TW DEFINE 4.&SAPSCRIPT-COUNTER_0& =
&SAPSCRIPT-COUNTER_0(+)& LN XPOS
'2'CM WIDTH '10' CM HEIGHT '1'LN FRAME
I am also
giving the screen shot for the text element
omitted all the regular steps involved to build the LAYOUT(like creation of
Please send us your feedback/suggestions at webmaster@SAPTechnical.COM
©2006-2007 SAPTechnical.COM. All rights reserved.
product names are trademarks of their respective companies. SAPTechnical.COM
is in no way affiliated with SAP AG.
Graphic Design by Round the Bend Wizards