| Home • Tips • Tutorials • Forums • Certification Q's • Interview Q's • Jobs • Testimonials • Contact Us | ||
Document Categories:
What's New?
Contribute?Sample SpecsWhat's Hot? |
Printing internal table contents dynamically in SAPScriptBy C.Lakshmi Prasanna, Stride Software Here
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. Scenario:
1 Here the
input is given as 4 records
And the
Script is displaying the 4 records with each record enclosed in a Box
Scenario:
2 Here the
no of records chosen is 12 Observe
that now 12 records are enclosed with the boxes.
And now
follows the listing of the code which is the Driver program for the above Script *&-------------------------------------------------------------* *& Report ZSCRIPT *&-------------------------------------------------------------* 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.
endloop. 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.
Now
the details of the LAYOUT The
Script is designed with two pages FIRST and (I
have not enclosed the details of the steps involved in creating the Pages) In the
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 Line1:Sapscript-counter_0
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 Line2:Element
begins Line3:the
first BOX command which is enclosing the MATNR,,observe that here the
sapscript_counter is incremented by 1 which is achieved by
&SAPSCRIPT-COUNTER_0(+)& Line4:
again the sapscript-counter value is reinitialized to its previous value as the
next Line5:
another BOX command this time to enclose MAKTX Line6:
writing of the internal table variables MATNR and MAKTX to enable them to be
displayed on the output Text
Element 1.DEFINE
&SAPSCRIPT-COUNTER_0& = -1 2.ELEMENT 3.BOX YPOS
&SAPSCRIPT-COUNTER_0(+)& LN WIDTH '2' CM HEIGHT '1' LN
FRAME 10 TW DEFINE 4.&SAPSCRIPT-COUNTER_0& =
&SAPSCRIPT-COUNTER_0(-)& 5.BOX YPOS
&SAPSCRIPT-COUNTER_0(+)& LN XPOS
'2'CM WIDTH '10' CM HEIGHT '1'LN FRAME
10 TW 6.&itab-matnr&
&itab-maktx& I am also
giving the screen shot for the text element
I have
omitted all the regular steps involved to build the LAYOUT(like creation of
PAGES, |
|
|
Please send us your feedback/suggestions at webmaster@SAPTechnical.COM Home • Contribute • About Us • Privacy • Terms Of Use • Disclaimer • Safe • Companies: Advertise on SAPTechnical.COM | Post Job • Contact Us ©2006-2007 SAPTechnical.COM. All rights reserved. All
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 |
||